diff --git a/LICENSE.txt b/LICENSE.txt index 12d66cd3..fd74d70d 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,24 +1,24 @@ -Copyright (c) 2006, Second Life Reverse Engineering Team -All rights reserved. - -- Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - -- Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. -- Neither the name of the Second Life Reverse Engineering Team nor the names - of its contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. - +Copyright (c) 2006, Second Life Reverse Engineering Team +All rights reserved. + +- Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + +- Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +- Neither the name of the Second Life Reverse Engineering Team nor the names + of its contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + diff --git a/Ovatsus.CSharp.targets b/Ovatsus.CSharp.targets index be59e83a..1f124607 100644 --- a/Ovatsus.CSharp.targets +++ b/Ovatsus.CSharp.targets @@ -1,587 +1,587 @@ - - - - - - - - - $(SystemRoot)\Microsoft.NET\Framework\v1.0.3705 - $(SystemRoot)\Microsoft.NET\Framework\v1.1.4322 - C:\Program Files\Mono-1.1.9.2 - $(MonoPath)\bin\mcs.bat - $(MonoPath)\bin\gmcs.bat - $(MonoPath)\lib\mono\1.0 - $(MonoPath)\lib\mono\2.0 - - - - - - - - - .NET 1.0 - .NET 1.1 - .NET 2.0 - .NET CF 1.0 (Pocket PC 2003) - .NET CF 1.0 (Smartphone 2003) - .NET CF 2.0 (Pocket PC 2003) - .NET CF 2.0 (Windows CE 5.0) - .NET 1.1 (Mono Compiler & Libraries) - .NET 2.0 (Mono Compiler & Libraries) - .NET 1.1 (Mono Libraries) - .NET 2.0 (Mono Libraries) - Build All Platforms Simultaneously - Build All 2.0 Platforms Simultaneously - - - - - - - - - - - - - - - - - - - - - - - - - - - - - false - true - - false - true - - false - true - - false - true - - false - true - - false - true - - false - true - - false - true - - false - true - - false - true - - false - true - - false - true - - false - true - - false - true - - false - true - - false - true - - false - true - - false - true - - false - true - - false - true - - false - true - - false - true - - false - true - - false - true - - false - true - - false - true - - false - true - - - - - - - - - - NET_1_0 - NET_1_1 - NET_2_0 - NET_CF_1_0 - NET_CF_2_0 - NET_CF - Mono - - - - - - - - - true - full - false - DEBUG;TRACE - - - - pdbonly - true - TRACE - - - - - - - - - - bin - - - - bin\$(Platform)\$(Configuration) - - - - 4 - - - - prompt - - - - false - - - - $(DefineConstants);$(NET_1_0_Constant) - $(NET_1_0_Path) - v1.0 - - - - $(DefineConstants);$(NET_1_1_Constant) - v1.1 - - - - $(NET_1_1_Path) - - - - $(DefineConstants);$(NET_2_0_Constant) - - - - $(DefineConstants);$(NET_CF_1_0_Constant) - - - - $(DefineConstants);$(NET_CF_2_0_Constant) - - - - 3C41C503-53EF-4c2a-8DD4-A8217CAD115E - PocketPC - 4.20 - - - - 4DE813A2-67E0-4a00-945C-3188240A8243 - Smartphone - 4.20 - - - - E2BECB1F-8C8C-41ba-B736-9BE7D946A398 - WindowsCE - 5.0 - - - - $(AssemblyName) - 512 - $(DefineConstants);$(PlatformFamilyName) - {4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - $(DefineConstants);$(NET_CF_Constant) - - - - $(DefineConstants);$(Mono_Constant) - - - - true - - - - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $(NET_1_0_Path) - - - - $(NET_1_1_Path) - - - - $(Mono_1_1_LibPath) - - - - $(Mono_2_0_LibPath) - - - - - - false - - - - - - false - - - - - - false - - - - - - false - - - - - - - - - - - - ResolveAssemblyReferences;BeforeResGen;_CoreResGen_1_x;AfterResGen - - - - - - - - - - - - - - - - - - - - - - - $(CheckUnsupportedFeaturesDependsOn);Check_MS_1_x_UnsupportedFeatures - - - $(CheckUnsupportedFeaturesDependsOn);Check_All_Mono_UnsupportedFeatures - - - - - - - - - - - - - - - - - - - - - - - - - - - ResolveReferences; - ResolveKeySource; - BeforeCompile; - _TimeStampBeforeCompile; - MonoCoreCompile; - _TimeStampAfterCompile; - AfterCompile - - - - - - - - - - "$(Mono_1_1_CompilerPath)" - "$(Mono_2_0_CompilerPath)" - $(MonoCommandLine) /lib:$(AdditionalLibPaths) - $(MonoCommandLine)@(AddModules->' /addmodule:"%(Identity)"', '') - $(MonoCommandLine) /unsafe+ - $(MonoCommandLine) /checked+ - $(MonoCommandLine) /codepage:$(CodePage) - $(MonoCommandLine) /define:$(DefineConstants) - $(MonoCommandLine) /delaysign+ - $(MonoCommandLine) /doc:$(DocumentationFile) - $(MonoCommandLine) /debug+ - $(MonoCommandLine) /keycontainer:$(KeyContainerName) - $(MonoCommandLine) /keyfile:$(KeyContainerName) - $(MonoCommandLine) /langversion:$(LangVersion) - $(MonoCommandLine) /main:$(StartupObject) - $(MonoCommandLine) /noconfig+ - $(MonoCommandLine) /nostdlib+ - $(MonoCommandLine) /optimize+ - $(MonoCommandLine) /out:"@(IntermediateAssembly)" - $(MonoCommandLine)@(ReferencePath->' /reference:"%(Identity)"', '') - $(MonoCommandLine) $(CompilerResponseFile) - $(MonoCommandLine)@(Compile->' "%(Identity)"', '') - $(MonoCommandLine) /waraserror+ - $(MonoCommandLine) /warn:$(WarningLevel) - $(MonoCommandLine) /win32icon:$(Win32Icon) - $(MonoCommandLine) /win32res:$(Win32Resource) - exe - winexe - library - module - $(MonoCommandLine) /target:$(MonoTargetType) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - BuildAll - CleanAll - PublishOnlyAll - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + $(SystemRoot)\Microsoft.NET\Framework\v1.0.3705 + $(SystemRoot)\Microsoft.NET\Framework\v1.1.4322 + C:\Program Files\Mono-1.1.9.2 + $(MonoPath)\bin\mcs.bat + $(MonoPath)\bin\gmcs.bat + $(MonoPath)\lib\mono\1.0 + $(MonoPath)\lib\mono\2.0 + + + + + + + + + .NET 1.0 + .NET 1.1 + .NET 2.0 + .NET CF 1.0 (Pocket PC 2003) + .NET CF 1.0 (Smartphone 2003) + .NET CF 2.0 (Pocket PC 2003) + .NET CF 2.0 (Windows CE 5.0) + .NET 1.1 (Mono Compiler & Libraries) + .NET 2.0 (Mono Compiler & Libraries) + .NET 1.1 (Mono Libraries) + .NET 2.0 (Mono Libraries) + Build All Platforms Simultaneously + Build All 2.0 Platforms Simultaneously + + + + + + + + + + + + + + + + + + + + + + + + + + + + + false + true + + false + true + + false + true + + false + true + + false + true + + false + true + + false + true + + false + true + + false + true + + false + true + + false + true + + false + true + + false + true + + false + true + + false + true + + false + true + + false + true + + false + true + + false + true + + false + true + + false + true + + false + true + + false + true + + false + true + + false + true + + false + true + + false + true + + + + + + + + + + NET_1_0 + NET_1_1 + NET_2_0 + NET_CF_1_0 + NET_CF_2_0 + NET_CF + Mono + + + + + + + + + true + full + false + DEBUG;TRACE + + + + pdbonly + true + TRACE + + + + + + + + + + bin + + + + bin\$(Platform)\$(Configuration) + + + + 4 + + + + prompt + + + + false + + + + $(DefineConstants);$(NET_1_0_Constant) + $(NET_1_0_Path) + v1.0 + + + + $(DefineConstants);$(NET_1_1_Constant) + v1.1 + + + + $(NET_1_1_Path) + + + + $(DefineConstants);$(NET_2_0_Constant) + + + + $(DefineConstants);$(NET_CF_1_0_Constant) + + + + $(DefineConstants);$(NET_CF_2_0_Constant) + + + + 3C41C503-53EF-4c2a-8DD4-A8217CAD115E + PocketPC + 4.20 + + + + 4DE813A2-67E0-4a00-945C-3188240A8243 + Smartphone + 4.20 + + + + E2BECB1F-8C8C-41ba-B736-9BE7D946A398 + WindowsCE + 5.0 + + + + $(AssemblyName) + 512 + $(DefineConstants);$(PlatformFamilyName) + {4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + $(DefineConstants);$(NET_CF_Constant) + + + + $(DefineConstants);$(Mono_Constant) + + + + true + + + + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $(NET_1_0_Path) + + + + $(NET_1_1_Path) + + + + $(Mono_1_1_LibPath) + + + + $(Mono_2_0_LibPath) + + + + + + false + + + + + + false + + + + + + false + + + + + + false + + + + + + + + + + + + ResolveAssemblyReferences;BeforeResGen;_CoreResGen_1_x;AfterResGen + + + + + + + + + + + + + + + + + + + + + + + $(CheckUnsupportedFeaturesDependsOn);Check_MS_1_x_UnsupportedFeatures + + + $(CheckUnsupportedFeaturesDependsOn);Check_All_Mono_UnsupportedFeatures + + + + + + + + + + + + + + + + + + + + + + + + + + + ResolveReferences; + ResolveKeySource; + BeforeCompile; + _TimeStampBeforeCompile; + MonoCoreCompile; + _TimeStampAfterCompile; + AfterCompile + + + + + + + + + + "$(Mono_1_1_CompilerPath)" + "$(Mono_2_0_CompilerPath)" + $(MonoCommandLine) /lib:$(AdditionalLibPaths) + $(MonoCommandLine)@(AddModules->' /addmodule:"%(Identity)"', '') + $(MonoCommandLine) /unsafe+ + $(MonoCommandLine) /checked+ + $(MonoCommandLine) /codepage:$(CodePage) + $(MonoCommandLine) /define:$(DefineConstants) + $(MonoCommandLine) /delaysign+ + $(MonoCommandLine) /doc:$(DocumentationFile) + $(MonoCommandLine) /debug+ + $(MonoCommandLine) /keycontainer:$(KeyContainerName) + $(MonoCommandLine) /keyfile:$(KeyContainerName) + $(MonoCommandLine) /langversion:$(LangVersion) + $(MonoCommandLine) /main:$(StartupObject) + $(MonoCommandLine) /noconfig+ + $(MonoCommandLine) /nostdlib+ + $(MonoCommandLine) /optimize+ + $(MonoCommandLine) /out:"@(IntermediateAssembly)" + $(MonoCommandLine)@(ReferencePath->' /reference:"%(Identity)"', '') + $(MonoCommandLine) $(CompilerResponseFile) + $(MonoCommandLine)@(Compile->' "%(Identity)"', '') + $(MonoCommandLine) /waraserror+ + $(MonoCommandLine) /warn:$(WarningLevel) + $(MonoCommandLine) /win32icon:$(Win32Icon) + $(MonoCommandLine) /win32res:$(Win32Resource) + exe + winexe + library + module + $(MonoCommandLine) /target:$(MonoTargetType) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + BuildAll + CleanAll + PublishOnlyAll + + + + + + + + + + + + + + + + + + + + + + + diff --git a/README.txt b/README.txt index 4af986a5..58bd549b 100644 --- a/README.txt +++ b/README.txt @@ -1,112 +1,112 @@ - -libsecondlife -------------- - -We're still working on getting some documentation prepared for our first -"official" release, so bear with us for now. If you need any help we -have a couple of resources, the primary one being the #libsl IRC channel -on EFNet. There are also the web forums at -http://www.libsecondlife.org/forums/ and the libsecondlife-dev mailing -list at https://gna.org/mail/?group=libsecondlife and lastly you can use -the e-mail contact@libsecondlife.org for any general inquiries (although -we prefer developer-related questions to go to IRC, forums, or the -mailing list). - -To checkout a copy of libsecondlife trunk see -https://gna.org/svn/?group=libsecondlife for details. The HTTP method -seems to be more reliable. - -Windows ------------------------------------------------------------------ ------------------------------------------------------------------ - - -Microsoft Visual Studio ------------------------ - -Visual Studio 2005 project files are included to ease compiling on Windows -platforms. Some of the projects use a custom targets file that allows you -to compile against .NET 1.0/1.1, mono, or the Compact Framework. You will -need to authorize this custom file when you first open the solution file. - - -Software Needed (all Freeware) ------------------------------- - -Basic Stuff (Windows): - MS .NET Framework (1.1 and/or 2.0 depending on what you're working on; - preferably both). Get directly from Windows Update. - Visual C# Express - http://msdn.microsoft.com/vstudio/express/visualcsharp/ - nAnt (0.85) - http://nant.sourceforge.net/ - nUnit Framework (2.2.8 or greater) - http://www.nunit.org/ - -3D Stuff (i.e. sceneviewer) for Windows: - XNA - http://msdn.microsoft.com/directx/XNA/default.aspx - XGE - http://msdn.microsoft.com/directx/xna/gse/ - -If you are using Visual Studio or Visual C# Express you can simply open -the libsecondlife.sln solution file and begin compiling. It will complain -about a missing dependency if you didn't install the nUnit framework, you -can either install it now or remove libsecondlife.Tests from the solution -file. - - -NAnt under Windows ------------------------------------------------------------------ - -1) Get .Net Frameworks (1.1 and 2.0) plus any patches installed via -Windows Update. Multiple reboots may be needed. - -2) Install Visual C# Express (defaults are fine) - -3) Install nUnit Framework (defaults are fine) - -4) Unpack the 0.85 binary of nAnt in a directory you can be happy with - (I chose C:\bin\nant-0.85\bin). Add this to your XP PATH variable: - - * Start->My Computer->[Right Click]->Properties (new window) - * Advanced Tab -> Environment Variables (new window) - * System Variables is bottom subwindow, click on 'path' and then the - 'Edit' button below that. (new window) - * Add ';C:\bin\nant-0.85\bin' or whereever it is to the line and click - OK. - * Click OK twice more to close out system config windows. - -5) In a Command Prompt (yea you heard that right) cd to where you checked -out the trunk (You're looking for the dir that has libsecondlife.build and -Ovastus.CSharp.targets). I'm going to call this %TRUNK% from here on. - - * Run 'nant' and sit back. 'cd bin' and enjoy! - -6) [Optional] Not all apps and examples will be in nant due to various -compatibility and stability issues. If you're still interested: - - * Under %TRUNK%\libsecondlife-cs, open the libsecondlife.sln file and - Build the Solution (you're likely going to get warnings and such here). - * This may overwrite some of the files you created in step 5; If they - don't work re-run nant. - - -Linux ------------------------------------------------------------------ ------------------------------------------------------------------ - - -Software Needed ---------------- - -mono - http://www.mono-project.com/ -nAnt (0.85) - http://nant.sourceforge.net/ -nUnit Framework (2.2.8 or greater) - http://www.nunit.org/ - - -Compiling ---------- - -Simply go to the directory where you extracted libsecondlife, where the -libsecondlife.build file is located and type "nant". To build a zip file -package use "nant package", and to generate documentation use "nant doc". - - -Happy fiddling, ---libsecondlife Team + +libsecondlife +------------- + +We're still working on getting some documentation prepared for our first +"official" release, so bear with us for now. If you need any help we +have a couple of resources, the primary one being the #libsl IRC channel +on EFNet. There are also the web forums at +http://www.libsecondlife.org/forums/ and the libsecondlife-dev mailing +list at https://gna.org/mail/?group=libsecondlife and lastly you can use +the e-mail contact@libsecondlife.org for any general inquiries (although +we prefer developer-related questions to go to IRC, forums, or the +mailing list). + +To checkout a copy of libsecondlife trunk see +https://gna.org/svn/?group=libsecondlife for details. The HTTP method +seems to be more reliable. + +Windows +----------------------------------------------------------------- +----------------------------------------------------------------- + + +Microsoft Visual Studio +----------------------- + +Visual Studio 2005 project files are included to ease compiling on Windows +platforms. Some of the projects use a custom targets file that allows you +to compile against .NET 1.0/1.1, mono, or the Compact Framework. You will +need to authorize this custom file when you first open the solution file. + + +Software Needed (all Freeware) +------------------------------ + +Basic Stuff (Windows): + MS .NET Framework (1.1 and/or 2.0 depending on what you're working on; + preferably both). Get directly from Windows Update. + Visual C# Express - http://msdn.microsoft.com/vstudio/express/visualcsharp/ + nAnt (0.85) - http://nant.sourceforge.net/ + nUnit Framework (2.2.8 or greater) - http://www.nunit.org/ + +3D Stuff (i.e. sceneviewer) for Windows: + XNA - http://msdn.microsoft.com/directx/XNA/default.aspx + XGE - http://msdn.microsoft.com/directx/xna/gse/ + +If you are using Visual Studio or Visual C# Express you can simply open +the libsecondlife.sln solution file and begin compiling. It will complain +about a missing dependency if you didn't install the nUnit framework, you +can either install it now or remove libsecondlife.Tests from the solution +file. + + +NAnt under Windows +----------------------------------------------------------------- + +1) Get .Net Frameworks (1.1 and 2.0) plus any patches installed via +Windows Update. Multiple reboots may be needed. + +2) Install Visual C# Express (defaults are fine) + +3) Install nUnit Framework (defaults are fine) + +4) Unpack the 0.85 binary of nAnt in a directory you can be happy with + (I chose C:\bin\nant-0.85\bin). Add this to your XP PATH variable: + + * Start->My Computer->[Right Click]->Properties (new window) + * Advanced Tab -> Environment Variables (new window) + * System Variables is bottom subwindow, click on 'path' and then the + 'Edit' button below that. (new window) + * Add ';C:\bin\nant-0.85\bin' or whereever it is to the line and click + OK. + * Click OK twice more to close out system config windows. + +5) In a Command Prompt (yea you heard that right) cd to where you checked +out the trunk (You're looking for the dir that has libsecondlife.build and +Ovastus.CSharp.targets). I'm going to call this %TRUNK% from here on. + + * Run 'nant' and sit back. 'cd bin' and enjoy! + +6) [Optional] Not all apps and examples will be in nant due to various +compatibility and stability issues. If you're still interested: + + * Under %TRUNK%\libsecondlife-cs, open the libsecondlife.sln file and + Build the Solution (you're likely going to get warnings and such here). + * This may overwrite some of the files you created in step 5; If they + don't work re-run nant. + + +Linux +----------------------------------------------------------------- +----------------------------------------------------------------- + + +Software Needed +--------------- + +mono - http://www.mono-project.com/ +nAnt (0.85) - http://nant.sourceforge.net/ +nUnit Framework (2.2.8 or greater) - http://www.nunit.org/ + + +Compiling +--------- + +Simply go to the directory where you extracted libsecondlife, where the +libsecondlife.build file is located and type "nant". To build a zip file +package use "nant package", and to generate documentation use "nant doc". + + +Happy fiddling, +--libsecondlife Team diff --git a/applications/Decoder/Decoder.cs b/applications/Decoder/Decoder.cs index 9410a6bb..51ea4dd2 100644 --- a/applications/Decoder/Decoder.cs +++ b/applications/Decoder/Decoder.cs @@ -32,12 +32,12 @@ using System.Globalization; using System.IO; using System.Text.RegularExpressions; -using libsecondlife; +using libsecondlife; using libsecondlife.Packets; class Decoder { - private static int BUFSIZE = 8096; - + private static int BUFSIZE = 8096; + private static SecondLife client = new SecondLife(); private static ProtocolManager protocol = new ProtocolManager("keywords.txt", "message_template.msg", client); private static string grep = null; @@ -171,43 +171,43 @@ class Decoder { } else buf = data; - //Packet packet = new Packet(buf, pos, protocol); - // FIXME: Is this right? I haven't really looked at this code at all + //Packet packet = new Packet(buf, pos, protocol); + // FIXME: Is this right? I haven't really looked at this code at all Packet packet = Packet.BuildPacket(buf, ref pos); if (grep != null) { - bool match = false; - - //FIXME: This needs to be updated for the new libsecondlife API - //foreach (Block block in packet.Blocks()) - //{ - // foreach (Field field in block.Fields) - // { - // string value; - // if (field.Layout.Type == FieldType.Variable) - // value = DataConvert.toChoppedString(field.Data); - // else - // value = field.Data.ToString(); - // if (Regex.Match(packet.Layout.Name + "." + block.Layout.Name + "." + field.Layout.Name + " = " + value, grep, RegexOptions.IgnoreCase).Success) - // { - // match = true; - // break; - // } - - // // try matching variable fields in 0x notation - // if (field.Layout.Type == FieldType.Variable) - // { - // StringWriter sw = new StringWriter(); - // sw.Write("0x"); - // foreach (byte b in (byte[])field.Data) - // sw.Write("{0:x2}", b); - // if (Regex.Match(packet.Layout.Name + "." + block.Layout.Name + "." + field.Layout.Name + " = " + sw, grep, RegexOptions.IgnoreCase).Success) - // { - // match = true; - // break; - // } - // } - // } + bool match = false; + + //FIXME: This needs to be updated for the new libsecondlife API + //foreach (Block block in packet.Blocks()) + //{ + // foreach (Field field in block.Fields) + // { + // string value; + // if (field.Layout.Type == FieldType.Variable) + // value = DataConvert.toChoppedString(field.Data); + // else + // value = field.Data.ToString(); + // if (Regex.Match(packet.Layout.Name + "." + block.Layout.Name + "." + field.Layout.Name + " = " + value, grep, RegexOptions.IgnoreCase).Success) + // { + // match = true; + // break; + // } + + // // try matching variable fields in 0x notation + // if (field.Layout.Type == FieldType.Variable) + // { + // StringWriter sw = new StringWriter(); + // sw.Write("0x"); + // foreach (byte b in (byte[])field.Data) + // sw.Write("{0:x2}", b); + // if (Regex.Match(packet.Layout.Name + "." + block.Layout.Name + "." + field.Layout.Name + " = " + sw, grep, RegexOptions.IgnoreCase).Success) + // { + // match = true; + // break; + // } + // } + // } //} if (!match) { diff --git a/applications/Decoder/Decoder.csproj b/applications/Decoder/Decoder.csproj index 830cd346..68af62a6 100644 --- a/applications/Decoder/Decoder.csproj +++ b/applications/Decoder/Decoder.csproj @@ -1,56 +1,56 @@ - - - Debug - AnyCPU - 8.0.50727 - 2.0 - {7AE16AC1-E64C-4FDC-9B85-4BB6145D511C} - Exe - Properties - Decoder - Decoder - Decoder - - - true - full - false - ..\..\bin\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - {D9CDEDFB-8169-4B03-B57F-0DF638F044EC} - libsecondlife - - - - - - - - - - + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {7AE16AC1-E64C-4FDC-9B85-4BB6145D511C} + Exe + Properties + Decoder + Decoder + Decoder + + + true + full + false + ..\..\bin\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + {D9CDEDFB-8169-4B03-B57F-0DF638F044EC} + libsecondlife + + + + + + + + + + \ No newline at end of file diff --git a/applications/SLChat/SLChat.sln b/applications/SLChat/SLChat.sln index 80fab9a2..24b20c31 100644 --- a/applications/SLChat/SLChat.sln +++ b/applications/SLChat/SLChat.sln @@ -1,19 +1,19 @@ -Microsoft Visual Studio Solution File, Format Version 9.00 -# SharpDevelop 2.0.0.1462 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SLChat", "SLChat\SLChat.csproj", "{A6D955CD-1F55-459F-A7AD-01E591404989}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {A6D955CD-1F55-459F-A7AD-01E591404989}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A6D955CD-1F55-459F-A7AD-01E591404989}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A6D955CD-1F55-459F-A7AD-01E591404989}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A6D955CD-1F55-459F-A7AD-01E591404989}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal +Microsoft Visual Studio Solution File, Format Version 9.00 +# SharpDevelop 2.0.0.1462 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SLChat", "SLChat\SLChat.csproj", "{A6D955CD-1F55-459F-A7AD-01E591404989}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A6D955CD-1F55-459F-A7AD-01E591404989}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A6D955CD-1F55-459F-A7AD-01E591404989}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A6D955CD-1F55-459F-A7AD-01E591404989}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A6D955CD-1F55-459F-A7AD-01E591404989}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/applications/SLChat/SLChat/Core/ChatTextManager.cs b/applications/SLChat/SLChat/Core/ChatTextManager.cs index acf0ca31..b0fa8ade 100644 --- a/applications/SLChat/SLChat/Core/ChatTextManager.cs +++ b/applications/SLChat/SLChat/Core/ChatTextManager.cs @@ -1,151 +1,151 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Text; -using System.Windows.Forms; -using SLNetworkComm; -using libsecondlife; - -namespace SLChat -{ - public class ChatTextManager - { - private ITextPrinter textPrinter; - private SLNetCom netcom; - private PrefsManager prefs; - //Our color set for the different textes. - private Color colorProgram = Color.RoyalBlue; - private Color colorSLSystem = Color.Teal; - private Color colorUserText = Color.Black; - private Color colorObjectText = Color.DarkGreen; - private Color colorLindenText = Color.Chocolate; - - public ChatTextManager(ITextPrinter textPrinter, SLNetCom netcom, PrefsManager preferences) - { - this.textPrinter = textPrinter; - this.netcom = netcom; - this.prefs = preferences; - - this.AddNetcomEvents(); - } - - private void AddNetcomEvents() - { - netcom.ClientLoggedIn += new EventHandler(netcom_ClientLoggedIn); - netcom.ClientLoggedOut += new EventHandler(netcom_ClientLoggedOut); - netcom.ClientLoginError += new EventHandler(netcom_ClientLoginError); - netcom.ChatReceived += new EventHandler(netcom_ChatReceived); - } - - private void netcom_ChatReceived(object sender, ChatEventArgs e) - { - if (string.IsNullOrEmpty(e.Message)) return; - - if (prefs.setChatTimestamps) - { - - TimeSpan t = (DateTime.UtcNow - new DateTime(1970, 1, 1)); - DateTime tr = (new DateTime(1970,1,1)).AddSeconds(t.TotalSeconds); - tr = tr.AddHours(int.Parse(prefs.setChatTimeZ)); - textPrinter.ForeColor = Color.Gray; - textPrinter.PrintText(tr.ToString(prefs.setChatStampFormat)); - } - - StringBuilder sb = new StringBuilder(); - - //If the name is the users, the source is an agent, - //and a "/me" command is not being done, then we append "you" - //otherwise we append the full name. - if (e.FromName == netcom.LoginOptions.FullName & e.SourceType == SLSourceType.Avatar & !e.Message.ToLower().StartsWith("/me ") & !prefs.setUseFullName) - sb.Append("You"); - else - sb.Append(e.FromName); - - switch (e.Type) - { - case SLChatType.Say: - //sb.Append(": "); - break; - - case SLChatType.Whisper: - sb.Append(" whisper"); - break; - - case SLChatType.Shout: - sb.Append(" shout"); - break; - } - - //Setting us up for proper grammar, so we don't get "You shouts" - //but rather "You shout" - if(e.FromName != netcom.LoginOptions.FullName & e.Type != SLChatType.Say) - sb.Append("s"); - - //Checking for a /me command - string Mess = e.Message; - if(!e.Message.ToLower().StartsWith("/me ")) - { - sb.Append(": "); - }else { - Mess = e.Message.Remove(0,3); - } - - sb.Append(Mess); - - switch (e.SourceType) - { - case SLSourceType.Avatar: - if(e.FromName.Split(' ')[1]=="Linden") - { - textPrinter.ForeColor = colorLindenText; - }else{ - textPrinter.ForeColor = colorUserText; - } - break; - - case SLSourceType.Object: - textPrinter.ForeColor = colorObjectText; - break; - } - - textPrinter.PrintTextLine(sb.ToString()); - sb = null; - } - - private void netcom_ClientLoginError(object sender, ClientLoginEventArgs e) - { - textPrinter.ForeColor = colorSLSystem; - textPrinter.PrintTextLine("Login error: " + e.LoginReply); - } - - private void netcom_ClientLoggedOut(object sender, ClientLoginEventArgs e) - { - textPrinter.ForeColor = colorProgram; - textPrinter.PrintTextLine("Logged out of Second Life."); - - textPrinter.ForeColor = colorSLSystem; - textPrinter.PrintTextLine("Logout reply: " + e.LoginReply); - } - - private void netcom_ClientLoggedIn(object sender, ClientLoginEventArgs e) - { - textPrinter.ForeColor = colorProgram; - textPrinter.PrintTextLine("Logged into Second Life as " + netcom.LoginOptions.FullName + "."); - - textPrinter.ForeColor = colorSLSystem; - textPrinter.PrintTextLine("Login reply: " + e.LoginReply); - } - - public void PrintProgramMessage(string msg) - { - textPrinter.ForeColor = colorProgram; - textPrinter.PrintTextLine(msg); - } - - public ITextPrinter TextPrinter - { - get { return textPrinter; } - set { textPrinter = value; } - } - } -} +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Text; +using System.Windows.Forms; +using SLNetworkComm; +using libsecondlife; + +namespace SLChat +{ + public class ChatTextManager + { + private ITextPrinter textPrinter; + private SLNetCom netcom; + private PrefsManager prefs; + //Our color set for the different textes. + private Color colorProgram = Color.RoyalBlue; + private Color colorSLSystem = Color.Teal; + private Color colorUserText = Color.Black; + private Color colorObjectText = Color.DarkGreen; + private Color colorLindenText = Color.Chocolate; + + public ChatTextManager(ITextPrinter textPrinter, SLNetCom netcom, PrefsManager preferences) + { + this.textPrinter = textPrinter; + this.netcom = netcom; + this.prefs = preferences; + + this.AddNetcomEvents(); + } + + private void AddNetcomEvents() + { + netcom.ClientLoggedIn += new EventHandler(netcom_ClientLoggedIn); + netcom.ClientLoggedOut += new EventHandler(netcom_ClientLoggedOut); + netcom.ClientLoginError += new EventHandler(netcom_ClientLoginError); + netcom.ChatReceived += new EventHandler(netcom_ChatReceived); + } + + private void netcom_ChatReceived(object sender, ChatEventArgs e) + { + if (string.IsNullOrEmpty(e.Message)) return; + + if (prefs.setChatTimestamps) + { + + TimeSpan t = (DateTime.UtcNow - new DateTime(1970, 1, 1)); + DateTime tr = (new DateTime(1970,1,1)).AddSeconds(t.TotalSeconds); + tr = tr.AddHours(int.Parse(prefs.setChatTimeZ)); + textPrinter.ForeColor = Color.Gray; + textPrinter.PrintText(tr.ToString(prefs.setChatStampFormat)); + } + + StringBuilder sb = new StringBuilder(); + + //If the name is the users, the source is an agent, + //and a "/me" command is not being done, then we append "you" + //otherwise we append the full name. + if (e.FromName == netcom.LoginOptions.FullName & e.SourceType == SLSourceType.Avatar & !e.Message.ToLower().StartsWith("/me ") & !prefs.setUseFullName) + sb.Append("You"); + else + sb.Append(e.FromName); + + switch (e.Type) + { + case SLChatType.Say: + //sb.Append(": "); + break; + + case SLChatType.Whisper: + sb.Append(" whisper"); + break; + + case SLChatType.Shout: + sb.Append(" shout"); + break; + } + + //Setting us up for proper grammar, so we don't get "You shouts" + //but rather "You shout" + if(e.FromName != netcom.LoginOptions.FullName & e.Type != SLChatType.Say) + sb.Append("s"); + + //Checking for a /me command + string Mess = e.Message; + if(!e.Message.ToLower().StartsWith("/me ")) + { + sb.Append(": "); + }else { + Mess = e.Message.Remove(0,3); + } + + sb.Append(Mess); + + switch (e.SourceType) + { + case SLSourceType.Avatar: + if(e.FromName.Split(' ')[1]=="Linden") + { + textPrinter.ForeColor = colorLindenText; + }else{ + textPrinter.ForeColor = colorUserText; + } + break; + + case SLSourceType.Object: + textPrinter.ForeColor = colorObjectText; + break; + } + + textPrinter.PrintTextLine(sb.ToString()); + sb = null; + } + + private void netcom_ClientLoginError(object sender, ClientLoginEventArgs e) + { + textPrinter.ForeColor = colorSLSystem; + textPrinter.PrintTextLine("Login error: " + e.LoginReply); + } + + private void netcom_ClientLoggedOut(object sender, ClientLoginEventArgs e) + { + textPrinter.ForeColor = colorProgram; + textPrinter.PrintTextLine("Logged out of Second Life."); + + textPrinter.ForeColor = colorSLSystem; + textPrinter.PrintTextLine("Logout reply: " + e.LoginReply); + } + + private void netcom_ClientLoggedIn(object sender, ClientLoginEventArgs e) + { + textPrinter.ForeColor = colorProgram; + textPrinter.PrintTextLine("Logged into Second Life as " + netcom.LoginOptions.FullName + "."); + + textPrinter.ForeColor = colorSLSystem; + textPrinter.PrintTextLine("Login reply: " + e.LoginReply); + } + + public void PrintProgramMessage(string msg) + { + textPrinter.ForeColor = colorProgram; + textPrinter.PrintTextLine(msg); + } + + public ITextPrinter TextPrinter + { + get { return textPrinter; } + set { textPrinter = value; } + } + } +} diff --git a/applications/SLChat/SLChat/Core/IMTextManager.cs b/applications/SLChat/SLChat/Core/IMTextManager.cs index 19c41204..64da424e 100644 --- a/applications/SLChat/SLChat/Core/IMTextManager.cs +++ b/applications/SLChat/SLChat/Core/IMTextManager.cs @@ -1,79 +1,79 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Text; -using SLNetworkComm; -using libsecondlife; - -namespace SLChat -{ - public class IMTextManager - { - private ITextPrinter textPrinter; - private SLNetCom netcom; - private PrefsManager prefs; - - public IMTextManager(ITextPrinter textPrinter, SLNetCom netcom, PrefsManager preferences) - { - this.textPrinter = textPrinter; - this.netcom = netcom; - this.prefs = preferences; - - this.AddNetcomEvents(); - } - - private void AddNetcomEvents() - { - netcom.InstantMessageReceived += new EventHandler(netcom_InstantMessageReceived); - netcom.InstantMessageSent += new EventHandler(netcom_InstantMessageSent); - } - - private void netcom_InstantMessageSent(object sender, InstantMessageSentEventArgs e) - { - this.PrintIM(e.Timestamp, netcom.LoginOptions.FullName, e.Message); - } - - private void netcom_InstantMessageReceived(object sender, InstantMessageEventArgs e) - { - this.PrintIM(e.Timestamp, e.FromAgentName, e.Message); - } - - public void PrintIM(DateTime timestamp, string fromName, string message) - { - if (prefs.setIMTimestamps) - { - timestamp = timestamp.AddHours(int.Parse(prefs.setIMTimeZ)); - textPrinter.ForeColor = Color.Gray; - textPrinter.PrintText(timestamp.ToString(prefs.setIMStampFormat)); - } - - textPrinter.ForeColor = Color.Black; - - StringBuilder sb = new StringBuilder(); - - sb.Append(fromName); - sb.Append(": "); - sb.Append(message); - - textPrinter.PrintTextLine(sb.ToString()); - sb = null; - } - - public void PrintProgramMessage(string msg) - { - textPrinter.ForeColor = Color.RoyalBlue; - textPrinter.PrintTextLine(msg); - } - - public void PassIMEvent(InstantMessageEventArgs e) - { - this.netcom_InstantMessageReceived(netcom, e); - } - - public ITextPrinter TextPrinter - { - get { return textPrinter; } - set { textPrinter = value; } - } - } -} +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Text; +using SLNetworkComm; +using libsecondlife; + +namespace SLChat +{ + public class IMTextManager + { + private ITextPrinter textPrinter; + private SLNetCom netcom; + private PrefsManager prefs; + + public IMTextManager(ITextPrinter textPrinter, SLNetCom netcom, PrefsManager preferences) + { + this.textPrinter = textPrinter; + this.netcom = netcom; + this.prefs = preferences; + + this.AddNetcomEvents(); + } + + private void AddNetcomEvents() + { + netcom.InstantMessageReceived += new EventHandler(netcom_InstantMessageReceived); + netcom.InstantMessageSent += new EventHandler(netcom_InstantMessageSent); + } + + private void netcom_InstantMessageSent(object sender, InstantMessageSentEventArgs e) + { + this.PrintIM(e.Timestamp, netcom.LoginOptions.FullName, e.Message); + } + + private void netcom_InstantMessageReceived(object sender, InstantMessageEventArgs e) + { + this.PrintIM(e.Timestamp, e.FromAgentName, e.Message); + } + + public void PrintIM(DateTime timestamp, string fromName, string message) + { + if (prefs.setIMTimestamps) + { + timestamp = timestamp.AddHours(int.Parse(prefs.setIMTimeZ)); + textPrinter.ForeColor = Color.Gray; + textPrinter.PrintText(timestamp.ToString(prefs.setIMStampFormat)); + } + + textPrinter.ForeColor = Color.Black; + + StringBuilder sb = new StringBuilder(); + + sb.Append(fromName); + sb.Append(": "); + sb.Append(message); + + textPrinter.PrintTextLine(sb.ToString()); + sb = null; + } + + public void PrintProgramMessage(string msg) + { + textPrinter.ForeColor = Color.RoyalBlue; + textPrinter.PrintTextLine(msg); + } + + public void PassIMEvent(InstantMessageEventArgs e) + { + this.netcom_InstantMessageReceived(netcom, e); + } + + public ITextPrinter TextPrinter + { + get { return textPrinter; } + set { textPrinter = value; } + } + } +} diff --git a/applications/SLChat/SLChat/Core/ITextPrinter.cs b/applications/SLChat/SLChat/Core/ITextPrinter.cs index 739439b6..3c3c9609 100644 --- a/applications/SLChat/SLChat/Core/ITextPrinter.cs +++ b/applications/SLChat/SLChat/Core/ITextPrinter.cs @@ -1,18 +1,18 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Text; - -namespace SLChat -{ - public interface ITextPrinter - { - void PrintText(string text); - void PrintTextLine(string text); - - string Content { get; set; } - Color ForeColor { get; set; } - Color BackColor { get; set; } - Font Font { get; set; } - } -} +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Text; + +namespace SLChat +{ + public interface ITextPrinter + { + void PrintText(string text); + void PrintTextLine(string text); + + string Content { get; set; } + Color ForeColor { get; set; } + Color BackColor { get; set; } + Font Font { get; set; } + } +} diff --git a/applications/SLChat/SLChat/Core/PrefsManager.cs b/applications/SLChat/SLChat/Core/PrefsManager.cs index e58237cb..17649edb 100644 --- a/applications/SLChat/SLChat/Core/PrefsManager.cs +++ b/applications/SLChat/SLChat/Core/PrefsManager.cs @@ -1,232 +1,232 @@ -/* - * Created by SharpDevelop. - * User: Oz - * Date: 8/12/2006 - * Time: 2:48 PM - * - * To change this template use Tools | Options | Coding | Edit Standard Headers. - */ - -using System; -using System.Xml; -using System.Xml.XPath; -using System.IO; -using System.Collections; - -namespace SLChat -{ - /// - /// Description of PrefsManager. - /// Loads, saves, checks, etc. preferences and files related. - /// - public class PrefsManager - { - public bool setUseFullName = false; - public bool setListUserName = true; - public bool setIMTimestamps = true; - public bool setChatTimestamps = false; - public string setChatTimeZ = "-7"; - public string setIMTimeZ = "-3"; //For some reason IM timestamps only match PDT if you use -3 instead of -7 - public string setChatStampFormat = "[HH:mm] "; - public string setIMStampFormat = "[HH:mm] "; - public bool setSyncTimestamps = true; - public string[] profiles = new string[100]; //Sending out profiles - public Hashtable settings = new Hashtable(); //sending out the collected settings - - public PrefsManager() - { - - } - - public void SaveSettings(string username, string nodeparent, string nodechildren) - { - //Saving our login settings - //username = name of user/profile under which settings are saved - //nodeparent = name of node grouping to save under, i.e. "LoginSettings" - //nodechildren = collection of nodes with pre-set values saved under parent. - //pick whatever filename with .xml extension - string filename = @"Profiles\\"+username+"\\settings.xml"; - SaveDirectory(@"Profiles\\"+username+"\\"); - - XmlDocument xmlDoc = new XmlDocument(); - - try - { - xmlDoc.Load(filename); - } - catch(System.IO.FileNotFoundException) - { - //if file is not found, create a new xml file - XmlTextWriter xmlWriter = new XmlTextWriter(filename, System.Text.Encoding.UTF8); - xmlWriter.Formatting = Formatting.Indented; - xmlWriter.WriteProcessingInstruction("xml", "version='1.0' encoding='UTF-8'"); - xmlWriter.WriteStartElement("SLChatSettings"); - //If WriteProcessingInstruction is used as above, - //Do not use WriteEndElement() here - //xmlWriter.WriteEndElement(); - //it will cause the <Root> to be <Root /> - xmlWriter.Close(); - xmlDoc.Load(filename); - } - - XmlNode root = xmlDoc.DocumentElement; - XmlNodeList nodeList = xmlDoc.GetElementsByTagName(nodeparent); - if(nodeList.Count!=0){ - root.RemoveChild(nodeList[0]); - } - XmlElement loginSettings = xmlDoc.CreateElement(nodeparent); - string strSettings = nodechildren; - loginSettings.InnerXml = strSettings; - - root.AppendChild(loginSettings); - - xmlDoc.Save(filename); - } - - private void SaveDirectory(string PathName) - { - try - { - DirectoryInfo TheFolder = new DirectoryInfo(PathName); - if (TheFolder.Exists) - { - return; - } - - throw new FileNotFoundException(); - } - catch(FileNotFoundException ) - { - DirectoryInfo TheDir = new DirectoryInfo(PathName); - TheDir.Create(); - return; - } - } - - public void DeleteProfile(string username) - { - string PathName = @"Profiles\\"+username; - - try - { - DirectoryInfo TheFolder = new DirectoryInfo(PathName); - if (TheFolder.Exists) - { - TheFolder.Delete(true); - profiles[0] = "success"; - return; - } - - throw new FileNotFoundException(); - } - catch(FileNotFoundException ) - { - //If the folders are not found, inform user. - profiles[0] = "Profile not found."; - return; - } - catch(Exception e) - { - //An unexpected error occured. - profiles[0] = "Problem occured: "+e.Message; - return; - } - } - - public void LoadProfiles() - { - string PathName = @"Profiles\\"; - - try - { - DirectoryInfo TheFolder = new DirectoryInfo(PathName); - if (TheFolder.Exists) - { - int i = 0; - DirectoryInfo[] dirs = TheFolder.GetDirectories(); - foreach(DirectoryInfo di in dirs) - { - profiles[i] = di.Name; - i++; - } - return; - } - - throw new FileNotFoundException(); - } - catch(FileNotFoundException ) - { - //If the folders are not found, inform user. - profiles[0] = "No profiles found."; - return; - } - catch(Exception e) - { - //An unexpected error occured. - profiles[0] = "Problem occured: "+e.Message; - return; - } - } - - public void LoadSettings(string username, string parentnode) - { - //Load our login settings. - if(username==string.Empty) return; - - string filename = @"Profiles\\"+username+"\\settings.xml"; - - XmlDocument xmlDoc = new XmlDocument(); - - try - { - xmlDoc.Load(filename); - } - catch(System.IO.FileNotFoundException) - { - settings.Add("Error","File not found"); - return; - } - - XmlNode root = xmlDoc.DocumentElement; - XmlNodeList nodeList = xmlDoc.GetElementsByTagName(parentnode); - if(nodeList.Count>0){ - for(int i = 0;i + /// Description of PrefsManager. + /// Loads, saves, checks, etc. preferences and files related. + /// + public class PrefsManager + { + public bool setUseFullName = false; + public bool setListUserName = true; + public bool setIMTimestamps = true; + public bool setChatTimestamps = false; + public string setChatTimeZ = "-7"; + public string setIMTimeZ = "-3"; //For some reason IM timestamps only match PDT if you use -3 instead of -7 + public string setChatStampFormat = "[HH:mm] "; + public string setIMStampFormat = "[HH:mm] "; + public bool setSyncTimestamps = true; + public string[] profiles = new string[100]; //Sending out profiles + public Hashtable settings = new Hashtable(); //sending out the collected settings + + public PrefsManager() + { + + } + + public void SaveSettings(string username, string nodeparent, string nodechildren) + { + //Saving our login settings + //username = name of user/profile under which settings are saved + //nodeparent = name of node grouping to save under, i.e. "LoginSettings" + //nodechildren = collection of nodes with pre-set values saved under parent. + //pick whatever filename with .xml extension + string filename = @"Profiles\\"+username+"\\settings.xml"; + SaveDirectory(@"Profiles\\"+username+"\\"); + + XmlDocument xmlDoc = new XmlDocument(); + + try + { + xmlDoc.Load(filename); + } + catch(System.IO.FileNotFoundException) + { + //if file is not found, create a new xml file + XmlTextWriter xmlWriter = new XmlTextWriter(filename, System.Text.Encoding.UTF8); + xmlWriter.Formatting = Formatting.Indented; + xmlWriter.WriteProcessingInstruction("xml", "version='1.0' encoding='UTF-8'"); + xmlWriter.WriteStartElement("SLChatSettings"); + //If WriteProcessingInstruction is used as above, + //Do not use WriteEndElement() here + //xmlWriter.WriteEndElement(); + //it will cause the <Root> to be <Root /> + xmlWriter.Close(); + xmlDoc.Load(filename); + } + + XmlNode root = xmlDoc.DocumentElement; + XmlNodeList nodeList = xmlDoc.GetElementsByTagName(nodeparent); + if(nodeList.Count!=0){ + root.RemoveChild(nodeList[0]); + } + XmlElement loginSettings = xmlDoc.CreateElement(nodeparent); + string strSettings = nodechildren; + loginSettings.InnerXml = strSettings; + + root.AppendChild(loginSettings); + + xmlDoc.Save(filename); + } + + private void SaveDirectory(string PathName) + { + try + { + DirectoryInfo TheFolder = new DirectoryInfo(PathName); + if (TheFolder.Exists) + { + return; + } + + throw new FileNotFoundException(); + } + catch(FileNotFoundException ) + { + DirectoryInfo TheDir = new DirectoryInfo(PathName); + TheDir.Create(); + return; + } + } + + public void DeleteProfile(string username) + { + string PathName = @"Profiles\\"+username; + + try + { + DirectoryInfo TheFolder = new DirectoryInfo(PathName); + if (TheFolder.Exists) + { + TheFolder.Delete(true); + profiles[0] = "success"; + return; + } + + throw new FileNotFoundException(); + } + catch(FileNotFoundException ) + { + //If the folders are not found, inform user. + profiles[0] = "Profile not found."; + return; + } + catch(Exception e) + { + //An unexpected error occured. + profiles[0] = "Problem occured: "+e.Message; + return; + } + } + + public void LoadProfiles() + { + string PathName = @"Profiles\\"; + + try + { + DirectoryInfo TheFolder = new DirectoryInfo(PathName); + if (TheFolder.Exists) + { + int i = 0; + DirectoryInfo[] dirs = TheFolder.GetDirectories(); + foreach(DirectoryInfo di in dirs) + { + profiles[i] = di.Name; + i++; + } + return; + } + + throw new FileNotFoundException(); + } + catch(FileNotFoundException ) + { + //If the folders are not found, inform user. + profiles[0] = "No profiles found."; + return; + } + catch(Exception e) + { + //An unexpected error occured. + profiles[0] = "Problem occured: "+e.Message; + return; + } + } + + public void LoadSettings(string username, string parentnode) + { + //Load our login settings. + if(username==string.Empty) return; + + string filename = @"Profiles\\"+username+"\\settings.xml"; + + XmlDocument xmlDoc = new XmlDocument(); + + try + { + xmlDoc.Load(filename); + } + catch(System.IO.FileNotFoundException) + { + settings.Add("Error","File not found"); + return; + } + + XmlNode root = xmlDoc.DocumentElement; + XmlNodeList nodeList = xmlDoc.GetElementsByTagName(parentnode); + if(nodeList.Count>0){ + for(int i = 0;i - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.btnClose = new System.Windows.Forms.Button(); - this.rtbCredits = new System.Windows.Forms.RichTextBox(); - this.SuspendLayout(); - // - // btnClose - // - this.btnClose.Location = new System.Drawing.Point(227, 231); - this.btnClose.Name = "btnClose"; - this.btnClose.Size = new System.Drawing.Size(75, 23); - this.btnClose.TabIndex = 1; - this.btnClose.Text = "Close"; - this.btnClose.UseVisualStyleBackColor = true; - this.btnClose.Click += new System.EventHandler(this.btnClose_Click); - // - // rtbCredits - // - this.rtbCredits.BackColor = System.Drawing.Color.White; - this.rtbCredits.Location = new System.Drawing.Point(12, 12); - this.rtbCredits.Name = "rtbCredits"; - this.rtbCredits.ReadOnly = true; - this.rtbCredits.Size = new System.Drawing.Size(290, 209); - this.rtbCredits.TabIndex = 2; - this.rtbCredits.Text = ""; - this.rtbCredits.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(this.Link_Clicked); - // - // frmAbout - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(314, 266); - this.Controls.Add(this.rtbCredits); - this.Controls.Add(this.btnClose); - this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "frmAbout"; - this.ShowIcon = false; - this.ShowInTaskbar = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "About SLChat"; - this.ResumeLayout(false); - } - private System.Windows.Forms.RichTextBox rtbCredits; - - #endregion - - private System.Windows.Forms.Button btnClose; - } -} +namespace SLChat +{ + partial class frmAbout + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.btnClose = new System.Windows.Forms.Button(); + this.rtbCredits = new System.Windows.Forms.RichTextBox(); + this.SuspendLayout(); + // + // btnClose + // + this.btnClose.Location = new System.Drawing.Point(227, 231); + this.btnClose.Name = "btnClose"; + this.btnClose.Size = new System.Drawing.Size(75, 23); + this.btnClose.TabIndex = 1; + this.btnClose.Text = "Close"; + this.btnClose.UseVisualStyleBackColor = true; + this.btnClose.Click += new System.EventHandler(this.btnClose_Click); + // + // rtbCredits + // + this.rtbCredits.BackColor = System.Drawing.Color.White; + this.rtbCredits.Location = new System.Drawing.Point(12, 12); + this.rtbCredits.Name = "rtbCredits"; + this.rtbCredits.ReadOnly = true; + this.rtbCredits.Size = new System.Drawing.Size(290, 209); + this.rtbCredits.TabIndex = 2; + this.rtbCredits.Text = ""; + this.rtbCredits.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(this.Link_Clicked); + // + // frmAbout + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(314, 266); + this.Controls.Add(this.rtbCredits); + this.Controls.Add(this.btnClose); + this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "frmAbout"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "About SLChat"; + this.ResumeLayout(false); + } + private System.Windows.Forms.RichTextBox rtbCredits; + + #endregion + + private System.Windows.Forms.Button btnClose; + } +} diff --git a/applications/SLChat/SLChat/GUI/About.cs b/applications/SLChat/SLChat/GUI/About.cs index cfc08747..5af4f6f5 100644 --- a/applications/SLChat/SLChat/GUI/About.cs +++ b/applications/SLChat/SLChat/GUI/About.cs @@ -1,40 +1,40 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Text; -using System.Windows.Forms; - -namespace SLChat -{ - public partial class frmAbout : Form - { - private frmMain MainForm; - - public frmAbout(frmMain main) - { - InitializeComponent(); - MainForm = main; - rtbCredits.SelectionFont = new Font(rtbCredits.Font, FontStyle.Bold); - rtbCredits.AppendText("SLChat v0.0.0.3"); - rtbCredits.SelectionFont = new Font(rtbCredits.Font, FontStyle.Regular); - rtbCredits.AppendText("\nhttp://www.libsecondlife.org/content/view/16/32/"+ - "\n\nUsing the libsecondlife library (http://libsecondlife.org)"+ - "\n\nDeveloped by: Oz Spade, Delta Czukor, Baba Yamamoto"+ - "\n\nBuilt off of Delta Czukor's SLeek"+ - "\n\n\n\nA nark posing as someone who poses as a nark."); - } - - private void Link_Clicked (object sender, System.Windows.Forms.LinkClickedEventArgs e) - { - System.Diagnostics.Process.Start(e.LinkText); - } - - private void btnClose_Click(object sender, EventArgs e) - { - MainForm.aboutCreated = false; - this.Close(); - } - } -} +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; + +namespace SLChat +{ + public partial class frmAbout : Form + { + private frmMain MainForm; + + public frmAbout(frmMain main) + { + InitializeComponent(); + MainForm = main; + rtbCredits.SelectionFont = new Font(rtbCredits.Font, FontStyle.Bold); + rtbCredits.AppendText("SLChat v0.0.0.3"); + rtbCredits.SelectionFont = new Font(rtbCredits.Font, FontStyle.Regular); + rtbCredits.AppendText("\nhttp://www.libsecondlife.org/content/view/16/32/"+ + "\n\nUsing the libsecondlife library (http://libsecondlife.org)"+ + "\n\nDeveloped by: Oz Spade, Delta Czukor, Baba Yamamoto"+ + "\n\nBuilt off of Delta Czukor's SLeek"+ + "\n\n\n\nA nark posing as someone who poses as a nark."); + } + + private void Link_Clicked (object sender, System.Windows.Forms.LinkClickedEventArgs e) + { + System.Diagnostics.Process.Start(e.LinkText); + } + + private void btnClose_Click(object sender, EventArgs e) + { + MainForm.aboutCreated = false; + this.Close(); + } + } +} diff --git a/applications/SLChat/SLChat/GUI/About.resx b/applications/SLChat/SLChat/GUI/About.resx index 5ea0895e..7080a7d1 100644 --- a/applications/SLChat/SLChat/GUI/About.resx +++ b/applications/SLChat/SLChat/GUI/About.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/applications/SLChat/SLChat/GUI/IMTabWindow.Designer.cs b/applications/SLChat/SLChat/GUI/IMTabWindow.Designer.cs index e559d6d1..2b6e602f 100644 --- a/applications/SLChat/SLChat/GUI/IMTabWindow.Designer.cs +++ b/applications/SLChat/SLChat/GUI/IMTabWindow.Designer.cs @@ -1,123 +1,123 @@ -namespace SLChat -{ - partial class IMTabWindow - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Component Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.rtbIMText = new System.Windows.Forms.RichTextBox(); - this.cbxInput = new System.Windows.Forms.ComboBox(); - this.btnSend = new System.Windows.Forms.Button(); - this.btnClose = new System.Windows.Forms.Button(); - this.btnPrintKey = new System.Windows.Forms.Button(); - this.SuspendLayout(); - // - // rtbIMText - // - this.rtbIMText.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.rtbIMText.BackColor = System.Drawing.Color.White; - this.rtbIMText.HideSelection = false; - this.rtbIMText.Location = new System.Drawing.Point(3, 31); - this.rtbIMText.Name = "rtbIMText"; - this.rtbIMText.ReadOnly = true; - this.rtbIMText.Size = new System.Drawing.Size(354, 169); - this.rtbIMText.TabIndex = 0; - this.rtbIMText.Text = ""; - this.rtbIMText.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(this.Link_Clicked); - // - // cbxInput - // - this.cbxInput.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.cbxInput.FormattingEnabled = true; - this.cbxInput.Location = new System.Drawing.Point(3, 208); - this.cbxInput.Name = "cbxInput"; - this.cbxInput.Size = new System.Drawing.Size(273, 21); - this.cbxInput.TabIndex = 1; - this.cbxInput.KeyUp += new System.Windows.Forms.KeyEventHandler(this.cbxInput_KeyUp); - this.cbxInput.TextChanged += new System.EventHandler(this.cbxInput_TextChanged); - // - // btnSend - // - this.btnSend.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.btnSend.Enabled = false; - this.btnSend.Location = new System.Drawing.Point(282, 206); - this.btnSend.Name = "btnSend"; - this.btnSend.Size = new System.Drawing.Size(75, 23); - this.btnSend.TabIndex = 2; - this.btnSend.Text = "Send"; - this.btnSend.UseVisualStyleBackColor = true; - this.btnSend.Click += new System.EventHandler(this.btnSend_Click); - // - // btnClose - // - this.btnClose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.btnClose.Location = new System.Drawing.Point(282, 3); - this.btnClose.Name = "btnClose"; - this.btnClose.Size = new System.Drawing.Size(75, 23); - this.btnClose.TabIndex = 3; - this.btnClose.Text = "Close"; - this.btnClose.UseVisualStyleBackColor = true; - this.btnClose.Visible = false; - this.btnClose.Click += new System.EventHandler(this.BtnCloseClick); - // - // btnPrintKey - // - this.btnPrintKey.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.btnPrintKey.Location = new System.Drawing.Point(201, 3); - this.btnPrintKey.Name = "btnPrintKey"; - this.btnPrintKey.Size = new System.Drawing.Size(75, 23); - this.btnPrintKey.TabIndex = 4; - this.btnPrintKey.Text = "Print Key"; - this.btnPrintKey.UseVisualStyleBackColor = true; - this.btnPrintKey.Click += new System.EventHandler(this.BtnPrintKeyClick); - // - // IMTabWindow - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.btnPrintKey); - this.Controls.Add(this.btnClose); - this.Controls.Add(this.cbxInput); - this.Controls.Add(this.rtbIMText); - this.Controls.Add(this.btnSend); - this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Name = "IMTabWindow"; - this.Size = new System.Drawing.Size(360, 232); - this.ResumeLayout(false); - } - private System.Windows.Forms.Button btnPrintKey; - private System.Windows.Forms.Button btnClose; - - #endregion - - private System.Windows.Forms.RichTextBox rtbIMText; - private System.Windows.Forms.ComboBox cbxInput; - private System.Windows.Forms.Button btnSend; - } -} +namespace SLChat +{ + partial class IMTabWindow + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.rtbIMText = new System.Windows.Forms.RichTextBox(); + this.cbxInput = new System.Windows.Forms.ComboBox(); + this.btnSend = new System.Windows.Forms.Button(); + this.btnClose = new System.Windows.Forms.Button(); + this.btnPrintKey = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // rtbIMText + // + this.rtbIMText.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.rtbIMText.BackColor = System.Drawing.Color.White; + this.rtbIMText.HideSelection = false; + this.rtbIMText.Location = new System.Drawing.Point(3, 31); + this.rtbIMText.Name = "rtbIMText"; + this.rtbIMText.ReadOnly = true; + this.rtbIMText.Size = new System.Drawing.Size(354, 169); + this.rtbIMText.TabIndex = 0; + this.rtbIMText.Text = ""; + this.rtbIMText.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(this.Link_Clicked); + // + // cbxInput + // + this.cbxInput.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.cbxInput.FormattingEnabled = true; + this.cbxInput.Location = new System.Drawing.Point(3, 208); + this.cbxInput.Name = "cbxInput"; + this.cbxInput.Size = new System.Drawing.Size(273, 21); + this.cbxInput.TabIndex = 1; + this.cbxInput.KeyUp += new System.Windows.Forms.KeyEventHandler(this.cbxInput_KeyUp); + this.cbxInput.TextChanged += new System.EventHandler(this.cbxInput_TextChanged); + // + // btnSend + // + this.btnSend.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnSend.Enabled = false; + this.btnSend.Location = new System.Drawing.Point(282, 206); + this.btnSend.Name = "btnSend"; + this.btnSend.Size = new System.Drawing.Size(75, 23); + this.btnSend.TabIndex = 2; + this.btnSend.Text = "Send"; + this.btnSend.UseVisualStyleBackColor = true; + this.btnSend.Click += new System.EventHandler(this.btnSend_Click); + // + // btnClose + // + this.btnClose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btnClose.Location = new System.Drawing.Point(282, 3); + this.btnClose.Name = "btnClose"; + this.btnClose.Size = new System.Drawing.Size(75, 23); + this.btnClose.TabIndex = 3; + this.btnClose.Text = "Close"; + this.btnClose.UseVisualStyleBackColor = true; + this.btnClose.Visible = false; + this.btnClose.Click += new System.EventHandler(this.BtnCloseClick); + // + // btnPrintKey + // + this.btnPrintKey.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btnPrintKey.Location = new System.Drawing.Point(201, 3); + this.btnPrintKey.Name = "btnPrintKey"; + this.btnPrintKey.Size = new System.Drawing.Size(75, 23); + this.btnPrintKey.TabIndex = 4; + this.btnPrintKey.Text = "Print Key"; + this.btnPrintKey.UseVisualStyleBackColor = true; + this.btnPrintKey.Click += new System.EventHandler(this.BtnPrintKeyClick); + // + // IMTabWindow + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.btnPrintKey); + this.Controls.Add(this.btnClose); + this.Controls.Add(this.cbxInput); + this.Controls.Add(this.rtbIMText); + this.Controls.Add(this.btnSend); + this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.Name = "IMTabWindow"; + this.Size = new System.Drawing.Size(360, 232); + this.ResumeLayout(false); + } + private System.Windows.Forms.Button btnPrintKey; + private System.Windows.Forms.Button btnClose; + + #endregion + + private System.Windows.Forms.RichTextBox rtbIMText; + private System.Windows.Forms.ComboBox cbxInput; + private System.Windows.Forms.Button btnSend; + } +} diff --git a/applications/SLChat/SLChat/GUI/IMTabWindow.cs b/applications/SLChat/SLChat/GUI/IMTabWindow.cs index 4a2f42cb..c43ddbda 100644 --- a/applications/SLChat/SLChat/GUI/IMTabWindow.cs +++ b/applications/SLChat/SLChat/GUI/IMTabWindow.cs @@ -1,115 +1,115 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Drawing; -using System.Data; -using System.Text; -using System.Windows.Forms; -using SLNetworkComm; -using libsecondlife; - -namespace SLChat -{ - public partial class IMTabWindow : UserControl - { - private SLNetCom netcom; - private LLUUID target; - private LLUUID session; - private string toName; - private IMTextManager textManager; - private PrefsManager prefs; - public frmMain formMain; - public frmIMs formIM; - - public IMTabWindow(SLNetCom netcom, LLUUID target, LLUUID session, string toName, PrefsManager preferences) - { - InitializeComponent(); - - this.netcom = netcom; - this.target = target; - this.session = session; - this.toName = toName; - this.prefs = preferences; - - textManager = new IMTextManager(new RichTextBoxPrinter(rtbIMText), this.netcom, prefs); - } - - private void btnSend_Click(object sender, EventArgs e) - { - netcom.SendInstantMessage(cbxInput.Text, target, session); - this.ClearIMInput(); - } - - private void cbxInput_TextChanged(object sender, EventArgs e) - { - btnSend.Enabled = (cbxInput.Text.Length > 0); - } - - private void cbxInput_KeyUp(object sender, KeyEventArgs e) - { - if (e.KeyCode != Keys.Enter) return; - if (cbxInput.Text.Length == 0) return; - - netcom.SendInstantMessage(cbxInput.Text, target, session); - this.ClearIMInput(); - } - - private void Link_Clicked (object sender, System.Windows.Forms.LinkClickedEventArgs e) - { - System.Diagnostics.Process.Start(e.LinkText); - } - - private void BtnCloseClick(object sender, System.EventArgs e) - { - if(formMain!=null) - { - formMain.RemoveIMTab(this.toName); - } - - if(formIM!=null) - { - formIM.RemoveIMTab(this.toName); - } - } - - private void BtnPrintKeyClick(object sender, System.EventArgs e) - { - string key = target.ToString(); - key = key.Insert(8,"-"); - key = key.Insert(13,"-"); - key = key.Insert(18,"-"); - key = key.Insert(23,"-"); - textManager.PrintProgramMessage("Program: "+ toName + " == " + key); - } - - private void ClearIMInput() - { - cbxInput.Items.Add(cbxInput.Text); - cbxInput.Text = string.Empty; - } - - public LLUUID TargetId - { - get { return target; } - set { target = value; } - } - - public string TargetName - { - get { return toName; } - set { toName = value; } - } - - public LLUUID SessionId - { - get { return session; } - set { session = value; } - } - - public IMTextManager TextManager - { - get { return textManager; } - set { textManager = value; } - } - } -} +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Text; +using System.Windows.Forms; +using SLNetworkComm; +using libsecondlife; + +namespace SLChat +{ + public partial class IMTabWindow : UserControl + { + private SLNetCom netcom; + private LLUUID target; + private LLUUID session; + private string toName; + private IMTextManager textManager; + private PrefsManager prefs; + public frmMain formMain; + public frmIMs formIM; + + public IMTabWindow(SLNetCom netcom, LLUUID target, LLUUID session, string toName, PrefsManager preferences) + { + InitializeComponent(); + + this.netcom = netcom; + this.target = target; + this.session = session; + this.toName = toName; + this.prefs = preferences; + + textManager = new IMTextManager(new RichTextBoxPrinter(rtbIMText), this.netcom, prefs); + } + + private void btnSend_Click(object sender, EventArgs e) + { + netcom.SendInstantMessage(cbxInput.Text, target, session); + this.ClearIMInput(); + } + + private void cbxInput_TextChanged(object sender, EventArgs e) + { + btnSend.Enabled = (cbxInput.Text.Length > 0); + } + + private void cbxInput_KeyUp(object sender, KeyEventArgs e) + { + if (e.KeyCode != Keys.Enter) return; + if (cbxInput.Text.Length == 0) return; + + netcom.SendInstantMessage(cbxInput.Text, target, session); + this.ClearIMInput(); + } + + private void Link_Clicked (object sender, System.Windows.Forms.LinkClickedEventArgs e) + { + System.Diagnostics.Process.Start(e.LinkText); + } + + private void BtnCloseClick(object sender, System.EventArgs e) + { + if(formMain!=null) + { + formMain.RemoveIMTab(this.toName); + } + + if(formIM!=null) + { + formIM.RemoveIMTab(this.toName); + } + } + + private void BtnPrintKeyClick(object sender, System.EventArgs e) + { + string key = target.ToString(); + key = key.Insert(8,"-"); + key = key.Insert(13,"-"); + key = key.Insert(18,"-"); + key = key.Insert(23,"-"); + textManager.PrintProgramMessage("Program: "+ toName + " == " + key); + } + + private void ClearIMInput() + { + cbxInput.Items.Add(cbxInput.Text); + cbxInput.Text = string.Empty; + } + + public LLUUID TargetId + { + get { return target; } + set { target = value; } + } + + public string TargetName + { + get { return toName; } + set { toName = value; } + } + + public LLUUID SessionId + { + get { return session; } + set { session = value; } + } + + public IMTextManager TextManager + { + get { return textManager; } + set { textManager = value; } + } + } +} diff --git a/applications/SLChat/SLChat/GUI/IMTabWindow.resx b/applications/SLChat/SLChat/GUI/IMTabWindow.resx index 5ea0895e..7080a7d1 100644 --- a/applications/SLChat/SLChat/GUI/IMTabWindow.resx +++ b/applications/SLChat/SLChat/GUI/IMTabWindow.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/applications/SLChat/SLChat/GUI/InstantMessages.Designer.cs b/applications/SLChat/SLChat/GUI/InstantMessages.Designer.cs index d73353c7..1a0eed35 100644 --- a/applications/SLChat/SLChat/GUI/InstantMessages.Designer.cs +++ b/applications/SLChat/SLChat/GUI/InstantMessages.Designer.cs @@ -1,124 +1,124 @@ -namespace SLChat -{ - partial class frmIMs - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.tabIMs = new System.Windows.Forms.TabControl(); - this.tpgNewIM = new System.Windows.Forms.TabPage(); - this.btnNewIM = new System.Windows.Forms.Button(); - this.lbxFriendsList = new System.Windows.Forms.ListBox(); - this.btnClose = new System.Windows.Forms.Button(); - this.tabIMs.SuspendLayout(); - this.tpgNewIM.SuspendLayout(); - this.SuspendLayout(); - // - // tabIMs - // - this.tabIMs.Controls.Add(this.tpgNewIM); - this.tabIMs.Dock = System.Windows.Forms.DockStyle.Fill; - this.tabIMs.Location = new System.Drawing.Point(0, 0); - this.tabIMs.Name = "tabIMs"; - this.tabIMs.SelectedIndex = 0; - this.tabIMs.Size = new System.Drawing.Size(364, 266); - this.tabIMs.TabIndex = 0; - // - // tpgNewIM - // - this.tpgNewIM.Controls.Add(this.btnClose); - this.tpgNewIM.Controls.Add(this.btnNewIM); - this.tpgNewIM.Controls.Add(this.lbxFriendsList); - this.tpgNewIM.Location = new System.Drawing.Point(4, 22); - this.tpgNewIM.Name = "tpgNewIM"; - this.tpgNewIM.Padding = new System.Windows.Forms.Padding(3); - this.tpgNewIM.Size = new System.Drawing.Size(356, 240); - this.tpgNewIM.TabIndex = 0; - this.tpgNewIM.Text = "New IM"; - this.tpgNewIM.UseVisualStyleBackColor = true; - // - // btnNewIM - // - this.btnNewIM.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.btnNewIM.Location = new System.Drawing.Point(192, 209); - this.btnNewIM.Name = "btnNewIM"; - this.btnNewIM.Size = new System.Drawing.Size(75, 23); - this.btnNewIM.TabIndex = 2; - this.btnNewIM.Text = "New IM"; - this.btnNewIM.UseVisualStyleBackColor = true; - // - // lbxFriendsList - // - this.lbxFriendsList.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.lbxFriendsList.FormattingEnabled = true; - this.lbxFriendsList.IntegralHeight = false; - this.lbxFriendsList.Items.AddRange(new object[] { - "You have no friends, loser. :P"}); - this.lbxFriendsList.Location = new System.Drawing.Point(11, 6); - this.lbxFriendsList.Name = "lbxFriendsList"; - this.lbxFriendsList.Size = new System.Drawing.Size(337, 197); - this.lbxFriendsList.TabIndex = 0; - // - // btnClose - // - this.btnClose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.btnClose.Location = new System.Drawing.Point(273, 209); - this.btnClose.Name = "btnClose"; - this.btnClose.Size = new System.Drawing.Size(75, 23); - this.btnClose.TabIndex = 3; - this.btnClose.Text = "Close"; - this.btnClose.UseVisualStyleBackColor = true; - this.btnClose.Click += new System.EventHandler(this.btnClose_Click); - // - // frmIMs - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(364, 266); - this.Controls.Add(this.tabIMs); - this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Name = "frmIMs"; - this.ShowIcon = false; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "SLChat - IMs"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.frmIMs_FormClosing); - this.tabIMs.ResumeLayout(false); - this.tpgNewIM.ResumeLayout(false); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.TabControl tabIMs; - private System.Windows.Forms.TabPage tpgNewIM; - private System.Windows.Forms.ListBox lbxFriendsList; - private System.Windows.Forms.Button btnNewIM; - private System.Windows.Forms.Button btnClose; - } -} +namespace SLChat +{ + partial class frmIMs + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.tabIMs = new System.Windows.Forms.TabControl(); + this.tpgNewIM = new System.Windows.Forms.TabPage(); + this.btnNewIM = new System.Windows.Forms.Button(); + this.lbxFriendsList = new System.Windows.Forms.ListBox(); + this.btnClose = new System.Windows.Forms.Button(); + this.tabIMs.SuspendLayout(); + this.tpgNewIM.SuspendLayout(); + this.SuspendLayout(); + // + // tabIMs + // + this.tabIMs.Controls.Add(this.tpgNewIM); + this.tabIMs.Dock = System.Windows.Forms.DockStyle.Fill; + this.tabIMs.Location = new System.Drawing.Point(0, 0); + this.tabIMs.Name = "tabIMs"; + this.tabIMs.SelectedIndex = 0; + this.tabIMs.Size = new System.Drawing.Size(364, 266); + this.tabIMs.TabIndex = 0; + // + // tpgNewIM + // + this.tpgNewIM.Controls.Add(this.btnClose); + this.tpgNewIM.Controls.Add(this.btnNewIM); + this.tpgNewIM.Controls.Add(this.lbxFriendsList); + this.tpgNewIM.Location = new System.Drawing.Point(4, 22); + this.tpgNewIM.Name = "tpgNewIM"; + this.tpgNewIM.Padding = new System.Windows.Forms.Padding(3); + this.tpgNewIM.Size = new System.Drawing.Size(356, 240); + this.tpgNewIM.TabIndex = 0; + this.tpgNewIM.Text = "New IM"; + this.tpgNewIM.UseVisualStyleBackColor = true; + // + // btnNewIM + // + this.btnNewIM.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnNewIM.Location = new System.Drawing.Point(192, 209); + this.btnNewIM.Name = "btnNewIM"; + this.btnNewIM.Size = new System.Drawing.Size(75, 23); + this.btnNewIM.TabIndex = 2; + this.btnNewIM.Text = "New IM"; + this.btnNewIM.UseVisualStyleBackColor = true; + // + // lbxFriendsList + // + this.lbxFriendsList.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.lbxFriendsList.FormattingEnabled = true; + this.lbxFriendsList.IntegralHeight = false; + this.lbxFriendsList.Items.AddRange(new object[] { + "You have no friends, loser. :P"}); + this.lbxFriendsList.Location = new System.Drawing.Point(11, 6); + this.lbxFriendsList.Name = "lbxFriendsList"; + this.lbxFriendsList.Size = new System.Drawing.Size(337, 197); + this.lbxFriendsList.TabIndex = 0; + // + // btnClose + // + this.btnClose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnClose.Location = new System.Drawing.Point(273, 209); + this.btnClose.Name = "btnClose"; + this.btnClose.Size = new System.Drawing.Size(75, 23); + this.btnClose.TabIndex = 3; + this.btnClose.Text = "Close"; + this.btnClose.UseVisualStyleBackColor = true; + this.btnClose.Click += new System.EventHandler(this.btnClose_Click); + // + // frmIMs + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(364, 266); + this.Controls.Add(this.tabIMs); + this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.Name = "frmIMs"; + this.ShowIcon = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "SLChat - IMs"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.frmIMs_FormClosing); + this.tabIMs.ResumeLayout(false); + this.tpgNewIM.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.TabControl tabIMs; + private System.Windows.Forms.TabPage tpgNewIM; + private System.Windows.Forms.ListBox lbxFriendsList; + private System.Windows.Forms.Button btnNewIM; + private System.Windows.Forms.Button btnClose; + } +} diff --git a/applications/SLChat/SLChat/GUI/InstantMessages.cs b/applications/SLChat/SLChat/GUI/InstantMessages.cs index 31ec956f..00e8ce7f 100644 --- a/applications/SLChat/SLChat/GUI/InstantMessages.cs +++ b/applications/SLChat/SLChat/GUI/InstantMessages.cs @@ -1,88 +1,88 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Text; -using System.Windows.Forms; -using SLNetworkComm; -using libsecondlife; - -namespace SLChat -{ - public partial class frmIMs : Form - { - private SLNetCom netcom; - private Dictionary IMTabs; - private PrefsManager prefs; - - public frmIMs(SLNetCom netcom, PrefsManager preferences) - { - InitializeComponent(); - - this.netcom = netcom; - IMTabs = new Dictionary(); - prefs = preferences; - - this.AddNetcomEvents(); - } - - private void AddNetcomEvents() - { - netcom.InstantMessageReceived += new EventHandler(netcom_InstantMessageReceived); - } - - private void netcom_InstantMessageReceived(object sender, InstantMessageEventArgs e) - { - if (IMTabs.ContainsKey(e.FromAgentName)) return; - - this.AddIMTab(e.FromAgentId, e.Id, e.FromAgentName, e); - } - - public IMTabWindow AddIMTab(LLUUID target, LLUUID session, string targetName) - { - TabPage tabpage = new TabPage(targetName); - IMTabWindow imTab = new IMTabWindow(netcom, target, session, targetName, prefs); - imTab.Dock = DockStyle.Fill; - imTab.formIM = this; - - tabpage.Controls.Add(imTab); - - tabIMs.TabPages.Add(tabpage); - IMTabs.Add(targetName, imTab); - - return imTab; - } - - public IMTabWindow AddIMTab(LLUUID target, LLUUID session, string targetName, InstantMessageEventArgs e) - { - IMTabWindow imTab = this.AddIMTab(target, session, targetName); - imTab.TextManager.PassIMEvent(e); - - return imTab; - } - - public void RemoveIMTab(string targetName) - { - IMTabWindow imTab = IMTabs[targetName]; - TabPage tabpage = (TabPage)imTab.Parent; - - IMTabs.Remove(targetName); - imTab = null; - - tabIMs.TabPages.Remove(tabpage); - tabpage.Dispose(); - } - - private void frmIMs_FormClosing(object sender, FormClosingEventArgs e) - { - e.Cancel = true; - this.Visible = false; - } - - private void btnClose_Click(object sender, EventArgs e) - { - this.Visible = false; - } - } -} +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; +using SLNetworkComm; +using libsecondlife; + +namespace SLChat +{ + public partial class frmIMs : Form + { + private SLNetCom netcom; + private Dictionary IMTabs; + private PrefsManager prefs; + + public frmIMs(SLNetCom netcom, PrefsManager preferences) + { + InitializeComponent(); + + this.netcom = netcom; + IMTabs = new Dictionary(); + prefs = preferences; + + this.AddNetcomEvents(); + } + + private void AddNetcomEvents() + { + netcom.InstantMessageReceived += new EventHandler(netcom_InstantMessageReceived); + } + + private void netcom_InstantMessageReceived(object sender, InstantMessageEventArgs e) + { + if (IMTabs.ContainsKey(e.FromAgentName)) return; + + this.AddIMTab(e.FromAgentId, e.Id, e.FromAgentName, e); + } + + public IMTabWindow AddIMTab(LLUUID target, LLUUID session, string targetName) + { + TabPage tabpage = new TabPage(targetName); + IMTabWindow imTab = new IMTabWindow(netcom, target, session, targetName, prefs); + imTab.Dock = DockStyle.Fill; + imTab.formIM = this; + + tabpage.Controls.Add(imTab); + + tabIMs.TabPages.Add(tabpage); + IMTabs.Add(targetName, imTab); + + return imTab; + } + + public IMTabWindow AddIMTab(LLUUID target, LLUUID session, string targetName, InstantMessageEventArgs e) + { + IMTabWindow imTab = this.AddIMTab(target, session, targetName); + imTab.TextManager.PassIMEvent(e); + + return imTab; + } + + public void RemoveIMTab(string targetName) + { + IMTabWindow imTab = IMTabs[targetName]; + TabPage tabpage = (TabPage)imTab.Parent; + + IMTabs.Remove(targetName); + imTab = null; + + tabIMs.TabPages.Remove(tabpage); + tabpage.Dispose(); + } + + private void frmIMs_FormClosing(object sender, FormClosingEventArgs e) + { + e.Cancel = true; + this.Visible = false; + } + + private void btnClose_Click(object sender, EventArgs e) + { + this.Visible = false; + } + } +} diff --git a/applications/SLChat/SLChat/GUI/InstantMessages.resx b/applications/SLChat/SLChat/GUI/InstantMessages.resx index ff31a6db..19dc0dd8 100644 --- a/applications/SLChat/SLChat/GUI/InstantMessages.resx +++ b/applications/SLChat/SLChat/GUI/InstantMessages.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/applications/SLChat/SLChat/GUI/Login.Designer.cs b/applications/SLChat/SLChat/GUI/Login.Designer.cs index 150689ac..b5c17bfe 100644 --- a/applications/SLChat/SLChat/GUI/Login.Designer.cs +++ b/applications/SLChat/SLChat/GUI/Login.Designer.cs @@ -1,210 +1,210 @@ -namespace SLChat -{ - partial class frmLogin - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.label1 = new System.Windows.Forms.Label(); - this.txtFirstName = new System.Windows.Forms.TextBox(); - this.txtLastName = new System.Windows.Forms.TextBox(); - this.label2 = new System.Windows.Forms.Label(); - this.txtPassword = new System.Windows.Forms.TextBox(); - this.label3 = new System.Windows.Forms.Label(); - this.cbxLocation = new System.Windows.Forms.ComboBox(); - this.btnCancel = new System.Windows.Forms.Button(); - this.btnLogin = new System.Windows.Forms.Button(); - this.rtbStatus = new System.Windows.Forms.RichTextBox(); - this.chkSaveLogin = new System.Windows.Forms.CheckBox(); - this.cbxProfiles = new System.Windows.Forms.ComboBox(); - this.lblProfiles = new System.Windows.Forms.Label(); - this.SuspendLayout(); - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(11, 46); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(96, 13); - this.label1.TabIndex = 0; - this.label1.Text = "First && Last Names"; - // - // txtFirstName - // - this.txtFirstName.Location = new System.Drawing.Point(11, 62); - this.txtFirstName.Name = "txtFirstName"; - this.txtFirstName.Size = new System.Drawing.Size(130, 21); - this.txtFirstName.TabIndex = 1; - // - // txtLastName - // - this.txtLastName.Location = new System.Drawing.Point(147, 62); - this.txtLastName.Name = "txtLastName"; - this.txtLastName.Size = new System.Drawing.Size(130, 21); - this.txtLastName.TabIndex = 2; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(11, 86); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(53, 13); - this.label2.TabIndex = 3; - this.label2.Text = "Password"; - // - // txtPassword - // - this.txtPassword.Location = new System.Drawing.Point(11, 103); - this.txtPassword.Name = "txtPassword"; - this.txtPassword.Size = new System.Drawing.Size(130, 21); - this.txtPassword.TabIndex = 4; - this.txtPassword.UseSystemPasswordChar = true; - // - // label3 - // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(147, 86); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(47, 13); - this.label3.TabIndex = 5; - this.label3.Text = "Location"; - // - // cbxLocation - // - this.cbxLocation.FormattingEnabled = true; - this.cbxLocation.Items.AddRange(new object[] { - "Home", - "Last"}); - this.cbxLocation.Location = new System.Drawing.Point(147, 103); - this.cbxLocation.Name = "cbxLocation"; - this.cbxLocation.Size = new System.Drawing.Size(130, 21); - this.cbxLocation.TabIndex = 6; - // - // btnCancel - // - this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.btnCancel.Location = new System.Drawing.Point(202, 130); - this.btnCancel.Name = "btnCancel"; - this.btnCancel.Size = new System.Drawing.Size(75, 23); - this.btnCancel.TabIndex = 7; - this.btnCancel.Text = "Cancel"; - this.btnCancel.UseVisualStyleBackColor = true; - this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); - // - // btnLogin - // - this.btnLogin.Location = new System.Drawing.Point(119, 130); - this.btnLogin.Name = "btnLogin"; - this.btnLogin.Size = new System.Drawing.Size(75, 23); - this.btnLogin.TabIndex = 8; - this.btnLogin.Text = "Login"; - this.btnLogin.UseVisualStyleBackColor = true; - this.btnLogin.Click += new System.EventHandler(this.btnLogin_Click); - // - // rtbStatus - // - this.rtbStatus.Location = new System.Drawing.Point(11, 168); - this.rtbStatus.Name = "rtbStatus"; - this.rtbStatus.ReadOnly = true; - this.rtbStatus.Size = new System.Drawing.Size(266, 42); - this.rtbStatus.TabIndex = 9; - this.rtbStatus.Text = "Status: Ready"; - // - // chkSaveLogin - // - this.chkSaveLogin.Location = new System.Drawing.Point(11, 130); - this.chkSaveLogin.Name = "chkSaveLogin"; - this.chkSaveLogin.Size = new System.Drawing.Size(102, 25); - this.chkSaveLogin.TabIndex = 10; - this.chkSaveLogin.Text = "Save Login Info"; - this.chkSaveLogin.UseVisualStyleBackColor = true; - // - // cbxProfiles - // - this.cbxProfiles.FormattingEnabled = true; - this.cbxProfiles.Location = new System.Drawing.Point(11, 22); - this.cbxProfiles.Name = "cbxProfiles"; - this.cbxProfiles.Size = new System.Drawing.Size(182, 21); - this.cbxProfiles.TabIndex = 12; - this.cbxProfiles.SelectedIndexChanged += new System.EventHandler(this.CbxProfilesSelectedIndexChanged); - // - // lblProfiles - // - this.lblProfiles.Location = new System.Drawing.Point(11, 6); - this.lblProfiles.Name = "lblProfiles"; - this.lblProfiles.Size = new System.Drawing.Size(67, 13); - this.lblProfiles.TabIndex = 13; - this.lblProfiles.Text = "Profiles"; - // - // frmLogin - // - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.frmLogin_Closing); - this.AcceptButton = this.btnLogin; - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.CancelButton = this.btnCancel; - this.ClientSize = new System.Drawing.Size(294, 222); - this.Controls.Add(this.lblProfiles); - this.Controls.Add(this.cbxProfiles); - this.Controls.Add(this.chkSaveLogin); - this.Controls.Add(this.rtbStatus); - this.Controls.Add(this.btnLogin); - this.Controls.Add(this.btnCancel); - this.Controls.Add(this.cbxLocation); - this.Controls.Add(this.label3); - this.Controls.Add(this.txtPassword); - this.Controls.Add(this.label2); - this.Controls.Add(this.txtLastName); - this.Controls.Add(this.txtFirstName); - this.Controls.Add(this.label1); - this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; - this.MaximizeBox = false; - this.Name = "frmLogin"; - this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; - this.Text = "Login"; - this.Shown += new System.EventHandler(this.frmLogin_Shown); - this.ResumeLayout(false); - this.PerformLayout(); - } - private System.Windows.Forms.Label lblProfiles; - private System.Windows.Forms.ComboBox cbxProfiles; - private System.Windows.Forms.CheckBox chkSaveLogin; - private System.Windows.Forms.RichTextBox rtbStatus; - - #endregion - - private System.Windows.Forms.Label label1; - private System.Windows.Forms.TextBox txtFirstName; - private System.Windows.Forms.TextBox txtLastName; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.TextBox txtPassword; - private System.Windows.Forms.Label label3; - private System.Windows.Forms.ComboBox cbxLocation; - private System.Windows.Forms.Button btnCancel; - private System.Windows.Forms.Button btnLogin; - } -} +namespace SLChat +{ + partial class frmLogin + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.label1 = new System.Windows.Forms.Label(); + this.txtFirstName = new System.Windows.Forms.TextBox(); + this.txtLastName = new System.Windows.Forms.TextBox(); + this.label2 = new System.Windows.Forms.Label(); + this.txtPassword = new System.Windows.Forms.TextBox(); + this.label3 = new System.Windows.Forms.Label(); + this.cbxLocation = new System.Windows.Forms.ComboBox(); + this.btnCancel = new System.Windows.Forms.Button(); + this.btnLogin = new System.Windows.Forms.Button(); + this.rtbStatus = new System.Windows.Forms.RichTextBox(); + this.chkSaveLogin = new System.Windows.Forms.CheckBox(); + this.cbxProfiles = new System.Windows.Forms.ComboBox(); + this.lblProfiles = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(11, 46); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(96, 13); + this.label1.TabIndex = 0; + this.label1.Text = "First && Last Names"; + // + // txtFirstName + // + this.txtFirstName.Location = new System.Drawing.Point(11, 62); + this.txtFirstName.Name = "txtFirstName"; + this.txtFirstName.Size = new System.Drawing.Size(130, 21); + this.txtFirstName.TabIndex = 1; + // + // txtLastName + // + this.txtLastName.Location = new System.Drawing.Point(147, 62); + this.txtLastName.Name = "txtLastName"; + this.txtLastName.Size = new System.Drawing.Size(130, 21); + this.txtLastName.TabIndex = 2; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(11, 86); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(53, 13); + this.label2.TabIndex = 3; + this.label2.Text = "Password"; + // + // txtPassword + // + this.txtPassword.Location = new System.Drawing.Point(11, 103); + this.txtPassword.Name = "txtPassword"; + this.txtPassword.Size = new System.Drawing.Size(130, 21); + this.txtPassword.TabIndex = 4; + this.txtPassword.UseSystemPasswordChar = true; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(147, 86); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(47, 13); + this.label3.TabIndex = 5; + this.label3.Text = "Location"; + // + // cbxLocation + // + this.cbxLocation.FormattingEnabled = true; + this.cbxLocation.Items.AddRange(new object[] { + "Home", + "Last"}); + this.cbxLocation.Location = new System.Drawing.Point(147, 103); + this.cbxLocation.Name = "cbxLocation"; + this.cbxLocation.Size = new System.Drawing.Size(130, 21); + this.cbxLocation.TabIndex = 6; + // + // btnCancel + // + this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.btnCancel.Location = new System.Drawing.Point(202, 130); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.Size = new System.Drawing.Size(75, 23); + this.btnCancel.TabIndex = 7; + this.btnCancel.Text = "Cancel"; + this.btnCancel.UseVisualStyleBackColor = true; + this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click); + // + // btnLogin + // + this.btnLogin.Location = new System.Drawing.Point(119, 130); + this.btnLogin.Name = "btnLogin"; + this.btnLogin.Size = new System.Drawing.Size(75, 23); + this.btnLogin.TabIndex = 8; + this.btnLogin.Text = "Login"; + this.btnLogin.UseVisualStyleBackColor = true; + this.btnLogin.Click += new System.EventHandler(this.btnLogin_Click); + // + // rtbStatus + // + this.rtbStatus.Location = new System.Drawing.Point(11, 168); + this.rtbStatus.Name = "rtbStatus"; + this.rtbStatus.ReadOnly = true; + this.rtbStatus.Size = new System.Drawing.Size(266, 42); + this.rtbStatus.TabIndex = 9; + this.rtbStatus.Text = "Status: Ready"; + // + // chkSaveLogin + // + this.chkSaveLogin.Location = new System.Drawing.Point(11, 130); + this.chkSaveLogin.Name = "chkSaveLogin"; + this.chkSaveLogin.Size = new System.Drawing.Size(102, 25); + this.chkSaveLogin.TabIndex = 10; + this.chkSaveLogin.Text = "Save Login Info"; + this.chkSaveLogin.UseVisualStyleBackColor = true; + // + // cbxProfiles + // + this.cbxProfiles.FormattingEnabled = true; + this.cbxProfiles.Location = new System.Drawing.Point(11, 22); + this.cbxProfiles.Name = "cbxProfiles"; + this.cbxProfiles.Size = new System.Drawing.Size(182, 21); + this.cbxProfiles.TabIndex = 12; + this.cbxProfiles.SelectedIndexChanged += new System.EventHandler(this.CbxProfilesSelectedIndexChanged); + // + // lblProfiles + // + this.lblProfiles.Location = new System.Drawing.Point(11, 6); + this.lblProfiles.Name = "lblProfiles"; + this.lblProfiles.Size = new System.Drawing.Size(67, 13); + this.lblProfiles.TabIndex = 13; + this.lblProfiles.Text = "Profiles"; + // + // frmLogin + // + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.frmLogin_Closing); + this.AcceptButton = this.btnLogin; + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.CancelButton = this.btnCancel; + this.ClientSize = new System.Drawing.Size(294, 222); + this.Controls.Add(this.lblProfiles); + this.Controls.Add(this.cbxProfiles); + this.Controls.Add(this.chkSaveLogin); + this.Controls.Add(this.rtbStatus); + this.Controls.Add(this.btnLogin); + this.Controls.Add(this.btnCancel); + this.Controls.Add(this.cbxLocation); + this.Controls.Add(this.label3); + this.Controls.Add(this.txtPassword); + this.Controls.Add(this.label2); + this.Controls.Add(this.txtLastName); + this.Controls.Add(this.txtFirstName); + this.Controls.Add(this.label1); + this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.MaximizeBox = false; + this.Name = "frmLogin"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Login"; + this.Shown += new System.EventHandler(this.frmLogin_Shown); + this.ResumeLayout(false); + this.PerformLayout(); + } + private System.Windows.Forms.Label lblProfiles; + private System.Windows.Forms.ComboBox cbxProfiles; + private System.Windows.Forms.CheckBox chkSaveLogin; + private System.Windows.Forms.RichTextBox rtbStatus; + + #endregion + + private System.Windows.Forms.Label label1; + private System.Windows.Forms.TextBox txtFirstName; + private System.Windows.Forms.TextBox txtLastName; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.TextBox txtPassword; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.ComboBox cbxLocation; + private System.Windows.Forms.Button btnCancel; + private System.Windows.Forms.Button btnLogin; + } +} diff --git a/applications/SLChat/SLChat/GUI/Login.cs b/applications/SLChat/SLChat/GUI/Login.cs index 21f3c9d5..400e3f7e 100644 --- a/applications/SLChat/SLChat/GUI/Login.cs +++ b/applications/SLChat/SLChat/GUI/Login.cs @@ -1,210 +1,210 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Text; -using System.Windows.Forms; -using SLNetworkComm; -using libsecondlife; - -namespace SLChat -{ - public partial class frmLogin : Form - { - private bool mainCreated; //Checks if we've created a mainform - public frmMain MainForm; //main form tossing back and forth - private SLNetCom netcom; //Network communication - public PrefsManager prefs; //Our preferences manger. - //These are used for our settings loading/saving - //to see if we have changed our settings since they were last loaded - private string setFirstName; - private string setLastName; - private string setLLocation; //Login Location - private bool setSaveLogin; //Save Login check box - private Hashtable settings = new Hashtable(); //Hashtable for our loaded settings. - - public frmLogin() - { - InitializeComponent(); - - //Try to load the login settings. - prefs = new PrefsManager(); - prefs.LoadProfiles(); - //Load the profiles to our combobox. - string[] profiles = new string[100]; - profiles = prefs.profiles; - for(int i=0;i(netcom_ClientLoggedIn); - netcom.ClientLoggedOut += new EventHandler(netcom_ClientLoggedOut); - netcom.ClientLoginError += new EventHandler(netcom_ClientLoginError); - } - - private void netcom_ClientLoginError(object sender, ClientLoginEventArgs e) - { - rtbStatus.Text = e.LoginReply; - btnLogin.Enabled = true; - } - - private void netcom_ClientLoggedIn(object sender, ClientLoginEventArgs e) - { - //Check if we've already created the chatscreen - //and react approprietly. - if(!mainCreated){ - //create the chat screen and send ourselves - //so the chatscreen can reference us easily. - MainForm.Show(); - mainCreated = true; - MainForm.loginVisible = false; - this.Hide(); - }else{ - MainForm.Focus(); - this.Hide(); - } - } - - private void netcom_ClientLoggedOut(object sender, ClientLoginEventArgs e) - { - btnLogin.Enabled = true; - } - - private void btnCancel_Click(object sender, EventArgs e) - { - if(mainCreated) - { - MainForm.loginVisible = false; - this.Hide(); - }else{ - this.Close(); - } - } - - private void btnLogin_Click(object sender, EventArgs e) - { - //Save our settings on the following conditions: - //The user has checked the appropriet checkbox - //The content has changed from last being loaded. - if(chkSaveLogin.Checked != false) - { - //If the checkbox is checked - if(chkSaveLogin.Checked != setSaveLogin | txtFirstName.Text != setFirstName | txtLastName.Text != setLastName | cbxLocation.Text != setLLocation) - { - //If there have been any changes from when - //the settings were last loaded. - //Setting up our child node settings. - string strSettings = ""+ - ""+ - ""+ - ""; - //Sending off the settings to be saved. - prefs.SaveSettings(txtFirstName.Text+"_"+txtLastName.Text,"LoginSettings",strSettings); - //Clean up the combo box that lists profiles. - if(cbxProfiles.Items.Contains("No profiles found.")) - { - cbxProfiles.Items.Remove("No profiles found."); - } - cbxProfiles.Items.Add(txtFirstName.Text+"_"+txtLastName.Text); - cbxProfiles.SelectedItem = txtFirstName.Text+"_"+txtLastName.Text; - } - }else{ - //If unchecked, delete the login settings - //no point in having unused information remain. - prefs.DeleteSettings(cbxProfiles.Text,"LoginSettings"); - } - - btnLogin.Enabled = false; - - rtbStatus.Text = "Logging in..."; - Application.DoEvents(); - - netcom.LoginOptions.FirstName = txtFirstName.Text; - netcom.LoginOptions.LastName = txtLastName.Text; - netcom.LoginOptions.Password = txtPassword.Text; - netcom.LoginOptions.StartLocation = cbxLocation.Text; - netcom.Login(); - } - - public void CloseApp() - { - this.Dispose(); - } - - private void frmLogin_Closing(object sender, FormClosingEventArgs e) - { - if(mainCreated==true) - { - if(MainForm.Visible==true) - { - MainForm.loginVisible = false; - e.Cancel = true; - this.Hide(); - }else{ - this.Dispose(); - } - }else{ - this.Dispose(); - } - } - - private void CbxProfilesSelectedIndexChanged(object sender, System.EventArgs e) - { - - //Load login settings based on what profile is selected - prefs.LoadSettings(cbxProfiles.Text,"LoginSettings"); - - settings = prefs.settings; - - if(!settings.ContainsKey("Error")) - { - IDictionaryEnumerator myEnum = settings.GetEnumerator(); - while (myEnum.MoveNext()) - { - if(myEnum.Key.ToString()=="SaveLoginInfo") - { - chkSaveLogin.Checked = setSaveLogin = true; - }else if(myEnum.Key.ToString()=="FirstName"){ - txtFirstName.Text = setFirstName = myEnum.Value.ToString(); - }else if(myEnum.Key.ToString()=="LastName"){ - txtLastName.Text = setLastName = myEnum.Value.ToString(); - }else if(myEnum.Key.ToString()=="LoginLocation"){ - cbxLocation.Text = setLLocation = myEnum.Value.ToString(); - } - } - }else{ - IDictionaryEnumerator myEnum = settings.GetEnumerator(); - while (myEnum.MoveNext()) - { - if(myEnum.Key.ToString()=="Error") - { - rtbStatus.Text = "Error loading settings: "+myEnum.Value.ToString(); - } - } - } - settings.Clear(); - prefs.settings.Clear(); - } - } -} +using System; +using System.Collections; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; +using SLNetworkComm; +using libsecondlife; + +namespace SLChat +{ + public partial class frmLogin : Form + { + private bool mainCreated; //Checks if we've created a mainform + public frmMain MainForm; //main form tossing back and forth + private SLNetCom netcom; //Network communication + public PrefsManager prefs; //Our preferences manger. + //These are used for our settings loading/saving + //to see if we have changed our settings since they were last loaded + private string setFirstName; + private string setLastName; + private string setLLocation; //Login Location + private bool setSaveLogin; //Save Login check box + private Hashtable settings = new Hashtable(); //Hashtable for our loaded settings. + + public frmLogin() + { + InitializeComponent(); + + //Try to load the login settings. + prefs = new PrefsManager(); + prefs.LoadProfiles(); + //Load the profiles to our combobox. + string[] profiles = new string[100]; + profiles = prefs.profiles; + for(int i=0;i(netcom_ClientLoggedIn); + netcom.ClientLoggedOut += new EventHandler(netcom_ClientLoggedOut); + netcom.ClientLoginError += new EventHandler(netcom_ClientLoginError); + } + + private void netcom_ClientLoginError(object sender, ClientLoginEventArgs e) + { + rtbStatus.Text = e.LoginReply; + btnLogin.Enabled = true; + } + + private void netcom_ClientLoggedIn(object sender, ClientLoginEventArgs e) + { + //Check if we've already created the chatscreen + //and react approprietly. + if(!mainCreated){ + //create the chat screen and send ourselves + //so the chatscreen can reference us easily. + MainForm.Show(); + mainCreated = true; + MainForm.loginVisible = false; + this.Hide(); + }else{ + MainForm.Focus(); + this.Hide(); + } + } + + private void netcom_ClientLoggedOut(object sender, ClientLoginEventArgs e) + { + btnLogin.Enabled = true; + } + + private void btnCancel_Click(object sender, EventArgs e) + { + if(mainCreated) + { + MainForm.loginVisible = false; + this.Hide(); + }else{ + this.Close(); + } + } + + private void btnLogin_Click(object sender, EventArgs e) + { + //Save our settings on the following conditions: + //The user has checked the appropriet checkbox + //The content has changed from last being loaded. + if(chkSaveLogin.Checked != false) + { + //If the checkbox is checked + if(chkSaveLogin.Checked != setSaveLogin | txtFirstName.Text != setFirstName | txtLastName.Text != setLastName | cbxLocation.Text != setLLocation) + { + //If there have been any changes from when + //the settings were last loaded. + //Setting up our child node settings. + string strSettings = ""+ + ""+ + ""+ + ""; + //Sending off the settings to be saved. + prefs.SaveSettings(txtFirstName.Text+"_"+txtLastName.Text,"LoginSettings",strSettings); + //Clean up the combo box that lists profiles. + if(cbxProfiles.Items.Contains("No profiles found.")) + { + cbxProfiles.Items.Remove("No profiles found."); + } + cbxProfiles.Items.Add(txtFirstName.Text+"_"+txtLastName.Text); + cbxProfiles.SelectedItem = txtFirstName.Text+"_"+txtLastName.Text; + } + }else{ + //If unchecked, delete the login settings + //no point in having unused information remain. + prefs.DeleteSettings(cbxProfiles.Text,"LoginSettings"); + } + + btnLogin.Enabled = false; + + rtbStatus.Text = "Logging in..."; + Application.DoEvents(); + + netcom.LoginOptions.FirstName = txtFirstName.Text; + netcom.LoginOptions.LastName = txtLastName.Text; + netcom.LoginOptions.Password = txtPassword.Text; + netcom.LoginOptions.StartLocation = cbxLocation.Text; + netcom.Login(); + } + + public void CloseApp() + { + this.Dispose(); + } + + private void frmLogin_Closing(object sender, FormClosingEventArgs e) + { + if(mainCreated==true) + { + if(MainForm.Visible==true) + { + MainForm.loginVisible = false; + e.Cancel = true; + this.Hide(); + }else{ + this.Dispose(); + } + }else{ + this.Dispose(); + } + } + + private void CbxProfilesSelectedIndexChanged(object sender, System.EventArgs e) + { + + //Load login settings based on what profile is selected + prefs.LoadSettings(cbxProfiles.Text,"LoginSettings"); + + settings = prefs.settings; + + if(!settings.ContainsKey("Error")) + { + IDictionaryEnumerator myEnum = settings.GetEnumerator(); + while (myEnum.MoveNext()) + { + if(myEnum.Key.ToString()=="SaveLoginInfo") + { + chkSaveLogin.Checked = setSaveLogin = true; + }else if(myEnum.Key.ToString()=="FirstName"){ + txtFirstName.Text = setFirstName = myEnum.Value.ToString(); + }else if(myEnum.Key.ToString()=="LastName"){ + txtLastName.Text = setLastName = myEnum.Value.ToString(); + }else if(myEnum.Key.ToString()=="LoginLocation"){ + cbxLocation.Text = setLLocation = myEnum.Value.ToString(); + } + } + }else{ + IDictionaryEnumerator myEnum = settings.GetEnumerator(); + while (myEnum.MoveNext()) + { + if(myEnum.Key.ToString()=="Error") + { + rtbStatus.Text = "Error loading settings: "+myEnum.Value.ToString(); + } + } + } + settings.Clear(); + prefs.settings.Clear(); + } + } +} diff --git a/applications/SLChat/SLChat/GUI/Login.resx b/applications/SLChat/SLChat/GUI/Login.resx index 5ea0895e..7080a7d1 100644 --- a/applications/SLChat/SLChat/GUI/Login.resx +++ b/applications/SLChat/SLChat/GUI/Login.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/applications/SLChat/SLChat/GUI/MainForm.Designer.cs b/applications/SLChat/SLChat/GUI/MainForm.Designer.cs index d744e6c1..a0a6a738 100644 --- a/applications/SLChat/SLChat/GUI/MainForm.Designer.cs +++ b/applications/SLChat/SLChat/GUI/MainForm.Designer.cs @@ -1,463 +1,463 @@ -namespace SLChat -{ - partial class frmMain - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmMain)); - this.menuStrip1 = new System.Windows.Forms.MenuStrip(); - this.mnuFile = new System.Windows.Forms.ToolStripMenuItem(); - this.mnuLoginout = new System.Windows.Forms.ToolStripMenuItem(); - this.mnuFileSep = new System.Windows.Forms.ToolStripSeparator(); - this.mnuFileExit = new System.Windows.Forms.ToolStripMenuItem(); - this.mnuEdit = new System.Windows.Forms.ToolStripMenuItem(); - this.mnuEditPrefs = new System.Windows.Forms.ToolStripMenuItem(); - this.mnuView = new System.Windows.Forms.ToolStripMenuItem(); - this.mnuViewFriends = new System.Windows.Forms.ToolStripMenuItem(); - this.mnuViewIMs = new System.Windows.Forms.ToolStripMenuItem(); - this.mnuViewInventory = new System.Windows.Forms.ToolStripMenuItem(); - this.mnuHelp = new System.Windows.Forms.ToolStripMenuItem(); - this.mnuHelpAbout = new System.Windows.Forms.ToolStripMenuItem(); - this.rtbChat = new System.Windows.Forms.RichTextBox(); - this.lbxUsers = new System.Windows.Forms.ListBox(); - this.cnxListNames = new System.Windows.Forms.ContextMenuStrip(this.components); - this.mnuKey = new System.Windows.Forms.ToolStripMenuItem(); - this.tolSeperator = new System.Windows.Forms.ToolStripSeparator(); - this.mnuRemove = new System.Windows.Forms.ToolStripMenuItem(); - this.pnlInput = new System.Windows.Forms.Panel(); - this.cbxChatType = new System.Windows.Forms.ComboBox(); - this.txtInput = new System.Windows.Forms.TextBox(); - this.btnSend = new System.Windows.Forms.Button(); - this.toolStrip1 = new System.Windows.Forms.ToolStrip(); - this.tbtnIM = new System.Windows.Forms.ToolStripButton(); - this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); - this.tbtnFriends = new System.Windows.Forms.ToolStripButton(); - this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); - this.tbtnInventory = new System.Windows.Forms.ToolStripButton(); - this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); - this.sptChat = new System.Windows.Forms.SplitContainer(); - this.tabIMs = new System.Windows.Forms.TabControl(); - this.tabLocalChat = new System.Windows.Forms.TabPage(); - this.menuStrip1.SuspendLayout(); - this.cnxListNames.SuspendLayout(); - this.pnlInput.SuspendLayout(); - this.toolStrip1.SuspendLayout(); - this.sptChat.Panel1.SuspendLayout(); - this.sptChat.Panel2.SuspendLayout(); - this.sptChat.SuspendLayout(); - this.tabIMs.SuspendLayout(); - this.tabLocalChat.SuspendLayout(); - this.SuspendLayout(); - // - // menuStrip1 - // - this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.mnuFile, - this.mnuEdit, - this.mnuView, - this.mnuHelp}); - this.menuStrip1.Location = new System.Drawing.Point(0, 0); - this.menuStrip1.Name = "menuStrip1"; - this.menuStrip1.RenderMode = System.Windows.Forms.ToolStripRenderMode.System; - this.menuStrip1.Size = new System.Drawing.Size(540, 24); - this.menuStrip1.TabIndex = 6; - this.menuStrip1.Text = "menuStrip1"; - // - // mnuFile - // - this.mnuFile.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.mnuLoginout, - this.mnuFileSep, - this.mnuFileExit}); - this.mnuFile.Name = "mnuFile"; - this.mnuFile.Size = new System.Drawing.Size(35, 20); - this.mnuFile.Text = "&File"; - // - // mnuLoginout - // - this.mnuLoginout.Name = "mnuLoginout"; - this.mnuLoginout.Size = new System.Drawing.Size(111, 22); - this.mnuLoginout.Text = "&Login..."; - this.mnuLoginout.Click += new System.EventHandler(this.mnuLoginout_Click); - // - // mnuFileSep - // - this.mnuFileSep.Name = "mnuFileSep"; - this.mnuFileSep.Size = new System.Drawing.Size(108, 6); - // - // mnuFileExit - // - this.mnuFileExit.Name = "mnuFileExit"; - this.mnuFileExit.Size = new System.Drawing.Size(111, 22); - this.mnuFileExit.Text = "E&xit"; - this.mnuFileExit.Click += new System.EventHandler(this.mnuFileExit_Click); - // - // mnuEdit - // - this.mnuEdit.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.mnuEditPrefs}); - this.mnuEdit.Name = "mnuEdit"; - this.mnuEdit.Size = new System.Drawing.Size(37, 20); - this.mnuEdit.Text = "&Edit"; - // - // mnuEditPrefs - // - this.mnuEditPrefs.Name = "mnuEditPrefs"; - this.mnuEditPrefs.Size = new System.Drawing.Size(144, 22); - this.mnuEditPrefs.Text = "&Preferences..."; - this.mnuEditPrefs.Click += new System.EventHandler(this.MnuEditPrefsClick); - // - // mnuView - // - this.mnuView.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.mnuViewFriends, - this.mnuViewIMs, - this.mnuViewInventory}); - this.mnuView.Name = "mnuView"; - this.mnuView.Size = new System.Drawing.Size(41, 20); - this.mnuView.Text = "&View"; - // - // mnuViewFriends - // - this.mnuViewFriends.CheckOnClick = true; - this.mnuViewFriends.Name = "mnuViewFriends"; - this.mnuViewFriends.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) - | System.Windows.Forms.Keys.F))); - this.mnuViewFriends.Size = new System.Drawing.Size(197, 22); - this.mnuViewFriends.Text = "&Friends"; - // - // mnuViewIMs - // - this.mnuViewIMs.CheckOnClick = true; - this.mnuViewIMs.Name = "mnuViewIMs"; - this.mnuViewIMs.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.T))); - this.mnuViewIMs.Size = new System.Drawing.Size(197, 22); - this.mnuViewIMs.Text = "&Instant Messages"; - this.mnuViewIMs.Click += new System.EventHandler(this.mnuViewIMs_Click); - // - // mnuViewInventory - // - this.mnuViewInventory.CheckOnClick = true; - this.mnuViewInventory.Name = "mnuViewInventory"; - this.mnuViewInventory.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.I))); - this.mnuViewInventory.Size = new System.Drawing.Size(197, 22); - this.mnuViewInventory.Text = "I&nventory"; - // - // mnuHelp - // - this.mnuHelp.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.mnuHelpAbout}); - this.mnuHelp.Name = "mnuHelp"; - this.mnuHelp.Size = new System.Drawing.Size(40, 20); - this.mnuHelp.Text = "&Help"; - // - // mnuHelpAbout - // - this.mnuHelpAbout.Name = "mnuHelpAbout"; - this.mnuHelpAbout.Size = new System.Drawing.Size(115, 22); - this.mnuHelpAbout.Text = "&About..."; - this.mnuHelpAbout.Click += new System.EventHandler(this.mnuHelpAbout_Click); - // - // rtbChat - // - this.rtbChat.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.rtbChat.BackColor = System.Drawing.Color.White; - this.rtbChat.HideSelection = false; - this.rtbChat.Location = new System.Drawing.Point(0, 0); - this.rtbChat.Name = "rtbChat"; - this.rtbChat.ReadOnly = true; - this.rtbChat.ShowSelectionMargin = true; - this.rtbChat.Size = new System.Drawing.Size(394, 298); - this.rtbChat.TabIndex = 4; - this.rtbChat.Text = ""; - this.rtbChat.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(this.Link_Clicked); - // - // lbxUsers - // - this.lbxUsers.ContextMenuStrip = this.cnxListNames; - this.lbxUsers.Dock = System.Windows.Forms.DockStyle.Fill; - this.lbxUsers.FormattingEnabled = true; - this.lbxUsers.IntegralHeight = false; - this.lbxUsers.Location = new System.Drawing.Point(0, 0); - this.lbxUsers.Name = "lbxUsers"; - this.lbxUsers.Size = new System.Drawing.Size(128, 298); - this.lbxUsers.TabIndex = 3; - // - // cnxListNames - // - this.cnxListNames.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.mnuKey, - this.tolSeperator, - this.mnuRemove}); - this.cnxListNames.Name = "cnxListNames"; - this.cnxListNames.RenderMode = System.Windows.Forms.ToolStripRenderMode.System; - this.cnxListNames.Size = new System.Drawing.Size(154, 54); - // - // mnuKey - // - this.mnuKey.Name = "mnuKey"; - this.mnuKey.Size = new System.Drawing.Size(153, 22); - this.mnuKey.Text = "Print Key (UUID)"; - this.mnuKey.Click += new System.EventHandler(this.MnuKeyClick); - // - // tolSeperator - // - this.tolSeperator.Name = "tolSeperator"; - this.tolSeperator.Size = new System.Drawing.Size(150, 6); - // - // mnuRemove - // - this.mnuRemove.Name = "mnuRemove"; - this.mnuRemove.Size = new System.Drawing.Size(153, 22); - this.mnuRemove.Text = "Remove"; - this.mnuRemove.Click += new System.EventHandler(this.MnuRemoveClick); - // - // pnlInput - // - this.pnlInput.Controls.Add(this.cbxChatType); - this.pnlInput.Controls.Add(this.txtInput); - this.pnlInput.Controls.Add(this.btnSend); - this.pnlInput.Dock = System.Windows.Forms.DockStyle.Bottom; - this.pnlInput.Location = new System.Drawing.Point(3, 301); - this.pnlInput.Name = "pnlInput"; - this.pnlInput.Size = new System.Drawing.Size(526, 24); - this.pnlInput.TabIndex = 4; - // - // cbxChatType - // - this.cbxChatType.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.cbxChatType.FlatStyle = System.Windows.Forms.FlatStyle.System; - this.cbxChatType.FormattingEnabled = true; - this.cbxChatType.Items.AddRange(new object[] { - "Say", - "Shout", - "Whisper"}); - this.cbxChatType.Location = new System.Drawing.Point(371, 0); - this.cbxChatType.Name = "cbxChatType"; - this.cbxChatType.Size = new System.Drawing.Size(73, 21); - this.cbxChatType.TabIndex = 1; - this.cbxChatType.Text = "Say"; - // - // txtInput - // - this.txtInput.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.txtInput.Location = new System.Drawing.Point(0, 0); - this.txtInput.MaxLength = 977; - this.txtInput.Name = "txtInput"; - this.txtInput.Size = new System.Drawing.Size(365, 21); - this.txtInput.TabIndex = 0; - this.txtInput.KeyUp += new System.Windows.Forms.KeyEventHandler(this.txtInput_KeyUp); - this.txtInput.TextChanged += new System.EventHandler(this.txtInput_TextChanged); - // - // btnSend - // - this.btnSend.Dock = System.Windows.Forms.DockStyle.Right; - this.btnSend.Enabled = false; - this.btnSend.Location = new System.Drawing.Point(450, 0); - this.btnSend.Name = "btnSend"; - this.btnSend.Size = new System.Drawing.Size(76, 24); - this.btnSend.TabIndex = 2; - this.btnSend.Text = "Send"; - this.btnSend.UseVisualStyleBackColor = true; - this.btnSend.Click += new System.EventHandler(this.btnSend_Click); - // - // toolStrip1 - // - this.toolStrip1.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden; - this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.tbtnIM, - this.toolStripSeparator2, - this.tbtnFriends, - this.toolStripSeparator1, - this.tbtnInventory, - this.toolStripSeparator3}); - this.toolStrip1.Location = new System.Drawing.Point(0, 24); - this.toolStrip1.Name = "toolStrip1"; - this.toolStrip1.RenderMode = System.Windows.Forms.ToolStripRenderMode.System; - this.toolStrip1.Size = new System.Drawing.Size(540, 25); - this.toolStrip1.TabIndex = 5; - this.toolStrip1.Text = "toolStrip1"; - // - // tbtnIM - // - this.tbtnIM.CheckOnClick = true; - this.tbtnIM.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; - this.tbtnIM.Image = ((System.Drawing.Image)(resources.GetObject("tbtnIM.Image"))); - this.tbtnIM.ImageTransparentColor = System.Drawing.Color.Magenta; - this.tbtnIM.Name = "tbtnIM"; - this.tbtnIM.Size = new System.Drawing.Size(23, 22); - this.tbtnIM.Text = "IM"; - this.tbtnIM.Click += new System.EventHandler(this.tbtnIM_Click); - // - // toolStripSeparator2 - // - this.toolStripSeparator2.Name = "toolStripSeparator2"; - this.toolStripSeparator2.Size = new System.Drawing.Size(6, 25); - // - // tbtnFriends - // - this.tbtnFriends.CheckOnClick = true; - this.tbtnFriends.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; - this.tbtnFriends.Image = ((System.Drawing.Image)(resources.GetObject("tbtnFriends.Image"))); - this.tbtnFriends.ImageTransparentColor = System.Drawing.Color.Magenta; - this.tbtnFriends.Name = "tbtnFriends"; - this.tbtnFriends.Size = new System.Drawing.Size(46, 22); - this.tbtnFriends.Text = "Friends"; - // - // toolStripSeparator1 - // - this.toolStripSeparator1.Name = "toolStripSeparator1"; - this.toolStripSeparator1.Size = new System.Drawing.Size(6, 25); - // - // tbtnInventory - // - this.tbtnInventory.CheckOnClick = true; - this.tbtnInventory.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; - this.tbtnInventory.Image = ((System.Drawing.Image)(resources.GetObject("tbtnInventory.Image"))); - this.tbtnInventory.ImageTransparentColor = System.Drawing.Color.Magenta; - this.tbtnInventory.Name = "tbtnInventory"; - this.tbtnInventory.Size = new System.Drawing.Size(59, 22); - this.tbtnInventory.Text = "Inventory"; - // - // toolStripSeparator3 - // - this.toolStripSeparator3.Name = "toolStripSeparator3"; - this.toolStripSeparator3.Size = new System.Drawing.Size(6, 25); - // - // sptChat - // - this.sptChat.Dock = System.Windows.Forms.DockStyle.Fill; - this.sptChat.Location = new System.Drawing.Point(3, 3); - this.sptChat.Name = "sptChat"; - // - // sptChat.Panel1 - // - this.sptChat.Panel1.Controls.Add(this.rtbChat); - this.sptChat.Panel1MinSize = 0; - // - // sptChat.Panel2 - // - this.sptChat.Panel2.Controls.Add(this.lbxUsers); - this.sptChat.Panel2MinSize = 0; - this.sptChat.Size = new System.Drawing.Size(526, 298); - this.sptChat.SplitterDistance = 394; - this.sptChat.TabIndex = 7; - // - // tabIMs - // - this.tabIMs.Appearance = System.Windows.Forms.TabAppearance.Buttons; - this.tabIMs.Controls.Add(this.tabLocalChat); - this.tabIMs.Dock = System.Windows.Forms.DockStyle.Fill; - this.tabIMs.Location = new System.Drawing.Point(0, 49); - this.tabIMs.Name = "tabIMs"; - this.tabIMs.SelectedIndex = 0; - this.tabIMs.Size = new System.Drawing.Size(540, 357); - this.tabIMs.TabIndex = 5; - // - // tabLocalChat - // - this.tabLocalChat.Controls.Add(this.sptChat); - this.tabLocalChat.Controls.Add(this.pnlInput); - this.tabLocalChat.Location = new System.Drawing.Point(4, 25); - this.tabLocalChat.Name = "tabLocalChat"; - this.tabLocalChat.Padding = new System.Windows.Forms.Padding(3); - this.tabLocalChat.Size = new System.Drawing.Size(532, 328); - this.tabLocalChat.TabIndex = 0; - this.tabLocalChat.Text = "Local Chat"; - this.tabLocalChat.UseVisualStyleBackColor = true; - // - // frmMain - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(540, 406); - this.Controls.Add(this.tabIMs); - this.Controls.Add(this.toolStrip1); - this.Controls.Add(this.menuStrip1); - this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.MainMenuStrip = this.menuStrip1; - this.Name = "frmMain"; - this.Text = "SLChat"; - this.VisibleChanged += new System.EventHandler(this.frmMain_VisibleChanged); - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.frmMain_Closing); - this.menuStrip1.ResumeLayout(false); - this.menuStrip1.PerformLayout(); - this.cnxListNames.ResumeLayout(false); - this.pnlInput.ResumeLayout(false); - this.pnlInput.PerformLayout(); - this.toolStrip1.ResumeLayout(false); - this.toolStrip1.PerformLayout(); - this.sptChat.Panel1.ResumeLayout(false); - this.sptChat.Panel2.ResumeLayout(false); - this.sptChat.ResumeLayout(false); - this.tabIMs.ResumeLayout(false); - this.tabLocalChat.ResumeLayout(false); - this.ResumeLayout(false); - this.PerformLayout(); - } - private System.Windows.Forms.TabPage tabLocalChat; - private System.Windows.Forms.TabControl tabIMs; - private System.Windows.Forms.ToolStripMenuItem mnuRemove; - private System.Windows.Forms.ToolStripSeparator tolSeperator; - private System.Windows.Forms.ToolStripMenuItem mnuKey; - private System.Windows.Forms.ContextMenuStrip cnxListNames; - private System.Windows.Forms.ToolStripSeparator mnuFileSep; - private System.Windows.Forms.Panel pnlInput; - private System.Windows.Forms.SplitContainer sptChat; - private System.Windows.Forms.ComboBox cbxChatType; - private System.Windows.Forms.Button btnSend; - private System.Windows.Forms.TextBox txtInput; - - #endregion - - private System.Windows.Forms.MenuStrip menuStrip1; - private System.Windows.Forms.ToolStripMenuItem mnuFile; - private System.Windows.Forms.ToolStripMenuItem mnuFileExit; - private System.Windows.Forms.ToolStripMenuItem mnuEdit; - private System.Windows.Forms.ToolStripMenuItem mnuEditPrefs; - private System.Windows.Forms.ToolStripMenuItem mnuHelp; - private System.Windows.Forms.ToolStripMenuItem mnuHelpAbout; - private System.Windows.Forms.RichTextBox rtbChat; - private System.Windows.Forms.ListBox lbxUsers; - private System.Windows.Forms.ToolStripMenuItem mnuLoginout; - private System.Windows.Forms.ToolStripMenuItem mnuView; - private System.Windows.Forms.ToolStripMenuItem mnuViewIMs; - private System.Windows.Forms.ToolStrip toolStrip1; - private System.Windows.Forms.ToolStripButton tbtnIM; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; - private System.Windows.Forms.ToolStripButton tbtnInventory; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; - private System.Windows.Forms.ToolStripMenuItem mnuViewInventory; - private System.Windows.Forms.ToolStripMenuItem mnuViewFriends; - private System.Windows.Forms.ToolStripButton tbtnFriends; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator3; - } -} +namespace SLChat +{ + partial class frmMain + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmMain)); + this.menuStrip1 = new System.Windows.Forms.MenuStrip(); + this.mnuFile = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuLoginout = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuFileSep = new System.Windows.Forms.ToolStripSeparator(); + this.mnuFileExit = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuEdit = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuEditPrefs = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuView = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuViewFriends = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuViewIMs = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuViewInventory = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuHelp = new System.Windows.Forms.ToolStripMenuItem(); + this.mnuHelpAbout = new System.Windows.Forms.ToolStripMenuItem(); + this.rtbChat = new System.Windows.Forms.RichTextBox(); + this.lbxUsers = new System.Windows.Forms.ListBox(); + this.cnxListNames = new System.Windows.Forms.ContextMenuStrip(this.components); + this.mnuKey = new System.Windows.Forms.ToolStripMenuItem(); + this.tolSeperator = new System.Windows.Forms.ToolStripSeparator(); + this.mnuRemove = new System.Windows.Forms.ToolStripMenuItem(); + this.pnlInput = new System.Windows.Forms.Panel(); + this.cbxChatType = new System.Windows.Forms.ComboBox(); + this.txtInput = new System.Windows.Forms.TextBox(); + this.btnSend = new System.Windows.Forms.Button(); + this.toolStrip1 = new System.Windows.Forms.ToolStrip(); + this.tbtnIM = new System.Windows.Forms.ToolStripButton(); + this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); + this.tbtnFriends = new System.Windows.Forms.ToolStripButton(); + this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); + this.tbtnInventory = new System.Windows.Forms.ToolStripButton(); + this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); + this.sptChat = new System.Windows.Forms.SplitContainer(); + this.tabIMs = new System.Windows.Forms.TabControl(); + this.tabLocalChat = new System.Windows.Forms.TabPage(); + this.menuStrip1.SuspendLayout(); + this.cnxListNames.SuspendLayout(); + this.pnlInput.SuspendLayout(); + this.toolStrip1.SuspendLayout(); + this.sptChat.Panel1.SuspendLayout(); + this.sptChat.Panel2.SuspendLayout(); + this.sptChat.SuspendLayout(); + this.tabIMs.SuspendLayout(); + this.tabLocalChat.SuspendLayout(); + this.SuspendLayout(); + // + // menuStrip1 + // + this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.mnuFile, + this.mnuEdit, + this.mnuView, + this.mnuHelp}); + this.menuStrip1.Location = new System.Drawing.Point(0, 0); + this.menuStrip1.Name = "menuStrip1"; + this.menuStrip1.RenderMode = System.Windows.Forms.ToolStripRenderMode.System; + this.menuStrip1.Size = new System.Drawing.Size(540, 24); + this.menuStrip1.TabIndex = 6; + this.menuStrip1.Text = "menuStrip1"; + // + // mnuFile + // + this.mnuFile.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.mnuLoginout, + this.mnuFileSep, + this.mnuFileExit}); + this.mnuFile.Name = "mnuFile"; + this.mnuFile.Size = new System.Drawing.Size(35, 20); + this.mnuFile.Text = "&File"; + // + // mnuLoginout + // + this.mnuLoginout.Name = "mnuLoginout"; + this.mnuLoginout.Size = new System.Drawing.Size(111, 22); + this.mnuLoginout.Text = "&Login..."; + this.mnuLoginout.Click += new System.EventHandler(this.mnuLoginout_Click); + // + // mnuFileSep + // + this.mnuFileSep.Name = "mnuFileSep"; + this.mnuFileSep.Size = new System.Drawing.Size(108, 6); + // + // mnuFileExit + // + this.mnuFileExit.Name = "mnuFileExit"; + this.mnuFileExit.Size = new System.Drawing.Size(111, 22); + this.mnuFileExit.Text = "E&xit"; + this.mnuFileExit.Click += new System.EventHandler(this.mnuFileExit_Click); + // + // mnuEdit + // + this.mnuEdit.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.mnuEditPrefs}); + this.mnuEdit.Name = "mnuEdit"; + this.mnuEdit.Size = new System.Drawing.Size(37, 20); + this.mnuEdit.Text = "&Edit"; + // + // mnuEditPrefs + // + this.mnuEditPrefs.Name = "mnuEditPrefs"; + this.mnuEditPrefs.Size = new System.Drawing.Size(144, 22); + this.mnuEditPrefs.Text = "&Preferences..."; + this.mnuEditPrefs.Click += new System.EventHandler(this.MnuEditPrefsClick); + // + // mnuView + // + this.mnuView.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.mnuViewFriends, + this.mnuViewIMs, + this.mnuViewInventory}); + this.mnuView.Name = "mnuView"; + this.mnuView.Size = new System.Drawing.Size(41, 20); + this.mnuView.Text = "&View"; + // + // mnuViewFriends + // + this.mnuViewFriends.CheckOnClick = true; + this.mnuViewFriends.Name = "mnuViewFriends"; + this.mnuViewFriends.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) + | System.Windows.Forms.Keys.F))); + this.mnuViewFriends.Size = new System.Drawing.Size(197, 22); + this.mnuViewFriends.Text = "&Friends"; + // + // mnuViewIMs + // + this.mnuViewIMs.CheckOnClick = true; + this.mnuViewIMs.Name = "mnuViewIMs"; + this.mnuViewIMs.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.T))); + this.mnuViewIMs.Size = new System.Drawing.Size(197, 22); + this.mnuViewIMs.Text = "&Instant Messages"; + this.mnuViewIMs.Click += new System.EventHandler(this.mnuViewIMs_Click); + // + // mnuViewInventory + // + this.mnuViewInventory.CheckOnClick = true; + this.mnuViewInventory.Name = "mnuViewInventory"; + this.mnuViewInventory.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.I))); + this.mnuViewInventory.Size = new System.Drawing.Size(197, 22); + this.mnuViewInventory.Text = "I&nventory"; + // + // mnuHelp + // + this.mnuHelp.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.mnuHelpAbout}); + this.mnuHelp.Name = "mnuHelp"; + this.mnuHelp.Size = new System.Drawing.Size(40, 20); + this.mnuHelp.Text = "&Help"; + // + // mnuHelpAbout + // + this.mnuHelpAbout.Name = "mnuHelpAbout"; + this.mnuHelpAbout.Size = new System.Drawing.Size(115, 22); + this.mnuHelpAbout.Text = "&About..."; + this.mnuHelpAbout.Click += new System.EventHandler(this.mnuHelpAbout_Click); + // + // rtbChat + // + this.rtbChat.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.rtbChat.BackColor = System.Drawing.Color.White; + this.rtbChat.HideSelection = false; + this.rtbChat.Location = new System.Drawing.Point(0, 0); + this.rtbChat.Name = "rtbChat"; + this.rtbChat.ReadOnly = true; + this.rtbChat.ShowSelectionMargin = true; + this.rtbChat.Size = new System.Drawing.Size(394, 298); + this.rtbChat.TabIndex = 4; + this.rtbChat.Text = ""; + this.rtbChat.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(this.Link_Clicked); + // + // lbxUsers + // + this.lbxUsers.ContextMenuStrip = this.cnxListNames; + this.lbxUsers.Dock = System.Windows.Forms.DockStyle.Fill; + this.lbxUsers.FormattingEnabled = true; + this.lbxUsers.IntegralHeight = false; + this.lbxUsers.Location = new System.Drawing.Point(0, 0); + this.lbxUsers.Name = "lbxUsers"; + this.lbxUsers.Size = new System.Drawing.Size(128, 298); + this.lbxUsers.TabIndex = 3; + // + // cnxListNames + // + this.cnxListNames.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.mnuKey, + this.tolSeperator, + this.mnuRemove}); + this.cnxListNames.Name = "cnxListNames"; + this.cnxListNames.RenderMode = System.Windows.Forms.ToolStripRenderMode.System; + this.cnxListNames.Size = new System.Drawing.Size(154, 54); + // + // mnuKey + // + this.mnuKey.Name = "mnuKey"; + this.mnuKey.Size = new System.Drawing.Size(153, 22); + this.mnuKey.Text = "Print Key (UUID)"; + this.mnuKey.Click += new System.EventHandler(this.MnuKeyClick); + // + // tolSeperator + // + this.tolSeperator.Name = "tolSeperator"; + this.tolSeperator.Size = new System.Drawing.Size(150, 6); + // + // mnuRemove + // + this.mnuRemove.Name = "mnuRemove"; + this.mnuRemove.Size = new System.Drawing.Size(153, 22); + this.mnuRemove.Text = "Remove"; + this.mnuRemove.Click += new System.EventHandler(this.MnuRemoveClick); + // + // pnlInput + // + this.pnlInput.Controls.Add(this.cbxChatType); + this.pnlInput.Controls.Add(this.txtInput); + this.pnlInput.Controls.Add(this.btnSend); + this.pnlInput.Dock = System.Windows.Forms.DockStyle.Bottom; + this.pnlInput.Location = new System.Drawing.Point(3, 301); + this.pnlInput.Name = "pnlInput"; + this.pnlInput.Size = new System.Drawing.Size(526, 24); + this.pnlInput.TabIndex = 4; + // + // cbxChatType + // + this.cbxChatType.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.cbxChatType.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.cbxChatType.FormattingEnabled = true; + this.cbxChatType.Items.AddRange(new object[] { + "Say", + "Shout", + "Whisper"}); + this.cbxChatType.Location = new System.Drawing.Point(371, 0); + this.cbxChatType.Name = "cbxChatType"; + this.cbxChatType.Size = new System.Drawing.Size(73, 21); + this.cbxChatType.TabIndex = 1; + this.cbxChatType.Text = "Say"; + // + // txtInput + // + this.txtInput.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.txtInput.Location = new System.Drawing.Point(0, 0); + this.txtInput.MaxLength = 977; + this.txtInput.Name = "txtInput"; + this.txtInput.Size = new System.Drawing.Size(365, 21); + this.txtInput.TabIndex = 0; + this.txtInput.KeyUp += new System.Windows.Forms.KeyEventHandler(this.txtInput_KeyUp); + this.txtInput.TextChanged += new System.EventHandler(this.txtInput_TextChanged); + // + // btnSend + // + this.btnSend.Dock = System.Windows.Forms.DockStyle.Right; + this.btnSend.Enabled = false; + this.btnSend.Location = new System.Drawing.Point(450, 0); + this.btnSend.Name = "btnSend"; + this.btnSend.Size = new System.Drawing.Size(76, 24); + this.btnSend.TabIndex = 2; + this.btnSend.Text = "Send"; + this.btnSend.UseVisualStyleBackColor = true; + this.btnSend.Click += new System.EventHandler(this.btnSend_Click); + // + // toolStrip1 + // + this.toolStrip1.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden; + this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.tbtnIM, + this.toolStripSeparator2, + this.tbtnFriends, + this.toolStripSeparator1, + this.tbtnInventory, + this.toolStripSeparator3}); + this.toolStrip1.Location = new System.Drawing.Point(0, 24); + this.toolStrip1.Name = "toolStrip1"; + this.toolStrip1.RenderMode = System.Windows.Forms.ToolStripRenderMode.System; + this.toolStrip1.Size = new System.Drawing.Size(540, 25); + this.toolStrip1.TabIndex = 5; + this.toolStrip1.Text = "toolStrip1"; + // + // tbtnIM + // + this.tbtnIM.CheckOnClick = true; + this.tbtnIM.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this.tbtnIM.Image = ((System.Drawing.Image)(resources.GetObject("tbtnIM.Image"))); + this.tbtnIM.ImageTransparentColor = System.Drawing.Color.Magenta; + this.tbtnIM.Name = "tbtnIM"; + this.tbtnIM.Size = new System.Drawing.Size(23, 22); + this.tbtnIM.Text = "IM"; + this.tbtnIM.Click += new System.EventHandler(this.tbtnIM_Click); + // + // toolStripSeparator2 + // + this.toolStripSeparator2.Name = "toolStripSeparator2"; + this.toolStripSeparator2.Size = new System.Drawing.Size(6, 25); + // + // tbtnFriends + // + this.tbtnFriends.CheckOnClick = true; + this.tbtnFriends.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this.tbtnFriends.Image = ((System.Drawing.Image)(resources.GetObject("tbtnFriends.Image"))); + this.tbtnFriends.ImageTransparentColor = System.Drawing.Color.Magenta; + this.tbtnFriends.Name = "tbtnFriends"; + this.tbtnFriends.Size = new System.Drawing.Size(46, 22); + this.tbtnFriends.Text = "Friends"; + // + // toolStripSeparator1 + // + this.toolStripSeparator1.Name = "toolStripSeparator1"; + this.toolStripSeparator1.Size = new System.Drawing.Size(6, 25); + // + // tbtnInventory + // + this.tbtnInventory.CheckOnClick = true; + this.tbtnInventory.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this.tbtnInventory.Image = ((System.Drawing.Image)(resources.GetObject("tbtnInventory.Image"))); + this.tbtnInventory.ImageTransparentColor = System.Drawing.Color.Magenta; + this.tbtnInventory.Name = "tbtnInventory"; + this.tbtnInventory.Size = new System.Drawing.Size(59, 22); + this.tbtnInventory.Text = "Inventory"; + // + // toolStripSeparator3 + // + this.toolStripSeparator3.Name = "toolStripSeparator3"; + this.toolStripSeparator3.Size = new System.Drawing.Size(6, 25); + // + // sptChat + // + this.sptChat.Dock = System.Windows.Forms.DockStyle.Fill; + this.sptChat.Location = new System.Drawing.Point(3, 3); + this.sptChat.Name = "sptChat"; + // + // sptChat.Panel1 + // + this.sptChat.Panel1.Controls.Add(this.rtbChat); + this.sptChat.Panel1MinSize = 0; + // + // sptChat.Panel2 + // + this.sptChat.Panel2.Controls.Add(this.lbxUsers); + this.sptChat.Panel2MinSize = 0; + this.sptChat.Size = new System.Drawing.Size(526, 298); + this.sptChat.SplitterDistance = 394; + this.sptChat.TabIndex = 7; + // + // tabIMs + // + this.tabIMs.Appearance = System.Windows.Forms.TabAppearance.Buttons; + this.tabIMs.Controls.Add(this.tabLocalChat); + this.tabIMs.Dock = System.Windows.Forms.DockStyle.Fill; + this.tabIMs.Location = new System.Drawing.Point(0, 49); + this.tabIMs.Name = "tabIMs"; + this.tabIMs.SelectedIndex = 0; + this.tabIMs.Size = new System.Drawing.Size(540, 357); + this.tabIMs.TabIndex = 5; + // + // tabLocalChat + // + this.tabLocalChat.Controls.Add(this.sptChat); + this.tabLocalChat.Controls.Add(this.pnlInput); + this.tabLocalChat.Location = new System.Drawing.Point(4, 25); + this.tabLocalChat.Name = "tabLocalChat"; + this.tabLocalChat.Padding = new System.Windows.Forms.Padding(3); + this.tabLocalChat.Size = new System.Drawing.Size(532, 328); + this.tabLocalChat.TabIndex = 0; + this.tabLocalChat.Text = "Local Chat"; + this.tabLocalChat.UseVisualStyleBackColor = true; + // + // frmMain + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(540, 406); + this.Controls.Add(this.tabIMs); + this.Controls.Add(this.toolStrip1); + this.Controls.Add(this.menuStrip1); + this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.MainMenuStrip = this.menuStrip1; + this.Name = "frmMain"; + this.Text = "SLChat"; + this.VisibleChanged += new System.EventHandler(this.frmMain_VisibleChanged); + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.frmMain_Closing); + this.menuStrip1.ResumeLayout(false); + this.menuStrip1.PerformLayout(); + this.cnxListNames.ResumeLayout(false); + this.pnlInput.ResumeLayout(false); + this.pnlInput.PerformLayout(); + this.toolStrip1.ResumeLayout(false); + this.toolStrip1.PerformLayout(); + this.sptChat.Panel1.ResumeLayout(false); + this.sptChat.Panel2.ResumeLayout(false); + this.sptChat.ResumeLayout(false); + this.tabIMs.ResumeLayout(false); + this.tabLocalChat.ResumeLayout(false); + this.ResumeLayout(false); + this.PerformLayout(); + } + private System.Windows.Forms.TabPage tabLocalChat; + private System.Windows.Forms.TabControl tabIMs; + private System.Windows.Forms.ToolStripMenuItem mnuRemove; + private System.Windows.Forms.ToolStripSeparator tolSeperator; + private System.Windows.Forms.ToolStripMenuItem mnuKey; + private System.Windows.Forms.ContextMenuStrip cnxListNames; + private System.Windows.Forms.ToolStripSeparator mnuFileSep; + private System.Windows.Forms.Panel pnlInput; + private System.Windows.Forms.SplitContainer sptChat; + private System.Windows.Forms.ComboBox cbxChatType; + private System.Windows.Forms.Button btnSend; + private System.Windows.Forms.TextBox txtInput; + + #endregion + + private System.Windows.Forms.MenuStrip menuStrip1; + private System.Windows.Forms.ToolStripMenuItem mnuFile; + private System.Windows.Forms.ToolStripMenuItem mnuFileExit; + private System.Windows.Forms.ToolStripMenuItem mnuEdit; + private System.Windows.Forms.ToolStripMenuItem mnuEditPrefs; + private System.Windows.Forms.ToolStripMenuItem mnuHelp; + private System.Windows.Forms.ToolStripMenuItem mnuHelpAbout; + private System.Windows.Forms.RichTextBox rtbChat; + private System.Windows.Forms.ListBox lbxUsers; + private System.Windows.Forms.ToolStripMenuItem mnuLoginout; + private System.Windows.Forms.ToolStripMenuItem mnuView; + private System.Windows.Forms.ToolStripMenuItem mnuViewIMs; + private System.Windows.Forms.ToolStrip toolStrip1; + private System.Windows.Forms.ToolStripButton tbtnIM; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; + private System.Windows.Forms.ToolStripButton tbtnInventory; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; + private System.Windows.Forms.ToolStripMenuItem mnuViewInventory; + private System.Windows.Forms.ToolStripMenuItem mnuViewFriends; + private System.Windows.Forms.ToolStripButton tbtnFriends; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator3; + } +} diff --git a/applications/SLChat/SLChat/GUI/MainForm.cs b/applications/SLChat/SLChat/GUI/MainForm.cs index 505b249e..4e885cc4 100644 --- a/applications/SLChat/SLChat/GUI/MainForm.cs +++ b/applications/SLChat/SLChat/GUI/MainForm.cs @@ -1,558 +1,558 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Text; -using System.Windows.Forms; -using SLNetworkComm; -using libsecondlife; - -namespace SLChat -{ - public partial class frmMain : Form - { - private SLNetCom netcom; - private ChatTextManager chatManager; - private frmAbout AboutForm; - private frmLogin LoginForm; - private frmPrefs PrefsForm; - private Dictionary IMTabs; - private PrefsManager prefs; - - private frmIMs IMForm; - - public bool loginVisible; - public bool aboutCreated; - public bool prefsCreated; - Hashtable settings = new Hashtable(); - //Stores residents who have spoken Name and Key - //used for printing key to text (and later things). - Hashtable userHash = new Hashtable(); - private int lastchan; - - public frmMain(frmLogin Login, SLNetCom net,PrefsManager preferences) - { - InitializeComponent(); - - LoginForm = Login; - netcom = net; - - prefs = preferences; - - netcom.NetcomSync = this; - netcom.LoginOptions.UserAgent = "SLChat v0.0.0.2"; - netcom.LoginOptions.Author = "ozspade@slinked.net"; - this.AddNetcomEvents(); - - chatManager = new ChatTextManager(new RichTextBoxPrinter(rtbChat), netcom, prefs); - - this.RefreshWindowTitle(); - - IMTabs = new Dictionary(); - IMForm = new frmIMs(netcom, prefs); - IMForm.VisibleChanged += new EventHandler(IMForm_VisibleChanged); - } - - private void frmMain_VisibleChanged(object sender, EventArgs e) - { - LoadSettings("ChatSettings"); - LoadSettings("TimestampSettings"); - } - - private void IMForm_VisibleChanged(object sender, EventArgs e) - { - mnuViewIMs.Checked = tbtnIM.Checked = IMForm.Visible; - } - - private void AddNetcomEvents() - { - netcom.ClientLoggedIn += new EventHandler(netcom_ClientLoggedIn); - netcom.ClientLoggedOut += new EventHandler(netcom_ClientLoggedOut); - netcom.ChatReceived += new EventHandler(netcom_ChatReceived); - netcom.InstantMessageReceived += new EventHandler(netcom_InstantMessageReceived); - } - - private void netcom_InstantMessageReceived(object sender, InstantMessageEventArgs e) - { - if (!tbtnIM.Checked) - { - tbtnIM.ForeColor = Color.Red; - } - - if (IMTabs.ContainsKey(e.FromAgentName)) - { - return; - } - - this.AddIMTab(e.FromAgentId, e.Id, e.FromAgentName, e); - } - - private void netcom_ChatReceived(object sender, ChatEventArgs e) - { - if (e.FromName == netcom.LoginOptions.FullName & !prefs.setListUserName) return; - - string name = e.FromName; - if (e.FromName == netcom.LoginOptions.FullName & !prefs.setUseFullName & e.SourceType == SLSourceType.Avatar) name = "You"; - - if(e.SourceType == SLSourceType.Object) name = "(Ob) " + e.FromName; - - //Send our name and UUID to the function along - //with telling it that we are adding (true) not - //deleting (false) - UpdateUserList(name,e.SourceId.ToString(),true); - } - - private void netcom_ClientLoggedOut(object sender, ClientLoginEventArgs e) - { - mnuLoginout.Text = "&Login..."; - - cbxChatType.Enabled = false; - txtInput.Enabled = false; - btnSend.Enabled = false; - - this.RefreshWindowTitle(); - } - - private void netcom_ClientLoggedIn(object sender, ClientLoginEventArgs e) - { - mnuLoginout.Text = "&Logout"; - - txtInput.Enabled = true; - cbxChatType.Enabled = true; - - this.RefreshWindowTitle(); - } - - private void mnuLoginout_Click(object sender, EventArgs e) - { - switch (mnuLoginout.Text) - { - case "&Login...": - if(loginVisible) - { - LoginForm.Focus(); - }else{ - loginVisible = true; - LoginForm.Show(); - } - break; - - case "&Logout": - netcom.Logout(); - break; - } - } - - private void txtInput_KeyUp(object sender, KeyEventArgs e) - { - if (e.Control) - { - if(e.Shift) - { - if(e.KeyCode == Keys.Enter){ - //Ctrl+Shift+Enter = Whisper - int chan = ChannelGrabber(txtInput.Text); - string message = MessageCleanup(txtInput.Text,chan); - netcom.ChatOut(message, SLChatType.Whisper, chan); - this.ClearChatInput(); - } - }else{ - if(e.KeyCode == Keys.Enter){ - //Ctrl+Enter = Shout - int chan = ChannelGrabber(txtInput.Text); - string message = MessageCleanup(txtInput.Text,chan); - netcom.ChatOut(message, SLChatType.Shout, chan); - this.ClearChatInput(); - }else if(e.KeyCode == Keys.A){ - //Ctrl+A = Select all - txtInput.SelectAll(); - } - } - } - else if(e.KeyCode == Keys.Enter) - { - //Enter only = whatever is in the combobox - int chan = ChannelGrabber(txtInput.Text); - string message = MessageCleanup(txtInput.Text,chan); - if(cbxChatType.Text=="Say") - { - netcom.ChatOut(message, SLChatType.Say, chan); - }else if(cbxChatType.Text=="Shout"){ - netcom.ChatOut(message, SLChatType.Shout, chan); - }else if(cbxChatType.Text=="Whisper"){ - netcom.ChatOut(message, SLChatType.Whisper, chan); - } - this.ClearChatInput(); - } - } - - private void btnSend_Click(object sender, EventArgs e) - { - //Send whatever is in the combobox - int chan = ChannelGrabber(txtInput.Text); - string message = MessageCleanup(txtInput.Text,chan); - if(cbxChatType.Text=="Say") - { - netcom.ChatOut(message, SLChatType.Say, chan); - }else if(cbxChatType.Text=="Shout"){ - netcom.ChatOut(message, SLChatType.Shout, chan); - }else if(cbxChatType.Text=="Whisper"){ - netcom.ChatOut(message, SLChatType.Whisper, chan); - } - this.ClearChatInput(); - } - - private string MessageCleanup(string message, int chan) - { - //Here we clean up the message by removing "//" - //and "/ " from strings if the Channel is not - //0. Returns the cleaned up message. - string mess = message; - if(chan!=0) - { - if(message.StartsWith("//")){ - mess = message.Remove(0,2); - }else{ - mess = message.Remove(0,message.Split(' ')[0].Length + 1); - } - } - - return mess; - } - - private int ChannelGrabber(string message) - { - //Grabs the channel from the message if a channel - //is given. Returns the found channel. - if(message.StartsWith("//")){ - return lastchan; - }else if(message.StartsWith("/")){ - string mes = message.Split(' ')[0]; - if(mes=="/me"){ - return 0; - } - mes = mes.Remove(0,1); - int res = int.Parse(mes); - lastchan = res; - return res; - }else{ - return 0; - } - } - - private void ClearChatInput() - { - //txtInput.Items.Add(txtInput.Text); Need to instead add items to an array to be recalled by Arrow keys? - txtInput.Text = string.Empty; - } - - private void mnuFileExit_Click(object sender, EventArgs e) - { - if (netcom.LoggedIn) - { - netcom.Logout(); - } - - LoginForm.CloseApp(); - } - - private void frmMain_Closing(object sender, FormClosingEventArgs e) - { - if (netcom.LoggedIn) - { - netcom.Logout(); - } - - if(loginVisible==false) - { - LoginForm.CloseApp(); - }else{ - e.Cancel = true; - this.Hide(); - } - } - - private void RefreshWindowTitle() - { - StringBuilder sb = new StringBuilder(); - sb.Append("SLChat: "); - - if (netcom.LoggedIn) - { - sb.Append(netcom.LoginOptions.FullName); - } - else - { - sb.Append("Logged Out"); - } - - this.Text = sb.ToString(); - sb = null; - } - - private void tbtnIM_Click(object sender, EventArgs e) - { - IMForm.Visible = tbtnIM.Checked; - tbtnIM.ForeColor = Color.FromKnownColor(KnownColor.ControlText); - } - - private void mnuViewIMs_Click(object sender, EventArgs e) - { - IMForm.Visible = mnuViewIMs.Checked; - } - - private void txtInput_TextChanged(object sender, EventArgs e) - { - btnSend.Enabled = (txtInput.Text.Length > 0); - } - - private void Link_Clicked (object sender, System.Windows.Forms.LinkClickedEventArgs e) - { - //User clicked a link in the chat, launch default browser - System.Diagnostics.Process.Start(e.LinkText); - } - - private void mnuHelpAbout_Click(object sender, EventArgs e) - { - if(!aboutCreated) - { - AboutForm = new frmAbout(this); - AboutForm.ShowDialog(); - aboutCreated = true; - }else{ - AboutForm.Focus(); - } - } - - private void MnuEditPrefsClick(object sender, System.EventArgs e) - { - if(!prefsCreated) - { - PrefsForm = new frmPrefs(this,netcom.LoginOptions.FirstName+"_"+netcom.LoginOptions.LastName,prefs); - PrefsForm.Show(); - prefsCreated = true; - }else{ - PrefsForm.Focus(); - } - } - - private void MnuKeyClick(object sender, System.EventArgs e) - { - //This prints the selected user's Key to rChatHistory - //with the pretext of "Program:" - if(userHash.ContainsValue(lbxUsers.SelectedItem.ToString())) - { - IDictionaryEnumerator myEnum = userHash.GetEnumerator(); - while (myEnum.MoveNext()) - { - if(myEnum.Value.ToString()==lbxUsers.SelectedItem.ToString()) - { - string name = myEnum.Value.ToString(); - string key = myEnum.Key.ToString(); - key = key.Insert(8,"-"); - key = key.Insert(13,"-"); - key = key.Insert(18,"-"); - key = key.Insert(23,"-"); - chatManager.PrintProgramMessage("Program: "+ name + " == " + key); - } - } - } - } - - private void MnuRemoveClick(object sender, System.EventArgs e) - { - //Remove a user from the list and update user list - if(lbxUsers.SelectedItem.ToString() != null) - { - UpdateUserList(lbxUsers.SelectedItem.ToString(),null,false); - } - } - - public IMTabWindow AddIMTab(LLUUID target, LLUUID session, string targetName) - { - TabPage tabpage = new TabPage(targetName); - IMTabWindow imTab = new IMTabWindow(netcom, target, session, targetName, prefs); - imTab.Dock = DockStyle.Fill; - imTab.formMain = this; - - tabpage.Controls.Add(imTab); - - tabIMs.TabPages.Add(tabpage); - IMTabs.Add(targetName, imTab); - - return imTab; - } - - public IMTabWindow AddIMTab(LLUUID target, LLUUID session, string targetName, InstantMessageEventArgs e) - { - IMTabWindow imTab = this.AddIMTab(target, session, targetName); - imTab.TextManager.PassIMEvent(e); - - return imTab; - } - - public void RemoveIMTab(string targetName) - { - IMTabWindow imTab = IMTabs[targetName]; - TabPage tabpage = (TabPage)imTab.Parent; - - IMTabs.Remove(targetName); - imTab = null; - - tabIMs.TabPages.Remove(tabpage); - tabpage.Dispose(); - } - - private void UpdateUserList(string name, string key, bool adding) - { - //Update the user list to either add a user to the - //userhash and list box or remove a user based on "adding" - //True = add - //False = remove - if(adding==true) - { - if(userHash.ContainsKey(key)) - { - //We loop through the enumerator so that we can - //compare the matching value. - IDictionaryEnumerator myEnum = userHash.GetEnumerator(); - while (myEnum.MoveNext()) - { - //If we find a matching key - if(myEnum.Key.ToString()==key) - { - //And if the name is not the same and - //has changed - if(myEnum.Value.ToString()!=name) - { - //Remove the old name and key. - userHash.Remove(key); - lbxUsers.Items.Remove(myEnum.Value.ToString()); - //Add the Name and Key of the - //resident who spoke. Used for printing key. - userHash.Add(key,name); - //Finaly add the name of the resident to the - //list box. - lbxUsers.Items.Add(name); - return; - } - - } - } - }else{ - //We add the fresh new name and key. - //Add the Name and Key of the - //resident who spoke. Used for printing key. - userHash.Add(key,name); - //and then add it tot he listbox again. - lbxUsers.Items.Add(name); - } - }else{ - //removing from the user list - //Removing a user from the Names List. This should - //perhaps be done automaticly somehow, maybe by offline - //status or distance? - if(name != null) - { - //This is basicly removing the person from our - //userHash, hashtable, which stores Name and Key used - //for printing key to chat. - if(userHash.ContainsValue(name)) - { - IDictionaryEnumerator myEnum = userHash.GetEnumerator(); - while (myEnum.MoveNext()) - { - if(myEnum.Value.ToString()==name) - { - //Remove from our hashtable, just to keep things clean. - userHash.Remove(myEnum.Key); - //Remove from the actual list element. - lbxUsers.Items.Remove(name); - return; - } - } - } - } - } - } - - public void LoadSettings(string parentnode) - { - //Our local load settings, used when we start up the - //chat/main form. - prefs.LoadSettings(netcom.LoginOptions.FirstName+"_"+netcom.LoginOptions.LastName,parentnode); - - settings = prefs.settings; - - if(!settings.ContainsKey("Error")) - { - IDictionaryEnumerator myEnum = settings.GetEnumerator(); - while (myEnum.MoveNext()) - { - if(parentnode=="ChatSettings") - { - if(myEnum.Key.ToString()=="UseFullName") - { - if(myEnum.Value.ToString()=="true"){ - prefs.setUseFullName = true; - }else{ - prefs.setUseFullName = false; - } - }else if(myEnum.Key.ToString()=="ListUserName"){ - if(myEnum.Value.ToString()=="true"){ - prefs.setListUserName = true; - }else{ - prefs.setListUserName = false; - UpdateUserList(netcom.LoginOptions.FullName,null,false); - UpdateUserList("You",null,false); - } - } - }else if(parentnode=="TimestampSettings"){ - if(myEnum.Key.ToString()=="ShowIMTimestamps") - { - if(myEnum.Value.ToString()=="true") - { - prefs.setIMTimestamps = true; - }else{ - prefs.setIMTimestamps = false; - } - }else if(myEnum.Key.ToString()=="ShowChatTimestamps"){ - if(myEnum.Value.ToString()=="true"){ - prefs.setChatTimestamps = true; - }else{ - prefs.setChatTimestamps = false; - } - }else if(myEnum.Key.ToString()=="IMTimeZone"){ - prefs.setIMTimeZ = myEnum.Value.ToString(); - }else if(myEnum.Key.ToString()=="ChatTimeZone"){ - prefs.setChatTimeZ = myEnum.Value.ToString(); - }else if(myEnum.Key.ToString()=="IMStampFormat"){ - prefs.setIMStampFormat = myEnum.Value.ToString(); - }else if(myEnum.Key.ToString()=="ChatStampFormat"){ - prefs.setChatStampFormat = myEnum.Value.ToString(); - }else if(myEnum.Key.ToString()=="SyncStampSettings"){ - if(myEnum.Value.ToString()=="true"){ - prefs.setSyncTimestamps = true; - }else{ - prefs.setSyncTimestamps = false; - } - } - } - } - }else{ - IDictionaryEnumerator myEnum = settings.GetEnumerator(); - while (myEnum.MoveNext()) - { - if(myEnum.Key.ToString()=="Error") - { - //rtbStatus.Text = "Error loading settings: "+myEnum.Value.ToString(); - } - } - } - settings.Clear(); - prefs.settings.Clear(); - } - } -} +using System; +using System.Collections; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; +using SLNetworkComm; +using libsecondlife; + +namespace SLChat +{ + public partial class frmMain : Form + { + private SLNetCom netcom; + private ChatTextManager chatManager; + private frmAbout AboutForm; + private frmLogin LoginForm; + private frmPrefs PrefsForm; + private Dictionary IMTabs; + private PrefsManager prefs; + + private frmIMs IMForm; + + public bool loginVisible; + public bool aboutCreated; + public bool prefsCreated; + Hashtable settings = new Hashtable(); + //Stores residents who have spoken Name and Key + //used for printing key to text (and later things). + Hashtable userHash = new Hashtable(); + private int lastchan; + + public frmMain(frmLogin Login, SLNetCom net,PrefsManager preferences) + { + InitializeComponent(); + + LoginForm = Login; + netcom = net; + + prefs = preferences; + + netcom.NetcomSync = this; + netcom.LoginOptions.UserAgent = "SLChat v0.0.0.2"; + netcom.LoginOptions.Author = "ozspade@slinked.net"; + this.AddNetcomEvents(); + + chatManager = new ChatTextManager(new RichTextBoxPrinter(rtbChat), netcom, prefs); + + this.RefreshWindowTitle(); + + IMTabs = new Dictionary(); + IMForm = new frmIMs(netcom, prefs); + IMForm.VisibleChanged += new EventHandler(IMForm_VisibleChanged); + } + + private void frmMain_VisibleChanged(object sender, EventArgs e) + { + LoadSettings("ChatSettings"); + LoadSettings("TimestampSettings"); + } + + private void IMForm_VisibleChanged(object sender, EventArgs e) + { + mnuViewIMs.Checked = tbtnIM.Checked = IMForm.Visible; + } + + private void AddNetcomEvents() + { + netcom.ClientLoggedIn += new EventHandler(netcom_ClientLoggedIn); + netcom.ClientLoggedOut += new EventHandler(netcom_ClientLoggedOut); + netcom.ChatReceived += new EventHandler(netcom_ChatReceived); + netcom.InstantMessageReceived += new EventHandler(netcom_InstantMessageReceived); + } + + private void netcom_InstantMessageReceived(object sender, InstantMessageEventArgs e) + { + if (!tbtnIM.Checked) + { + tbtnIM.ForeColor = Color.Red; + } + + if (IMTabs.ContainsKey(e.FromAgentName)) + { + return; + } + + this.AddIMTab(e.FromAgentId, e.Id, e.FromAgentName, e); + } + + private void netcom_ChatReceived(object sender, ChatEventArgs e) + { + if (e.FromName == netcom.LoginOptions.FullName & !prefs.setListUserName) return; + + string name = e.FromName; + if (e.FromName == netcom.LoginOptions.FullName & !prefs.setUseFullName & e.SourceType == SLSourceType.Avatar) name = "You"; + + if(e.SourceType == SLSourceType.Object) name = "(Ob) " + e.FromName; + + //Send our name and UUID to the function along + //with telling it that we are adding (true) not + //deleting (false) + UpdateUserList(name,e.SourceId.ToString(),true); + } + + private void netcom_ClientLoggedOut(object sender, ClientLoginEventArgs e) + { + mnuLoginout.Text = "&Login..."; + + cbxChatType.Enabled = false; + txtInput.Enabled = false; + btnSend.Enabled = false; + + this.RefreshWindowTitle(); + } + + private void netcom_ClientLoggedIn(object sender, ClientLoginEventArgs e) + { + mnuLoginout.Text = "&Logout"; + + txtInput.Enabled = true; + cbxChatType.Enabled = true; + + this.RefreshWindowTitle(); + } + + private void mnuLoginout_Click(object sender, EventArgs e) + { + switch (mnuLoginout.Text) + { + case "&Login...": + if(loginVisible) + { + LoginForm.Focus(); + }else{ + loginVisible = true; + LoginForm.Show(); + } + break; + + case "&Logout": + netcom.Logout(); + break; + } + } + + private void txtInput_KeyUp(object sender, KeyEventArgs e) + { + if (e.Control) + { + if(e.Shift) + { + if(e.KeyCode == Keys.Enter){ + //Ctrl+Shift+Enter = Whisper + int chan = ChannelGrabber(txtInput.Text); + string message = MessageCleanup(txtInput.Text,chan); + netcom.ChatOut(message, SLChatType.Whisper, chan); + this.ClearChatInput(); + } + }else{ + if(e.KeyCode == Keys.Enter){ + //Ctrl+Enter = Shout + int chan = ChannelGrabber(txtInput.Text); + string message = MessageCleanup(txtInput.Text,chan); + netcom.ChatOut(message, SLChatType.Shout, chan); + this.ClearChatInput(); + }else if(e.KeyCode == Keys.A){ + //Ctrl+A = Select all + txtInput.SelectAll(); + } + } + } + else if(e.KeyCode == Keys.Enter) + { + //Enter only = whatever is in the combobox + int chan = ChannelGrabber(txtInput.Text); + string message = MessageCleanup(txtInput.Text,chan); + if(cbxChatType.Text=="Say") + { + netcom.ChatOut(message, SLChatType.Say, chan); + }else if(cbxChatType.Text=="Shout"){ + netcom.ChatOut(message, SLChatType.Shout, chan); + }else if(cbxChatType.Text=="Whisper"){ + netcom.ChatOut(message, SLChatType.Whisper, chan); + } + this.ClearChatInput(); + } + } + + private void btnSend_Click(object sender, EventArgs e) + { + //Send whatever is in the combobox + int chan = ChannelGrabber(txtInput.Text); + string message = MessageCleanup(txtInput.Text,chan); + if(cbxChatType.Text=="Say") + { + netcom.ChatOut(message, SLChatType.Say, chan); + }else if(cbxChatType.Text=="Shout"){ + netcom.ChatOut(message, SLChatType.Shout, chan); + }else if(cbxChatType.Text=="Whisper"){ + netcom.ChatOut(message, SLChatType.Whisper, chan); + } + this.ClearChatInput(); + } + + private string MessageCleanup(string message, int chan) + { + //Here we clean up the message by removing "//" + //and "/ " from strings if the Channel is not + //0. Returns the cleaned up message. + string mess = message; + if(chan!=0) + { + if(message.StartsWith("//")){ + mess = message.Remove(0,2); + }else{ + mess = message.Remove(0,message.Split(' ')[0].Length + 1); + } + } + + return mess; + } + + private int ChannelGrabber(string message) + { + //Grabs the channel from the message if a channel + //is given. Returns the found channel. + if(message.StartsWith("//")){ + return lastchan; + }else if(message.StartsWith("/")){ + string mes = message.Split(' ')[0]; + if(mes=="/me"){ + return 0; + } + mes = mes.Remove(0,1); + int res = int.Parse(mes); + lastchan = res; + return res; + }else{ + return 0; + } + } + + private void ClearChatInput() + { + //txtInput.Items.Add(txtInput.Text); Need to instead add items to an array to be recalled by Arrow keys? + txtInput.Text = string.Empty; + } + + private void mnuFileExit_Click(object sender, EventArgs e) + { + if (netcom.LoggedIn) + { + netcom.Logout(); + } + + LoginForm.CloseApp(); + } + + private void frmMain_Closing(object sender, FormClosingEventArgs e) + { + if (netcom.LoggedIn) + { + netcom.Logout(); + } + + if(loginVisible==false) + { + LoginForm.CloseApp(); + }else{ + e.Cancel = true; + this.Hide(); + } + } + + private void RefreshWindowTitle() + { + StringBuilder sb = new StringBuilder(); + sb.Append("SLChat: "); + + if (netcom.LoggedIn) + { + sb.Append(netcom.LoginOptions.FullName); + } + else + { + sb.Append("Logged Out"); + } + + this.Text = sb.ToString(); + sb = null; + } + + private void tbtnIM_Click(object sender, EventArgs e) + { + IMForm.Visible = tbtnIM.Checked; + tbtnIM.ForeColor = Color.FromKnownColor(KnownColor.ControlText); + } + + private void mnuViewIMs_Click(object sender, EventArgs e) + { + IMForm.Visible = mnuViewIMs.Checked; + } + + private void txtInput_TextChanged(object sender, EventArgs e) + { + btnSend.Enabled = (txtInput.Text.Length > 0); + } + + private void Link_Clicked (object sender, System.Windows.Forms.LinkClickedEventArgs e) + { + //User clicked a link in the chat, launch default browser + System.Diagnostics.Process.Start(e.LinkText); + } + + private void mnuHelpAbout_Click(object sender, EventArgs e) + { + if(!aboutCreated) + { + AboutForm = new frmAbout(this); + AboutForm.ShowDialog(); + aboutCreated = true; + }else{ + AboutForm.Focus(); + } + } + + private void MnuEditPrefsClick(object sender, System.EventArgs e) + { + if(!prefsCreated) + { + PrefsForm = new frmPrefs(this,netcom.LoginOptions.FirstName+"_"+netcom.LoginOptions.LastName,prefs); + PrefsForm.Show(); + prefsCreated = true; + }else{ + PrefsForm.Focus(); + } + } + + private void MnuKeyClick(object sender, System.EventArgs e) + { + //This prints the selected user's Key to rChatHistory + //with the pretext of "Program:" + if(userHash.ContainsValue(lbxUsers.SelectedItem.ToString())) + { + IDictionaryEnumerator myEnum = userHash.GetEnumerator(); + while (myEnum.MoveNext()) + { + if(myEnum.Value.ToString()==lbxUsers.SelectedItem.ToString()) + { + string name = myEnum.Value.ToString(); + string key = myEnum.Key.ToString(); + key = key.Insert(8,"-"); + key = key.Insert(13,"-"); + key = key.Insert(18,"-"); + key = key.Insert(23,"-"); + chatManager.PrintProgramMessage("Program: "+ name + " == " + key); + } + } + } + } + + private void MnuRemoveClick(object sender, System.EventArgs e) + { + //Remove a user from the list and update user list + if(lbxUsers.SelectedItem.ToString() != null) + { + UpdateUserList(lbxUsers.SelectedItem.ToString(),null,false); + } + } + + public IMTabWindow AddIMTab(LLUUID target, LLUUID session, string targetName) + { + TabPage tabpage = new TabPage(targetName); + IMTabWindow imTab = new IMTabWindow(netcom, target, session, targetName, prefs); + imTab.Dock = DockStyle.Fill; + imTab.formMain = this; + + tabpage.Controls.Add(imTab); + + tabIMs.TabPages.Add(tabpage); + IMTabs.Add(targetName, imTab); + + return imTab; + } + + public IMTabWindow AddIMTab(LLUUID target, LLUUID session, string targetName, InstantMessageEventArgs e) + { + IMTabWindow imTab = this.AddIMTab(target, session, targetName); + imTab.TextManager.PassIMEvent(e); + + return imTab; + } + + public void RemoveIMTab(string targetName) + { + IMTabWindow imTab = IMTabs[targetName]; + TabPage tabpage = (TabPage)imTab.Parent; + + IMTabs.Remove(targetName); + imTab = null; + + tabIMs.TabPages.Remove(tabpage); + tabpage.Dispose(); + } + + private void UpdateUserList(string name, string key, bool adding) + { + //Update the user list to either add a user to the + //userhash and list box or remove a user based on "adding" + //True = add + //False = remove + if(adding==true) + { + if(userHash.ContainsKey(key)) + { + //We loop through the enumerator so that we can + //compare the matching value. + IDictionaryEnumerator myEnum = userHash.GetEnumerator(); + while (myEnum.MoveNext()) + { + //If we find a matching key + if(myEnum.Key.ToString()==key) + { + //And if the name is not the same and + //has changed + if(myEnum.Value.ToString()!=name) + { + //Remove the old name and key. + userHash.Remove(key); + lbxUsers.Items.Remove(myEnum.Value.ToString()); + //Add the Name and Key of the + //resident who spoke. Used for printing key. + userHash.Add(key,name); + //Finaly add the name of the resident to the + //list box. + lbxUsers.Items.Add(name); + return; + } + + } + } + }else{ + //We add the fresh new name and key. + //Add the Name and Key of the + //resident who spoke. Used for printing key. + userHash.Add(key,name); + //and then add it tot he listbox again. + lbxUsers.Items.Add(name); + } + }else{ + //removing from the user list + //Removing a user from the Names List. This should + //perhaps be done automaticly somehow, maybe by offline + //status or distance? + if(name != null) + { + //This is basicly removing the person from our + //userHash, hashtable, which stores Name and Key used + //for printing key to chat. + if(userHash.ContainsValue(name)) + { + IDictionaryEnumerator myEnum = userHash.GetEnumerator(); + while (myEnum.MoveNext()) + { + if(myEnum.Value.ToString()==name) + { + //Remove from our hashtable, just to keep things clean. + userHash.Remove(myEnum.Key); + //Remove from the actual list element. + lbxUsers.Items.Remove(name); + return; + } + } + } + } + } + } + + public void LoadSettings(string parentnode) + { + //Our local load settings, used when we start up the + //chat/main form. + prefs.LoadSettings(netcom.LoginOptions.FirstName+"_"+netcom.LoginOptions.LastName,parentnode); + + settings = prefs.settings; + + if(!settings.ContainsKey("Error")) + { + IDictionaryEnumerator myEnum = settings.GetEnumerator(); + while (myEnum.MoveNext()) + { + if(parentnode=="ChatSettings") + { + if(myEnum.Key.ToString()=="UseFullName") + { + if(myEnum.Value.ToString()=="true"){ + prefs.setUseFullName = true; + }else{ + prefs.setUseFullName = false; + } + }else if(myEnum.Key.ToString()=="ListUserName"){ + if(myEnum.Value.ToString()=="true"){ + prefs.setListUserName = true; + }else{ + prefs.setListUserName = false; + UpdateUserList(netcom.LoginOptions.FullName,null,false); + UpdateUserList("You",null,false); + } + } + }else if(parentnode=="TimestampSettings"){ + if(myEnum.Key.ToString()=="ShowIMTimestamps") + { + if(myEnum.Value.ToString()=="true") + { + prefs.setIMTimestamps = true; + }else{ + prefs.setIMTimestamps = false; + } + }else if(myEnum.Key.ToString()=="ShowChatTimestamps"){ + if(myEnum.Value.ToString()=="true"){ + prefs.setChatTimestamps = true; + }else{ + prefs.setChatTimestamps = false; + } + }else if(myEnum.Key.ToString()=="IMTimeZone"){ + prefs.setIMTimeZ = myEnum.Value.ToString(); + }else if(myEnum.Key.ToString()=="ChatTimeZone"){ + prefs.setChatTimeZ = myEnum.Value.ToString(); + }else if(myEnum.Key.ToString()=="IMStampFormat"){ + prefs.setIMStampFormat = myEnum.Value.ToString(); + }else if(myEnum.Key.ToString()=="ChatStampFormat"){ + prefs.setChatStampFormat = myEnum.Value.ToString(); + }else if(myEnum.Key.ToString()=="SyncStampSettings"){ + if(myEnum.Value.ToString()=="true"){ + prefs.setSyncTimestamps = true; + }else{ + prefs.setSyncTimestamps = false; + } + } + } + } + }else{ + IDictionaryEnumerator myEnum = settings.GetEnumerator(); + while (myEnum.MoveNext()) + { + if(myEnum.Key.ToString()=="Error") + { + //rtbStatus.Text = "Error loading settings: "+myEnum.Value.ToString(); + } + } + } + settings.Clear(); + prefs.settings.Clear(); + } + } +} diff --git a/applications/SLChat/SLChat/GUI/MainForm.resx b/applications/SLChat/SLChat/GUI/MainForm.resx index dd32c7ea..943af53a 100644 --- a/applications/SLChat/SLChat/GUI/MainForm.resx +++ b/applications/SLChat/SLChat/GUI/MainForm.resx @@ -1,175 +1,175 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 17, 17 - - - 225, 17 - - - 126, 17 - - - - - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAgxJREFUOE+lkvtL - U2EYx+0PEbtpFwnBKPGKiJImGP0gYhIYs1E5GF5gIxkpA00JRSmMEF0ohMh+GaRWYlqabMVcNdS2QpaI - VqiDIYhk397vA6fXhCjyhYdzeM/5fp7vczkAdeL2cwho7v/wWzT1zcN+Pwhr51uY2/y41PQaF+wzKKiZ - QvaN58g0jyLd5KEUcQbg+84P/Cm2tncQjW3j68YWIqubCC3FcOJc478BAuGoZM6zvoRnakXEruEIjhc4 - /g5gZop9c+voGAyLbQIfeBZxLL9BA1jzXvuGbWamuKh+GmmVbswE19A59FEBbmoAG7YbsLtm2mZmiml9 - cvabNDwpz6YB7LYBoMXCumkJr7LOmnnHzBQ/9X2Bo2cOibm1GsBREbAQiYmw/8lnuCeWkVzcgnZlnw1j - 3HV/wuNXK6i/9x5Hc6wawDlTXHbLJ+LZUBQPRyKwdQdxutwl1h+NLXHh5Ht1ewBHsiwawCW57HyDAfWR - dvl0uhZQ1eqX8aVc7EKLqrum651ATLf9OJx5XQM4KmY0xPzZ0hFAiQJnXB0WwME0E3IsL5B17ZlADqWb - NYDrOepdlcysmTWWOrxqbceRWtaLk0VO1XW72D5Vckd2gMBfq8zdpmUG62NJvKM4+XyziDk24xmfWoGE - s1c0gHPmbrPTpHNJKOCo2G1mZs20zcwUJ5yp1AB5+8/zEwgF5GMVDxh4AAAAAElFTkSuQmCC - - - - - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAgxJREFUOE+lkvtL - U2EYx+0PEbtpFwnBKPGKiJImGP0gYhIYs1E5GF5gIxkpA00JRSmMEF0ohMh+GaRWYlqabMVcNdS2QpaI - VqiDIYhk397vA6fXhCjyhYdzeM/5fp7vczkAdeL2cwho7v/wWzT1zcN+Pwhr51uY2/y41PQaF+wzKKiZ - QvaN58g0jyLd5KEUcQbg+84P/Cm2tncQjW3j68YWIqubCC3FcOJc478BAuGoZM6zvoRnakXEruEIjhc4 - /g5gZop9c+voGAyLbQIfeBZxLL9BA1jzXvuGbWamuKh+GmmVbswE19A59FEBbmoAG7YbsLtm2mZmiml9 - cvabNDwpz6YB7LYBoMXCumkJr7LOmnnHzBQ/9X2Bo2cOibm1GsBREbAQiYmw/8lnuCeWkVzcgnZlnw1j - 3HV/wuNXK6i/9x5Hc6wawDlTXHbLJ+LZUBQPRyKwdQdxutwl1h+NLXHh5Ht1ewBHsiwawCW57HyDAfWR - dvl0uhZQ1eqX8aVc7EKLqrum651ATLf9OJx5XQM4KmY0xPzZ0hFAiQJnXB0WwME0E3IsL5B17ZlADqWb - NYDrOepdlcysmTWWOrxqbceRWtaLk0VO1XW72D5Vckd2gMBfq8zdpmUG62NJvKM4+XyziDk24xmfWoGE - s1c0gHPmbrPTpHNJKOCo2G1mZs20zcwUJ5yp1AB5+8/zEwgF5GMVDxh4AAAAAElFTkSuQmCC - - - - - iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAgxJREFUOE+lkvtL - U2EYx+0PEbtpFwnBKPGKiJImGP0gYhIYs1E5GF5gIxkpA00JRSmMEF0ohMh+GaRWYlqabMVcNdS2QpaI - VqiDIYhk397vA6fXhCjyhYdzeM/5fp7vczkAdeL2cwho7v/wWzT1zcN+Pwhr51uY2/y41PQaF+wzKKiZ - QvaN58g0jyLd5KEUcQbg+84P/Cm2tncQjW3j68YWIqubCC3FcOJc478BAuGoZM6zvoRnakXEruEIjhc4 - /g5gZop9c+voGAyLbQIfeBZxLL9BA1jzXvuGbWamuKh+GmmVbswE19A59FEBbmoAG7YbsLtm2mZmiml9 - cvabNDwpz6YB7LYBoMXCumkJr7LOmnnHzBQ/9X2Bo2cOibm1GsBREbAQiYmw/8lnuCeWkVzcgnZlnw1j - 3HV/wuNXK6i/9x5Hc6wawDlTXHbLJ+LZUBQPRyKwdQdxutwl1h+NLXHh5Ht1ewBHsiwawCW57HyDAfWR - dvl0uhZQ1eqX8aVc7EKLqrum651ATLf9OJx5XQM4KmY0xPzZ0hFAiQJnXB0WwME0E3IsL5B17ZlADqWb - NYDrOepdlcysmTWWOrxqbceRWtaLk0VO1XW72D5Vckd2gMBfq8zdpmUG62NJvKM4+XyziDk24xmfWoGE - s1c0gHPmbrPTpHNJKOCo2G1mZs20zcwUJ5yp1AB5+8/zEwgF5GMVDxh4AAAAAElFTkSuQmCC - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + + 225, 17 + + + 126, 17 + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAgxJREFUOE+lkvtL + U2EYx+0PEbtpFwnBKPGKiJImGP0gYhIYs1E5GF5gIxkpA00JRSmMEF0ohMh+GaRWYlqabMVcNdS2QpaI + VqiDIYhk397vA6fXhCjyhYdzeM/5fp7vczkAdeL2cwho7v/wWzT1zcN+Pwhr51uY2/y41PQaF+wzKKiZ + QvaN58g0jyLd5KEUcQbg+84P/Cm2tncQjW3j68YWIqubCC3FcOJc478BAuGoZM6zvoRnakXEruEIjhc4 + /g5gZop9c+voGAyLbQIfeBZxLL9BA1jzXvuGbWamuKh+GmmVbswE19A59FEBbmoAG7YbsLtm2mZmiml9 + cvabNDwpz6YB7LYBoMXCumkJr7LOmnnHzBQ/9X2Bo2cOibm1GsBREbAQiYmw/8lnuCeWkVzcgnZlnw1j + 3HV/wuNXK6i/9x5Hc6wawDlTXHbLJ+LZUBQPRyKwdQdxutwl1h+NLXHh5Ht1ewBHsiwawCW57HyDAfWR + dvl0uhZQ1eqX8aVc7EKLqrum651ATLf9OJx5XQM4KmY0xPzZ0hFAiQJnXB0WwME0E3IsL5B17ZlADqWb + NYDrOepdlcysmTWWOrxqbceRWtaLk0VO1XW72D5Vckd2gMBfq8zdpmUG62NJvKM4+XyziDk24xmfWoGE + s1c0gHPmbrPTpHNJKOCo2G1mZs20zcwUJ5yp1AB5+8/zEwgF5GMVDxh4AAAAAElFTkSuQmCC + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAgxJREFUOE+lkvtL + U2EYx+0PEbtpFwnBKPGKiJImGP0gYhIYs1E5GF5gIxkpA00JRSmMEF0ohMh+GaRWYlqabMVcNdS2QpaI + VqiDIYhk397vA6fXhCjyhYdzeM/5fp7vczkAdeL2cwho7v/wWzT1zcN+Pwhr51uY2/y41PQaF+wzKKiZ + QvaN58g0jyLd5KEUcQbg+84P/Cm2tncQjW3j68YWIqubCC3FcOJc478BAuGoZM6zvoRnakXEruEIjhc4 + /g5gZop9c+voGAyLbQIfeBZxLL9BA1jzXvuGbWamuKh+GmmVbswE19A59FEBbmoAG7YbsLtm2mZmiml9 + cvabNDwpz6YB7LYBoMXCumkJr7LOmnnHzBQ/9X2Bo2cOibm1GsBREbAQiYmw/8lnuCeWkVzcgnZlnw1j + 3HV/wuNXK6i/9x5Hc6wawDlTXHbLJ+LZUBQPRyKwdQdxutwl1h+NLXHh5Ht1ewBHsiwawCW57HyDAfWR + dvl0uhZQ1eqX8aVc7EKLqrum651ATLf9OJx5XQM4KmY0xPzZ0hFAiQJnXB0WwME0E3IsL5B17ZlADqWb + NYDrOepdlcysmTWWOrxqbceRWtaLk0VO1XW72D5Vckd2gMBfq8zdpmUG62NJvKM4+XyziDk24xmfWoGE + s1c0gHPmbrPTpHNJKOCo2G1mZs20zcwUJ5yp1AB5+8/zEwgF5GMVDxh4AAAAAElFTkSuQmCC + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAgxJREFUOE+lkvtL + U2EYx+0PEbtpFwnBKPGKiJImGP0gYhIYs1E5GF5gIxkpA00JRSmMEF0ohMh+GaRWYlqabMVcNdS2QpaI + VqiDIYhk397vA6fXhCjyhYdzeM/5fp7vczkAdeL2cwho7v/wWzT1zcN+Pwhr51uY2/y41PQaF+wzKKiZ + QvaN58g0jyLd5KEUcQbg+84P/Cm2tncQjW3j68YWIqubCC3FcOJc478BAuGoZM6zvoRnakXEruEIjhc4 + /g5gZop9c+voGAyLbQIfeBZxLL9BA1jzXvuGbWamuKh+GmmVbswE19A59FEBbmoAG7YbsLtm2mZmiml9 + cvabNDwpz6YB7LYBoMXCumkJr7LOmnnHzBQ/9X2Bo2cOibm1GsBREbAQiYmw/8lnuCeWkVzcgnZlnw1j + 3HV/wuNXK6i/9x5Hc6wawDlTXHbLJ+LZUBQPRyKwdQdxutwl1h+NLXHh5Ht1ewBHsiwawCW57HyDAfWR + dvl0uhZQ1eqX8aVc7EKLqrum651ATLf9OJx5XQM4KmY0xPzZ0hFAiQJnXB0WwME0E3IsL5B17ZlADqWb + NYDrOepdlcysmTWWOrxqbceRWtaLk0VO1XW72D5Vckd2gMBfq8zdpmUG62NJvKM4+XyziDk24xmfWoGE + s1c0gHPmbrPTpHNJKOCo2G1mZs20zcwUJ5yp1AB5+8/zEwgF5GMVDxh4AAAAAElFTkSuQmCC + + \ No newline at end of file diff --git a/applications/SLChat/SLChat/GUI/Preferences.Designer.cs b/applications/SLChat/SLChat/GUI/Preferences.Designer.cs index 348c3a7f..3be3515a 100644 --- a/applications/SLChat/SLChat/GUI/Preferences.Designer.cs +++ b/applications/SLChat/SLChat/GUI/Preferences.Designer.cs @@ -1,454 +1,454 @@ -/* - * Created by SharpDevelop. - * User: ${USER} - * Date: ${DATE} - * Time: ${TIME} - * - * To change this template use Tools | Options | Coding | Edit Standard Headers. - */ -namespace SLChat -{ - partial class frmPrefs : System.Windows.Forms.Form - { - /// - /// Designer variable used to keep track of non-visual components. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Disposes resources used by the form. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing) { - if (components != null) { - components.Dispose(); - } - } - base.Dispose(disposing); - } - - /// - /// This method is required for Windows Forms designer support. - /// Do not change the method contents inside the source code editor. The Forms designer might - /// not be able to load this method if it was changed manually. - /// - private void InitializeComponent() - { - this.lbxChoices = new System.Windows.Forms.ListBox(); - this.btnOk = new System.Windows.Forms.Button(); - this.btnCancel = new System.Windows.Forms.Button(); - this.btnApply = new System.Windows.Forms.Button(); - this.gbxGeneral = new System.Windows.Forms.GroupBox(); - this.gbxChat = new System.Windows.Forms.GroupBox(); - this.chkListUserName = new System.Windows.Forms.CheckBox(); - this.chkYouName = new System.Windows.Forms.CheckBox(); - this.gbxProfiles = new System.Windows.Forms.GroupBox(); - this.lblProfNote = new System.Windows.Forms.Label(); - this.lblProfNoteTxt = new System.Windows.Forms.Label(); - this.btnPDelete = new System.Windows.Forms.Button(); - this.cbxProfiles = new System.Windows.Forms.ComboBox(); - this.lblProfile = new System.Windows.Forms.Label(); - this.gbxIM = new System.Windows.Forms.GroupBox(); - this.gbxTimestamps = new System.Windows.Forms.GroupBox(); - this.chkSyncStamps = new System.Windows.Forms.CheckBox(); - this.gbxIMStamps = new System.Windows.Forms.GroupBox(); - this.txtIMStampFormat = new System.Windows.Forms.TextBox(); - this.lblIMStampFormat = new System.Windows.Forms.Label(); - this.numIMTimeZ = new System.Windows.Forms.NumericUpDown(); - this.lblIMTimeZ = new System.Windows.Forms.Label(); - this.gbxChatStamps = new System.Windows.Forms.GroupBox(); - this.txtChatStampFormat = new System.Windows.Forms.TextBox(); - this.lblChatStampFormat = new System.Windows.Forms.Label(); - this.numChatTimeZ = new System.Windows.Forms.NumericUpDown(); - this.lblChatTimeZ = new System.Windows.Forms.Label(); - this.chkIMTimestamps = new System.Windows.Forms.CheckBox(); - this.chkChatTimestamps = new System.Windows.Forms.CheckBox(); - this.btnDefaults = new System.Windows.Forms.Button(); - this.gbxChat.SuspendLayout(); - this.gbxProfiles.SuspendLayout(); - this.gbxTimestamps.SuspendLayout(); - this.gbxIMStamps.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numIMTimeZ)).BeginInit(); - this.gbxChatStamps.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numChatTimeZ)).BeginInit(); - this.SuspendLayout(); - // - // lbxChoices - // - this.lbxChoices.FormattingEnabled = true; - this.lbxChoices.Items.AddRange(new object[] { - "General", - "Profiles", - "Chat", - "IM", - "Timestamps"}); - this.lbxChoices.Location = new System.Drawing.Point(3, 6); - this.lbxChoices.Name = "lbxChoices"; - this.lbxChoices.Size = new System.Drawing.Size(100, 316); - this.lbxChoices.TabIndex = 0; - this.lbxChoices.SelectedIndexChanged += new System.EventHandler(this.LbxChoicesSelectedIndexChanged); - // - // btnOk - // - this.btnOk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.btnOk.Location = new System.Drawing.Point(250, 325); - this.btnOk.Name = "btnOk"; - this.btnOk.Size = new System.Drawing.Size(75, 23); - this.btnOk.TabIndex = 1; - this.btnOk.Text = "OK"; - this.btnOk.UseVisualStyleBackColor = true; - this.btnOk.Click += new System.EventHandler(this.BtnOkClick); - // - // btnCancel - // - this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.btnCancel.Location = new System.Drawing.Point(330, 325); - this.btnCancel.Name = "btnCancel"; - this.btnCancel.Size = new System.Drawing.Size(75, 23); - this.btnCancel.TabIndex = 2; - this.btnCancel.Text = "Cancel"; - this.btnCancel.UseVisualStyleBackColor = true; - this.btnCancel.Click += new System.EventHandler(this.BtnCancelClick); - // - // btnApply - // - this.btnApply.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.btnApply.Location = new System.Drawing.Point(410, 325); - this.btnApply.Name = "btnApply"; - this.btnApply.Size = new System.Drawing.Size(75, 23); - this.btnApply.TabIndex = 3; - this.btnApply.Text = "Apply"; - this.btnApply.UseVisualStyleBackColor = true; - this.btnApply.Click += new System.EventHandler(this.BtnApplyClick); - // - // gbxGeneral - // - this.gbxGeneral.Location = new System.Drawing.Point(106, 6); - this.gbxGeneral.Name = "gbxGeneral"; - this.gbxGeneral.Size = new System.Drawing.Size(380, 315); - this.gbxGeneral.TabIndex = 4; - this.gbxGeneral.TabStop = false; - this.gbxGeneral.Text = "General"; - // - // gbxChat - // - this.gbxChat.Controls.Add(this.chkListUserName); - this.gbxChat.Controls.Add(this.chkYouName); - this.gbxChat.Location = new System.Drawing.Point(106, 6); - this.gbxChat.Name = "gbxChat"; - this.gbxChat.Size = new System.Drawing.Size(380, 315); - this.gbxChat.TabIndex = 5; - this.gbxChat.TabStop = false; - this.gbxChat.Text = "Chat"; - // - // chkListUserName - // - this.chkListUserName.Location = new System.Drawing.Point(6, 46); - this.chkListUserName.Name = "chkListUserName"; - this.chkListUserName.Size = new System.Drawing.Size(193, 24); - this.chkListUserName.TabIndex = 2; - this.chkListUserName.Text = "List you in local chat\'s resident list"; - this.chkListUserName.UseVisualStyleBackColor = true; - // - // chkYouName - // - this.chkYouName.Location = new System.Drawing.Point(6, 20); - this.chkYouName.Name = "chkYouName"; - this.chkYouName.Size = new System.Drawing.Size(179, 24); - this.chkYouName.TabIndex = 0; - this.chkYouName.Text = "Use full name instead of \"You\""; - this.chkYouName.UseVisualStyleBackColor = true; - // - // gbxProfiles - // - this.gbxProfiles.Controls.Add(this.lblProfNote); - this.gbxProfiles.Controls.Add(this.lblProfNoteTxt); - this.gbxProfiles.Controls.Add(this.btnPDelete); - this.gbxProfiles.Controls.Add(this.cbxProfiles); - this.gbxProfiles.Controls.Add(this.lblProfile); - this.gbxProfiles.Location = new System.Drawing.Point(106, 6); - this.gbxProfiles.Name = "gbxProfiles"; - this.gbxProfiles.Size = new System.Drawing.Size(380, 315); - this.gbxProfiles.TabIndex = 5; - this.gbxProfiles.TabStop = false; - this.gbxProfiles.Text = "Profiles"; - // - // lblProfNote - // - this.lblProfNote.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.lblProfNote.ForeColor = System.Drawing.Color.Red; - this.lblProfNote.Location = new System.Drawing.Point(6, 25); - this.lblProfNote.Name = "lblProfNote"; - this.lblProfNote.Size = new System.Drawing.Size(38, 14); - this.lblProfNote.TabIndex = 4; - this.lblProfNote.Text = "Note:"; - // - // lblProfNoteTxt - // - this.lblProfNoteTxt.Location = new System.Drawing.Point(41, 25); - this.lblProfNoteTxt.Name = "lblProfNoteTxt"; - this.lblProfNoteTxt.Size = new System.Drawing.Size(336, 14); - this.lblProfNoteTxt.TabIndex = 3; - this.lblProfNoteTxt.Text = "Changes to profiles are effective immedietly and can not be undone."; - // - // btnPDelete - // - this.btnPDelete.Location = new System.Drawing.Point(141, 75); - this.btnPDelete.Name = "btnPDelete"; - this.btnPDelete.Size = new System.Drawing.Size(75, 23); - this.btnPDelete.TabIndex = 2; - this.btnPDelete.Text = "Delete"; - this.btnPDelete.UseVisualStyleBackColor = true; - this.btnPDelete.Click += new System.EventHandler(this.BtnPDeleteClick); - // - // cbxProfiles - // - this.cbxProfiles.FormattingEnabled = true; - this.cbxProfiles.Location = new System.Drawing.Point(50, 48); - this.cbxProfiles.Name = "cbxProfiles"; - this.cbxProfiles.Size = new System.Drawing.Size(166, 21); - this.cbxProfiles.TabIndex = 1; - // - // lblProfile - // - this.lblProfile.Location = new System.Drawing.Point(6, 51); - this.lblProfile.Name = "lblProfile"; - this.lblProfile.Size = new System.Drawing.Size(50, 17); - this.lblProfile.TabIndex = 0; - this.lblProfile.Text = "Profile:"; - // - // gbxIM - // - this.gbxIM.Location = new System.Drawing.Point(106, 6); - this.gbxIM.Name = "gbxIM"; - this.gbxIM.Size = new System.Drawing.Size(380, 315); - this.gbxIM.TabIndex = 6; - this.gbxIM.TabStop = false; - this.gbxIM.Text = "IM"; - // - // gbxTimestamps - // - this.gbxTimestamps.Controls.Add(this.chkSyncStamps); - this.gbxTimestamps.Controls.Add(this.gbxIMStamps); - this.gbxTimestamps.Controls.Add(this.gbxChatStamps); - this.gbxTimestamps.Controls.Add(this.chkIMTimestamps); - this.gbxTimestamps.Controls.Add(this.chkChatTimestamps); - this.gbxTimestamps.Location = new System.Drawing.Point(106, 6); - this.gbxTimestamps.Name = "gbxTimestamps"; - this.gbxTimestamps.Size = new System.Drawing.Size(380, 315); - this.gbxTimestamps.TabIndex = 7; - this.gbxTimestamps.TabStop = false; - this.gbxTimestamps.Text = "Timestamps"; - // - // chkSyncStamps - // - this.chkSyncStamps.Location = new System.Drawing.Point(6, 132); - this.chkSyncStamps.Name = "chkSyncStamps"; - this.chkSyncStamps.Size = new System.Drawing.Size(270, 24); - this.chkSyncStamps.TabIndex = 2; - this.chkSyncStamps.Text = "Sync Settings (IM matches Chat)(Not yet working)"; - this.chkSyncStamps.UseVisualStyleBackColor = true; - // - // gbxIMStamps - // - this.gbxIMStamps.Controls.Add(this.txtIMStampFormat); - this.gbxIMStamps.Controls.Add(this.lblIMStampFormat); - this.gbxIMStamps.Controls.Add(this.numIMTimeZ); - this.gbxIMStamps.Controls.Add(this.lblIMTimeZ); - this.gbxIMStamps.Location = new System.Drawing.Point(6, 200); - this.gbxIMStamps.Name = "gbxIMStamps"; - this.gbxIMStamps.Size = new System.Drawing.Size(367, 68); - this.gbxIMStamps.TabIndex = 4; - this.gbxIMStamps.TabStop = false; - this.gbxIMStamps.Text = "IM"; - // - // txtIMStampFormat - // - this.txtIMStampFormat.Location = new System.Drawing.Point(115, 38); - this.txtIMStampFormat.Name = "txtIMStampFormat"; - this.txtIMStampFormat.Size = new System.Drawing.Size(100, 21); - this.txtIMStampFormat.TabIndex = 1; - // - // lblIMStampFormat - // - this.lblIMStampFormat.Location = new System.Drawing.Point(6, 41); - this.lblIMStampFormat.Name = "lblIMStampFormat"; - this.lblIMStampFormat.Size = new System.Drawing.Size(100, 15); - this.lblIMStampFormat.TabIndex = 3; - this.lblIMStampFormat.Text = "Timestamp Format:"; - // - // numIMTimeZ - // - this.numIMTimeZ.Location = new System.Drawing.Point(170, 15); - this.numIMTimeZ.Maximum = new decimal(new int[] { - 24, - 0, - 0, - 0}); - this.numIMTimeZ.Minimum = new decimal(new int[] { - 24, - 0, - 0, - -2147483648}); - this.numIMTimeZ.Name = "numIMTimeZ"; - this.numIMTimeZ.Size = new System.Drawing.Size(45, 21); - this.numIMTimeZ.TabIndex = 0; - // - // lblIMTimeZ - // - this.lblIMTimeZ.Location = new System.Drawing.Point(6, 17); - this.lblIMTimeZ.Name = "lblIMTimeZ"; - this.lblIMTimeZ.Size = new System.Drawing.Size(158, 15); - this.lblIMTimeZ.TabIndex = 2; - this.lblIMTimeZ.Text = "Time Zone Offset (UTC/GMT):"; - // - // gbxChatStamps - // - this.gbxChatStamps.Controls.Add(this.txtChatStampFormat); - this.gbxChatStamps.Controls.Add(this.lblChatStampFormat); - this.gbxChatStamps.Controls.Add(this.numChatTimeZ); - this.gbxChatStamps.Controls.Add(this.lblChatTimeZ); - this.gbxChatStamps.Location = new System.Drawing.Point(6, 42); - this.gbxChatStamps.Name = "gbxChatStamps"; - this.gbxChatStamps.Size = new System.Drawing.Size(367, 68); - this.gbxChatStamps.TabIndex = 1; - this.gbxChatStamps.TabStop = false; - this.gbxChatStamps.Text = "Chat"; - // - // txtChatStampFormat - // - this.txtChatStampFormat.Location = new System.Drawing.Point(115, 38); - this.txtChatStampFormat.Name = "txtChatStampFormat"; - this.txtChatStampFormat.Size = new System.Drawing.Size(100, 21); - this.txtChatStampFormat.TabIndex = 1; - // - // lblChatStampFormat - // - this.lblChatStampFormat.Location = new System.Drawing.Point(6, 41); - this.lblChatStampFormat.Name = "lblChatStampFormat"; - this.lblChatStampFormat.Size = new System.Drawing.Size(100, 15); - this.lblChatStampFormat.TabIndex = 3; - this.lblChatStampFormat.Text = "Timestamp Format:"; - // - // numChatTimeZ - // - this.numChatTimeZ.Location = new System.Drawing.Point(170, 15); - this.numChatTimeZ.Maximum = new decimal(new int[] { - 24, - 0, - 0, - 0}); - this.numChatTimeZ.Minimum = new decimal(new int[] { - 24, - 0, - 0, - -2147483648}); - this.numChatTimeZ.Name = "numChatTimeZ"; - this.numChatTimeZ.Size = new System.Drawing.Size(45, 21); - this.numChatTimeZ.TabIndex = 0; - // - // lblChatTimeZ - // - this.lblChatTimeZ.Location = new System.Drawing.Point(6, 17); - this.lblChatTimeZ.Name = "lblChatTimeZ"; - this.lblChatTimeZ.Size = new System.Drawing.Size(158, 15); - this.lblChatTimeZ.TabIndex = 2; - this.lblChatTimeZ.Text = "Time Zone Offset (UTC/GMT):"; - // - // chkIMTimestamps - // - this.chkIMTimestamps.Location = new System.Drawing.Point(6, 172); - this.chkIMTimestamps.Name = "chkIMTimestamps"; - this.chkIMTimestamps.Size = new System.Drawing.Size(143, 24); - this.chkIMTimestamps.TabIndex = 3; - this.chkIMTimestamps.Text = "Show timestamps in IMs"; - this.chkIMTimestamps.UseVisualStyleBackColor = true; - // - // chkChatTimestamps - // - this.chkChatTimestamps.Location = new System.Drawing.Point(6, 20); - this.chkChatTimestamps.Name = "chkChatTimestamps"; - this.chkChatTimestamps.Size = new System.Drawing.Size(153, 24); - this.chkChatTimestamps.TabIndex = 0; - this.chkChatTimestamps.Text = "Show timestamps in chat"; - this.chkChatTimestamps.UseVisualStyleBackColor = true; - // - // btnDefaults - // - this.btnDefaults.Location = new System.Drawing.Point(3, 325); - this.btnDefaults.Name = "btnDefaults"; - this.btnDefaults.Size = new System.Drawing.Size(100, 23); - this.btnDefaults.TabIndex = 4; - this.btnDefaults.Text = "Restore Defaults"; - this.btnDefaults.UseVisualStyleBackColor = true; - this.btnDefaults.Click += new System.EventHandler(this.BtnDefaultsClick); - // - // frmPrefs - // - this.AcceptButton = this.btnOk; - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.CancelButton = this.btnCancel; - this.ClientSize = new System.Drawing.Size(494, 352); - this.Controls.Add(this.gbxTimestamps); - this.Controls.Add(this.gbxIM); - this.Controls.Add(this.btnDefaults); - this.Controls.Add(this.gbxChat); - this.Controls.Add(this.gbxProfiles); - this.Controls.Add(this.gbxGeneral); - this.Controls.Add(this.btnApply); - this.Controls.Add(this.btnCancel); - this.Controls.Add(this.btnOk); - this.Controls.Add(this.lbxChoices); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "frmPrefs"; - this.ShowInTaskbar = false; - this.Text = "Preferences"; - this.gbxChat.ResumeLayout(false); - this.gbxProfiles.ResumeLayout(false); - this.gbxTimestamps.ResumeLayout(false); - this.gbxIMStamps.ResumeLayout(false); - this.gbxIMStamps.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numIMTimeZ)).EndInit(); - this.gbxChatStamps.ResumeLayout(false); - this.gbxChatStamps.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.numChatTimeZ)).EndInit(); - this.ResumeLayout(false); - } - private System.Windows.Forms.Button btnDefaults; - private System.Windows.Forms.CheckBox chkSyncStamps; - private System.Windows.Forms.Label lblChatTimeZ; - private System.Windows.Forms.NumericUpDown numChatTimeZ; - private System.Windows.Forms.Label lblChatStampFormat; - private System.Windows.Forms.TextBox txtChatStampFormat; - private System.Windows.Forms.GroupBox gbxChatStamps; - private System.Windows.Forms.Label lblIMTimeZ; - private System.Windows.Forms.NumericUpDown numIMTimeZ; - private System.Windows.Forms.Label lblIMStampFormat; - private System.Windows.Forms.TextBox txtIMStampFormat; - private System.Windows.Forms.GroupBox gbxIMStamps; - private System.Windows.Forms.GroupBox gbxTimestamps; - private System.Windows.Forms.CheckBox chkListUserName; - private System.Windows.Forms.Label lblProfNoteTxt; - private System.Windows.Forms.Label lblProfNote; - private System.Windows.Forms.CheckBox chkIMTimestamps; - private System.Windows.Forms.GroupBox gbxIM; - private System.Windows.Forms.Label lblProfile; - private System.Windows.Forms.ComboBox cbxProfiles; - private System.Windows.Forms.Button btnPDelete; - private System.Windows.Forms.GroupBox gbxProfiles; - private System.Windows.Forms.CheckBox chkYouName; - private System.Windows.Forms.CheckBox chkChatTimestamps; - private System.Windows.Forms.GroupBox gbxChat; - private System.Windows.Forms.GroupBox gbxGeneral; - private System.Windows.Forms.Button btnApply; - private System.Windows.Forms.Button btnCancel; - private System.Windows.Forms.Button btnOk; - private System.Windows.Forms.ListBox lbxChoices; - } -} +/* + * Created by SharpDevelop. + * User: ${USER} + * Date: ${DATE} + * Time: ${TIME} + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ +namespace SLChat +{ + partial class frmPrefs : System.Windows.Forms.Form + { + /// + /// Designer variable used to keep track of non-visual components. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Disposes resources used by the form. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing) { + if (components != null) { + components.Dispose(); + } + } + base.Dispose(disposing); + } + + /// + /// This method is required for Windows Forms designer support. + /// Do not change the method contents inside the source code editor. The Forms designer might + /// not be able to load this method if it was changed manually. + /// + private void InitializeComponent() + { + this.lbxChoices = new System.Windows.Forms.ListBox(); + this.btnOk = new System.Windows.Forms.Button(); + this.btnCancel = new System.Windows.Forms.Button(); + this.btnApply = new System.Windows.Forms.Button(); + this.gbxGeneral = new System.Windows.Forms.GroupBox(); + this.gbxChat = new System.Windows.Forms.GroupBox(); + this.chkListUserName = new System.Windows.Forms.CheckBox(); + this.chkYouName = new System.Windows.Forms.CheckBox(); + this.gbxProfiles = new System.Windows.Forms.GroupBox(); + this.lblProfNote = new System.Windows.Forms.Label(); + this.lblProfNoteTxt = new System.Windows.Forms.Label(); + this.btnPDelete = new System.Windows.Forms.Button(); + this.cbxProfiles = new System.Windows.Forms.ComboBox(); + this.lblProfile = new System.Windows.Forms.Label(); + this.gbxIM = new System.Windows.Forms.GroupBox(); + this.gbxTimestamps = new System.Windows.Forms.GroupBox(); + this.chkSyncStamps = new System.Windows.Forms.CheckBox(); + this.gbxIMStamps = new System.Windows.Forms.GroupBox(); + this.txtIMStampFormat = new System.Windows.Forms.TextBox(); + this.lblIMStampFormat = new System.Windows.Forms.Label(); + this.numIMTimeZ = new System.Windows.Forms.NumericUpDown(); + this.lblIMTimeZ = new System.Windows.Forms.Label(); + this.gbxChatStamps = new System.Windows.Forms.GroupBox(); + this.txtChatStampFormat = new System.Windows.Forms.TextBox(); + this.lblChatStampFormat = new System.Windows.Forms.Label(); + this.numChatTimeZ = new System.Windows.Forms.NumericUpDown(); + this.lblChatTimeZ = new System.Windows.Forms.Label(); + this.chkIMTimestamps = new System.Windows.Forms.CheckBox(); + this.chkChatTimestamps = new System.Windows.Forms.CheckBox(); + this.btnDefaults = new System.Windows.Forms.Button(); + this.gbxChat.SuspendLayout(); + this.gbxProfiles.SuspendLayout(); + this.gbxTimestamps.SuspendLayout(); + this.gbxIMStamps.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numIMTimeZ)).BeginInit(); + this.gbxChatStamps.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numChatTimeZ)).BeginInit(); + this.SuspendLayout(); + // + // lbxChoices + // + this.lbxChoices.FormattingEnabled = true; + this.lbxChoices.Items.AddRange(new object[] { + "General", + "Profiles", + "Chat", + "IM", + "Timestamps"}); + this.lbxChoices.Location = new System.Drawing.Point(3, 6); + this.lbxChoices.Name = "lbxChoices"; + this.lbxChoices.Size = new System.Drawing.Size(100, 316); + this.lbxChoices.TabIndex = 0; + this.lbxChoices.SelectedIndexChanged += new System.EventHandler(this.LbxChoicesSelectedIndexChanged); + // + // btnOk + // + this.btnOk.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnOk.Location = new System.Drawing.Point(250, 325); + this.btnOk.Name = "btnOk"; + this.btnOk.Size = new System.Drawing.Size(75, 23); + this.btnOk.TabIndex = 1; + this.btnOk.Text = "OK"; + this.btnOk.UseVisualStyleBackColor = true; + this.btnOk.Click += new System.EventHandler(this.BtnOkClick); + // + // btnCancel + // + this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.btnCancel.Location = new System.Drawing.Point(330, 325); + this.btnCancel.Name = "btnCancel"; + this.btnCancel.Size = new System.Drawing.Size(75, 23); + this.btnCancel.TabIndex = 2; + this.btnCancel.Text = "Cancel"; + this.btnCancel.UseVisualStyleBackColor = true; + this.btnCancel.Click += new System.EventHandler(this.BtnCancelClick); + // + // btnApply + // + this.btnApply.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.btnApply.Location = new System.Drawing.Point(410, 325); + this.btnApply.Name = "btnApply"; + this.btnApply.Size = new System.Drawing.Size(75, 23); + this.btnApply.TabIndex = 3; + this.btnApply.Text = "Apply"; + this.btnApply.UseVisualStyleBackColor = true; + this.btnApply.Click += new System.EventHandler(this.BtnApplyClick); + // + // gbxGeneral + // + this.gbxGeneral.Location = new System.Drawing.Point(106, 6); + this.gbxGeneral.Name = "gbxGeneral"; + this.gbxGeneral.Size = new System.Drawing.Size(380, 315); + this.gbxGeneral.TabIndex = 4; + this.gbxGeneral.TabStop = false; + this.gbxGeneral.Text = "General"; + // + // gbxChat + // + this.gbxChat.Controls.Add(this.chkListUserName); + this.gbxChat.Controls.Add(this.chkYouName); + this.gbxChat.Location = new System.Drawing.Point(106, 6); + this.gbxChat.Name = "gbxChat"; + this.gbxChat.Size = new System.Drawing.Size(380, 315); + this.gbxChat.TabIndex = 5; + this.gbxChat.TabStop = false; + this.gbxChat.Text = "Chat"; + // + // chkListUserName + // + this.chkListUserName.Location = new System.Drawing.Point(6, 46); + this.chkListUserName.Name = "chkListUserName"; + this.chkListUserName.Size = new System.Drawing.Size(193, 24); + this.chkListUserName.TabIndex = 2; + this.chkListUserName.Text = "List you in local chat\'s resident list"; + this.chkListUserName.UseVisualStyleBackColor = true; + // + // chkYouName + // + this.chkYouName.Location = new System.Drawing.Point(6, 20); + this.chkYouName.Name = "chkYouName"; + this.chkYouName.Size = new System.Drawing.Size(179, 24); + this.chkYouName.TabIndex = 0; + this.chkYouName.Text = "Use full name instead of \"You\""; + this.chkYouName.UseVisualStyleBackColor = true; + // + // gbxProfiles + // + this.gbxProfiles.Controls.Add(this.lblProfNote); + this.gbxProfiles.Controls.Add(this.lblProfNoteTxt); + this.gbxProfiles.Controls.Add(this.btnPDelete); + this.gbxProfiles.Controls.Add(this.cbxProfiles); + this.gbxProfiles.Controls.Add(this.lblProfile); + this.gbxProfiles.Location = new System.Drawing.Point(106, 6); + this.gbxProfiles.Name = "gbxProfiles"; + this.gbxProfiles.Size = new System.Drawing.Size(380, 315); + this.gbxProfiles.TabIndex = 5; + this.gbxProfiles.TabStop = false; + this.gbxProfiles.Text = "Profiles"; + // + // lblProfNote + // + this.lblProfNote.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblProfNote.ForeColor = System.Drawing.Color.Red; + this.lblProfNote.Location = new System.Drawing.Point(6, 25); + this.lblProfNote.Name = "lblProfNote"; + this.lblProfNote.Size = new System.Drawing.Size(38, 14); + this.lblProfNote.TabIndex = 4; + this.lblProfNote.Text = "Note:"; + // + // lblProfNoteTxt + // + this.lblProfNoteTxt.Location = new System.Drawing.Point(41, 25); + this.lblProfNoteTxt.Name = "lblProfNoteTxt"; + this.lblProfNoteTxt.Size = new System.Drawing.Size(336, 14); + this.lblProfNoteTxt.TabIndex = 3; + this.lblProfNoteTxt.Text = "Changes to profiles are effective immedietly and can not be undone."; + // + // btnPDelete + // + this.btnPDelete.Location = new System.Drawing.Point(141, 75); + this.btnPDelete.Name = "btnPDelete"; + this.btnPDelete.Size = new System.Drawing.Size(75, 23); + this.btnPDelete.TabIndex = 2; + this.btnPDelete.Text = "Delete"; + this.btnPDelete.UseVisualStyleBackColor = true; + this.btnPDelete.Click += new System.EventHandler(this.BtnPDeleteClick); + // + // cbxProfiles + // + this.cbxProfiles.FormattingEnabled = true; + this.cbxProfiles.Location = new System.Drawing.Point(50, 48); + this.cbxProfiles.Name = "cbxProfiles"; + this.cbxProfiles.Size = new System.Drawing.Size(166, 21); + this.cbxProfiles.TabIndex = 1; + // + // lblProfile + // + this.lblProfile.Location = new System.Drawing.Point(6, 51); + this.lblProfile.Name = "lblProfile"; + this.lblProfile.Size = new System.Drawing.Size(50, 17); + this.lblProfile.TabIndex = 0; + this.lblProfile.Text = "Profile:"; + // + // gbxIM + // + this.gbxIM.Location = new System.Drawing.Point(106, 6); + this.gbxIM.Name = "gbxIM"; + this.gbxIM.Size = new System.Drawing.Size(380, 315); + this.gbxIM.TabIndex = 6; + this.gbxIM.TabStop = false; + this.gbxIM.Text = "IM"; + // + // gbxTimestamps + // + this.gbxTimestamps.Controls.Add(this.chkSyncStamps); + this.gbxTimestamps.Controls.Add(this.gbxIMStamps); + this.gbxTimestamps.Controls.Add(this.gbxChatStamps); + this.gbxTimestamps.Controls.Add(this.chkIMTimestamps); + this.gbxTimestamps.Controls.Add(this.chkChatTimestamps); + this.gbxTimestamps.Location = new System.Drawing.Point(106, 6); + this.gbxTimestamps.Name = "gbxTimestamps"; + this.gbxTimestamps.Size = new System.Drawing.Size(380, 315); + this.gbxTimestamps.TabIndex = 7; + this.gbxTimestamps.TabStop = false; + this.gbxTimestamps.Text = "Timestamps"; + // + // chkSyncStamps + // + this.chkSyncStamps.Location = new System.Drawing.Point(6, 132); + this.chkSyncStamps.Name = "chkSyncStamps"; + this.chkSyncStamps.Size = new System.Drawing.Size(270, 24); + this.chkSyncStamps.TabIndex = 2; + this.chkSyncStamps.Text = "Sync Settings (IM matches Chat)(Not yet working)"; + this.chkSyncStamps.UseVisualStyleBackColor = true; + // + // gbxIMStamps + // + this.gbxIMStamps.Controls.Add(this.txtIMStampFormat); + this.gbxIMStamps.Controls.Add(this.lblIMStampFormat); + this.gbxIMStamps.Controls.Add(this.numIMTimeZ); + this.gbxIMStamps.Controls.Add(this.lblIMTimeZ); + this.gbxIMStamps.Location = new System.Drawing.Point(6, 200); + this.gbxIMStamps.Name = "gbxIMStamps"; + this.gbxIMStamps.Size = new System.Drawing.Size(367, 68); + this.gbxIMStamps.TabIndex = 4; + this.gbxIMStamps.TabStop = false; + this.gbxIMStamps.Text = "IM"; + // + // txtIMStampFormat + // + this.txtIMStampFormat.Location = new System.Drawing.Point(115, 38); + this.txtIMStampFormat.Name = "txtIMStampFormat"; + this.txtIMStampFormat.Size = new System.Drawing.Size(100, 21); + this.txtIMStampFormat.TabIndex = 1; + // + // lblIMStampFormat + // + this.lblIMStampFormat.Location = new System.Drawing.Point(6, 41); + this.lblIMStampFormat.Name = "lblIMStampFormat"; + this.lblIMStampFormat.Size = new System.Drawing.Size(100, 15); + this.lblIMStampFormat.TabIndex = 3; + this.lblIMStampFormat.Text = "Timestamp Format:"; + // + // numIMTimeZ + // + this.numIMTimeZ.Location = new System.Drawing.Point(170, 15); + this.numIMTimeZ.Maximum = new decimal(new int[] { + 24, + 0, + 0, + 0}); + this.numIMTimeZ.Minimum = new decimal(new int[] { + 24, + 0, + 0, + -2147483648}); + this.numIMTimeZ.Name = "numIMTimeZ"; + this.numIMTimeZ.Size = new System.Drawing.Size(45, 21); + this.numIMTimeZ.TabIndex = 0; + // + // lblIMTimeZ + // + this.lblIMTimeZ.Location = new System.Drawing.Point(6, 17); + this.lblIMTimeZ.Name = "lblIMTimeZ"; + this.lblIMTimeZ.Size = new System.Drawing.Size(158, 15); + this.lblIMTimeZ.TabIndex = 2; + this.lblIMTimeZ.Text = "Time Zone Offset (UTC/GMT):"; + // + // gbxChatStamps + // + this.gbxChatStamps.Controls.Add(this.txtChatStampFormat); + this.gbxChatStamps.Controls.Add(this.lblChatStampFormat); + this.gbxChatStamps.Controls.Add(this.numChatTimeZ); + this.gbxChatStamps.Controls.Add(this.lblChatTimeZ); + this.gbxChatStamps.Location = new System.Drawing.Point(6, 42); + this.gbxChatStamps.Name = "gbxChatStamps"; + this.gbxChatStamps.Size = new System.Drawing.Size(367, 68); + this.gbxChatStamps.TabIndex = 1; + this.gbxChatStamps.TabStop = false; + this.gbxChatStamps.Text = "Chat"; + // + // txtChatStampFormat + // + this.txtChatStampFormat.Location = new System.Drawing.Point(115, 38); + this.txtChatStampFormat.Name = "txtChatStampFormat"; + this.txtChatStampFormat.Size = new System.Drawing.Size(100, 21); + this.txtChatStampFormat.TabIndex = 1; + // + // lblChatStampFormat + // + this.lblChatStampFormat.Location = new System.Drawing.Point(6, 41); + this.lblChatStampFormat.Name = "lblChatStampFormat"; + this.lblChatStampFormat.Size = new System.Drawing.Size(100, 15); + this.lblChatStampFormat.TabIndex = 3; + this.lblChatStampFormat.Text = "Timestamp Format:"; + // + // numChatTimeZ + // + this.numChatTimeZ.Location = new System.Drawing.Point(170, 15); + this.numChatTimeZ.Maximum = new decimal(new int[] { + 24, + 0, + 0, + 0}); + this.numChatTimeZ.Minimum = new decimal(new int[] { + 24, + 0, + 0, + -2147483648}); + this.numChatTimeZ.Name = "numChatTimeZ"; + this.numChatTimeZ.Size = new System.Drawing.Size(45, 21); + this.numChatTimeZ.TabIndex = 0; + // + // lblChatTimeZ + // + this.lblChatTimeZ.Location = new System.Drawing.Point(6, 17); + this.lblChatTimeZ.Name = "lblChatTimeZ"; + this.lblChatTimeZ.Size = new System.Drawing.Size(158, 15); + this.lblChatTimeZ.TabIndex = 2; + this.lblChatTimeZ.Text = "Time Zone Offset (UTC/GMT):"; + // + // chkIMTimestamps + // + this.chkIMTimestamps.Location = new System.Drawing.Point(6, 172); + this.chkIMTimestamps.Name = "chkIMTimestamps"; + this.chkIMTimestamps.Size = new System.Drawing.Size(143, 24); + this.chkIMTimestamps.TabIndex = 3; + this.chkIMTimestamps.Text = "Show timestamps in IMs"; + this.chkIMTimestamps.UseVisualStyleBackColor = true; + // + // chkChatTimestamps + // + this.chkChatTimestamps.Location = new System.Drawing.Point(6, 20); + this.chkChatTimestamps.Name = "chkChatTimestamps"; + this.chkChatTimestamps.Size = new System.Drawing.Size(153, 24); + this.chkChatTimestamps.TabIndex = 0; + this.chkChatTimestamps.Text = "Show timestamps in chat"; + this.chkChatTimestamps.UseVisualStyleBackColor = true; + // + // btnDefaults + // + this.btnDefaults.Location = new System.Drawing.Point(3, 325); + this.btnDefaults.Name = "btnDefaults"; + this.btnDefaults.Size = new System.Drawing.Size(100, 23); + this.btnDefaults.TabIndex = 4; + this.btnDefaults.Text = "Restore Defaults"; + this.btnDefaults.UseVisualStyleBackColor = true; + this.btnDefaults.Click += new System.EventHandler(this.BtnDefaultsClick); + // + // frmPrefs + // + this.AcceptButton = this.btnOk; + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.CancelButton = this.btnCancel; + this.ClientSize = new System.Drawing.Size(494, 352); + this.Controls.Add(this.gbxTimestamps); + this.Controls.Add(this.gbxIM); + this.Controls.Add(this.btnDefaults); + this.Controls.Add(this.gbxChat); + this.Controls.Add(this.gbxProfiles); + this.Controls.Add(this.gbxGeneral); + this.Controls.Add(this.btnApply); + this.Controls.Add(this.btnCancel); + this.Controls.Add(this.btnOk); + this.Controls.Add(this.lbxChoices); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "frmPrefs"; + this.ShowInTaskbar = false; + this.Text = "Preferences"; + this.gbxChat.ResumeLayout(false); + this.gbxProfiles.ResumeLayout(false); + this.gbxTimestamps.ResumeLayout(false); + this.gbxIMStamps.ResumeLayout(false); + this.gbxIMStamps.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numIMTimeZ)).EndInit(); + this.gbxChatStamps.ResumeLayout(false); + this.gbxChatStamps.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numChatTimeZ)).EndInit(); + this.ResumeLayout(false); + } + private System.Windows.Forms.Button btnDefaults; + private System.Windows.Forms.CheckBox chkSyncStamps; + private System.Windows.Forms.Label lblChatTimeZ; + private System.Windows.Forms.NumericUpDown numChatTimeZ; + private System.Windows.Forms.Label lblChatStampFormat; + private System.Windows.Forms.TextBox txtChatStampFormat; + private System.Windows.Forms.GroupBox gbxChatStamps; + private System.Windows.Forms.Label lblIMTimeZ; + private System.Windows.Forms.NumericUpDown numIMTimeZ; + private System.Windows.Forms.Label lblIMStampFormat; + private System.Windows.Forms.TextBox txtIMStampFormat; + private System.Windows.Forms.GroupBox gbxIMStamps; + private System.Windows.Forms.GroupBox gbxTimestamps; + private System.Windows.Forms.CheckBox chkListUserName; + private System.Windows.Forms.Label lblProfNoteTxt; + private System.Windows.Forms.Label lblProfNote; + private System.Windows.Forms.CheckBox chkIMTimestamps; + private System.Windows.Forms.GroupBox gbxIM; + private System.Windows.Forms.Label lblProfile; + private System.Windows.Forms.ComboBox cbxProfiles; + private System.Windows.Forms.Button btnPDelete; + private System.Windows.Forms.GroupBox gbxProfiles; + private System.Windows.Forms.CheckBox chkYouName; + private System.Windows.Forms.CheckBox chkChatTimestamps; + private System.Windows.Forms.GroupBox gbxChat; + private System.Windows.Forms.GroupBox gbxGeneral; + private System.Windows.Forms.Button btnApply; + private System.Windows.Forms.Button btnCancel; + private System.Windows.Forms.Button btnOk; + private System.Windows.Forms.ListBox lbxChoices; + } +} diff --git a/applications/SLChat/SLChat/GUI/Preferences.cs b/applications/SLChat/SLChat/GUI/Preferences.cs index caf9055f..1bc773de 100644 --- a/applications/SLChat/SLChat/GUI/Preferences.cs +++ b/applications/SLChat/SLChat/GUI/Preferences.cs @@ -1,239 +1,239 @@ -/* - * Created by SharpDevelop. - * User: Oz - * Date: 8/12/2006 - * Time: 12:31 AM - * - * To change this template use Tools | Options | Coding | Edit Standard Headers. - */ - -using System; -using System.Drawing; -using System.Windows.Forms; -using System.Collections; - -namespace SLChat -{ - /// - /// Description of Preferences. - /// - public partial class frmPrefs - { - private frmMain MainForm; - private PrefsManager prefs; - //The name of the user whose profiles to load - //NOTE: format is first_last i.e. "Bob_Smith" - string user; - Hashtable settings = new Hashtable(); - - public frmPrefs(frmMain main, string username, PrefsManager preferences) - { - // - // The InitializeComponent() call is required for Windows Forms designer support. - // - InitializeComponent(); - - lbxChoices.SelectedIndex = lbxChoices.FindString("General"); - user = username; - prefs = preferences; - MainForm = main; - LoadDefaults(); - //our private load settings to handle how they turn out - //LoadSettings("GeneralSettings"); - LoadSettings("ChatSettings"); - LoadSettings("TimestampSettings"); - // - // TODO: Add constructor code after the InitializeComponent() call. - // - } - - private void LoadDefaults() - { - //Loads the defaults settings before anything else - //Chat - chkYouName.Checked = false; - chkListUserName.Checked = true; - //Timestamps - chkIMTimestamps.Checked = true; - chkChatTimestamps.Checked = false; - numIMTimeZ.Text = "-3"; - numChatTimeZ.Text = "-7"; - txtIMStampFormat.Text = "[HH:mm] "; - txtChatStampFormat.Text = "[HH:mm] "; - chkSyncStamps.Checked = true; - } - - private void LoadSettings(string parentnode) - { - prefs.LoadSettings(user,parentnode); - - settings = prefs.settings; - - if(!settings.ContainsKey("Error")) - { - IDictionaryEnumerator myEnum = settings.GetEnumerator(); - while (myEnum.MoveNext()) - { - if(parentnode=="ChatSettings") - { - if(myEnum.Key.ToString()=="UseFullName") - { - if(myEnum.Value.ToString()=="true"){ - chkYouName.Checked = prefs.setUseFullName = true; - }else{ - chkYouName.Checked = prefs.setUseFullName = false; - } - }else if(myEnum.Key.ToString()=="ListUserName"){ - if(myEnum.Value.ToString()=="true"){ - chkListUserName.Checked = prefs.setListUserName = true; - }else{ - chkListUserName.Checked = prefs.setListUserName = false; - } - } - }else if(parentnode=="TimestampSettings"){ - if(myEnum.Key.ToString()=="ShowIMTimestamps") - { - if(myEnum.Value.ToString()=="true") - { - chkIMTimestamps.Checked = prefs.setIMTimestamps = true; - }else{ - chkIMTimestamps.Checked = prefs.setIMTimestamps = false; - } - }else if(myEnum.Key.ToString()=="ShowChatTimestamps"){ - if(myEnum.Value.ToString()=="true"){ - chkChatTimestamps.Checked = prefs.setChatTimestamps = true; - }else{ - chkChatTimestamps.Checked = prefs.setChatTimestamps = false; - } - }else if(myEnum.Key.ToString()=="IMTimeZone"){ - numIMTimeZ.Text = prefs.setIMTimeZ = myEnum.Value.ToString(); - }else if(myEnum.Key.ToString()=="ChatTimeZone"){ - numChatTimeZ.Text = prefs.setChatTimeZ = myEnum.Value.ToString(); - }else if(myEnum.Key.ToString()=="IMStampFormat"){ - txtIMStampFormat.Text = prefs.setIMStampFormat = myEnum.Value.ToString(); - }else if(myEnum.Key.ToString()=="ChatStampFormat"){ - txtChatStampFormat.Text = prefs.setChatStampFormat = myEnum.Value.ToString(); - }else if(myEnum.Key.ToString()=="SyncStampSettings"){ - if(myEnum.Value.ToString()=="true"){ - chkSyncStamps.Checked = prefs.setSyncTimestamps = true; - }else{ - chkSyncStamps.Checked = prefs.setSyncTimestamps = false; - } - } - } - } - }else{ - IDictionaryEnumerator myEnum = settings.GetEnumerator(); - while (myEnum.MoveNext()) - { - if(myEnum.Key.ToString()=="Error") - { - //rtbStatus.Text = "Error loading settings: "+myEnum.Value.ToString(); - } - } - } - settings.Clear(); - prefs.settings.Clear(); - } - - private void SaveSettings() - { - if(chkYouName.Checked != prefs.setUseFullName - | chkListUserName.Checked != prefs.setListUserName) - { - string strChat = ""+ - ""; - prefs.SaveSettings(user,"ChatSettings",strChat); - MainForm.LoadSettings("ChatSettings"); - } - - if(chkIMTimestamps.Checked != prefs.setIMTimestamps | chkChatTimestamps.Checked != prefs.setChatTimestamps | - numIMTimeZ.Text != prefs.setIMTimeZ | numChatTimeZ.Text != prefs.setChatTimeZ | - txtIMStampFormat.Text != prefs.setIMStampFormat | txtChatStampFormat.Text != prefs.setChatStampFormat | - chkSyncStamps.Checked != prefs.setSyncTimestamps) - { - string strStamps = ""+ - ""+ - ""+ - ""+ - ""+ - ""+ - ""; - prefs.SaveSettings(user,"TimestampSettings",strStamps); - MainForm.LoadSettings("TimestampSettings"); - } - } - - public void LbxChoicesSelectedIndexChanged(object sender, System.EventArgs e) - { - gbxGeneral.Visible = false; - gbxChat.Visible = false; - gbxIM.Visible = false; - gbxTimestamps.Visible = false; - gbxProfiles.Visible = false; - if(lbxChoices.SelectedItem.ToString() == "General") - { - gbxGeneral.Visible = true; - }else if(lbxChoices.SelectedItem.ToString() == "Chat"){ - gbxChat.Visible = true; - }else if(lbxChoices.SelectedItem.ToString() == "IM"){ - gbxIM.Visible = true; - }else if(lbxChoices.SelectedItem.ToString() == "Timestamps"){ - gbxTimestamps.Visible = true; - }else if(lbxChoices.SelectedItem.ToString() == "Profiles"){ - gbxProfiles.Visible = true; - prefs.LoadProfiles(); - //Load the profiles to our combobox. - cbxProfiles.Items.Clear(); - string[] profiles = new string[100]; - profiles = prefs.profiles; - for(int i=0;i + /// Description of Preferences. + /// + public partial class frmPrefs + { + private frmMain MainForm; + private PrefsManager prefs; + //The name of the user whose profiles to load + //NOTE: format is first_last i.e. "Bob_Smith" + string user; + Hashtable settings = new Hashtable(); + + public frmPrefs(frmMain main, string username, PrefsManager preferences) + { + // + // The InitializeComponent() call is required for Windows Forms designer support. + // + InitializeComponent(); + + lbxChoices.SelectedIndex = lbxChoices.FindString("General"); + user = username; + prefs = preferences; + MainForm = main; + LoadDefaults(); + //our private load settings to handle how they turn out + //LoadSettings("GeneralSettings"); + LoadSettings("ChatSettings"); + LoadSettings("TimestampSettings"); + // + // TODO: Add constructor code after the InitializeComponent() call. + // + } + + private void LoadDefaults() + { + //Loads the defaults settings before anything else + //Chat + chkYouName.Checked = false; + chkListUserName.Checked = true; + //Timestamps + chkIMTimestamps.Checked = true; + chkChatTimestamps.Checked = false; + numIMTimeZ.Text = "-3"; + numChatTimeZ.Text = "-7"; + txtIMStampFormat.Text = "[HH:mm] "; + txtChatStampFormat.Text = "[HH:mm] "; + chkSyncStamps.Checked = true; + } + + private void LoadSettings(string parentnode) + { + prefs.LoadSettings(user,parentnode); + + settings = prefs.settings; + + if(!settings.ContainsKey("Error")) + { + IDictionaryEnumerator myEnum = settings.GetEnumerator(); + while (myEnum.MoveNext()) + { + if(parentnode=="ChatSettings") + { + if(myEnum.Key.ToString()=="UseFullName") + { + if(myEnum.Value.ToString()=="true"){ + chkYouName.Checked = prefs.setUseFullName = true; + }else{ + chkYouName.Checked = prefs.setUseFullName = false; + } + }else if(myEnum.Key.ToString()=="ListUserName"){ + if(myEnum.Value.ToString()=="true"){ + chkListUserName.Checked = prefs.setListUserName = true; + }else{ + chkListUserName.Checked = prefs.setListUserName = false; + } + } + }else if(parentnode=="TimestampSettings"){ + if(myEnum.Key.ToString()=="ShowIMTimestamps") + { + if(myEnum.Value.ToString()=="true") + { + chkIMTimestamps.Checked = prefs.setIMTimestamps = true; + }else{ + chkIMTimestamps.Checked = prefs.setIMTimestamps = false; + } + }else if(myEnum.Key.ToString()=="ShowChatTimestamps"){ + if(myEnum.Value.ToString()=="true"){ + chkChatTimestamps.Checked = prefs.setChatTimestamps = true; + }else{ + chkChatTimestamps.Checked = prefs.setChatTimestamps = false; + } + }else if(myEnum.Key.ToString()=="IMTimeZone"){ + numIMTimeZ.Text = prefs.setIMTimeZ = myEnum.Value.ToString(); + }else if(myEnum.Key.ToString()=="ChatTimeZone"){ + numChatTimeZ.Text = prefs.setChatTimeZ = myEnum.Value.ToString(); + }else if(myEnum.Key.ToString()=="IMStampFormat"){ + txtIMStampFormat.Text = prefs.setIMStampFormat = myEnum.Value.ToString(); + }else if(myEnum.Key.ToString()=="ChatStampFormat"){ + txtChatStampFormat.Text = prefs.setChatStampFormat = myEnum.Value.ToString(); + }else if(myEnum.Key.ToString()=="SyncStampSettings"){ + if(myEnum.Value.ToString()=="true"){ + chkSyncStamps.Checked = prefs.setSyncTimestamps = true; + }else{ + chkSyncStamps.Checked = prefs.setSyncTimestamps = false; + } + } + } + } + }else{ + IDictionaryEnumerator myEnum = settings.GetEnumerator(); + while (myEnum.MoveNext()) + { + if(myEnum.Key.ToString()=="Error") + { + //rtbStatus.Text = "Error loading settings: "+myEnum.Value.ToString(); + } + } + } + settings.Clear(); + prefs.settings.Clear(); + } + + private void SaveSettings() + { + if(chkYouName.Checked != prefs.setUseFullName + | chkListUserName.Checked != prefs.setListUserName) + { + string strChat = ""+ + ""; + prefs.SaveSettings(user,"ChatSettings",strChat); + MainForm.LoadSettings("ChatSettings"); + } + + if(chkIMTimestamps.Checked != prefs.setIMTimestamps | chkChatTimestamps.Checked != prefs.setChatTimestamps | + numIMTimeZ.Text != prefs.setIMTimeZ | numChatTimeZ.Text != prefs.setChatTimeZ | + txtIMStampFormat.Text != prefs.setIMStampFormat | txtChatStampFormat.Text != prefs.setChatStampFormat | + chkSyncStamps.Checked != prefs.setSyncTimestamps) + { + string strStamps = ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""; + prefs.SaveSettings(user,"TimestampSettings",strStamps); + MainForm.LoadSettings("TimestampSettings"); + } + } + + public void LbxChoicesSelectedIndexChanged(object sender, System.EventArgs e) + { + gbxGeneral.Visible = false; + gbxChat.Visible = false; + gbxIM.Visible = false; + gbxTimestamps.Visible = false; + gbxProfiles.Visible = false; + if(lbxChoices.SelectedItem.ToString() == "General") + { + gbxGeneral.Visible = true; + }else if(lbxChoices.SelectedItem.ToString() == "Chat"){ + gbxChat.Visible = true; + }else if(lbxChoices.SelectedItem.ToString() == "IM"){ + gbxIM.Visible = true; + }else if(lbxChoices.SelectedItem.ToString() == "Timestamps"){ + gbxTimestamps.Visible = true; + }else if(lbxChoices.SelectedItem.ToString() == "Profiles"){ + gbxProfiles.Visible = true; + prefs.LoadProfiles(); + //Load the profiles to our combobox. + cbxProfiles.Items.Clear(); + string[] profiles = new string[100]; + profiles = prefs.profiles; + for(int i=0;i - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/applications/SLChat/SLChat/Program.cs b/applications/SLChat/SLChat/Program.cs index 7ddc73bb..bf41f2db 100644 --- a/applications/SLChat/SLChat/Program.cs +++ b/applications/SLChat/SLChat/Program.cs @@ -1,20 +1,20 @@ -using System; -using System.Collections.Generic; -using System.Windows.Forms; - -namespace SLChat -{ - static class Program - { - /// - /// The main entry point for the application. - /// - [STAThread] - static void Main() - { - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new frmLogin()); - } - } -} +using System; +using System.Collections.Generic; +using System.Windows.Forms; + +namespace SLChat +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new frmLogin()); + } + } +} diff --git a/applications/SLChat/SLChat/Properties/AssemblyInfo.cs b/applications/SLChat/SLChat/Properties/AssemblyInfo.cs index 3794ed0f..1590c444 100644 --- a/applications/SLChat/SLChat/Properties/AssemblyInfo.cs +++ b/applications/SLChat/SLChat/Properties/AssemblyInfo.cs @@ -1,33 +1,33 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("SLChat")] -[assembly: AssemblyDescription("Text only SL client")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -//[assembly: AssemblyProduct("SLChat")] -[assembly: AssemblyCopyright("Copyright © 2006")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("9b31339a-b5e3-47ad-b6a3-0be444974cf2")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -[assembly: AssemblyVersion("0.0.0.3")] -[assembly: AssemblyFileVersion("0.0.0.3")] +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("SLChat")] +[assembly: AssemblyDescription("Text only SL client")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +//[assembly: AssemblyProduct("SLChat")] +[assembly: AssemblyCopyright("Copyright © 2006")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("9b31339a-b5e3-47ad-b6a3-0be444974cf2")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("0.0.0.3")] +[assembly: AssemblyFileVersion("0.0.0.3")] diff --git a/applications/SLChat/SLChat/Properties/Resources.Designer.cs b/applications/SLChat/SLChat/Properties/Resources.Designer.cs index 7807b355..4b5699d3 100644 --- a/applications/SLChat/SLChat/Properties/Resources.Designer.cs +++ b/applications/SLChat/SLChat/Properties/Resources.Designer.cs @@ -1,71 +1,71 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.42 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace SLChat.Properties -{ - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources - { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() - { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager - { - get - { - if ((resourceMan == null)) - { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SLChat.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture - { - get - { - return resourceCulture; - } - set - { - resourceCulture = value; - } - } - } -} +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SLChat.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SLChat.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/applications/SLChat/SLChat/Properties/Resources.resx b/applications/SLChat/SLChat/Properties/Resources.resx index ffecec85..af7dbebb 100644 --- a/applications/SLChat/SLChat/Properties/Resources.resx +++ b/applications/SLChat/SLChat/Properties/Resources.resx @@ -1,117 +1,117 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/applications/SLChat/SLChat/Properties/Settings.Designer.cs b/applications/SLChat/SLChat/Properties/Settings.Designer.cs index 6a5991ca..f237b06e 100644 --- a/applications/SLChat/SLChat/Properties/Settings.Designer.cs +++ b/applications/SLChat/SLChat/Properties/Settings.Designer.cs @@ -1,30 +1,30 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.42 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace SLChat.Properties -{ - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase - { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default - { - get - { - return defaultInstance; - } - } - } -} +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SLChat.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/applications/SLChat/SLChat/Properties/Settings.settings b/applications/SLChat/SLChat/Properties/Settings.settings index abf36c5d..39645652 100644 --- a/applications/SLChat/SLChat/Properties/Settings.settings +++ b/applications/SLChat/SLChat/Properties/Settings.settings @@ -1,7 +1,7 @@ - - - - - - - + + + + + + + diff --git a/applications/SLChat/SLChat/SLChat.csproj b/applications/SLChat/SLChat/SLChat.csproj index 7877134c..c5a9857e 100644 --- a/applications/SLChat/SLChat/SLChat.csproj +++ b/applications/SLChat/SLChat/SLChat.csproj @@ -1,131 +1,131 @@ - - - Debug - AnyCPU - 8.0.50727 - 2.0 - {A6D955CD-1F55-459F-A7AD-01E591404989} - WinExe - Properties - SLChat - SLChat - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - D:\Oz's Files\Second Life Stuff\libsecondlife\libsecondlife-cs\bin\Debug\libsecondlife.dll - False - - - - - Form - - - About.cs - - - - UserControl - - - IMTabWindow.cs - - - - Form - - - InstantMessages.cs - - - - Form - - - Login.cs - - - Form - - - MainForm.cs - - - - - - - - Designer - About.cs - - - Designer - IMTabWindow.cs - - - Designer - InstantMessages.cs - - - Designer - Login.cs - - - Designer - MainForm.cs - - - ResXFileCodeGenerator - Resources.Designer.cs - Designer - - - True - Resources.resx - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - True - Settings.settings - True - - - - - Preferences.cs - - - - Preferences.cs - - - - + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {A6D955CD-1F55-459F-A7AD-01E591404989} + WinExe + Properties + SLChat + SLChat + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + D:\Oz's Files\Second Life Stuff\libsecondlife\libsecondlife-cs\bin\Debug\libsecondlife.dll + False + + + + + Form + + + About.cs + + + + UserControl + + + IMTabWindow.cs + + + + Form + + + InstantMessages.cs + + + + Form + + + Login.cs + + + Form + + + MainForm.cs + + + + + + + + Designer + About.cs + + + Designer + IMTabWindow.cs + + + Designer + InstantMessages.cs + + + Designer + Login.cs + + + Designer + MainForm.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + Preferences.cs + + + + Preferences.cs + + + + \ No newline at end of file diff --git a/applications/SLChat/SLChat/SLNetCom/SLLoginOptions.cs b/applications/SLChat/SLChat/SLNetCom/SLLoginOptions.cs index 5f6af7c0..235d16d3 100644 --- a/applications/SLChat/SLChat/SLNetCom/SLLoginOptions.cs +++ b/applications/SLChat/SLChat/SLNetCom/SLLoginOptions.cs @@ -1,68 +1,68 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace SLNetworkComm -{ - public class SLLoginOptions - { - private string firstName; - private string lastName; - private string password; - private string author = string.Empty; - private string userAgent = string.Empty; - private string startLocation = "Home"; - - public SLLoginOptions() - { - - } - - public string FirstName - { - get { return firstName; } - set { firstName = value; } - } - - public string LastName - { - get { return lastName; } - set { lastName = value; } - } - - public string FullName - { - get - { - if (string.IsNullOrEmpty(firstName) || string.IsNullOrEmpty(lastName)) - return string.Empty; - else - return firstName + " " + lastName; - } - } - - public string Password - { - get { return password; } - set { password = value; } - } - - public string StartLocation - { - get { return startLocation; } - set { startLocation = value; } - } - - public string UserAgent - { - get { return userAgent; } - set { userAgent = value; } - } - - public string Author - { - get { return author; } - set { author = value; } - } - } -} +using System; +using System.Collections.Generic; +using System.Text; + +namespace SLNetworkComm +{ + public class SLLoginOptions + { + private string firstName; + private string lastName; + private string password; + private string author = string.Empty; + private string userAgent = string.Empty; + private string startLocation = "Home"; + + public SLLoginOptions() + { + + } + + public string FirstName + { + get { return firstName; } + set { firstName = value; } + } + + public string LastName + { + get { return lastName; } + set { lastName = value; } + } + + public string FullName + { + get + { + if (string.IsNullOrEmpty(firstName) || string.IsNullOrEmpty(lastName)) + return string.Empty; + else + return firstName + " " + lastName; + } + } + + public string Password + { + get { return password; } + set { password = value; } + } + + public string StartLocation + { + get { return startLocation; } + set { startLocation = value; } + } + + public string UserAgent + { + get { return userAgent; } + set { userAgent = value; } + } + + public string Author + { + get { return author; } + set { author = value; } + } + } +} diff --git a/applications/SLChat/SLChat/SLNetCom/SLNetCom.cs b/applications/SLChat/SLChat/SLNetCom/SLNetCom.cs index da0379f3..e2d2a3ec 100644 --- a/applications/SLChat/SLChat/SLNetCom/SLNetCom.cs +++ b/applications/SLChat/SLChat/SLNetCom/SLNetCom.cs @@ -1,357 +1,357 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.ComponentModel; -using System.Text; -using libsecondlife; - -namespace SLNetworkComm -{ - /// - /// Description of SLNetCom: - /// NetCom stands for Network Communication - /// Basically all functions that have to do with communicating - /// too and from SL should happen in here. This keeps things - /// organized and interface seperate from network code. - /// - public partial class SLNetCom - { - private SecondLife client; - private bool loggedIn = false; - private SLLoginOptions loginOptions; - - // NetcomSync is used for raising IM/Chat events on the - // GUI/main thread. Useful if you're modifying GUI controls - // in the client app when responding to IM/Chat events. - private ISynchronizeInvoke netcomSync; - - public SLNetCom() - { - this.InitializeClient(); - loginOptions = new SLLoginOptions(); - } - - public SLNetCom(string firstName, string lastName, string password, string loginLocation) - { - this.InitializeClient(); - - loginOptions = new SLLoginOptions(); - loginOptions.FirstName = firstName; - loginOptions.LastName = lastName; - loginOptions.Password = password; - loginOptions.StartLocation = loginLocation; - } - - public SLNetCom(SLLoginOptions logOptions) - { - this.InitializeClient(); - loginOptions = logOptions; - } - - private void InitializeClient() - { - client = new SecondLife("keywords.txt", "message_template.msg"); - client.Network.RegisterCallback("ChatFromSimulator", new PacketCallback(ChatIncoming)); - client.Network.RegisterCallback("ImprovedInstantMessage", new PacketCallback(InstantMessageIncoming)); - } - - private void InstantMessageIncoming(Packet packet, Simulator simulator) - { - if (packet.Layout.Name != "ImprovedInstantMessage") return; - - LLUUID FromAgentID = new LLUUID(); - LLUUID ToAgentID = new LLUUID(); - uint ParentEstateID = 0; - LLUUID RegionID = new LLUUID(); - LLVector3 Position = new LLVector3(); - bool Offline = false; - byte Dialog = 0; - LLUUID ID = new LLUUID(); - uint Timestamp = 0; - DateTime dt = new DateTime(1970, 1, 1, 0, 0, 0, 0); //The Unix epoch! - string FromAgentName = string.Empty; - string Message = string.Empty; - string BinaryBucket = string.Empty; - - ArrayList blocks = packet.Blocks(); - - foreach (Block block in blocks) - { - foreach (Field field in block.Fields) - { - switch (field.Layout.Name) - { - case "FromAgentID": - FromAgentID = (LLUUID)field.Data; - break; - - case "ToAgentID": - ToAgentID = (LLUUID)field.Data; - break; - - case "ParentEstateID": - ParentEstateID = (uint)field.Data; - break; - - case "RegionID": - RegionID = (LLUUID)field.Data; - break; - - case "Position": - Position = (LLVector3)field.Data; - break; - - case "Offline": - Offline = ((byte)field.Data == 1 ? true : false); - break; - - case "Dialog": - Dialog = (byte)field.Data; - break; - - case "ID": - ID = (LLUUID)field.Data; - break; - - case "Timestamp": - Timestamp = (uint)field.Data; - - if (Timestamp == 0) //User is online - dt = DateTime.Now; - else //User is offline - dt = dt.AddSeconds(Timestamp); - - break; - - case "FromAgentName": - FromAgentName = System.Text.Encoding.UTF8.GetString((byte[])field.Data).Replace("\0", string.Empty); - break; - - case "Message": - Message = System.Text.Encoding.UTF8.GetString((byte[])field.Data).Replace("\0", string.Empty); - break; - - case "BinaryBucket": - BinaryBucket = System.Text.Encoding.UTF8.GetString((byte[])field.Data).Replace("\0", string.Empty); - break; - } - } - - InstantMessageEventArgs eventArgs = new InstantMessageEventArgs( - FromAgentID, ToAgentID, ParentEstateID, RegionID, - Position, Offline, Dialog, ID, - dt, FromAgentName, Message, BinaryBucket); - - if (netcomSync != null) - { - object[] ea = new object[1]; - ea[0] = eventArgs; - netcomSync.Invoke(new OnInstantMessageRaise(OnInstantMessageReceived), ea); - } - else - { - OnInstantMessageReceived(eventArgs); - } - } - } - - private void ChatIncoming(Packet packet, Simulator simulator) - { - if (packet.Layout.Name != "ChatFromSimulator") return; - - string fromname = string.Empty; //Name of source. - LLUUID sourceid = new LLUUID(); //UUID of source, object/avatar - LLUUID ownerid = new LLUUID(); //UUID of owner, if object UUID = owner of object, if avatar UUID = same as source - SLSourceType sourcetype = SLSourceType.None; - SLChatType chattype = SLChatType.Whisper; - bool audible = false; //Audible: 1 if audible, 0 if beyond 20m (message is null) - LLVector3 position = new LLVector3(); //Region local position of source. - string message = string.Empty; //Message from source - byte command = 0; //Unused? - LLUUID commandID = new LLUUID(); //Unused? - - ArrayList blocks = packet.Blocks(); - - foreach (Block block in blocks) - { - foreach (Field field in block.Fields) - { - switch (field.Layout.Name) - { - case "SourceID": - sourceid = (LLUUID)field.Data; - break; - - case "OwnerID": - ownerid = (LLUUID)field.Data; - break; - - case "FromName": - fromname = System.Text.Encoding.UTF8.GetString((byte[])field.Data).Replace("\0", string.Empty); - break; - - case "SourceType": - sourcetype = (SLSourceType)(byte)field.Data; - break; - - case "ChatType": - chattype = (SLChatType)(byte)field.Data; - break; - - case "Audible": - audible = ((byte)field.Data == 1 ? true : false); - break; - - case "Message": - message = System.Text.Encoding.UTF8.GetString((byte[])field.Data).Replace("\0", string.Empty); - break; - - case "Position": - position = (LLVector3)field.Data; - break; - - case "Command": - command = (byte)field.Data; - break; - - case "CommandID": - commandID = (LLUUID)field.Data; - break; - } - } - - ChatEventArgs eventArgs = new ChatEventArgs( - message, chattype, - position, sourcetype, sourceid, ownerid, - fromname, audible, command, commandID); - - if (netcomSync != null) - { - object[] ea = new object[1]; - ea[0] = eventArgs; - netcomSync.Invoke(new OnChatRaise(OnChatReceived), ea); - } - else - { - OnChatReceived(eventArgs); - } - } - } - - public void Login() - { - //LoginReply will be used to contain the output text. - string loginReply; - - //Checking for empty/null login fields. Leave the Login() method if true. - if (string.IsNullOrEmpty(loginOptions.FirstName) || - string.IsNullOrEmpty(loginOptions.LastName) || - string.IsNullOrEmpty(loginOptions.Password) || - string.IsNullOrEmpty(loginOptions.StartLocation)) - { - loginReply = "A login field is blank!"; - - OnClientLoginError(new ClientLoginEventArgs(loginReply)); - return; - } - - Hashtable loginParams = NetworkManager.DefaultLoginValues( - loginOptions.FirstName, loginOptions.LastName, loginOptions.Password, - "00:00:00:00:00:00", - loginOptions.StartLocation.ToLower(), - 1, 50, 50, 50, "Win", - "0", loginOptions.UserAgent, loginOptions.Author); - - //uri:Ahern&195&233&30 - - // An example of how to pass additional options to the login server - // Request information on the Root Inventory Folder, and Inventory Skeleton - // alAdditionalInfo.Add("inventory-skeleton"); - - //ArrayList alAdditionalInfo = new ArrayList(); - //alAdditionalInfo.Add("inventory-root"); - //loginParams.Add("options",alAdditionalInfo); - - //Hashtable loginReply = new Hashtable(); - - if (client.Network.Login(loginParams)) - { - // Login was successful - loginReply = "Message of the day: " + client.Network.LoginValues["message"]; - loggedIn = true; - - OnClientLoggedIn(new ClientLoginEventArgs(loginReply)); - } - else - { - // Login failed - loginReply = "Error logging in: " + client.Network.LoginError; - - OnClientLoginError(new ClientLoginEventArgs(loginReply)); - } - } - - public void Logout() - { - if (!loggedIn) return; - - client.Network.Logout(); - loggedIn = false; - - string logoutReply = "Successfully logged out!"; - OnClientLoggedOut(new ClientLoginEventArgs(logoutReply)); - } - - public void ChatOut(string chat, SLChatType type, int channel) - { - if (!loggedIn) return; - if (string.IsNullOrEmpty(chat)) return; - - switch (type) - { - case SLChatType.Say: - client.Avatar.Say(chat, channel); - break; - - case SLChatType.Shout: - client.Avatar.Shout(chat, channel); - break; - - case SLChatType.Whisper: - client.Avatar.Whisper(chat, channel); - break; - } - - OnChatSent(new ChatSentEventArgs(chat, type, channel)); - } - - public void SendInstantMessage(string message, LLUUID target, LLUUID session) - { - if (!loggedIn) return; - - client.Avatar.InstantMessage(loginOptions.FullName, session, target, message, null); - OnInstantMessageSent(new InstantMessageSentEventArgs(message, target, session, DateTime.Now)); - } - - public SecondLife Client - { - get { return client; } - } - - public bool LoggedIn - { - get { return loggedIn; } - } - - public SLLoginOptions LoginOptions - { - get { return loginOptions; } - } - - public ISynchronizeInvoke NetcomSync - { - get { return netcomSync; } - set { netcomSync = value; } - } - } -} +using System; +using System.Collections; +using System.Collections.Generic; +using System.ComponentModel; +using System.Text; +using libsecondlife; + +namespace SLNetworkComm +{ + /// + /// Description of SLNetCom: + /// NetCom stands for Network Communication + /// Basically all functions that have to do with communicating + /// too and from SL should happen in here. This keeps things + /// organized and interface seperate from network code. + /// + public partial class SLNetCom + { + private SecondLife client; + private bool loggedIn = false; + private SLLoginOptions loginOptions; + + // NetcomSync is used for raising IM/Chat events on the + // GUI/main thread. Useful if you're modifying GUI controls + // in the client app when responding to IM/Chat events. + private ISynchronizeInvoke netcomSync; + + public SLNetCom() + { + this.InitializeClient(); + loginOptions = new SLLoginOptions(); + } + + public SLNetCom(string firstName, string lastName, string password, string loginLocation) + { + this.InitializeClient(); + + loginOptions = new SLLoginOptions(); + loginOptions.FirstName = firstName; + loginOptions.LastName = lastName; + loginOptions.Password = password; + loginOptions.StartLocation = loginLocation; + } + + public SLNetCom(SLLoginOptions logOptions) + { + this.InitializeClient(); + loginOptions = logOptions; + } + + private void InitializeClient() + { + client = new SecondLife("keywords.txt", "message_template.msg"); + client.Network.RegisterCallback("ChatFromSimulator", new PacketCallback(ChatIncoming)); + client.Network.RegisterCallback("ImprovedInstantMessage", new PacketCallback(InstantMessageIncoming)); + } + + private void InstantMessageIncoming(Packet packet, Simulator simulator) + { + if (packet.Layout.Name != "ImprovedInstantMessage") return; + + LLUUID FromAgentID = new LLUUID(); + LLUUID ToAgentID = new LLUUID(); + uint ParentEstateID = 0; + LLUUID RegionID = new LLUUID(); + LLVector3 Position = new LLVector3(); + bool Offline = false; + byte Dialog = 0; + LLUUID ID = new LLUUID(); + uint Timestamp = 0; + DateTime dt = new DateTime(1970, 1, 1, 0, 0, 0, 0); //The Unix epoch! + string FromAgentName = string.Empty; + string Message = string.Empty; + string BinaryBucket = string.Empty; + + ArrayList blocks = packet.Blocks(); + + foreach (Block block in blocks) + { + foreach (Field field in block.Fields) + { + switch (field.Layout.Name) + { + case "FromAgentID": + FromAgentID = (LLUUID)field.Data; + break; + + case "ToAgentID": + ToAgentID = (LLUUID)field.Data; + break; + + case "ParentEstateID": + ParentEstateID = (uint)field.Data; + break; + + case "RegionID": + RegionID = (LLUUID)field.Data; + break; + + case "Position": + Position = (LLVector3)field.Data; + break; + + case "Offline": + Offline = ((byte)field.Data == 1 ? true : false); + break; + + case "Dialog": + Dialog = (byte)field.Data; + break; + + case "ID": + ID = (LLUUID)field.Data; + break; + + case "Timestamp": + Timestamp = (uint)field.Data; + + if (Timestamp == 0) //User is online + dt = DateTime.Now; + else //User is offline + dt = dt.AddSeconds(Timestamp); + + break; + + case "FromAgentName": + FromAgentName = System.Text.Encoding.UTF8.GetString((byte[])field.Data).Replace("\0", string.Empty); + break; + + case "Message": + Message = System.Text.Encoding.UTF8.GetString((byte[])field.Data).Replace("\0", string.Empty); + break; + + case "BinaryBucket": + BinaryBucket = System.Text.Encoding.UTF8.GetString((byte[])field.Data).Replace("\0", string.Empty); + break; + } + } + + InstantMessageEventArgs eventArgs = new InstantMessageEventArgs( + FromAgentID, ToAgentID, ParentEstateID, RegionID, + Position, Offline, Dialog, ID, + dt, FromAgentName, Message, BinaryBucket); + + if (netcomSync != null) + { + object[] ea = new object[1]; + ea[0] = eventArgs; + netcomSync.Invoke(new OnInstantMessageRaise(OnInstantMessageReceived), ea); + } + else + { + OnInstantMessageReceived(eventArgs); + } + } + } + + private void ChatIncoming(Packet packet, Simulator simulator) + { + if (packet.Layout.Name != "ChatFromSimulator") return; + + string fromname = string.Empty; //Name of source. + LLUUID sourceid = new LLUUID(); //UUID of source, object/avatar + LLUUID ownerid = new LLUUID(); //UUID of owner, if object UUID = owner of object, if avatar UUID = same as source + SLSourceType sourcetype = SLSourceType.None; + SLChatType chattype = SLChatType.Whisper; + bool audible = false; //Audible: 1 if audible, 0 if beyond 20m (message is null) + LLVector3 position = new LLVector3(); //Region local position of source. + string message = string.Empty; //Message from source + byte command = 0; //Unused? + LLUUID commandID = new LLUUID(); //Unused? + + ArrayList blocks = packet.Blocks(); + + foreach (Block block in blocks) + { + foreach (Field field in block.Fields) + { + switch (field.Layout.Name) + { + case "SourceID": + sourceid = (LLUUID)field.Data; + break; + + case "OwnerID": + ownerid = (LLUUID)field.Data; + break; + + case "FromName": + fromname = System.Text.Encoding.UTF8.GetString((byte[])field.Data).Replace("\0", string.Empty); + break; + + case "SourceType": + sourcetype = (SLSourceType)(byte)field.Data; + break; + + case "ChatType": + chattype = (SLChatType)(byte)field.Data; + break; + + case "Audible": + audible = ((byte)field.Data == 1 ? true : false); + break; + + case "Message": + message = System.Text.Encoding.UTF8.GetString((byte[])field.Data).Replace("\0", string.Empty); + break; + + case "Position": + position = (LLVector3)field.Data; + break; + + case "Command": + command = (byte)field.Data; + break; + + case "CommandID": + commandID = (LLUUID)field.Data; + break; + } + } + + ChatEventArgs eventArgs = new ChatEventArgs( + message, chattype, + position, sourcetype, sourceid, ownerid, + fromname, audible, command, commandID); + + if (netcomSync != null) + { + object[] ea = new object[1]; + ea[0] = eventArgs; + netcomSync.Invoke(new OnChatRaise(OnChatReceived), ea); + } + else + { + OnChatReceived(eventArgs); + } + } + } + + public void Login() + { + //LoginReply will be used to contain the output text. + string loginReply; + + //Checking for empty/null login fields. Leave the Login() method if true. + if (string.IsNullOrEmpty(loginOptions.FirstName) || + string.IsNullOrEmpty(loginOptions.LastName) || + string.IsNullOrEmpty(loginOptions.Password) || + string.IsNullOrEmpty(loginOptions.StartLocation)) + { + loginReply = "A login field is blank!"; + + OnClientLoginError(new ClientLoginEventArgs(loginReply)); + return; + } + + Hashtable loginParams = NetworkManager.DefaultLoginValues( + loginOptions.FirstName, loginOptions.LastName, loginOptions.Password, + "00:00:00:00:00:00", + loginOptions.StartLocation.ToLower(), + 1, 50, 50, 50, "Win", + "0", loginOptions.UserAgent, loginOptions.Author); + + //uri:Ahern&195&233&30 + + // An example of how to pass additional options to the login server + // Request information on the Root Inventory Folder, and Inventory Skeleton + // alAdditionalInfo.Add("inventory-skeleton"); + + //ArrayList alAdditionalInfo = new ArrayList(); + //alAdditionalInfo.Add("inventory-root"); + //loginParams.Add("options",alAdditionalInfo); + + //Hashtable loginReply = new Hashtable(); + + if (client.Network.Login(loginParams)) + { + // Login was successful + loginReply = "Message of the day: " + client.Network.LoginValues["message"]; + loggedIn = true; + + OnClientLoggedIn(new ClientLoginEventArgs(loginReply)); + } + else + { + // Login failed + loginReply = "Error logging in: " + client.Network.LoginError; + + OnClientLoginError(new ClientLoginEventArgs(loginReply)); + } + } + + public void Logout() + { + if (!loggedIn) return; + + client.Network.Logout(); + loggedIn = false; + + string logoutReply = "Successfully logged out!"; + OnClientLoggedOut(new ClientLoginEventArgs(logoutReply)); + } + + public void ChatOut(string chat, SLChatType type, int channel) + { + if (!loggedIn) return; + if (string.IsNullOrEmpty(chat)) return; + + switch (type) + { + case SLChatType.Say: + client.Avatar.Say(chat, channel); + break; + + case SLChatType.Shout: + client.Avatar.Shout(chat, channel); + break; + + case SLChatType.Whisper: + client.Avatar.Whisper(chat, channel); + break; + } + + OnChatSent(new ChatSentEventArgs(chat, type, channel)); + } + + public void SendInstantMessage(string message, LLUUID target, LLUUID session) + { + if (!loggedIn) return; + + client.Avatar.InstantMessage(loginOptions.FullName, session, target, message, null); + OnInstantMessageSent(new InstantMessageSentEventArgs(message, target, session, DateTime.Now)); + } + + public SecondLife Client + { + get { return client; } + } + + public bool LoggedIn + { + get { return loggedIn; } + } + + public SLLoginOptions LoginOptions + { + get { return loginOptions; } + } + + public ISynchronizeInvoke NetcomSync + { + get { return netcomSync; } + set { netcomSync = value; } + } + } +} diff --git a/applications/SLChat/SLChat/SLNetCom/SLNetComEnums.cs b/applications/SLChat/SLChat/SLNetCom/SLNetComEnums.cs index 4be75703..fdc9695e 100644 --- a/applications/SLChat/SLChat/SLNetCom/SLNetComEnums.cs +++ b/applications/SLChat/SLChat/SLNetCom/SLNetComEnums.cs @@ -1,23 +1,23 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace SLNetworkComm -{ - public enum SLChatType - { - Whisper, - Say, - Shout, - Unknown, - TypingNotification, - ChatbarToggle - }; - - public enum SLSourceType - { - None, - Avatar, - Object - }; -} +using System; +using System.Collections.Generic; +using System.Text; + +namespace SLNetworkComm +{ + public enum SLChatType + { + Whisper, + Say, + Shout, + Unknown, + TypingNotification, + ChatbarToggle + }; + + public enum SLSourceType + { + None, + Avatar, + Object + }; +} diff --git a/applications/SLChat/SLChat/SLNetCom/SLNetComEvents.cs b/applications/SLChat/SLChat/SLNetCom/SLNetComEvents.cs index 67813287..16ee8a9c 100644 --- a/applications/SLChat/SLChat/SLNetCom/SLNetComEvents.cs +++ b/applications/SLChat/SLChat/SLNetCom/SLNetComEvents.cs @@ -1,314 +1,314 @@ -using System; -using System.Collections.Generic; -using System.Text; -using libsecondlife; - -namespace SLNetworkComm -{ - public partial class SLNetCom - { - // For the NetcomSync stuff - private delegate void OnClientLoginRaise(ClientLoginEventArgs e); - private delegate void OnChatRaise(ChatEventArgs e); - private delegate void OnInstantMessageRaise(InstantMessageEventArgs e); - - public event EventHandler ClientLoggedIn; - public event EventHandler ClientLoginError; - public event EventHandler ClientLoggedOut; - public event EventHandler ChatReceived; - public event EventHandler ChatSent; - public event EventHandler InstantMessageReceived; - public event EventHandler InstantMessageSent; - - protected virtual void OnClientLoggedIn(ClientLoginEventArgs e) - { - if (ClientLoggedIn != null) ClientLoggedIn(this, e); - } - - protected virtual void OnClientLoginError(ClientLoginEventArgs e) - { - if (ClientLoginError != null) ClientLoginError(this, e); - } - - protected virtual void OnClientLoggedOut(ClientLoginEventArgs e) - { - if (ClientLoggedOut != null) ClientLoggedOut(this, e); - } - - protected virtual void OnChatReceived(ChatEventArgs e) - { - if (ChatReceived != null) ChatReceived(this, e); - } - - protected virtual void OnChatSent(ChatSentEventArgs e) - { - if (ChatSent != null) ChatSent(this, e); - } - - protected virtual void OnInstantMessageReceived(InstantMessageEventArgs e) - { - if (InstantMessageReceived != null) InstantMessageReceived(this, e); - } - - protected virtual void OnInstantMessageSent(InstantMessageSentEventArgs e) - { - if (InstantMessageSent != null) InstantMessageSent(this, e); - } - } - - public class ClientLoginEventArgs : EventArgs - { - private string _loginReply; - - public ClientLoginEventArgs(string loginReply) - { - _loginReply = loginReply; - } - - public string LoginReply - { - get { return _loginReply; } - } - } - - public class ChatEventArgs : EventArgs - { - private string _message; - private SLChatType _type; - private LLVector3 _sourcePos; - private SLSourceType _sourceType; - private LLUUID _sourceId; - private LLUUID _ownerId; - private string _fromName; - private bool _audible; - private byte _command; - private LLUUID _commandId; - - public ChatEventArgs( - string message, SLChatType type, LLVector3 sourcePos, SLSourceType sourceType, - LLUUID sourceId, LLUUID ownerId, string fromName, - bool audible, byte command, LLUUID commandId) - { - _message = message; - _type = type; - _sourcePos = sourcePos; - _sourceType = sourceType; - _sourceId = sourceId; - _ownerId = ownerId; - _fromName = fromName; - _audible = audible; - _command = command; - _commandId = commandId; - } - - public string Message - { - get { return _message; } - } - - public SLChatType Type - { - get { return _type; } - } - - public LLVector3 SourcePosition - { - get { return _sourcePos; } - } - - public SLSourceType SourceType - { - get { return _sourceType; } - } - - public LLUUID SourceId - { - get { return _sourceId; } - } - - public LLUUID OwnerId - { - get { return _ownerId; } - } - - public string FromName - { - get { return _fromName; } - } - - public bool Audible - { - get { return _audible; } - } - - public byte Command - { - get { return _command; } - } - - public LLUUID CommandId - { - get { return _commandId; } - } - } - - public class ChatSentEventArgs : EventArgs - { - private string _message; - private SLChatType _messageType; - private int _channel; - - public ChatSentEventArgs(string message, SLChatType messageType, int channel) - { - _message = message; - _messageType = messageType; - _channel = channel; - } - - public string Message - { - get { return _message; } - } - - public SLChatType MessageType - { - get { return _messageType; } - } - - public int Channel - { - get { return _channel; } - } - } - - public class InstantMessageEventArgs : EventArgs - { - private LLUUID _fromAgentId; - private LLUUID _toAgentId; - private uint _parentEstateId; - private LLUUID _regionId; - private LLVector3 _position; - private bool _offline; - private byte _dialog; - private LLUUID _id; - private DateTime _timestamp; - private string _fromAgentName; - private string _message; - private string _binaryBucket; - - public InstantMessageEventArgs( - LLUUID fromAgentId, LLUUID toAgentId, uint parentEstateId, LLUUID regionId, - LLVector3 position, bool offline, byte dialog, LLUUID id, - DateTime timestamp, string fromAgentName, string message, string binaryBucket) - { - _fromAgentId = fromAgentId; - _toAgentId = toAgentId; - _parentEstateId = parentEstateId; - _regionId = regionId; - _position = position; - _offline = offline; - _dialog = dialog; - _id = id; - _timestamp = timestamp; - _fromAgentName = fromAgentName; - _message = message; - _binaryBucket = binaryBucket; - } - - public LLUUID FromAgentId - { - get { return _fromAgentId; } - } - - public LLUUID ToAgentId - { - get { return _toAgentId; } - } - - public uint ParentEstateId - { - get { return _parentEstateId; } - } - - public LLUUID RegionId - { - get { return _regionId; } - } - - public LLVector3 Position - { - get { return _position; } - } - - public bool Offline - { - get { return _offline; } - } - - public byte Dialog - { - get { return _dialog; } - } - - public LLUUID Id - { - get { return _id; } - } - - public DateTime Timestamp - { - get { return _timestamp; } - } - - public string FromAgentName - { - get { return _fromAgentName; } - } - - public string Message - { - get { return _message; } - } - - public string BinaryBucket - { - get { return _binaryBucket; } - } - } - - public class InstantMessageSentEventArgs : EventArgs - { - private string _message; - private LLUUID _targetId; - private LLUUID _sessionId; - private DateTime _timestamp; - - public InstantMessageSentEventArgs(string message, LLUUID targetId, LLUUID sessionId, DateTime timestamp) - { - _message = message; - _targetId = targetId; - _sessionId = sessionId; - _timestamp = timestamp; - } - - public string Message - { - get { return _message; } - } - - public LLUUID TargetId - { - get { return _targetId; } - } - - public LLUUID SessionId - { - get { return _sessionId; } - } - - public DateTime Timestamp - { - get { return _timestamp; } - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using libsecondlife; + +namespace SLNetworkComm +{ + public partial class SLNetCom + { + // For the NetcomSync stuff + private delegate void OnClientLoginRaise(ClientLoginEventArgs e); + private delegate void OnChatRaise(ChatEventArgs e); + private delegate void OnInstantMessageRaise(InstantMessageEventArgs e); + + public event EventHandler ClientLoggedIn; + public event EventHandler ClientLoginError; + public event EventHandler ClientLoggedOut; + public event EventHandler ChatReceived; + public event EventHandler ChatSent; + public event EventHandler InstantMessageReceived; + public event EventHandler InstantMessageSent; + + protected virtual void OnClientLoggedIn(ClientLoginEventArgs e) + { + if (ClientLoggedIn != null) ClientLoggedIn(this, e); + } + + protected virtual void OnClientLoginError(ClientLoginEventArgs e) + { + if (ClientLoginError != null) ClientLoginError(this, e); + } + + protected virtual void OnClientLoggedOut(ClientLoginEventArgs e) + { + if (ClientLoggedOut != null) ClientLoggedOut(this, e); + } + + protected virtual void OnChatReceived(ChatEventArgs e) + { + if (ChatReceived != null) ChatReceived(this, e); + } + + protected virtual void OnChatSent(ChatSentEventArgs e) + { + if (ChatSent != null) ChatSent(this, e); + } + + protected virtual void OnInstantMessageReceived(InstantMessageEventArgs e) + { + if (InstantMessageReceived != null) InstantMessageReceived(this, e); + } + + protected virtual void OnInstantMessageSent(InstantMessageSentEventArgs e) + { + if (InstantMessageSent != null) InstantMessageSent(this, e); + } + } + + public class ClientLoginEventArgs : EventArgs + { + private string _loginReply; + + public ClientLoginEventArgs(string loginReply) + { + _loginReply = loginReply; + } + + public string LoginReply + { + get { return _loginReply; } + } + } + + public class ChatEventArgs : EventArgs + { + private string _message; + private SLChatType _type; + private LLVector3 _sourcePos; + private SLSourceType _sourceType; + private LLUUID _sourceId; + private LLUUID _ownerId; + private string _fromName; + private bool _audible; + private byte _command; + private LLUUID _commandId; + + public ChatEventArgs( + string message, SLChatType type, LLVector3 sourcePos, SLSourceType sourceType, + LLUUID sourceId, LLUUID ownerId, string fromName, + bool audible, byte command, LLUUID commandId) + { + _message = message; + _type = type; + _sourcePos = sourcePos; + _sourceType = sourceType; + _sourceId = sourceId; + _ownerId = ownerId; + _fromName = fromName; + _audible = audible; + _command = command; + _commandId = commandId; + } + + public string Message + { + get { return _message; } + } + + public SLChatType Type + { + get { return _type; } + } + + public LLVector3 SourcePosition + { + get { return _sourcePos; } + } + + public SLSourceType SourceType + { + get { return _sourceType; } + } + + public LLUUID SourceId + { + get { return _sourceId; } + } + + public LLUUID OwnerId + { + get { return _ownerId; } + } + + public string FromName + { + get { return _fromName; } + } + + public bool Audible + { + get { return _audible; } + } + + public byte Command + { + get { return _command; } + } + + public LLUUID CommandId + { + get { return _commandId; } + } + } + + public class ChatSentEventArgs : EventArgs + { + private string _message; + private SLChatType _messageType; + private int _channel; + + public ChatSentEventArgs(string message, SLChatType messageType, int channel) + { + _message = message; + _messageType = messageType; + _channel = channel; + } + + public string Message + { + get { return _message; } + } + + public SLChatType MessageType + { + get { return _messageType; } + } + + public int Channel + { + get { return _channel; } + } + } + + public class InstantMessageEventArgs : EventArgs + { + private LLUUID _fromAgentId; + private LLUUID _toAgentId; + private uint _parentEstateId; + private LLUUID _regionId; + private LLVector3 _position; + private bool _offline; + private byte _dialog; + private LLUUID _id; + private DateTime _timestamp; + private string _fromAgentName; + private string _message; + private string _binaryBucket; + + public InstantMessageEventArgs( + LLUUID fromAgentId, LLUUID toAgentId, uint parentEstateId, LLUUID regionId, + LLVector3 position, bool offline, byte dialog, LLUUID id, + DateTime timestamp, string fromAgentName, string message, string binaryBucket) + { + _fromAgentId = fromAgentId; + _toAgentId = toAgentId; + _parentEstateId = parentEstateId; + _regionId = regionId; + _position = position; + _offline = offline; + _dialog = dialog; + _id = id; + _timestamp = timestamp; + _fromAgentName = fromAgentName; + _message = message; + _binaryBucket = binaryBucket; + } + + public LLUUID FromAgentId + { + get { return _fromAgentId; } + } + + public LLUUID ToAgentId + { + get { return _toAgentId; } + } + + public uint ParentEstateId + { + get { return _parentEstateId; } + } + + public LLUUID RegionId + { + get { return _regionId; } + } + + public LLVector3 Position + { + get { return _position; } + } + + public bool Offline + { + get { return _offline; } + } + + public byte Dialog + { + get { return _dialog; } + } + + public LLUUID Id + { + get { return _id; } + } + + public DateTime Timestamp + { + get { return _timestamp; } + } + + public string FromAgentName + { + get { return _fromAgentName; } + } + + public string Message + { + get { return _message; } + } + + public string BinaryBucket + { + get { return _binaryBucket; } + } + } + + public class InstantMessageSentEventArgs : EventArgs + { + private string _message; + private LLUUID _targetId; + private LLUUID _sessionId; + private DateTime _timestamp; + + public InstantMessageSentEventArgs(string message, LLUUID targetId, LLUUID sessionId, DateTime timestamp) + { + _message = message; + _targetId = targetId; + _sessionId = sessionId; + _timestamp = timestamp; + } + + public string Message + { + get { return _message; } + } + + public LLUUID TargetId + { + get { return _targetId; } + } + + public LLUUID SessionId + { + get { return _sessionId; } + } + + public DateTime Timestamp + { + get { return _timestamp; } + } + } +} diff --git a/applications/SLIRC/Program.cs b/applications/SLIRC/Program.cs index 54df3d2f..4bd67c80 100644 --- a/applications/SLIRC/Program.cs +++ b/applications/SLIRC/Program.cs @@ -1,20 +1,20 @@ -using System; -using System.Collections.Generic; -using System.Windows.Forms; - -namespace SLIRC -{ - static class Program - { - /// - /// The main entry point for the application. - /// - [STAThread] - static void Main() - { - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new frmSLIRC()); - } - } +using System; +using System.Collections.Generic; +using System.Windows.Forms; + +namespace SLIRC +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new frmSLIRC()); + } + } } \ No newline at end of file diff --git a/applications/SLIRC/Properties/AssemblyInfo.cs b/applications/SLIRC/Properties/AssemblyInfo.cs index 55e298bd..5309c733 100644 --- a/applications/SLIRC/Properties/AssemblyInfo.cs +++ b/applications/SLIRC/Properties/AssemblyInfo.cs @@ -1,33 +1,33 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("SLIRC")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Thearis Systems/RedWire Virtual")] -[assembly: AssemblyProduct("SLIRC")] -[assembly: AssemblyCopyright("Copyright © Thearis Systems/RedWire Virtual 2006")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("d8888e7d-b69e-455a-83d0-7ff4bed18b81")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("SLIRC")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Thearis Systems/RedWire Virtual")] +[assembly: AssemblyProduct("SLIRC")] +[assembly: AssemblyCopyright("Copyright © Thearis Systems/RedWire Virtual 2006")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("d8888e7d-b69e-455a-83d0-7ff4bed18b81")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/applications/SLIRC/Properties/Resources.Designer.cs b/applications/SLIRC/Properties/Resources.Designer.cs index 63297449..8b83e63f 100644 --- a/applications/SLIRC/Properties/Resources.Designer.cs +++ b/applications/SLIRC/Properties/Resources.Designer.cs @@ -1,71 +1,71 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.42 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace SLIRC.Properties -{ - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources - { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() - { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager - { - get - { - if ((resourceMan == null)) - { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SLIRC.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture - { - get - { - return resourceCulture; - } - set - { - resourceCulture = value; - } - } - } -} +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SLIRC.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SLIRC.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/applications/SLIRC/Properties/Resources.resx b/applications/SLIRC/Properties/Resources.resx index ffecec85..af7dbebb 100644 --- a/applications/SLIRC/Properties/Resources.resx +++ b/applications/SLIRC/Properties/Resources.resx @@ -1,117 +1,117 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/applications/SLIRC/Properties/Settings.Designer.cs b/applications/SLIRC/Properties/Settings.Designer.cs index 4e5b1d24..1c3c6f29 100644 --- a/applications/SLIRC/Properties/Settings.Designer.cs +++ b/applications/SLIRC/Properties/Settings.Designer.cs @@ -1,30 +1,30 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.42 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace SLIRC.Properties -{ - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase - { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default - { - get - { - return defaultInstance; - } - } - } -} +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace SLIRC.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/applications/SLIRC/Properties/Settings.settings b/applications/SLIRC/Properties/Settings.settings index abf36c5d..39645652 100644 --- a/applications/SLIRC/Properties/Settings.settings +++ b/applications/SLIRC/Properties/Settings.settings @@ -1,7 +1,7 @@ - - - - - - - + + + + + + + diff --git a/applications/SLIRC/SLIRC.csproj b/applications/SLIRC/SLIRC.csproj index b0998d96..9a52e290 100644 --- a/applications/SLIRC/SLIRC.csproj +++ b/applications/SLIRC/SLIRC.csproj @@ -1,83 +1,83 @@ - - - Debug - AnyCPU - 8.0.50727 - 2.0 - {8855EB2F-BC4C-485A-A577-0989EB16BFDC} - WinExe - Properties - SLIRC - SLIRC - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - False - ..\..\Desktop\SmartIrc4net-0.3.5\bin\net\debug\Meebey.SmartIrc4net.dll - - - - - - - - - - - Form - - - frmSLIRC.cs - - - - - Designer - frmSLIRC.cs - - - ResXFileCodeGenerator - Resources.Designer.cs - Designer - - - True - Resources.resx - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - True - Settings.settings - True - - - - + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {8855EB2F-BC4C-485A-A577-0989EB16BFDC} + WinExe + Properties + SLIRC + SLIRC + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + False + ..\..\Desktop\SmartIrc4net-0.3.5\bin\net\debug\Meebey.SmartIrc4net.dll + + + + + + + + + + + Form + + + frmSLIRC.cs + + + + + Designer + frmSLIRC.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + \ No newline at end of file diff --git a/applications/SLIRC/SLIRC.sln b/applications/SLIRC/SLIRC.sln index f14cf2aa..3f926b2b 100644 --- a/applications/SLIRC/SLIRC.sln +++ b/applications/SLIRC/SLIRC.sln @@ -1,20 +1,20 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual C# Express 2005 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SLIRC", "SLIRC.csproj", "{8855EB2F-BC4C-485A-A577-0989EB16BFDC}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {8855EB2F-BC4C-485A-A577-0989EB16BFDC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8855EB2F-BC4C-485A-A577-0989EB16BFDC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8855EB2F-BC4C-485A-A577-0989EB16BFDC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8855EB2F-BC4C-485A-A577-0989EB16BFDC}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual C# Express 2005 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SLIRC", "SLIRC.csproj", "{8855EB2F-BC4C-485A-A577-0989EB16BFDC}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {8855EB2F-BC4C-485A-A577-0989EB16BFDC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8855EB2F-BC4C-485A-A577-0989EB16BFDC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8855EB2F-BC4C-485A-A577-0989EB16BFDC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8855EB2F-BC4C-485A-A577-0989EB16BFDC}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/applications/SLIRC/frmSLIRC.Designer.cs b/applications/SLIRC/frmSLIRC.Designer.cs index b65e4c38..3bb4ff61 100644 --- a/applications/SLIRC/frmSLIRC.Designer.cs +++ b/applications/SLIRC/frmSLIRC.Designer.cs @@ -1,296 +1,296 @@ -namespace SLIRC -{ - partial class frmSLIRC - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - try - { - ircclient.Disconnect(); - } - catch - { - - } - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.grpLogin = new System.Windows.Forms.GroupBox(); - this.label3 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.label1 = new System.Windows.Forms.Label(); - this.txtPassword = new System.Windows.Forms.TextBox(); - this.txtLastName = new System.Windows.Forms.TextBox(); - this.cmdConnect = new System.Windows.Forms.Button(); - this.txtFirstName = new System.Windows.Forms.TextBox(); - this.lstLog = new System.Windows.Forms.ListBox(); - this.lstAllowedUsers = new System.Windows.Forms.ListBox(); - this.txtServerName = new System.Windows.Forms.TextBox(); - this.label4 = new System.Windows.Forms.Label(); - this.label5 = new System.Windows.Forms.Label(); - this.txtPort = new System.Windows.Forms.TextBox(); - this.txtChannel = new System.Windows.Forms.TextBox(); - this.btnJoin = new System.Windows.Forms.Button(); - this.txtMessage = new System.Windows.Forms.TextBox(); - this.btnSay = new System.Windows.Forms.Button(); - this.grpDebug = new System.Windows.Forms.GroupBox(); - this.btnGetPos = new System.Windows.Forms.Button(); - this.grpLogin.SuspendLayout(); - this.grpDebug.SuspendLayout(); - this.SuspendLayout(); - // - // grpLogin - // - this.grpLogin.Controls.Add(this.label3); - this.grpLogin.Controls.Add(this.label2); - this.grpLogin.Controls.Add(this.label1); - this.grpLogin.Controls.Add(this.txtPassword); - this.grpLogin.Controls.Add(this.txtLastName); - this.grpLogin.Controls.Add(this.cmdConnect); - this.grpLogin.Controls.Add(this.txtFirstName); - this.grpLogin.Enabled = false; - this.grpLogin.Location = new System.Drawing.Point(2, 242); - this.grpLogin.Name = "grpLogin"; - this.grpLogin.Size = new System.Drawing.Size(560, 77); - this.grpLogin.TabIndex = 51; - this.grpLogin.TabStop = false; - // - // label3 - // - this.label3.Location = new System.Drawing.Point(280, 24); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(120, 16); - this.label3.TabIndex = 50; - this.label3.Text = "Password"; - // - // label2 - // - this.label2.Location = new System.Drawing.Point(152, 24); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(120, 16); - this.label2.TabIndex = 50; - this.label2.Text = "Last Name"; - // - // label1 - // - this.label1.Location = new System.Drawing.Point(16, 24); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(120, 16); - this.label1.TabIndex = 50; - this.label1.Text = "First Name"; - // - // txtPassword - // - this.txtPassword.Location = new System.Drawing.Point(280, 40); - this.txtPassword.Name = "txtPassword"; - this.txtPassword.PasswordChar = '*'; - this.txtPassword.Size = new System.Drawing.Size(120, 20); - this.txtPassword.TabIndex = 2; - // - // txtLastName - // - this.txtLastName.Location = new System.Drawing.Point(152, 40); - this.txtLastName.Name = "txtLastName"; - this.txtLastName.Size = new System.Drawing.Size(112, 20); - this.txtLastName.TabIndex = 1; - // - // cmdConnect - // - this.cmdConnect.Location = new System.Drawing.Point(424, 40); - this.cmdConnect.Name = "cmdConnect"; - this.cmdConnect.Size = new System.Drawing.Size(120, 24); - this.cmdConnect.TabIndex = 3; - this.cmdConnect.Text = "Connect"; - this.cmdConnect.Click += new System.EventHandler(this.cmdConnect_Click); - // - // txtFirstName - // - this.txtFirstName.Location = new System.Drawing.Point(16, 40); - this.txtFirstName.Name = "txtFirstName"; - this.txtFirstName.Size = new System.Drawing.Size(120, 20); - this.txtFirstName.TabIndex = 0; - // - // lstLog - // - this.lstLog.Enabled = false; - this.lstLog.FormattingEnabled = true; - this.lstLog.Location = new System.Drawing.Point(19, 11); - this.lstLog.Name = "lstLog"; - this.lstLog.Size = new System.Drawing.Size(315, 225); - this.lstLog.TabIndex = 52; - // - // lstAllowedUsers - // - this.lstAllowedUsers.Enabled = false; - this.lstAllowedUsers.FormattingEnabled = true; - this.lstAllowedUsers.Location = new System.Drawing.Point(349, 13); - this.lstAllowedUsers.Name = "lstAllowedUsers"; - this.lstAllowedUsers.Size = new System.Drawing.Size(212, 108); - this.lstAllowedUsers.TabIndex = 53; - // - // txtServerName - // - this.txtServerName.Location = new System.Drawing.Point(349, 141); - this.txtServerName.Name = "txtServerName"; - this.txtServerName.Size = new System.Drawing.Size(130, 20); - this.txtServerName.TabIndex = 54; - this.txtServerName.Text = "irc.efnet.pl"; - // - // label4 - // - this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(351, 125); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(69, 13); - this.label4.TabIndex = 55; - this.label4.Text = "Server Name"; - // - // label5 - // - this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(483, 124); - this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(26, 13); - this.label5.TabIndex = 55; - this.label5.Text = "Port"; - // - // txtPort - // - this.txtPort.Location = new System.Drawing.Point(486, 141); - this.txtPort.Name = "txtPort"; - this.txtPort.Size = new System.Drawing.Size(60, 20); - this.txtPort.TabIndex = 56; - this.txtPort.Text = "6667"; - // - // txtChannel - // - this.txtChannel.Location = new System.Drawing.Point(349, 167); - this.txtChannel.Name = "txtChannel"; - this.txtChannel.Size = new System.Drawing.Size(130, 20); - this.txtChannel.TabIndex = 54; - this.txtChannel.Text = "#libsl"; - // - // btnJoin - // - this.btnJoin.Enabled = false; - this.btnJoin.Location = new System.Drawing.Point(487, 167); - this.btnJoin.Name = "btnJoin"; - this.btnJoin.Size = new System.Drawing.Size(58, 20); - this.btnJoin.TabIndex = 57; - this.btnJoin.Text = "Join"; - this.btnJoin.UseVisualStyleBackColor = true; - this.btnJoin.Click += new System.EventHandler(this.btnJoin_Click); - // - // txtMessage - // - this.txtMessage.Enabled = false; - this.txtMessage.Location = new System.Drawing.Point(350, 199); - this.txtMessage.Name = "txtMessage"; - this.txtMessage.Size = new System.Drawing.Size(194, 20); - this.txtMessage.TabIndex = 58; - // - // btnSay - // - this.btnSay.Enabled = false; - this.btnSay.Location = new System.Drawing.Point(470, 219); - this.btnSay.Name = "btnSay"; - this.btnSay.Size = new System.Drawing.Size(74, 25); - this.btnSay.TabIndex = 59; - this.btnSay.Text = "Say"; - this.btnSay.UseVisualStyleBackColor = true; - this.btnSay.Click += new System.EventHandler(this.btnSay_Click); - // - // grpDebug - // - this.grpDebug.Controls.Add(this.btnGetPos); - this.grpDebug.Location = new System.Drawing.Point(2, 325); - this.grpDebug.Name = "grpDebug"; - this.grpDebug.Size = new System.Drawing.Size(559, 64); - this.grpDebug.TabIndex = 60; - this.grpDebug.TabStop = false; - this.grpDebug.Text = "Debugging"; - // - // btnGetPos - // - this.btnGetPos.Location = new System.Drawing.Point(14, 21); - this.btnGetPos.Name = "btnGetPos"; - this.btnGetPos.Size = new System.Drawing.Size(87, 24); - this.btnGetPos.TabIndex = 0; - this.btnGetPos.Text = "Get Position"; - this.btnGetPos.UseVisualStyleBackColor = true; - this.btnGetPos.Click += new System.EventHandler(this.btnGetPos_Click); - // - // frmSLIRC - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(566, 393); - this.Controls.Add(this.grpDebug); - this.Controls.Add(this.btnSay); - this.Controls.Add(this.txtMessage); - this.Controls.Add(this.btnJoin); - this.Controls.Add(this.txtPort); - this.Controls.Add(this.label5); - this.Controls.Add(this.label4); - this.Controls.Add(this.txtChannel); - this.Controls.Add(this.txtServerName); - this.Controls.Add(this.lstAllowedUsers); - this.Controls.Add(this.lstLog); - this.Controls.Add(this.grpLogin); - this.Name = "frmSLIRC"; - this.Text = "Second Life <-> IRC"; - this.Load += new System.EventHandler(this.frmSLIRC_Load); - this.grpLogin.ResumeLayout(false); - this.grpLogin.PerformLayout(); - this.grpDebug.ResumeLayout(false); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.GroupBox grpLogin; - private System.Windows.Forms.Label label3; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.TextBox txtPassword; - private System.Windows.Forms.TextBox txtLastName; - private System.Windows.Forms.Button cmdConnect; - private System.Windows.Forms.TextBox txtFirstName; - private System.Windows.Forms.ListBox lstLog; - private System.Windows.Forms.ListBox lstAllowedUsers; - private System.Windows.Forms.TextBox txtServerName; - private System.Windows.Forms.Label label4; - private System.Windows.Forms.Label label5; - private System.Windows.Forms.TextBox txtPort; - private System.Windows.Forms.TextBox txtChannel; - private System.Windows.Forms.Button btnJoin; - private System.Windows.Forms.TextBox txtMessage; - private System.Windows.Forms.Button btnSay; - private System.Windows.Forms.GroupBox grpDebug; - private System.Windows.Forms.Button btnGetPos; - } -} - +namespace SLIRC +{ + partial class frmSLIRC + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + try + { + ircclient.Disconnect(); + } + catch + { + + } + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.grpLogin = new System.Windows.Forms.GroupBox(); + this.label3 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.txtPassword = new System.Windows.Forms.TextBox(); + this.txtLastName = new System.Windows.Forms.TextBox(); + this.cmdConnect = new System.Windows.Forms.Button(); + this.txtFirstName = new System.Windows.Forms.TextBox(); + this.lstLog = new System.Windows.Forms.ListBox(); + this.lstAllowedUsers = new System.Windows.Forms.ListBox(); + this.txtServerName = new System.Windows.Forms.TextBox(); + this.label4 = new System.Windows.Forms.Label(); + this.label5 = new System.Windows.Forms.Label(); + this.txtPort = new System.Windows.Forms.TextBox(); + this.txtChannel = new System.Windows.Forms.TextBox(); + this.btnJoin = new System.Windows.Forms.Button(); + this.txtMessage = new System.Windows.Forms.TextBox(); + this.btnSay = new System.Windows.Forms.Button(); + this.grpDebug = new System.Windows.Forms.GroupBox(); + this.btnGetPos = new System.Windows.Forms.Button(); + this.grpLogin.SuspendLayout(); + this.grpDebug.SuspendLayout(); + this.SuspendLayout(); + // + // grpLogin + // + this.grpLogin.Controls.Add(this.label3); + this.grpLogin.Controls.Add(this.label2); + this.grpLogin.Controls.Add(this.label1); + this.grpLogin.Controls.Add(this.txtPassword); + this.grpLogin.Controls.Add(this.txtLastName); + this.grpLogin.Controls.Add(this.cmdConnect); + this.grpLogin.Controls.Add(this.txtFirstName); + this.grpLogin.Enabled = false; + this.grpLogin.Location = new System.Drawing.Point(2, 242); + this.grpLogin.Name = "grpLogin"; + this.grpLogin.Size = new System.Drawing.Size(560, 77); + this.grpLogin.TabIndex = 51; + this.grpLogin.TabStop = false; + // + // label3 + // + this.label3.Location = new System.Drawing.Point(280, 24); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(120, 16); + this.label3.TabIndex = 50; + this.label3.Text = "Password"; + // + // label2 + // + this.label2.Location = new System.Drawing.Point(152, 24); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(120, 16); + this.label2.TabIndex = 50; + this.label2.Text = "Last Name"; + // + // label1 + // + this.label1.Location = new System.Drawing.Point(16, 24); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(120, 16); + this.label1.TabIndex = 50; + this.label1.Text = "First Name"; + // + // txtPassword + // + this.txtPassword.Location = new System.Drawing.Point(280, 40); + this.txtPassword.Name = "txtPassword"; + this.txtPassword.PasswordChar = '*'; + this.txtPassword.Size = new System.Drawing.Size(120, 20); + this.txtPassword.TabIndex = 2; + // + // txtLastName + // + this.txtLastName.Location = new System.Drawing.Point(152, 40); + this.txtLastName.Name = "txtLastName"; + this.txtLastName.Size = new System.Drawing.Size(112, 20); + this.txtLastName.TabIndex = 1; + // + // cmdConnect + // + this.cmdConnect.Location = new System.Drawing.Point(424, 40); + this.cmdConnect.Name = "cmdConnect"; + this.cmdConnect.Size = new System.Drawing.Size(120, 24); + this.cmdConnect.TabIndex = 3; + this.cmdConnect.Text = "Connect"; + this.cmdConnect.Click += new System.EventHandler(this.cmdConnect_Click); + // + // txtFirstName + // + this.txtFirstName.Location = new System.Drawing.Point(16, 40); + this.txtFirstName.Name = "txtFirstName"; + this.txtFirstName.Size = new System.Drawing.Size(120, 20); + this.txtFirstName.TabIndex = 0; + // + // lstLog + // + this.lstLog.Enabled = false; + this.lstLog.FormattingEnabled = true; + this.lstLog.Location = new System.Drawing.Point(19, 11); + this.lstLog.Name = "lstLog"; + this.lstLog.Size = new System.Drawing.Size(315, 225); + this.lstLog.TabIndex = 52; + // + // lstAllowedUsers + // + this.lstAllowedUsers.Enabled = false; + this.lstAllowedUsers.FormattingEnabled = true; + this.lstAllowedUsers.Location = new System.Drawing.Point(349, 13); + this.lstAllowedUsers.Name = "lstAllowedUsers"; + this.lstAllowedUsers.Size = new System.Drawing.Size(212, 108); + this.lstAllowedUsers.TabIndex = 53; + // + // txtServerName + // + this.txtServerName.Location = new System.Drawing.Point(349, 141); + this.txtServerName.Name = "txtServerName"; + this.txtServerName.Size = new System.Drawing.Size(130, 20); + this.txtServerName.TabIndex = 54; + this.txtServerName.Text = "irc.efnet.pl"; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(351, 125); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(69, 13); + this.label4.TabIndex = 55; + this.label4.Text = "Server Name"; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(483, 124); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(26, 13); + this.label5.TabIndex = 55; + this.label5.Text = "Port"; + // + // txtPort + // + this.txtPort.Location = new System.Drawing.Point(486, 141); + this.txtPort.Name = "txtPort"; + this.txtPort.Size = new System.Drawing.Size(60, 20); + this.txtPort.TabIndex = 56; + this.txtPort.Text = "6667"; + // + // txtChannel + // + this.txtChannel.Location = new System.Drawing.Point(349, 167); + this.txtChannel.Name = "txtChannel"; + this.txtChannel.Size = new System.Drawing.Size(130, 20); + this.txtChannel.TabIndex = 54; + this.txtChannel.Text = "#libsl"; + // + // btnJoin + // + this.btnJoin.Enabled = false; + this.btnJoin.Location = new System.Drawing.Point(487, 167); + this.btnJoin.Name = "btnJoin"; + this.btnJoin.Size = new System.Drawing.Size(58, 20); + this.btnJoin.TabIndex = 57; + this.btnJoin.Text = "Join"; + this.btnJoin.UseVisualStyleBackColor = true; + this.btnJoin.Click += new System.EventHandler(this.btnJoin_Click); + // + // txtMessage + // + this.txtMessage.Enabled = false; + this.txtMessage.Location = new System.Drawing.Point(350, 199); + this.txtMessage.Name = "txtMessage"; + this.txtMessage.Size = new System.Drawing.Size(194, 20); + this.txtMessage.TabIndex = 58; + // + // btnSay + // + this.btnSay.Enabled = false; + this.btnSay.Location = new System.Drawing.Point(470, 219); + this.btnSay.Name = "btnSay"; + this.btnSay.Size = new System.Drawing.Size(74, 25); + this.btnSay.TabIndex = 59; + this.btnSay.Text = "Say"; + this.btnSay.UseVisualStyleBackColor = true; + this.btnSay.Click += new System.EventHandler(this.btnSay_Click); + // + // grpDebug + // + this.grpDebug.Controls.Add(this.btnGetPos); + this.grpDebug.Location = new System.Drawing.Point(2, 325); + this.grpDebug.Name = "grpDebug"; + this.grpDebug.Size = new System.Drawing.Size(559, 64); + this.grpDebug.TabIndex = 60; + this.grpDebug.TabStop = false; + this.grpDebug.Text = "Debugging"; + // + // btnGetPos + // + this.btnGetPos.Location = new System.Drawing.Point(14, 21); + this.btnGetPos.Name = "btnGetPos"; + this.btnGetPos.Size = new System.Drawing.Size(87, 24); + this.btnGetPos.TabIndex = 0; + this.btnGetPos.Text = "Get Position"; + this.btnGetPos.UseVisualStyleBackColor = true; + this.btnGetPos.Click += new System.EventHandler(this.btnGetPos_Click); + // + // frmSLIRC + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(566, 393); + this.Controls.Add(this.grpDebug); + this.Controls.Add(this.btnSay); + this.Controls.Add(this.txtMessage); + this.Controls.Add(this.btnJoin); + this.Controls.Add(this.txtPort); + this.Controls.Add(this.label5); + this.Controls.Add(this.label4); + this.Controls.Add(this.txtChannel); + this.Controls.Add(this.txtServerName); + this.Controls.Add(this.lstAllowedUsers); + this.Controls.Add(this.lstLog); + this.Controls.Add(this.grpLogin); + this.Name = "frmSLIRC"; + this.Text = "Second Life <-> IRC"; + this.Load += new System.EventHandler(this.frmSLIRC_Load); + this.grpLogin.ResumeLayout(false); + this.grpLogin.PerformLayout(); + this.grpDebug.ResumeLayout(false); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.GroupBox grpLogin; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.TextBox txtPassword; + private System.Windows.Forms.TextBox txtLastName; + private System.Windows.Forms.Button cmdConnect; + private System.Windows.Forms.TextBox txtFirstName; + private System.Windows.Forms.ListBox lstLog; + private System.Windows.Forms.ListBox lstAllowedUsers; + private System.Windows.Forms.TextBox txtServerName; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.TextBox txtPort; + private System.Windows.Forms.TextBox txtChannel; + private System.Windows.Forms.Button btnJoin; + private System.Windows.Forms.TextBox txtMessage; + private System.Windows.Forms.Button btnSay; + private System.Windows.Forms.GroupBox grpDebug; + private System.Windows.Forms.Button btnGetPos; + } +} + diff --git a/applications/SLIRC/frmSLIRC.cs b/applications/SLIRC/frmSLIRC.cs index cd62ea13..2b19efea 100644 --- a/applications/SLIRC/frmSLIRC.cs +++ b/applications/SLIRC/frmSLIRC.cs @@ -1,163 +1,163 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Text; -using System.Windows.Forms; -using System.Collections; -using System.Threading; -using libsecondlife; -using Meebey.SmartIrc4net; -namespace SLIRC -{ - public partial class frmSLIRC : Form - { - private SecondLife client; - private IrcClient ircclient; - private Thread listenthread; - public frmSLIRC() - { - InitializeComponent(); - ircclient = new IrcClient(); - } - public void Listen() - { - ircclient.Listen(); - } - private void cmdConnect_Click(object sender, EventArgs e) - { - if (cmdConnect.Text == "Connect") - { - cmdConnect.Text = "Disconnect"; - txtFirstName.Enabled = txtLastName.Enabled = txtPassword.Enabled = false; - - Hashtable loginParams = NetworkManager.DefaultLoginValues(txtFirstName.Text, - txtLastName.Text, txtPassword.Text, "00:00:00:00:00:00", "last", 1, 50, 50, 50, - "Win", "0", "accountant", "jhurliman@wsu.edu"); - if (client.Network.Login(loginParams)) - { - LogMessage("Logged into Second Life"); - lstAllowedUsers.Enabled = lstLog.Enabled = btnJoin.Enabled = txtMessage.Enabled = btnSay.Enabled = true; - ircclient.OnChannelMessage += new IrcEventHandler(ircclient_OnChannelMessage); - //Connect to IRC server, yaydey yadah - try - { - ircclient.Connect(new string[] { txtServerName.Text }, int.Parse(txtPort.Text)); - LogMessage("Connected to IRC Server."); - ircclient.Login(client.Avatar.FirstName + client.Avatar.LastName, "SLIRC Gateway"); - ircclient.RfcJoin(txtChannel.Text); - LogMessage("Logged in"); - if(listenthread != null) listenthread.Abort(); - listenthread = new Thread(Listen); - listenthread.Start(); - } - catch (Exception ex) - { - MessageBox.Show("OH NOES! " + ex.Message); - - } - - } - else - { - MessageBox.Show(this, "Error logging in: " + client.Network.LoginError); - //if(listenthread) listenthread.Abort(); - cmdConnect.Text = "Connect"; - lstAllowedUsers.Enabled = lstLog.Enabled = btnJoin.Enabled = btnSay.Enabled = false; - txtFirstName.Enabled = txtLastName.Enabled = txtPassword.Enabled = true; - } - } - else - { - cmdConnect.Text = "Connect"; - lstAllowedUsers.Enabled = btnJoin.Enabled = txtMessage.Enabled = btnSay.Enabled = false; - txtFirstName.Enabled = txtLastName.Enabled = txtPassword.Enabled = true; - ircclient.RfcQuit("SLIRC Disconnect."); - listenthread.Abort(); - client.Network.Logout(); - } - - } - - void ircclient_OnChannelMessage(object sender, IrcEventArgs e) - { - LogMessage(e.Data.Nick + ": " + e.Data.Message); - //From IRC -> Inject to SL - client.Avatar.Say(e.Data.Nick + ": " + e.Data.Message, 0); - } - - private void frmSLIRC_Load(object sender, EventArgs e) - { - try - { - client = new SecondLife("keywords.txt", "message_template.msg"); - client.Avatar.OnChat += new ChatCallback(Avatar_OnChat); - grpLogin.Enabled = true; - } - catch (Exception error) - { - MessageBox.Show(this, error.ToString()); - } - } - private delegate void SingleStringDelegate(string s); - void LogMessage(string msg) - { - if (!this.InvokeRequired) - { - int i = lstLog.Items.Add(msg); - lstLog.SelectedIndex = i; - } - else - { - Invoke(new SingleStringDelegate(LogMessage), new object[] { msg }); - } - } - void AddToAllowedList(string name) - { - if (!this.InvokeRequired) - { - lstAllowedUsers.Items.Add(name); - } - else - { - Invoke(new SingleStringDelegate(AddToAllowedList), new object[] { name }); - } - } - void Avatar_OnChat(string message, byte audible, byte type, byte sourcetype, string name, LLUUID id, byte command, LLUUID commandID) - { - if (message.Equals("addme")) - { - //Add to the list - LogMessage("Adding " + name + " to the allowed list"); - AddToAllowedList(name); - } - else - { - if (lstAllowedUsers.Items.Contains(name) && audible == 1 && !message.Equals("")) - { - LogMessage(name + ": " + message); - ircclient.SendMessage(SendType.Message, txtChannel.Text, name + " : " + message); - } - } - } - - private void btnJoin_Click(object sender, EventArgs e) - { - ircclient.RfcJoin(txtChannel.Text); - LogMessage("Joining " + txtChannel.Text); - } - - private void btnGetPos_Click(object sender, EventArgs e) - { - LogMessage("Position: " + client.Avatar.Position.X.ToString() + " " + client.Avatar.Position.Y.ToString()); - } - - private void btnSay_Click(object sender, EventArgs e) - { - client.Avatar.Say(ircclient.Nickname + ": " + txtMessage.Text, 0); - ircclient.SendMessage(SendType.Message, txtChannel.Text, txtMessage.Text); - } - - } +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; +using System.Collections; +using System.Threading; +using libsecondlife; +using Meebey.SmartIrc4net; +namespace SLIRC +{ + public partial class frmSLIRC : Form + { + private SecondLife client; + private IrcClient ircclient; + private Thread listenthread; + public frmSLIRC() + { + InitializeComponent(); + ircclient = new IrcClient(); + } + public void Listen() + { + ircclient.Listen(); + } + private void cmdConnect_Click(object sender, EventArgs e) + { + if (cmdConnect.Text == "Connect") + { + cmdConnect.Text = "Disconnect"; + txtFirstName.Enabled = txtLastName.Enabled = txtPassword.Enabled = false; + + Hashtable loginParams = NetworkManager.DefaultLoginValues(txtFirstName.Text, + txtLastName.Text, txtPassword.Text, "00:00:00:00:00:00", "last", 1, 50, 50, 50, + "Win", "0", "accountant", "jhurliman@wsu.edu"); + if (client.Network.Login(loginParams)) + { + LogMessage("Logged into Second Life"); + lstAllowedUsers.Enabled = lstLog.Enabled = btnJoin.Enabled = txtMessage.Enabled = btnSay.Enabled = true; + ircclient.OnChannelMessage += new IrcEventHandler(ircclient_OnChannelMessage); + //Connect to IRC server, yaydey yadah + try + { + ircclient.Connect(new string[] { txtServerName.Text }, int.Parse(txtPort.Text)); + LogMessage("Connected to IRC Server."); + ircclient.Login(client.Avatar.FirstName + client.Avatar.LastName, "SLIRC Gateway"); + ircclient.RfcJoin(txtChannel.Text); + LogMessage("Logged in"); + if(listenthread != null) listenthread.Abort(); + listenthread = new Thread(Listen); + listenthread.Start(); + } + catch (Exception ex) + { + MessageBox.Show("OH NOES! " + ex.Message); + + } + + } + else + { + MessageBox.Show(this, "Error logging in: " + client.Network.LoginError); + //if(listenthread) listenthread.Abort(); + cmdConnect.Text = "Connect"; + lstAllowedUsers.Enabled = lstLog.Enabled = btnJoin.Enabled = btnSay.Enabled = false; + txtFirstName.Enabled = txtLastName.Enabled = txtPassword.Enabled = true; + } + } + else + { + cmdConnect.Text = "Connect"; + lstAllowedUsers.Enabled = btnJoin.Enabled = txtMessage.Enabled = btnSay.Enabled = false; + txtFirstName.Enabled = txtLastName.Enabled = txtPassword.Enabled = true; + ircclient.RfcQuit("SLIRC Disconnect."); + listenthread.Abort(); + client.Network.Logout(); + } + + } + + void ircclient_OnChannelMessage(object sender, IrcEventArgs e) + { + LogMessage(e.Data.Nick + ": " + e.Data.Message); + //From IRC -> Inject to SL + client.Avatar.Say(e.Data.Nick + ": " + e.Data.Message, 0); + } + + private void frmSLIRC_Load(object sender, EventArgs e) + { + try + { + client = new SecondLife("keywords.txt", "message_template.msg"); + client.Avatar.OnChat += new ChatCallback(Avatar_OnChat); + grpLogin.Enabled = true; + } + catch (Exception error) + { + MessageBox.Show(this, error.ToString()); + } + } + private delegate void SingleStringDelegate(string s); + void LogMessage(string msg) + { + if (!this.InvokeRequired) + { + int i = lstLog.Items.Add(msg); + lstLog.SelectedIndex = i; + } + else + { + Invoke(new SingleStringDelegate(LogMessage), new object[] { msg }); + } + } + void AddToAllowedList(string name) + { + if (!this.InvokeRequired) + { + lstAllowedUsers.Items.Add(name); + } + else + { + Invoke(new SingleStringDelegate(AddToAllowedList), new object[] { name }); + } + } + void Avatar_OnChat(string message, byte audible, byte type, byte sourcetype, string name, LLUUID id, byte command, LLUUID commandID) + { + if (message.Equals("addme")) + { + //Add to the list + LogMessage("Adding " + name + " to the allowed list"); + AddToAllowedList(name); + } + else + { + if (lstAllowedUsers.Items.Contains(name) && audible == 1 && !message.Equals("")) + { + LogMessage(name + ": " + message); + ircclient.SendMessage(SendType.Message, txtChannel.Text, name + " : " + message); + } + } + } + + private void btnJoin_Click(object sender, EventArgs e) + { + ircclient.RfcJoin(txtChannel.Text); + LogMessage("Joining " + txtChannel.Text); + } + + private void btnGetPos_Click(object sender, EventArgs e) + { + LogMessage("Position: " + client.Avatar.Position.X.ToString() + " " + client.Avatar.Position.Y.ToString()); + } + + private void btnSay_Click(object sender, EventArgs e) + { + client.Avatar.Say(ircclient.Nickname + ": " + txtMessage.Text, 0); + ircclient.SendMessage(SendType.Message, txtChannel.Text, txtMessage.Text); + } + + } } \ No newline at end of file diff --git a/applications/SLIRC/frmSLIRC.resx b/applications/SLIRC/frmSLIRC.resx index ff31a6db..19dc0dd8 100644 --- a/applications/SLIRC/frmSLIRC.resx +++ b/applications/SLIRC/frmSLIRC.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/applications/SecondSuite/AssemblyInfo.cs b/applications/SecondSuite/AssemblyInfo.cs index a4267772..4f236967 100644 --- a/applications/SecondSuite/AssemblyInfo.cs +++ b/applications/SecondSuite/AssemblyInfo.cs @@ -1,58 +1,58 @@ -using System.Reflection; -using System.Runtime.CompilerServices; - -// -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -// -[assembly: AssemblyTitle("Second Suite")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("John Hurliman")] -[assembly: AssemblyProduct("Second Suite")] -[assembly: AssemblyCopyright("(c) 2006 John Hurliman")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Revision and Build Numbers -// by using the '*' as shown below: - -[assembly: AssemblyVersion("1.0.*")] - -// -// In order to sign your assembly you must specify a key to use. Refer to the -// Microsoft .NET Framework documentation for more information on assembly signing. -// -// Use the attributes below to control which key is used for signing. -// -// Notes: -// (*) If no key is specified, the assembly is not signed. -// (*) KeyName refers to a key that has been installed in the Crypto Service -// Provider (CSP) on your machine. KeyFile refers to a file which contains -// a key. -// (*) If the KeyFile and the KeyName values are both specified, the -// following processing occurs: -// (1) If the KeyName can be found in the CSP, that key is used. -// (2) If the KeyName does not exist and the KeyFile does exist, the key -// in the KeyFile is installed into the CSP and used. -// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. -// When specifying the KeyFile, the location of the KeyFile should be -// relative to the project output directory which is -// %Project Directory%\obj\. For example, if your KeyFile is -// located in the project directory, you would specify the AssemblyKeyFile -// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] -// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework -// documentation for more information on this. -// -[assembly: AssemblyDelaySign(false)] -[assembly: AssemblyKeyFile("")] -[assembly: AssemblyKeyName("")] +using System.Reflection; +using System.Runtime.CompilerServices; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly: AssemblyTitle("Second Suite")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("John Hurliman")] +[assembly: AssemblyProduct("Second Suite")] +[assembly: AssemblyCopyright("(c) 2006 John Hurliman")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly: AssemblyVersion("1.0.*")] + +// +// In order to sign your assembly you must specify a key to use. Refer to the +// Microsoft .NET Framework documentation for more information on assembly signing. +// +// Use the attributes below to control which key is used for signing. +// +// Notes: +// (*) If no key is specified, the assembly is not signed. +// (*) KeyName refers to a key that has been installed in the Crypto Service +// Provider (CSP) on your machine. KeyFile refers to a file which contains +// a key. +// (*) If the KeyFile and the KeyName values are both specified, the +// following processing occurs: +// (1) If the KeyName can be found in the CSP, that key is used. +// (2) If the KeyName does not exist and the KeyFile does exist, the key +// in the KeyFile is installed into the CSP and used. +// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. +// When specifying the KeyFile, the location of the KeyFile should be +// relative to the project output directory which is +// %Project Directory%\obj\. For example, if your KeyFile is +// located in the project directory, you would specify the AssemblyKeyFile +// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] +// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework +// documentation for more information on this. +// +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] +[assembly: AssemblyKeyName("")] diff --git a/applications/SecondSuite/Global.cs b/applications/SecondSuite/Global.cs index af62eb49..b1154582 100644 --- a/applications/SecondSuite/Global.cs +++ b/applications/SecondSuite/Global.cs @@ -1,19 +1,19 @@ -using System; -using System.Collections; -using System.Threading; -using SecondSuite.Plugins; - -namespace SecondSuite -{ - public class Global - { - public Global() - { - } - - public static PluginCollection Plugins = new PluginCollection(); - public static Mutex PluginsMutex = new Mutex(false, "PluginsMutex"); - public static ArrayList Clients = new ArrayList(); - public static Mutex ClientsMutex = new Mutex(false, "ClientsMutex"); - } -} +using System; +using System.Collections; +using System.Threading; +using SecondSuite.Plugins; + +namespace SecondSuite +{ + public class Global + { + public Global() + { + } + + public static PluginCollection Plugins = new PluginCollection(); + public static Mutex PluginsMutex = new Mutex(false, "PluginsMutex"); + public static ArrayList Clients = new ArrayList(); + public static Mutex ClientsMutex = new Mutex(false, "ClientsMutex"); + } +} diff --git a/applications/SecondSuite/Plugins/Accountant/Accountant.cs b/applications/SecondSuite/Plugins/Accountant/Accountant.cs index d15a5b05..6b44b224 100644 --- a/applications/SecondSuite/Plugins/Accountant/Accountant.cs +++ b/applications/SecondSuite/Plugins/Accountant/Accountant.cs @@ -1,68 +1,68 @@ -/* - * Copyright (c) 2006, Second Life Reverse Engineering Team - * All rights reserved. - * - * - Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - Neither the name of the Second Life Reverse Engineering Team nor the names - * of its contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using libsecondlife; -using SecondSuite.Plugins; - -namespace SecondSuite.Plugins -{ - /// - /// Accountant plugin implementation - /// - public class Accountant : SSPlugin - { - public string Name { get { return "Accountant"; } } - public string Author { get { return "John Hurliman"; } } - public string Homepage { get { return "http://www.highenergychemistry.com/"; } } - public string Description { get { return "Transfer money between accounts"; } } - public bool SecondLifeClient { get { return true; } } - public ConnectionEvent ConnectionHandler { get { return OnConnection; } } - public override string ToString() { return Name; } - - private frmAccountant Form; - private ConnectionEvent OnConnection; - - public void Init(SecondLife client) - { - Form = new frmAccountant(client); - OnConnection = new ConnectionEvent(Form.Connected); - } - - public System.Windows.Forms.Form Load() - { - return Form; - } - - public void Shutdown() - { - if (Form != null) - { - Form.Close(); - } - } - } -} +/* + * Copyright (c) 2006, Second Life Reverse Engineering Team + * All rights reserved. + * + * - Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Neither the name of the Second Life Reverse Engineering Team nor the names + * of its contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using libsecondlife; +using SecondSuite.Plugins; + +namespace SecondSuite.Plugins +{ + /// + /// Accountant plugin implementation + /// + public class Accountant : SSPlugin + { + public string Name { get { return "Accountant"; } } + public string Author { get { return "John Hurliman"; } } + public string Homepage { get { return "http://www.highenergychemistry.com/"; } } + public string Description { get { return "Transfer money between accounts"; } } + public bool SecondLifeClient { get { return true; } } + public ConnectionEvent ConnectionHandler { get { return OnConnection; } } + public override string ToString() { return Name; } + + private frmAccountant Form; + private ConnectionEvent OnConnection; + + public void Init(SecondLife client) + { + Form = new frmAccountant(client); + OnConnection = new ConnectionEvent(Form.Connected); + } + + public System.Windows.Forms.Form Load() + { + return Form; + } + + public void Shutdown() + { + if (Form != null) + { + Form.Close(); + } + } + } +} diff --git a/applications/SecondSuite/Plugins/Accountant/Accountant.csproj b/applications/SecondSuite/Plugins/Accountant/Accountant.csproj index 99711c2a..0e6bccb8 100644 --- a/applications/SecondSuite/Plugins/Accountant/Accountant.csproj +++ b/applications/SecondSuite/Plugins/Accountant/Accountant.csproj @@ -1,132 +1,132 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/applications/SecondSuite/Plugins/Accountant/AssemblyInfo.cs b/applications/SecondSuite/Plugins/Accountant/AssemblyInfo.cs index 177a4f0e..9f89a328 100644 --- a/applications/SecondSuite/Plugins/Accountant/AssemblyInfo.cs +++ b/applications/SecondSuite/Plugins/Accountant/AssemblyInfo.cs @@ -1,58 +1,58 @@ -using System.Reflection; -using System.Runtime.CompilerServices; - -// -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -// -[assembly: AssemblyTitle("")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("")] -[assembly: AssemblyCopyright("")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Revision and Build Numbers -// by using the '*' as shown below: - -[assembly: AssemblyVersion("1.0.*")] - -// -// In order to sign your assembly you must specify a key to use. Refer to the -// Microsoft .NET Framework documentation for more information on assembly signing. -// -// Use the attributes below to control which key is used for signing. -// -// Notes: -// (*) If no key is specified, the assembly is not signed. -// (*) KeyName refers to a key that has been installed in the Crypto Service -// Provider (CSP) on your machine. KeyFile refers to a file which contains -// a key. -// (*) If the KeyFile and the KeyName values are both specified, the -// following processing occurs: -// (1) If the KeyName can be found in the CSP, that key is used. -// (2) If the KeyName does not exist and the KeyFile does exist, the key -// in the KeyFile is installed into the CSP and used. -// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. -// When specifying the KeyFile, the location of the KeyFile should be -// relative to the project output directory which is -// %Project Directory%\obj\. For example, if your KeyFile is -// located in the project directory, you would specify the AssemblyKeyFile -// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] -// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework -// documentation for more information on this. -// -[assembly: AssemblyDelaySign(false)] -[assembly: AssemblyKeyFile("")] -[assembly: AssemblyKeyName("")] +using System.Reflection; +using System.Runtime.CompilerServices; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly: AssemblyTitle("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly: AssemblyVersion("1.0.*")] + +// +// In order to sign your assembly you must specify a key to use. Refer to the +// Microsoft .NET Framework documentation for more information on assembly signing. +// +// Use the attributes below to control which key is used for signing. +// +// Notes: +// (*) If no key is specified, the assembly is not signed. +// (*) KeyName refers to a key that has been installed in the Crypto Service +// Provider (CSP) on your machine. KeyFile refers to a file which contains +// a key. +// (*) If the KeyFile and the KeyName values are both specified, the +// following processing occurs: +// (1) If the KeyName can be found in the CSP, that key is used. +// (2) If the KeyName does not exist and the KeyFile does exist, the key +// in the KeyFile is installed into the CSP and used. +// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. +// When specifying the KeyFile, the location of the KeyFile should be +// relative to the project output directory which is +// %Project Directory%\obj\. For example, if your KeyFile is +// located in the project directory, you would specify the AssemblyKeyFile +// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] +// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework +// documentation for more information on this. +// +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] +[assembly: AssemblyKeyName("")] diff --git a/applications/SecondSuite/Plugins/Accountant/frmAccountant.cs b/applications/SecondSuite/Plugins/Accountant/frmAccountant.cs index 58d595c3..01a56a24 100644 --- a/applications/SecondSuite/Plugins/Accountant/frmAccountant.cs +++ b/applications/SecondSuite/Plugins/Accountant/frmAccountant.cs @@ -1,406 +1,406 @@ -using System; -using System.Drawing; -using System.Collections; -using System.ComponentModel; -using System.Windows.Forms; -using System.Threading; -using libsecondlife; - -namespace SecondSuite.Plugins -{ - /// - /// Summary description for frmAccountant. - /// - public class frmAccountant : System.Windows.Forms.Form - { - private System.Windows.Forms.ListView lstFind; - private System.Windows.Forms.ColumnHeader colName; - private System.Windows.Forms.ColumnHeader colOnline; - private System.Windows.Forms.ColumnHeader colUuid; - private System.Windows.Forms.Label label7; - private System.Windows.Forms.Button cmdTransfer; - private System.Windows.Forms.TextBox txtTransfer; - private System.Windows.Forms.TextBox txtFind; - private System.Windows.Forms.Button cmdFind; - private System.Windows.Forms.Label label5; - private System.Windows.Forms.Label lblBalance; - private System.Windows.Forms.Label label6; - private System.Windows.Forms.Label lblName; - private System.Windows.Forms.Label label4; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.TextBox txtDescription; - /// - /// Required designer variable. - /// - private System.ComponentModel.Container components = null; - - // libsecondlife instance - private SecondLife Client; - // Mutex for locking the listview - Mutex lstFindMutex; - - public frmAccountant(SecondLife client) - { - // - // Required for Windows Form Designer support - // - InitializeComponent(); - - Client = client; - lstFindMutex = new Mutex(false, "lstFindMutex"); - - // Install our packet handlers - Client.Network.RegisterCallback("MoneyBalanceReply", new PacketCallback(BalanceHandler)); - Client.Network.RegisterCallback("DirPeopleReply", new PacketCallback(DirPeopleHandler)); - } - - /// - /// Clean up any resources being used. - /// - protected override void Dispose( bool disposing ) - { - if( disposing ) - { - if(components != null) - { - components.Dispose(); - } - } - base.Dispose( disposing ); - } - - public void Connected() - { - lblName.Text = Client.Network.LoginValues["first_name"] + " " + - Client.Network.LoginValues["last_name"]; - - // MoneyBalanceRequest - Hashtable blocks = new Hashtable(); - Hashtable fields = new Hashtable(); - blocks = new Hashtable(); - fields = new Hashtable(); - fields["AgentID"] = Client.Network.AgentID; - fields["TransactionID"] = LLUUID.GenerateUUID(); - blocks[fields] = "MoneyData"; - Packet packet = PacketBuilder.BuildPacket("MoneyBalanceRequest", Client.Protocol, blocks, - Helpers.MSG_RELIABLE); - - Client.Network.SendPacket(packet); - } - - private void BalanceHandler(Packet packet, Simulator simulator) - { - if (packet.Layout.Name == "MoneyBalanceReply") - { - int balance = 0; - int squareMetersCredit = 0; - string description = ""; - LLUUID transactionID = null; - bool transactionSuccess = false; - - foreach (Block block in packet.Blocks()) - { - foreach (Field field in block.Fields) - { - if (field.Layout.Name == "MoneyBalance") - { - balance = (int)field.Data; - } - else if (field.Layout.Name == "SquareMetersCredit") - { - squareMetersCredit = (int)field.Data; - } - else if (field.Layout.Name == "Description") - { - byte[] byteArray = (byte[])field.Data; - description = System.Text.Encoding.ASCII.GetString(byteArray).Replace("\0", ""); - } - else if (field.Layout.Name == "TransactionID") - { - transactionID = (LLUUID)field.Data; - } - else if (field.Layout.Name == "TransactionSuccess") - { - transactionSuccess = (bool)field.Data; - } - } - } - - lblBalance.Text = balance.ToString(); - } - } - - private void DirPeopleHandler(Packet packet, Simulator simulator) - { - lstFindMutex.WaitOne(); - - foreach (Block block in packet.Blocks()) - { - if (block.Layout.Name == "QueryReplies") - { - LLUUID id = null; - string firstName = ""; - string lastName = ""; - bool online = false; - - foreach (Field field in block.Fields) - { - if (field.Layout.Name == "AgentID") - { - id = (LLUUID)field.Data; - } - else if (field.Layout.Name == "LastName") - { - lastName = System.Text.Encoding.UTF8.GetString((byte[])field.Data).Replace("\0", ""); - } - else if (field.Layout.Name == "FirstName") - { - firstName = System.Text.Encoding.UTF8.GetString((byte[])field.Data).Replace("\0", ""); - } - else if (field.Layout.Name == "Online") - { - online = (bool)field.Data; - } - } - - if (id != null) - { - ListViewItem listItem = new ListViewItem(new string[] - { firstName + " " + lastName, (online ? "Yes" : "No"), id.ToString() }); - lstFind.Items.Add(listItem); - } - } - } - - lstFindMutex.ReleaseMutex(); - } - - #region Windows Form Designer generated code - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.lstFind = new System.Windows.Forms.ListView(); - this.colName = new System.Windows.Forms.ColumnHeader(); - this.colOnline = new System.Windows.Forms.ColumnHeader(); - this.colUuid = new System.Windows.Forms.ColumnHeader(); - this.label7 = new System.Windows.Forms.Label(); - this.cmdTransfer = new System.Windows.Forms.Button(); - this.txtTransfer = new System.Windows.Forms.TextBox(); - this.txtFind = new System.Windows.Forms.TextBox(); - this.cmdFind = new System.Windows.Forms.Button(); - this.label5 = new System.Windows.Forms.Label(); - this.lblBalance = new System.Windows.Forms.Label(); - this.label6 = new System.Windows.Forms.Label(); - this.lblName = new System.Windows.Forms.Label(); - this.label4 = new System.Windows.Forms.Label(); - this.label1 = new System.Windows.Forms.Label(); - this.txtDescription = new System.Windows.Forms.TextBox(); - this.SuspendLayout(); - // - // lstFind - // - this.lstFind.Activation = System.Windows.Forms.ItemActivation.OneClick; - this.lstFind.AllowColumnReorder = true; - this.lstFind.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.colName, - this.colOnline, - this.colUuid}); - this.lstFind.FullRowSelect = true; - this.lstFind.HideSelection = false; - this.lstFind.Location = new System.Drawing.Point(16, 88); - this.lstFind.Name = "lstFind"; - this.lstFind.Size = new System.Drawing.Size(336, 248); - this.lstFind.Sorting = System.Windows.Forms.SortOrder.Ascending; - this.lstFind.TabIndex = 53; - this.lstFind.View = System.Windows.Forms.View.Details; - // - // colName - // - this.colName.Text = "Name"; - this.colName.Width = 120; - // - // colOnline - // - this.colOnline.Text = "Online"; - this.colOnline.Width = 50; - // - // colUuid - // - this.colUuid.Text = "UUID"; - this.colUuid.Width = 150; - // - // label7 - // - this.label7.Location = new System.Drawing.Point(360, 152); - this.label7.Name = "label7"; - this.label7.Size = new System.Drawing.Size(88, 16); - this.label7.TabIndex = 56; - this.label7.Text = "Amount:"; - // - // cmdTransfer - // - this.cmdTransfer.Location = new System.Drawing.Point(472, 248); - this.cmdTransfer.Name = "cmdTransfer"; - this.cmdTransfer.Size = new System.Drawing.Size(104, 24); - this.cmdTransfer.TabIndex = 55; - this.cmdTransfer.Text = "Transfer Lindens"; - this.cmdTransfer.Click += new System.EventHandler(this.cmdTransfer_Click); - // - // txtTransfer - // - this.txtTransfer.Location = new System.Drawing.Point(360, 168); - this.txtTransfer.MaxLength = 7; - this.txtTransfer.Name = "txtTransfer"; - this.txtTransfer.Size = new System.Drawing.Size(104, 20); - this.txtTransfer.TabIndex = 54; - this.txtTransfer.Text = ""; - // - // txtFind - // - this.txtFind.Location = new System.Drawing.Point(16, 56); - this.txtFind.Name = "txtFind"; - this.txtFind.Size = new System.Drawing.Size(184, 20); - this.txtFind.TabIndex = 51; - this.txtFind.Text = ""; - // - // cmdFind - // - this.cmdFind.Location = new System.Drawing.Point(208, 56); - this.cmdFind.Name = "cmdFind"; - this.cmdFind.Size = new System.Drawing.Size(48, 24); - this.cmdFind.TabIndex = 52; - this.cmdFind.Text = "Find"; - this.cmdFind.Click += new System.EventHandler(this.cmdFind_Click); - // - // label5 - // - this.label5.Location = new System.Drawing.Point(16, 40); - this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(88, 16); - this.label5.TabIndex = 60; - this.label5.Text = "People Search"; - // - // lblBalance - // - this.lblBalance.Location = new System.Drawing.Point(512, 8); - this.lblBalance.Name = "lblBalance"; - this.lblBalance.Size = new System.Drawing.Size(64, 16); - this.lblBalance.TabIndex = 61; - this.lblBalance.TextAlign = System.Drawing.ContentAlignment.TopRight; - // - // label6 - // - this.label6.Location = new System.Drawing.Point(456, 8); - this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(56, 16); - this.label6.TabIndex = 59; - this.label6.Text = "Balance:"; - // - // lblName - // - this.lblName.Location = new System.Drawing.Point(64, 8); - this.lblName.Name = "lblName"; - this.lblName.Size = new System.Drawing.Size(184, 16); - this.lblName.TabIndex = 57; - // - // label4 - // - this.label4.Location = new System.Drawing.Point(16, 8); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(48, 16); - this.label4.TabIndex = 58; - this.label4.Text = "Name:"; - // - // label1 - // - this.label1.Location = new System.Drawing.Point(360, 200); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(168, 16); - this.label1.TabIndex = 63; - this.label1.Text = "Description (optional):"; - // - // txtDescription - // - this.txtDescription.Location = new System.Drawing.Point(360, 216); - this.txtDescription.MaxLength = 7; - this.txtDescription.Name = "txtDescription"; - this.txtDescription.Size = new System.Drawing.Size(216, 20); - this.txtDescription.TabIndex = 62; - this.txtDescription.Text = ""; - // - // frmAccountant - // - this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); - this.ClientSize = new System.Drawing.Size(592, 349); - this.Controls.Add(this.label1); - this.Controls.Add(this.txtDescription); - this.Controls.Add(this.txtTransfer); - this.Controls.Add(this.txtFind); - this.Controls.Add(this.lstFind); - this.Controls.Add(this.label7); - this.Controls.Add(this.cmdTransfer); - this.Controls.Add(this.cmdFind); - this.Controls.Add(this.label5); - this.Controls.Add(this.lblBalance); - this.Controls.Add(this.label6); - this.Controls.Add(this.lblName); - this.Controls.Add(this.label4); - this.Name = "frmAccountant"; - this.Text = "Accountant"; - this.ResumeLayout(false); - - } - #endregion - - private void cmdFind_Click(object sender, System.EventArgs e) - { - lstFind.Items.Clear(); - - Hashtable blocks = new Hashtable(); - Hashtable fields = new Hashtable(); - fields["QueryID"] = LLUUID.GenerateUUID(); - fields["QueryFlags"] = (uint)1; - fields["QueryStart"] = (int)0; - fields["QueryText"] = txtFind.Text; - blocks[fields] = "QueryData"; - - fields = new Hashtable(); - fields["AgentID"] = Client.Network.AgentID; - fields["SessionID"] = Client.Network.SessionID; - blocks[fields] = "AgentData"; - - Packet packet = PacketBuilder.BuildPacket("DirFindQuery", Client.Protocol, blocks, - Helpers.MSG_RELIABLE); - - Client.Network.SendPacket(packet); - } - - private void cmdTransfer_Click(object sender, System.EventArgs e) - { - int amount = 0; - - try - { - amount = System.Convert.ToInt32(txtTransfer.Text); - } - catch (Exception) - { - MessageBox.Show(txtTransfer.Text + " is not a valid amount"); - return; - } - - if (lstFind.SelectedItems.Count != 1) - { - MessageBox.Show("Find an avatar using the directory search and select " + - "their name to transfer money"); - return; - } - - Client.Avatar.GiveMoney(new LLUUID(lstFind.SelectedItems[0].SubItems[2].Text), - amount, "SLAccountant payment"); - } - } -} +using System; +using System.Drawing; +using System.Collections; +using System.ComponentModel; +using System.Windows.Forms; +using System.Threading; +using libsecondlife; + +namespace SecondSuite.Plugins +{ + /// + /// Summary description for frmAccountant. + /// + public class frmAccountant : System.Windows.Forms.Form + { + private System.Windows.Forms.ListView lstFind; + private System.Windows.Forms.ColumnHeader colName; + private System.Windows.Forms.ColumnHeader colOnline; + private System.Windows.Forms.ColumnHeader colUuid; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.Button cmdTransfer; + private System.Windows.Forms.TextBox txtTransfer; + private System.Windows.Forms.TextBox txtFind; + private System.Windows.Forms.Button cmdFind; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.Label lblBalance; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.Label lblName; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.TextBox txtDescription; + /// + /// Required designer variable. + /// + private System.ComponentModel.Container components = null; + + // libsecondlife instance + private SecondLife Client; + // Mutex for locking the listview + Mutex lstFindMutex; + + public frmAccountant(SecondLife client) + { + // + // Required for Windows Form Designer support + // + InitializeComponent(); + + Client = client; + lstFindMutex = new Mutex(false, "lstFindMutex"); + + // Install our packet handlers + Client.Network.RegisterCallback("MoneyBalanceReply", new PacketCallback(BalanceHandler)); + Client.Network.RegisterCallback("DirPeopleReply", new PacketCallback(DirPeopleHandler)); + } + + /// + /// Clean up any resources being used. + /// + protected override void Dispose( bool disposing ) + { + if( disposing ) + { + if(components != null) + { + components.Dispose(); + } + } + base.Dispose( disposing ); + } + + public void Connected() + { + lblName.Text = Client.Network.LoginValues["first_name"] + " " + + Client.Network.LoginValues["last_name"]; + + // MoneyBalanceRequest + Hashtable blocks = new Hashtable(); + Hashtable fields = new Hashtable(); + blocks = new Hashtable(); + fields = new Hashtable(); + fields["AgentID"] = Client.Network.AgentID; + fields["TransactionID"] = LLUUID.GenerateUUID(); + blocks[fields] = "MoneyData"; + Packet packet = PacketBuilder.BuildPacket("MoneyBalanceRequest", Client.Protocol, blocks, + Helpers.MSG_RELIABLE); + + Client.Network.SendPacket(packet); + } + + private void BalanceHandler(Packet packet, Simulator simulator) + { + if (packet.Layout.Name == "MoneyBalanceReply") + { + int balance = 0; + int squareMetersCredit = 0; + string description = ""; + LLUUID transactionID = null; + bool transactionSuccess = false; + + foreach (Block block in packet.Blocks()) + { + foreach (Field field in block.Fields) + { + if (field.Layout.Name == "MoneyBalance") + { + balance = (int)field.Data; + } + else if (field.Layout.Name == "SquareMetersCredit") + { + squareMetersCredit = (int)field.Data; + } + else if (field.Layout.Name == "Description") + { + byte[] byteArray = (byte[])field.Data; + description = System.Text.Encoding.ASCII.GetString(byteArray).Replace("\0", ""); + } + else if (field.Layout.Name == "TransactionID") + { + transactionID = (LLUUID)field.Data; + } + else if (field.Layout.Name == "TransactionSuccess") + { + transactionSuccess = (bool)field.Data; + } + } + } + + lblBalance.Text = balance.ToString(); + } + } + + private void DirPeopleHandler(Packet packet, Simulator simulator) + { + lstFindMutex.WaitOne(); + + foreach (Block block in packet.Blocks()) + { + if (block.Layout.Name == "QueryReplies") + { + LLUUID id = null; + string firstName = ""; + string lastName = ""; + bool online = false; + + foreach (Field field in block.Fields) + { + if (field.Layout.Name == "AgentID") + { + id = (LLUUID)field.Data; + } + else if (field.Layout.Name == "LastName") + { + lastName = System.Text.Encoding.UTF8.GetString((byte[])field.Data).Replace("\0", ""); + } + else if (field.Layout.Name == "FirstName") + { + firstName = System.Text.Encoding.UTF8.GetString((byte[])field.Data).Replace("\0", ""); + } + else if (field.Layout.Name == "Online") + { + online = (bool)field.Data; + } + } + + if (id != null) + { + ListViewItem listItem = new ListViewItem(new string[] + { firstName + " " + lastName, (online ? "Yes" : "No"), id.ToString() }); + lstFind.Items.Add(listItem); + } + } + } + + lstFindMutex.ReleaseMutex(); + } + + #region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.lstFind = new System.Windows.Forms.ListView(); + this.colName = new System.Windows.Forms.ColumnHeader(); + this.colOnline = new System.Windows.Forms.ColumnHeader(); + this.colUuid = new System.Windows.Forms.ColumnHeader(); + this.label7 = new System.Windows.Forms.Label(); + this.cmdTransfer = new System.Windows.Forms.Button(); + this.txtTransfer = new System.Windows.Forms.TextBox(); + this.txtFind = new System.Windows.Forms.TextBox(); + this.cmdFind = new System.Windows.Forms.Button(); + this.label5 = new System.Windows.Forms.Label(); + this.lblBalance = new System.Windows.Forms.Label(); + this.label6 = new System.Windows.Forms.Label(); + this.lblName = new System.Windows.Forms.Label(); + this.label4 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.txtDescription = new System.Windows.Forms.TextBox(); + this.SuspendLayout(); + // + // lstFind + // + this.lstFind.Activation = System.Windows.Forms.ItemActivation.OneClick; + this.lstFind.AllowColumnReorder = true; + this.lstFind.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.colName, + this.colOnline, + this.colUuid}); + this.lstFind.FullRowSelect = true; + this.lstFind.HideSelection = false; + this.lstFind.Location = new System.Drawing.Point(16, 88); + this.lstFind.Name = "lstFind"; + this.lstFind.Size = new System.Drawing.Size(336, 248); + this.lstFind.Sorting = System.Windows.Forms.SortOrder.Ascending; + this.lstFind.TabIndex = 53; + this.lstFind.View = System.Windows.Forms.View.Details; + // + // colName + // + this.colName.Text = "Name"; + this.colName.Width = 120; + // + // colOnline + // + this.colOnline.Text = "Online"; + this.colOnline.Width = 50; + // + // colUuid + // + this.colUuid.Text = "UUID"; + this.colUuid.Width = 150; + // + // label7 + // + this.label7.Location = new System.Drawing.Point(360, 152); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(88, 16); + this.label7.TabIndex = 56; + this.label7.Text = "Amount:"; + // + // cmdTransfer + // + this.cmdTransfer.Location = new System.Drawing.Point(472, 248); + this.cmdTransfer.Name = "cmdTransfer"; + this.cmdTransfer.Size = new System.Drawing.Size(104, 24); + this.cmdTransfer.TabIndex = 55; + this.cmdTransfer.Text = "Transfer Lindens"; + this.cmdTransfer.Click += new System.EventHandler(this.cmdTransfer_Click); + // + // txtTransfer + // + this.txtTransfer.Location = new System.Drawing.Point(360, 168); + this.txtTransfer.MaxLength = 7; + this.txtTransfer.Name = "txtTransfer"; + this.txtTransfer.Size = new System.Drawing.Size(104, 20); + this.txtTransfer.TabIndex = 54; + this.txtTransfer.Text = ""; + // + // txtFind + // + this.txtFind.Location = new System.Drawing.Point(16, 56); + this.txtFind.Name = "txtFind"; + this.txtFind.Size = new System.Drawing.Size(184, 20); + this.txtFind.TabIndex = 51; + this.txtFind.Text = ""; + // + // cmdFind + // + this.cmdFind.Location = new System.Drawing.Point(208, 56); + this.cmdFind.Name = "cmdFind"; + this.cmdFind.Size = new System.Drawing.Size(48, 24); + this.cmdFind.TabIndex = 52; + this.cmdFind.Text = "Find"; + this.cmdFind.Click += new System.EventHandler(this.cmdFind_Click); + // + // label5 + // + this.label5.Location = new System.Drawing.Point(16, 40); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(88, 16); + this.label5.TabIndex = 60; + this.label5.Text = "People Search"; + // + // lblBalance + // + this.lblBalance.Location = new System.Drawing.Point(512, 8); + this.lblBalance.Name = "lblBalance"; + this.lblBalance.Size = new System.Drawing.Size(64, 16); + this.lblBalance.TabIndex = 61; + this.lblBalance.TextAlign = System.Drawing.ContentAlignment.TopRight; + // + // label6 + // + this.label6.Location = new System.Drawing.Point(456, 8); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(56, 16); + this.label6.TabIndex = 59; + this.label6.Text = "Balance:"; + // + // lblName + // + this.lblName.Location = new System.Drawing.Point(64, 8); + this.lblName.Name = "lblName"; + this.lblName.Size = new System.Drawing.Size(184, 16); + this.lblName.TabIndex = 57; + // + // label4 + // + this.label4.Location = new System.Drawing.Point(16, 8); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(48, 16); + this.label4.TabIndex = 58; + this.label4.Text = "Name:"; + // + // label1 + // + this.label1.Location = new System.Drawing.Point(360, 200); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(168, 16); + this.label1.TabIndex = 63; + this.label1.Text = "Description (optional):"; + // + // txtDescription + // + this.txtDescription.Location = new System.Drawing.Point(360, 216); + this.txtDescription.MaxLength = 7; + this.txtDescription.Name = "txtDescription"; + this.txtDescription.Size = new System.Drawing.Size(216, 20); + this.txtDescription.TabIndex = 62; + this.txtDescription.Text = ""; + // + // frmAccountant + // + this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); + this.ClientSize = new System.Drawing.Size(592, 349); + this.Controls.Add(this.label1); + this.Controls.Add(this.txtDescription); + this.Controls.Add(this.txtTransfer); + this.Controls.Add(this.txtFind); + this.Controls.Add(this.lstFind); + this.Controls.Add(this.label7); + this.Controls.Add(this.cmdTransfer); + this.Controls.Add(this.cmdFind); + this.Controls.Add(this.label5); + this.Controls.Add(this.lblBalance); + this.Controls.Add(this.label6); + this.Controls.Add(this.lblName); + this.Controls.Add(this.label4); + this.Name = "frmAccountant"; + this.Text = "Accountant"; + this.ResumeLayout(false); + + } + #endregion + + private void cmdFind_Click(object sender, System.EventArgs e) + { + lstFind.Items.Clear(); + + Hashtable blocks = new Hashtable(); + Hashtable fields = new Hashtable(); + fields["QueryID"] = LLUUID.GenerateUUID(); + fields["QueryFlags"] = (uint)1; + fields["QueryStart"] = (int)0; + fields["QueryText"] = txtFind.Text; + blocks[fields] = "QueryData"; + + fields = new Hashtable(); + fields["AgentID"] = Client.Network.AgentID; + fields["SessionID"] = Client.Network.SessionID; + blocks[fields] = "AgentData"; + + Packet packet = PacketBuilder.BuildPacket("DirFindQuery", Client.Protocol, blocks, + Helpers.MSG_RELIABLE); + + Client.Network.SendPacket(packet); + } + + private void cmdTransfer_Click(object sender, System.EventArgs e) + { + int amount = 0; + + try + { + amount = System.Convert.ToInt32(txtTransfer.Text); + } + catch (Exception) + { + MessageBox.Show(txtTransfer.Text + " is not a valid amount"); + return; + } + + if (lstFind.SelectedItems.Count != 1) + { + MessageBox.Show("Find an avatar using the directory search and select " + + "their name to transfer money"); + return; + } + + Client.Avatar.GiveMoney(new LLUUID(lstFind.SelectedItems[0].SubItems[2].Text), + amount, "SLAccountant payment"); + } + } +} diff --git a/applications/SecondSuite/Plugins/Accountant/frmAccountant.resx b/applications/SecondSuite/Plugins/Accountant/frmAccountant.resx index d36cabfb..9d343c94 100644 --- a/applications/SecondSuite/Plugins/Accountant/frmAccountant.resx +++ b/applications/SecondSuite/Plugins/Accountant/frmAccountant.resx @@ -1,265 +1,265 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 1.3 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - False - - - Private - - - Private - - - Private - - - Private - - - Private - - - Private - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - Private - - - False - - - Private - - - False - - - (Default) - - - False - - - False - - - True - - - 8, 8 - - - True - - - 80 - - - frmAccountant - - - Private - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + False + + + Private + + + Private + + + Private + + + Private + + + Private + + + Private + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + Private + + + False + + + Private + + + False + + + (Default) + + + False + + + False + + + True + + + 8, 8 + + + True + + + 80 + + + frmAccountant + + + Private + \ No newline at end of file diff --git a/applications/SecondSuite/Plugins/PrimBuilder/AssemblyInfo.cs b/applications/SecondSuite/Plugins/PrimBuilder/AssemblyInfo.cs index 177a4f0e..9f89a328 100644 --- a/applications/SecondSuite/Plugins/PrimBuilder/AssemblyInfo.cs +++ b/applications/SecondSuite/Plugins/PrimBuilder/AssemblyInfo.cs @@ -1,58 +1,58 @@ -using System.Reflection; -using System.Runtime.CompilerServices; - -// -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -// -[assembly: AssemblyTitle("")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("")] -[assembly: AssemblyCopyright("")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Revision and Build Numbers -// by using the '*' as shown below: - -[assembly: AssemblyVersion("1.0.*")] - -// -// In order to sign your assembly you must specify a key to use. Refer to the -// Microsoft .NET Framework documentation for more information on assembly signing. -// -// Use the attributes below to control which key is used for signing. -// -// Notes: -// (*) If no key is specified, the assembly is not signed. -// (*) KeyName refers to a key that has been installed in the Crypto Service -// Provider (CSP) on your machine. KeyFile refers to a file which contains -// a key. -// (*) If the KeyFile and the KeyName values are both specified, the -// following processing occurs: -// (1) If the KeyName can be found in the CSP, that key is used. -// (2) If the KeyName does not exist and the KeyFile does exist, the key -// in the KeyFile is installed into the CSP and used. -// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. -// When specifying the KeyFile, the location of the KeyFile should be -// relative to the project output directory which is -// %Project Directory%\obj\. For example, if your KeyFile is -// located in the project directory, you would specify the AssemblyKeyFile -// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] -// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework -// documentation for more information on this. -// -[assembly: AssemblyDelaySign(false)] -[assembly: AssemblyKeyFile("")] -[assembly: AssemblyKeyName("")] +using System.Reflection; +using System.Runtime.CompilerServices; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly: AssemblyTitle("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly: AssemblyVersion("1.0.*")] + +// +// In order to sign your assembly you must specify a key to use. Refer to the +// Microsoft .NET Framework documentation for more information on assembly signing. +// +// Use the attributes below to control which key is used for signing. +// +// Notes: +// (*) If no key is specified, the assembly is not signed. +// (*) KeyName refers to a key that has been installed in the Crypto Service +// Provider (CSP) on your machine. KeyFile refers to a file which contains +// a key. +// (*) If the KeyFile and the KeyName values are both specified, the +// following processing occurs: +// (1) If the KeyName can be found in the CSP, that key is used. +// (2) If the KeyName does not exist and the KeyFile does exist, the key +// in the KeyFile is installed into the CSP and used. +// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. +// When specifying the KeyFile, the location of the KeyFile should be +// relative to the project output directory which is +// %Project Directory%\obj\. For example, if your KeyFile is +// located in the project directory, you would specify the AssemblyKeyFile +// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] +// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework +// documentation for more information on this. +// +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] +[assembly: AssemblyKeyName("")] diff --git a/applications/SecondSuite/Plugins/PrimBuilder/PrimBuilder.cs b/applications/SecondSuite/Plugins/PrimBuilder/PrimBuilder.cs index 4b4e98f4..18851c63 100644 --- a/applications/SecondSuite/Plugins/PrimBuilder/PrimBuilder.cs +++ b/applications/SecondSuite/Plugins/PrimBuilder/PrimBuilder.cs @@ -1,68 +1,68 @@ -/* - * Copyright (c) 2006, Second Life Reverse Engineering Team - * All rights reserved. - * - * - Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - Neither the name of the Second Life Reverse Engineering Team nor the names - * of its contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using libsecondlife; -using SecondSuite.Plugins; - -namespace SecondSuite.Plugins -{ - /// - /// Accountant plugin implementation - /// - public class PrimBuilder : SSPlugin - { - public string Name { get { return "Prim Builder"; } } - public string Author { get { return "John Hurliman"; } } - public string Homepage { get { return "http://www.highenergychemistry.com/"; } } - public string Description { get { return "Create prims the hard way"; } } - public bool SecondLifeClient { get { return true; } } - public ConnectionEvent ConnectionHandler { get { return OnConnection; } } - public override string ToString() { return Name; } - - private frmPrimBuilder Form; - private ConnectionEvent OnConnection; - - public void Init(SecondLife client) - { - Form = new frmPrimBuilder(client); - OnConnection = new ConnectionEvent(Form.Connected); - } - - public System.Windows.Forms.Form Load() - { - return Form; - } - - public void Shutdown() - { - if (Form != null) - { - Form.Close(); - } - } - } -} +/* + * Copyright (c) 2006, Second Life Reverse Engineering Team + * All rights reserved. + * + * - Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Neither the name of the Second Life Reverse Engineering Team nor the names + * of its contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using libsecondlife; +using SecondSuite.Plugins; + +namespace SecondSuite.Plugins +{ + /// + /// Accountant plugin implementation + /// + public class PrimBuilder : SSPlugin + { + public string Name { get { return "Prim Builder"; } } + public string Author { get { return "John Hurliman"; } } + public string Homepage { get { return "http://www.highenergychemistry.com/"; } } + public string Description { get { return "Create prims the hard way"; } } + public bool SecondLifeClient { get { return true; } } + public ConnectionEvent ConnectionHandler { get { return OnConnection; } } + public override string ToString() { return Name; } + + private frmPrimBuilder Form; + private ConnectionEvent OnConnection; + + public void Init(SecondLife client) + { + Form = new frmPrimBuilder(client); + OnConnection = new ConnectionEvent(Form.Connected); + } + + public System.Windows.Forms.Form Load() + { + return Form; + } + + public void Shutdown() + { + if (Form != null) + { + Form.Close(); + } + } + } +} diff --git a/applications/SecondSuite/Plugins/PrimBuilder/PrimBuilder.csproj b/applications/SecondSuite/Plugins/PrimBuilder/PrimBuilder.csproj index 083fab79..80538a62 100644 --- a/applications/SecondSuite/Plugins/PrimBuilder/PrimBuilder.csproj +++ b/applications/SecondSuite/Plugins/PrimBuilder/PrimBuilder.csproj @@ -1,130 +1,130 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/applications/SecondSuite/Plugins/PrimBuilder/frmPrimBuilder.cs b/applications/SecondSuite/Plugins/PrimBuilder/frmPrimBuilder.cs index 16beb5fc..05bd3362 100644 --- a/applications/SecondSuite/Plugins/PrimBuilder/frmPrimBuilder.cs +++ b/applications/SecondSuite/Plugins/PrimBuilder/frmPrimBuilder.cs @@ -1,1248 +1,1248 @@ -using System; -using System.Drawing; -using System.Collections; -using System.ComponentModel; -using System.Windows.Forms; -using System.Data; -using libsecondlife; - -namespace SecondSuite.Plugins -{ - /// - /// Summary description for Form1. - /// - public class frmPrimBuilder : System.Windows.Forms.Form - { - private System.Windows.Forms.Button cmdBuild; - private System.Windows.Forms.Label label4; - private System.Windows.Forms.Label label5; - private System.Windows.Forms.Label label6; - private System.Windows.Forms.Label label8; - private System.Windows.Forms.Label label9; - private System.Windows.Forms.Label label10; - private System.Windows.Forms.Label label7; - private System.Windows.Forms.Label label11; - private System.Windows.Forms.Label label12; - private System.Windows.Forms.Label label13; - private System.Windows.Forms.Label label14; - private System.Windows.Forms.Label label15; - private System.Windows.Forms.Label label16; - private System.Windows.Forms.Label label19; - private System.Windows.Forms.Label label20; - private System.Windows.Forms.Label label21; - private System.Windows.Forms.Label label22; - private System.Windows.Forms.Label label23; - private System.Windows.Forms.Label label24; - private System.Windows.Forms.Label label25; - private System.Windows.Forms.Label label28; - private System.Windows.Forms.Label label26; - private System.Windows.Forms.Label label27; - private System.Windows.Forms.Label label29; - private System.Windows.Forms.Label label30; - private System.Windows.Forms.Label label31; - private System.Windows.Forms.Label label32; - private System.Windows.Forms.Label label33; - private System.Windows.Forms.Label label34; - private System.Windows.Forms.NumericUpDown numScaleZ; - private System.Windows.Forms.Label label35; - private System.Windows.Forms.NumericUpDown numScaleY; - private System.Windows.Forms.Label label36; - private System.Windows.Forms.NumericUpDown numScaleX; - private System.Windows.Forms.Label label37; - private System.Windows.Forms.NumericUpDown numRotationZ; - private System.Windows.Forms.Label label38; - private System.Windows.Forms.NumericUpDown numRotationY; - private System.Windows.Forms.Label label39; - private System.Windows.Forms.NumericUpDown numRotationX; - private System.Windows.Forms.Label label40; - private System.Windows.Forms.NumericUpDown numRotationS; - private System.Windows.Forms.NumericUpDown numProfileHollow; - private System.Windows.Forms.NumericUpDown numPathCurve; - private System.Windows.Forms.NumericUpDown numProfileCurve; - private System.Windows.Forms.NumericUpDown numProfileBegin; - private System.Windows.Forms.NumericUpDown numProfileEnd; - private System.Windows.Forms.NumericUpDown numPathTwistBegin; - private System.Windows.Forms.NumericUpDown numPathTwist; - private System.Windows.Forms.NumericUpDown numPathTaperX; - private System.Windows.Forms.NumericUpDown numPathTaperY; - private System.Windows.Forms.NumericUpDown numPathShearX; - private System.Windows.Forms.NumericUpDown numPathShearY; - private System.Windows.Forms.NumericUpDown numPathScaleX; - private System.Windows.Forms.NumericUpDown numPathScaleY; - private System.Windows.Forms.NumericUpDown numPathRevolutions; - private System.Windows.Forms.NumericUpDown numPathRadiusOffset; - private System.Windows.Forms.NumericUpDown numPathBegin; - private System.Windows.Forms.NumericUpDown numPathEnd; - private System.Windows.Forms.NumericUpDown numMaterial; - private System.Windows.Forms.TextBox txtName; - private System.Windows.Forms.Label label3; - private System.Windows.Forms.NumericUpDown numPositionZ; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.NumericUpDown numPositionY; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.NumericUpDown numPositionX; - private System.Windows.Forms.Label label41; - private System.Windows.Forms.NumericUpDown numPathSkew; - /// - /// Required designer variable. - /// - private System.ComponentModel.Container components = null; - - // - SecondLife Client; - - public frmPrimBuilder(SecondLife client) - { - // - // Required for Windows Form Designer support - // - InitializeComponent(); - - Client = client; - Client.Network.RegisterCallback("CoarseLocationUpdate", new PacketCallback(LocationHandler)); - } - - private void LocationHandler(Packet packet, Simulator simulator) - { - if (numPositionX.Value == 0) - { - numPositionX.Value = (decimal)Client.Avatar.Position.X; - } - - if (numPositionY.Value == 0) - { - numPositionY.Value = (decimal)Client.Avatar.Position.Y; - } - - if (numPositionZ.Value == 0) - { - numPositionZ.Value = (decimal)Client.Avatar.Position.Z; - } - } - - public void Connected() - { - ; - } - - /// - /// Clean up any resources being used. - /// - protected override void Dispose( bool disposing ) - { - if( disposing ) - { - if (components != null) - { - components.Dispose(); - } - } - base.Dispose( disposing ); - } - - #region Windows Form Designer generated code - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.cmdBuild = new System.Windows.Forms.Button(); - this.label4 = new System.Windows.Forms.Label(); - this.label5 = new System.Windows.Forms.Label(); - this.label6 = new System.Windows.Forms.Label(); - this.label8 = new System.Windows.Forms.Label(); - this.label9 = new System.Windows.Forms.Label(); - this.label10 = new System.Windows.Forms.Label(); - this.label7 = new System.Windows.Forms.Label(); - this.label11 = new System.Windows.Forms.Label(); - this.label12 = new System.Windows.Forms.Label(); - this.label13 = new System.Windows.Forms.Label(); - this.label14 = new System.Windows.Forms.Label(); - this.label15 = new System.Windows.Forms.Label(); - this.label16 = new System.Windows.Forms.Label(); - this.label19 = new System.Windows.Forms.Label(); - this.label20 = new System.Windows.Forms.Label(); - this.label21 = new System.Windows.Forms.Label(); - this.label22 = new System.Windows.Forms.Label(); - this.label23 = new System.Windows.Forms.Label(); - this.label24 = new System.Windows.Forms.Label(); - this.label25 = new System.Windows.Forms.Label(); - this.label28 = new System.Windows.Forms.Label(); - this.label26 = new System.Windows.Forms.Label(); - this.label27 = new System.Windows.Forms.Label(); - this.label29 = new System.Windows.Forms.Label(); - this.label30 = new System.Windows.Forms.Label(); - this.label31 = new System.Windows.Forms.Label(); - this.label32 = new System.Windows.Forms.Label(); - this.label33 = new System.Windows.Forms.Label(); - this.label34 = new System.Windows.Forms.Label(); - this.numScaleZ = new System.Windows.Forms.NumericUpDown(); - this.label35 = new System.Windows.Forms.Label(); - this.numScaleY = new System.Windows.Forms.NumericUpDown(); - this.label36 = new System.Windows.Forms.Label(); - this.numScaleX = new System.Windows.Forms.NumericUpDown(); - this.label37 = new System.Windows.Forms.Label(); - this.numRotationZ = new System.Windows.Forms.NumericUpDown(); - this.label38 = new System.Windows.Forms.Label(); - this.numRotationY = new System.Windows.Forms.NumericUpDown(); - this.label39 = new System.Windows.Forms.Label(); - this.numRotationX = new System.Windows.Forms.NumericUpDown(); - this.label40 = new System.Windows.Forms.Label(); - this.numRotationS = new System.Windows.Forms.NumericUpDown(); - this.numProfileHollow = new System.Windows.Forms.NumericUpDown(); - this.numPathCurve = new System.Windows.Forms.NumericUpDown(); - this.numProfileCurve = new System.Windows.Forms.NumericUpDown(); - this.numProfileBegin = new System.Windows.Forms.NumericUpDown(); - this.numProfileEnd = new System.Windows.Forms.NumericUpDown(); - this.numPathTwistBegin = new System.Windows.Forms.NumericUpDown(); - this.numPathTwist = new System.Windows.Forms.NumericUpDown(); - this.numPathTaperX = new System.Windows.Forms.NumericUpDown(); - this.numPathTaperY = new System.Windows.Forms.NumericUpDown(); - this.numPathShearX = new System.Windows.Forms.NumericUpDown(); - this.numPathShearY = new System.Windows.Forms.NumericUpDown(); - this.numPathSkew = new System.Windows.Forms.NumericUpDown(); - this.numPathScaleX = new System.Windows.Forms.NumericUpDown(); - this.numPathScaleY = new System.Windows.Forms.NumericUpDown(); - this.numPathRevolutions = new System.Windows.Forms.NumericUpDown(); - this.numPathRadiusOffset = new System.Windows.Forms.NumericUpDown(); - this.numPathBegin = new System.Windows.Forms.NumericUpDown(); - this.numPathEnd = new System.Windows.Forms.NumericUpDown(); - this.numMaterial = new System.Windows.Forms.NumericUpDown(); - this.txtName = new System.Windows.Forms.TextBox(); - this.label3 = new System.Windows.Forms.Label(); - this.numPositionZ = new System.Windows.Forms.NumericUpDown(); - this.label2 = new System.Windows.Forms.Label(); - this.numPositionY = new System.Windows.Forms.NumericUpDown(); - this.label1 = new System.Windows.Forms.Label(); - this.numPositionX = new System.Windows.Forms.NumericUpDown(); - this.label41 = new System.Windows.Forms.Label(); - ((System.ComponentModel.ISupportInitialize)(this.numScaleZ)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numScaleY)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numScaleX)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numRotationZ)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numRotationY)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numRotationX)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numRotationS)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numProfileHollow)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numPathCurve)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numProfileCurve)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numProfileBegin)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numProfileEnd)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numPathTwistBegin)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numPathTwist)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numPathTaperX)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numPathTaperY)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numPathShearX)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numPathShearY)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numPathSkew)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numPathScaleX)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numPathScaleY)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numPathRevolutions)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numPathRadiusOffset)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numPathBegin)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numPathEnd)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numMaterial)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numPositionZ)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numPositionY)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.numPositionX)).BeginInit(); - this.SuspendLayout(); - // - // cmdBuild - // - this.cmdBuild.Location = new System.Drawing.Point(408, 536); - this.cmdBuild.Name = "cmdBuild"; - this.cmdBuild.Size = new System.Drawing.Size(104, 24); - this.cmdBuild.TabIndex = 31; - this.cmdBuild.Text = "Build Prim"; - this.cmdBuild.Click += new System.EventHandler(this.cmdBuild_Click); - // - // label4 - // - this.label4.Location = new System.Drawing.Point(16, 16); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(120, 20); - this.label4.TabIndex = 58; - this.label4.Text = "Name:"; - // - // label5 - // - this.label5.Location = new System.Drawing.Point(16, 48); - this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(120, 20); - this.label5.TabIndex = 59; - this.label5.Text = "Material:"; - // - // label6 - // - this.label6.Location = new System.Drawing.Point(16, 80); - this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(120, 20); - this.label6.TabIndex = 60; - this.label6.Text = "Path:"; - // - // label8 - // - this.label8.Location = new System.Drawing.Point(16, 112); - this.label8.Name = "label8"; - this.label8.Size = new System.Drawing.Size(120, 20); - this.label8.TabIndex = 62; - this.label8.Text = "Path Radius Offset:"; - // - // label9 - // - this.label9.Location = new System.Drawing.Point(16, 144); - this.label9.Name = "label9"; - this.label9.Size = new System.Drawing.Size(120, 20); - this.label9.TabIndex = 63; - this.label9.Text = "Path Revolutions:"; - // - // label10 - // - this.label10.Location = new System.Drawing.Point(16, 176); - this.label10.Name = "label10"; - this.label10.Size = new System.Drawing.Size(120, 20); - this.label10.TabIndex = 64; - this.label10.Text = "Path Scale:"; - // - // label7 - // - this.label7.Location = new System.Drawing.Point(136, 80); - this.label7.Name = "label7"; - this.label7.Size = new System.Drawing.Size(96, 20); - this.label7.TabIndex = 65; - this.label7.Text = "Begin:"; - // - // label11 - // - this.label11.Location = new System.Drawing.Point(328, 80); - this.label11.Name = "label11"; - this.label11.Size = new System.Drawing.Size(80, 20); - this.label11.TabIndex = 66; - this.label11.Text = "End:"; - // - // label12 - // - this.label12.Location = new System.Drawing.Point(136, 176); - this.label12.Name = "label12"; - this.label12.Size = new System.Drawing.Size(96, 20); - this.label12.TabIndex = 67; - this.label12.Text = "X:"; - // - // label13 - // - this.label13.Location = new System.Drawing.Point(328, 176); - this.label13.Name = "label13"; - this.label13.Size = new System.Drawing.Size(80, 20); - this.label13.TabIndex = 68; - this.label13.Text = "Y:"; - // - // label14 - // - this.label14.Location = new System.Drawing.Point(328, 208); - this.label14.Name = "label14"; - this.label14.Size = new System.Drawing.Size(80, 20); - this.label14.TabIndex = 71; - this.label14.Text = "Y:"; - // - // label15 - // - this.label15.Location = new System.Drawing.Point(136, 208); - this.label15.Name = "label15"; - this.label15.Size = new System.Drawing.Size(96, 20); - this.label15.TabIndex = 70; - this.label15.Text = "X:"; - // - // label16 - // - this.label16.Location = new System.Drawing.Point(16, 208); - this.label16.Name = "label16"; - this.label16.Size = new System.Drawing.Size(120, 20); - this.label16.TabIndex = 69; - this.label16.Text = "Path Shear:"; - // - // label19 - // - this.label19.Location = new System.Drawing.Point(16, 336); - this.label19.Name = "label19"; - this.label19.Size = new System.Drawing.Size(120, 20); - this.label19.TabIndex = 72; - this.label19.Text = "Path Skew:"; - // - // label20 - // - this.label20.Location = new System.Drawing.Point(328, 240); - this.label20.Name = "label20"; - this.label20.Size = new System.Drawing.Size(80, 20); - this.label20.TabIndex = 77; - this.label20.Text = "Y:"; - // - // label21 - // - this.label21.Location = new System.Drawing.Point(136, 240); - this.label21.Name = "label21"; - this.label21.Size = new System.Drawing.Size(96, 20); - this.label21.TabIndex = 76; - this.label21.Text = "X:"; - // - // label22 - // - this.label22.Location = new System.Drawing.Point(16, 240); - this.label22.Name = "label22"; - this.label22.Size = new System.Drawing.Size(120, 20); - this.label22.TabIndex = 75; - this.label22.Text = "Path Taper:"; - // - // label23 - // - this.label23.Location = new System.Drawing.Point(328, 272); - this.label23.Name = "label23"; - this.label23.Size = new System.Drawing.Size(80, 20); - this.label23.TabIndex = 80; - this.label23.Text = "Path Twist:"; - // - // label24 - // - this.label24.Location = new System.Drawing.Point(136, 272); - this.label24.Name = "label24"; - this.label24.Size = new System.Drawing.Size(96, 20); - this.label24.TabIndex = 79; - this.label24.Text = "Path Twist Begin:"; - // - // label25 - // - this.label25.Location = new System.Drawing.Point(16, 272); - this.label25.Name = "label25"; - this.label25.Size = new System.Drawing.Size(120, 20); - this.label25.TabIndex = 78; - this.label25.Text = "Twist:"; - // - // label28 - // - this.label28.Location = new System.Drawing.Point(16, 304); - this.label28.Name = "label28"; - this.label28.Size = new System.Drawing.Size(120, 20); - this.label28.TabIndex = 81; - this.label28.Text = "Profile:"; - // - // label26 - // - this.label26.Location = new System.Drawing.Point(328, 304); - this.label26.Name = "label26"; - this.label26.Size = new System.Drawing.Size(80, 20); - this.label26.TabIndex = 83; - this.label26.Text = "End:"; - // - // label27 - // - this.label27.Location = new System.Drawing.Point(136, 304); - this.label27.Name = "label27"; - this.label27.Size = new System.Drawing.Size(96, 20); - this.label27.TabIndex = 82; - this.label27.Text = "Begin:"; - // - // label29 - // - this.label29.Location = new System.Drawing.Point(288, 336); - this.label29.Name = "label29"; - this.label29.Size = new System.Drawing.Size(120, 20); - this.label29.TabIndex = 84; - this.label29.Text = "Profile Curve:"; - // - // label30 - // - this.label30.Location = new System.Drawing.Point(16, 368); - this.label30.Name = "label30"; - this.label30.Size = new System.Drawing.Size(120, 20); - this.label30.TabIndex = 85; - this.label30.Text = "Path Curve:"; - // - // label31 - // - this.label31.Location = new System.Drawing.Point(288, 368); - this.label31.Name = "label31"; - this.label31.Size = new System.Drawing.Size(120, 20); - this.label31.TabIndex = 86; - this.label31.Text = "Profile Hollow:"; - // - // label32 - // - this.label32.Location = new System.Drawing.Point(16, 400); - this.label32.Name = "label32"; - this.label32.Size = new System.Drawing.Size(120, 16); - this.label32.TabIndex = 87; - this.label32.Text = "Rotation:"; - // - // label33 - // - this.label33.Location = new System.Drawing.Point(16, 456); - this.label33.Name = "label33"; - this.label33.Size = new System.Drawing.Size(120, 20); - this.label33.TabIndex = 88; - this.label33.Text = "Scale:"; - // - // label34 - // - this.label34.Location = new System.Drawing.Point(272, 480); - this.label34.Name = "label34"; - this.label34.Size = new System.Drawing.Size(32, 20); - this.label34.TabIndex = 94; - this.label34.Text = "Z:"; - // - // numScaleZ - // - this.numScaleZ.DecimalPlaces = 5; - this.numScaleZ.Location = new System.Drawing.Point(304, 480); - this.numScaleZ.Maximum = new System.Decimal(new int[] { - 256, - 0, - 0, - 0}); - this.numScaleZ.Minimum = new System.Decimal(new int[] { - 10, - 0, - 0, - -2147483648}); - this.numScaleZ.Name = "numScaleZ"; - this.numScaleZ.Size = new System.Drawing.Size(80, 20); - this.numScaleZ.TabIndex = 27; - this.numScaleZ.Value = new System.Decimal(new int[] { - 5, - 0, - 0, - 65536}); - // - // label35 - // - this.label35.Location = new System.Drawing.Point(144, 480); - this.label35.Name = "label35"; - this.label35.Size = new System.Drawing.Size(32, 20); - this.label35.TabIndex = 92; - this.label35.Text = "Y:"; - // - // numScaleY - // - this.numScaleY.DecimalPlaces = 5; - this.numScaleY.Location = new System.Drawing.Point(176, 480); - this.numScaleY.Maximum = new System.Decimal(new int[] { - 256, - 0, - 0, - 0}); - this.numScaleY.Name = "numScaleY"; - this.numScaleY.Size = new System.Drawing.Size(80, 20); - this.numScaleY.TabIndex = 26; - this.numScaleY.Value = new System.Decimal(new int[] { - 5, - 0, - 0, - 65536}); - // - // label36 - // - this.label36.Location = new System.Drawing.Point(16, 480); - this.label36.Name = "label36"; - this.label36.Size = new System.Drawing.Size(32, 20); - this.label36.TabIndex = 90; - this.label36.Text = "X:"; - // - // numScaleX - // - this.numScaleX.DecimalPlaces = 5; - this.numScaleX.Location = new System.Drawing.Point(48, 480); - this.numScaleX.Maximum = new System.Decimal(new int[] { - 256, - 0, - 0, - 0}); - this.numScaleX.Name = "numScaleX"; - this.numScaleX.Size = new System.Drawing.Size(80, 20); - this.numScaleX.TabIndex = 25; - this.numScaleX.Value = new System.Decimal(new int[] { - 5, - 0, - 0, - 65536}); - // - // label37 - // - this.label37.Location = new System.Drawing.Point(272, 424); - this.label37.Name = "label37"; - this.label37.Size = new System.Drawing.Size(32, 20); - this.label37.TabIndex = 100; - this.label37.Text = "Z:"; - // - // numRotationZ - // - this.numRotationZ.DecimalPlaces = 5; - this.numRotationZ.Location = new System.Drawing.Point(304, 424); - this.numRotationZ.Maximum = new System.Decimal(new int[] { - 256, - 0, - 0, - 0}); - this.numRotationZ.Name = "numRotationZ"; - this.numRotationZ.Size = new System.Drawing.Size(80, 20); - this.numRotationZ.TabIndex = 23; - // - // label38 - // - this.label38.Location = new System.Drawing.Point(144, 424); - this.label38.Name = "label38"; - this.label38.Size = new System.Drawing.Size(32, 20); - this.label38.TabIndex = 98; - this.label38.Text = "Y:"; - // - // numRotationY - // - this.numRotationY.DecimalPlaces = 5; - this.numRotationY.Location = new System.Drawing.Point(176, 424); - this.numRotationY.Maximum = new System.Decimal(new int[] { - 256, - 0, - 0, - 0}); - this.numRotationY.Name = "numRotationY"; - this.numRotationY.Size = new System.Drawing.Size(80, 20); - this.numRotationY.TabIndex = 22; - // - // label39 - // - this.label39.Location = new System.Drawing.Point(16, 424); - this.label39.Name = "label39"; - this.label39.Size = new System.Drawing.Size(32, 20); - this.label39.TabIndex = 96; - this.label39.Text = "X:"; - // - // numRotationX - // - this.numRotationX.DecimalPlaces = 5; - this.numRotationX.Location = new System.Drawing.Point(48, 424); - this.numRotationX.Maximum = new System.Decimal(new int[] { - 256, - 0, - 0, - 0}); - this.numRotationX.Name = "numRotationX"; - this.numRotationX.Size = new System.Drawing.Size(80, 20); - this.numRotationX.TabIndex = 21; - // - // label40 - // - this.label40.Location = new System.Drawing.Point(400, 424); - this.label40.Name = "label40"; - this.label40.Size = new System.Drawing.Size(32, 20); - this.label40.TabIndex = 102; - this.label40.Text = "S:"; - // - // numRotationS - // - this.numRotationS.DecimalPlaces = 5; - this.numRotationS.Location = new System.Drawing.Point(432, 424); - this.numRotationS.Maximum = new System.Decimal(new int[] { - 256, - 0, - 0, - 0}); - this.numRotationS.Name = "numRotationS"; - this.numRotationS.Size = new System.Drawing.Size(80, 20); - this.numRotationS.TabIndex = 24; - // - // numProfileHollow - // - this.numProfileHollow.Location = new System.Drawing.Point(408, 368); - this.numProfileHollow.Maximum = new System.Decimal(new int[] { - 255, - 0, - 0, - 0}); - this.numProfileHollow.Name = "numProfileHollow"; - this.numProfileHollow.Size = new System.Drawing.Size(80, 20); - this.numProfileHollow.TabIndex = 20; - // - // numPathCurve - // - this.numPathCurve.Location = new System.Drawing.Point(136, 368); - this.numPathCurve.Maximum = new System.Decimal(new int[] { - 255, - 0, - 0, - 0}); - this.numPathCurve.Name = "numPathCurve"; - this.numPathCurve.Size = new System.Drawing.Size(80, 20); - this.numPathCurve.TabIndex = 19; - this.numPathCurve.Value = new System.Decimal(new int[] { - 16, - 0, - 0, - 0}); - // - // numProfileCurve - // - this.numProfileCurve.Location = new System.Drawing.Point(408, 336); - this.numProfileCurve.Maximum = new System.Decimal(new int[] { - 5, - 0, - 0, - 0}); - this.numProfileCurve.Name = "numProfileCurve"; - this.numProfileCurve.Size = new System.Drawing.Size(80, 20); - this.numProfileCurve.TabIndex = 18; - this.numProfileCurve.Value = new System.Decimal(new int[] { - 1, - 0, - 0, - 0}); - // - // numProfileBegin - // - this.numProfileBegin.Location = new System.Drawing.Point(232, 304); - this.numProfileBegin.Maximum = new System.Decimal(new int[] { - 1275, - 0, - 0, - 196608}); - this.numProfileBegin.Name = "numProfileBegin"; - this.numProfileBegin.Size = new System.Drawing.Size(80, 20); - this.numProfileBegin.TabIndex = 16; - // - // numProfileEnd - // - this.numProfileEnd.Location = new System.Drawing.Point(408, 304); - this.numProfileEnd.Maximum = new System.Decimal(new int[] { - 5, - 0, - 0, - 0}); - this.numProfileEnd.Minimum = new System.Decimal(new int[] { - 275, - 0, - 0, - -2147287040}); - this.numProfileEnd.Name = "numProfileEnd"; - this.numProfileEnd.Size = new System.Drawing.Size(80, 20); - this.numProfileEnd.TabIndex = 17; - // - // numPathTwistBegin - // - this.numPathTwistBegin.Location = new System.Drawing.Point(232, 272); - this.numPathTwistBegin.Maximum = new System.Decimal(new int[] { - 459, - 0, - 0, - 0}); - this.numPathTwistBegin.Minimum = new System.Decimal(new int[] { - 459, - 0, - 0, - -2147483648}); - this.numPathTwistBegin.Name = "numPathTwistBegin"; - this.numPathTwistBegin.Size = new System.Drawing.Size(80, 20); - this.numPathTwistBegin.TabIndex = 14; - // - // numPathTwist - // - this.numPathTwist.Location = new System.Drawing.Point(408, 272); - this.numPathTwist.Maximum = new System.Decimal(new int[] { - 459, - 0, - 0, - 0}); - this.numPathTwist.Minimum = new System.Decimal(new int[] { - 459, - 0, - 0, - -2147483648}); - this.numPathTwist.Name = "numPathTwist"; - this.numPathTwist.Size = new System.Drawing.Size(80, 20); - this.numPathTwist.TabIndex = 15; - // - // numPathTaperX - // - this.numPathTaperX.DecimalPlaces = 2; - this.numPathTaperX.Increment = new System.Decimal(new int[] { - 1, - 0, - 0, - 65536}); - this.numPathTaperX.Location = new System.Drawing.Point(232, 240); - this.numPathTaperX.Maximum = new System.Decimal(new int[] { - 255, - 0, - 0, - 131072}); - this.numPathTaperX.Minimum = new System.Decimal(new int[] { - 255, - 0, - 0, - -2147352576}); - this.numPathTaperX.Name = "numPathTaperX"; - this.numPathTaperX.Size = new System.Drawing.Size(80, 20); - this.numPathTaperX.TabIndex = 12; - // - // numPathTaperY - // - this.numPathTaperY.DecimalPlaces = 2; - this.numPathTaperY.Increment = new System.Decimal(new int[] { - 1, - 0, - 0, - 65536}); - this.numPathTaperY.Location = new System.Drawing.Point(408, 240); - this.numPathTaperY.Maximum = new System.Decimal(new int[] { - 255, - 0, - 0, - 131072}); - this.numPathTaperY.Minimum = new System.Decimal(new int[] { - 255, - 0, - 0, - -2147352576}); - this.numPathTaperY.Name = "numPathTaperY"; - this.numPathTaperY.Size = new System.Drawing.Size(80, 20); - this.numPathTaperY.TabIndex = 13; - // - // numPathShearX - // - this.numPathShearX.DecimalPlaces = 2; - this.numPathShearX.Increment = new System.Decimal(new int[] { - 1, - 0, - 0, - 65536}); - this.numPathShearX.Location = new System.Drawing.Point(232, 208); - this.numPathShearX.Maximum = new System.Decimal(new int[] { - 255, - 0, - 0, - 131072}); - this.numPathShearX.Minimum = new System.Decimal(new int[] { - 255, - 0, - 0, - -2147352576}); - this.numPathShearX.Name = "numPathShearX"; - this.numPathShearX.Size = new System.Drawing.Size(80, 20); - this.numPathShearX.TabIndex = 8; - // - // numPathShearY - // - this.numPathShearY.DecimalPlaces = 2; - this.numPathShearY.Increment = new System.Decimal(new int[] { - 1, - 0, - 0, - 65536}); - this.numPathShearY.Location = new System.Drawing.Point(408, 208); - this.numPathShearY.Maximum = new System.Decimal(new int[] { - 255, - 0, - 0, - 131072}); - this.numPathShearY.Minimum = new System.Decimal(new int[] { - 255, - 0, - 0, - -2147352576}); - this.numPathShearY.Name = "numPathShearY"; - this.numPathShearY.Size = new System.Drawing.Size(80, 20); - this.numPathShearY.TabIndex = 9; - // - // numPathSkew - // - this.numPathSkew.DecimalPlaces = 2; - this.numPathSkew.Increment = new System.Decimal(new int[] { - 1, - 0, - 0, - 65536}); - this.numPathSkew.Location = new System.Drawing.Point(136, 336); - this.numPathSkew.Maximum = new System.Decimal(new int[] { - 255, - 0, - 0, - 131072}); - this.numPathSkew.Minimum = new System.Decimal(new int[] { - 255, - 0, - 0, - -2147352576}); - this.numPathSkew.Name = "numPathSkew"; - this.numPathSkew.Size = new System.Drawing.Size(80, 20); - this.numPathSkew.TabIndex = 10; - // - // numPathScaleX - // - this.numPathScaleX.DecimalPlaces = 2; - this.numPathScaleX.Increment = new System.Decimal(new int[] { - 1, - 0, - 0, - 65536}); - this.numPathScaleX.Location = new System.Drawing.Point(232, 176); - this.numPathScaleX.Maximum = new System.Decimal(new int[] { - 155, - 0, - 0, - 131072}); - this.numPathScaleX.Name = "numPathScaleX"; - this.numPathScaleX.Size = new System.Drawing.Size(80, 20); - this.numPathScaleX.TabIndex = 6; - // - // numPathScaleY - // - this.numPathScaleY.DecimalPlaces = 2; - this.numPathScaleY.Increment = new System.Decimal(new int[] { - 1, - 0, - 0, - 65536}); - this.numPathScaleY.Location = new System.Drawing.Point(408, 176); - this.numPathScaleY.Maximum = new System.Decimal(new int[] { - 155, - 0, - 0, - 131072}); - this.numPathScaleY.Name = "numPathScaleY"; - this.numPathScaleY.Size = new System.Drawing.Size(80, 20); - this.numPathScaleY.TabIndex = 7; - // - // numPathRevolutions - // - this.numPathRevolutions.DecimalPlaces = 2; - this.numPathRevolutions.Increment = new System.Decimal(new int[] { - 1, - 0, - 0, - 65536}); - this.numPathRevolutions.Location = new System.Drawing.Point(136, 144); - this.numPathRevolutions.Maximum = new System.Decimal(new int[] { - 486, - 0, - 0, - 131072}); - this.numPathRevolutions.Name = "numPathRevolutions"; - this.numPathRevolutions.Size = new System.Drawing.Size(80, 20); - this.numPathRevolutions.TabIndex = 5; - this.numPathRevolutions.Value = new System.Decimal(new int[] { - 100, - 0, - 0, - 131072}); - // - // numPathRadiusOffset - // - this.numPathRadiusOffset.DecimalPlaces = 3; - this.numPathRadiusOffset.Increment = new System.Decimal(new int[] { - 1, - 0, - 0, - 65536}); - this.numPathRadiusOffset.Location = new System.Drawing.Point(136, 112); - this.numPathRadiusOffset.Maximum = new System.Decimal(new int[] { - 255, - 0, - 0, - 131072}); - this.numPathRadiusOffset.Minimum = new System.Decimal(new int[] { - 255, - 0, - 0, - -2147352576}); - this.numPathRadiusOffset.Name = "numPathRadiusOffset"; - this.numPathRadiusOffset.Size = new System.Drawing.Size(80, 20); - this.numPathRadiusOffset.TabIndex = 4; - // - // numPathBegin - // - this.numPathBegin.DecimalPlaces = 2; - this.numPathBegin.Increment = new System.Decimal(new int[] { - 1, - 0, - 0, - 65536}); - this.numPathBegin.Location = new System.Drawing.Point(232, 80); - this.numPathBegin.Maximum = new System.Decimal(new int[] { - 255, - 0, - 0, - 131072}); - this.numPathBegin.Name = "numPathBegin"; - this.numPathBegin.Size = new System.Drawing.Size(80, 20); - this.numPathBegin.TabIndex = 2; - // - // numPathEnd - // - this.numPathEnd.DecimalPlaces = 2; - this.numPathEnd.Increment = new System.Decimal(new int[] { - 1, - 0, - 0, - 65536}); - this.numPathEnd.Location = new System.Drawing.Point(408, 80); - this.numPathEnd.Maximum = new System.Decimal(new int[] { - 10, - 0, - 0, - 65536}); - this.numPathEnd.Minimum = new System.Decimal(new int[] { - 155, - 0, - 0, - -2147352576}); - this.numPathEnd.Name = "numPathEnd"; - this.numPathEnd.Size = new System.Drawing.Size(80, 20); - this.numPathEnd.TabIndex = 3; - this.numPathEnd.Value = new System.Decimal(new int[] { - 1, - 0, - 0, - 0}); - // - // numMaterial - // - this.numMaterial.Location = new System.Drawing.Point(136, 48); - this.numMaterial.Maximum = new System.Decimal(new int[] { - 255, - 0, - 0, - 0}); - this.numMaterial.Name = "numMaterial"; - this.numMaterial.Size = new System.Drawing.Size(80, 20); - this.numMaterial.TabIndex = 1; - // - // txtName - // - this.txtName.Location = new System.Drawing.Point(136, 16); - this.txtName.Name = "txtName"; - this.txtName.Size = new System.Drawing.Size(176, 20); - this.txtName.TabIndex = 0; - this.txtName.Text = ""; - // - // label3 - // - this.label3.Location = new System.Drawing.Point(272, 536); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(32, 16); - this.label3.TabIndex = 129; - this.label3.Text = "Z:"; - // - // numPositionZ - // - this.numPositionZ.DecimalPlaces = 5; - this.numPositionZ.Location = new System.Drawing.Point(304, 536); - this.numPositionZ.Maximum = new System.Decimal(new int[] { - 256, - 0, - 0, - 0}); - this.numPositionZ.Name = "numPositionZ"; - this.numPositionZ.Size = new System.Drawing.Size(80, 20); - this.numPositionZ.TabIndex = 30; - // - // label2 - // - this.label2.Location = new System.Drawing.Point(144, 536); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(32, 16); - this.label2.TabIndex = 127; - this.label2.Text = "Y:"; - // - // numPositionY - // - this.numPositionY.DecimalPlaces = 5; - this.numPositionY.Location = new System.Drawing.Point(176, 536); - this.numPositionY.Maximum = new System.Decimal(new int[] { - 256, - 0, - 0, - 0}); - this.numPositionY.Name = "numPositionY"; - this.numPositionY.Size = new System.Drawing.Size(80, 20); - this.numPositionY.TabIndex = 29; - // - // label1 - // - this.label1.Location = new System.Drawing.Point(16, 536); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(32, 16); - this.label1.TabIndex = 125; - this.label1.Text = "X:"; - // - // numPositionX - // - this.numPositionX.DecimalPlaces = 5; - this.numPositionX.Location = new System.Drawing.Point(48, 536); - this.numPositionX.Maximum = new System.Decimal(new int[] { - 256, - 0, - 0, - 0}); - this.numPositionX.Name = "numPositionX"; - this.numPositionX.Size = new System.Drawing.Size(80, 20); - this.numPositionX.TabIndex = 28; - // - // label41 - // - this.label41.Location = new System.Drawing.Point(16, 512); - this.label41.Name = "label41"; - this.label41.Size = new System.Drawing.Size(120, 20); - this.label41.TabIndex = 130; - this.label41.Text = "Sim Position:"; - // - // frmPrimBuilder - // - this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); - this.ClientSize = new System.Drawing.Size(528, 573); - this.Controls.Add(this.label41); - this.Controls.Add(this.label3); - this.Controls.Add(this.numPositionZ); - this.Controls.Add(this.label2); - this.Controls.Add(this.numPositionY); - this.Controls.Add(this.label1); - this.Controls.Add(this.numPositionX); - this.Controls.Add(this.txtName); - this.Controls.Add(this.numMaterial); - this.Controls.Add(this.numPathEnd); - this.Controls.Add(this.numPathBegin); - this.Controls.Add(this.numPathRadiusOffset); - this.Controls.Add(this.numPathRevolutions); - this.Controls.Add(this.numPathScaleY); - this.Controls.Add(this.numPathScaleX); - this.Controls.Add(this.numPathSkew); - this.Controls.Add(this.numPathShearY); - this.Controls.Add(this.numPathShearX); - this.Controls.Add(this.numPathTaperY); - this.Controls.Add(this.numPathTaperX); - this.Controls.Add(this.numPathTwist); - this.Controls.Add(this.numPathTwistBegin); - this.Controls.Add(this.numProfileEnd); - this.Controls.Add(this.numProfileBegin); - this.Controls.Add(this.numProfileCurve); - this.Controls.Add(this.numPathCurve); - this.Controls.Add(this.numProfileHollow); - this.Controls.Add(this.label40); - this.Controls.Add(this.numRotationS); - this.Controls.Add(this.label37); - this.Controls.Add(this.numRotationZ); - this.Controls.Add(this.label38); - this.Controls.Add(this.numRotationY); - this.Controls.Add(this.label39); - this.Controls.Add(this.numRotationX); - this.Controls.Add(this.label34); - this.Controls.Add(this.numScaleZ); - this.Controls.Add(this.label35); - this.Controls.Add(this.numScaleY); - this.Controls.Add(this.label36); - this.Controls.Add(this.numScaleX); - this.Controls.Add(this.label33); - this.Controls.Add(this.label32); - this.Controls.Add(this.label31); - this.Controls.Add(this.label30); - this.Controls.Add(this.label29); - this.Controls.Add(this.label26); - this.Controls.Add(this.label27); - this.Controls.Add(this.label28); - this.Controls.Add(this.label23); - this.Controls.Add(this.label24); - this.Controls.Add(this.label25); - this.Controls.Add(this.label20); - this.Controls.Add(this.label21); - this.Controls.Add(this.label22); - this.Controls.Add(this.label19); - this.Controls.Add(this.label14); - this.Controls.Add(this.label15); - this.Controls.Add(this.label16); - this.Controls.Add(this.label13); - this.Controls.Add(this.label12); - this.Controls.Add(this.label11); - this.Controls.Add(this.label7); - this.Controls.Add(this.label10); - this.Controls.Add(this.label9); - this.Controls.Add(this.label8); - this.Controls.Add(this.label6); - this.Controls.Add(this.label5); - this.Controls.Add(this.label4); - this.Controls.Add(this.cmdBuild); - this.Name = "frmPrimBuilder"; - this.Text = "Prim Builder"; - ((System.ComponentModel.ISupportInitialize)(this.numScaleZ)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numScaleY)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numScaleX)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numRotationZ)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numRotationY)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numRotationX)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numRotationS)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numProfileHollow)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numPathCurve)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numProfileCurve)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numProfileBegin)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numProfileEnd)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numPathTwistBegin)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numPathTwist)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numPathTaperX)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numPathTaperY)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numPathShearX)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numPathShearY)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numPathSkew)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numPathScaleX)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numPathScaleY)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numPathRevolutions)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numPathRadiusOffset)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numPathBegin)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numPathEnd)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numMaterial)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numPositionZ)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numPositionY)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.numPositionX)).EndInit(); - this.ResumeLayout(false); - - } - #endregion - - private void cmdBuild_Click(object sender, System.EventArgs e) - { - cmdBuild.Enabled = false; - - PrimObject prim = new PrimObject(new LLUUID("8955674724cb43ed920b47caed15465f")); - - prim.Material = (uint)numMaterial.Value; - prim.PathBegin = PrimObject.PathBeginByte((float)numPathBegin.Value); - prim.PathEnd = PrimObject.PathEndByte((float)numPathEnd.Value); - prim.PathRadiusOffset = PrimObject.PathRadiusOffsetByte((float)numPathRadiusOffset.Value); - prim.PathRevolutions = PrimObject.PathRevolutionsByte((float)numPathRevolutions.Value); - prim.PathScaleX = PrimObject.PathScaleByte((float)numPathScaleX.Value); - prim.PathScaleY = PrimObject.PathScaleByte((float)numPathScaleY.Value); - prim.PathShearX = PrimObject.PathShearByte((float)numPathShearX.Value); - prim.PathShearY = PrimObject.PathShearByte((float)numPathShearY.Value); - prim.PathTaperX = PrimObject.PathTaperByte((float)numPathTaperX.Value); - prim.PathTaperY = PrimObject.PathTaperByte((float)numPathTaperY.Value); - prim.PathTwistBegin = PrimObject.PathTwistByte((float)numPathTwistBegin.Value); - prim.PathTwist = PrimObject.PathTwistByte((float)numPathTwist.Value); - prim.ProfileBegin = PrimObject.ProfileBeginByte((float)numProfileBegin.Value); - prim.ProfileEnd = PrimObject.ProfileEndByte((float)numProfileEnd.Value); - prim.PathSkew = PrimObject.PathSkewByte((float)numPathSkew.Value); - prim.ProfileCurve = (uint)numProfileCurve.Value; - prim.PathCurve = (uint)numPathCurve.Value; - prim.ProfileHollow = (uint)numProfileHollow.Value; - prim.Rotation.X = (float)numRotationX.Value; - prim.Rotation.Y = (float)numRotationY.Value; - prim.Rotation.Z = (float)numRotationZ.Value; - prim.Rotation.S = (float)numRotationS.Value; - prim.Scale.X = (float)numScaleX.Value; - prim.Scale.Y = (float)numScaleY.Value; - prim.Scale.Z = (float)numScaleZ.Value; - prim.Position.X = (float)numPositionX.Value; - prim.Position.Y = (float)numPositionY.Value; - prim.Position.Z = (float)numPositionZ.Value; - - Client.CurrentRegion.RezObject(prim, prim.Position, new LLVector3(Client.Avatar.Position)); - - // Rate limiting - System.Threading.Thread.Sleep(250); - - cmdBuild.Enabled = true; - } - } -} +using System; +using System.Drawing; +using System.Collections; +using System.ComponentModel; +using System.Windows.Forms; +using System.Data; +using libsecondlife; + +namespace SecondSuite.Plugins +{ + /// + /// Summary description for Form1. + /// + public class frmPrimBuilder : System.Windows.Forms.Form + { + private System.Windows.Forms.Button cmdBuild; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.Label label8; + private System.Windows.Forms.Label label9; + private System.Windows.Forms.Label label10; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.Label label11; + private System.Windows.Forms.Label label12; + private System.Windows.Forms.Label label13; + private System.Windows.Forms.Label label14; + private System.Windows.Forms.Label label15; + private System.Windows.Forms.Label label16; + private System.Windows.Forms.Label label19; + private System.Windows.Forms.Label label20; + private System.Windows.Forms.Label label21; + private System.Windows.Forms.Label label22; + private System.Windows.Forms.Label label23; + private System.Windows.Forms.Label label24; + private System.Windows.Forms.Label label25; + private System.Windows.Forms.Label label28; + private System.Windows.Forms.Label label26; + private System.Windows.Forms.Label label27; + private System.Windows.Forms.Label label29; + private System.Windows.Forms.Label label30; + private System.Windows.Forms.Label label31; + private System.Windows.Forms.Label label32; + private System.Windows.Forms.Label label33; + private System.Windows.Forms.Label label34; + private System.Windows.Forms.NumericUpDown numScaleZ; + private System.Windows.Forms.Label label35; + private System.Windows.Forms.NumericUpDown numScaleY; + private System.Windows.Forms.Label label36; + private System.Windows.Forms.NumericUpDown numScaleX; + private System.Windows.Forms.Label label37; + private System.Windows.Forms.NumericUpDown numRotationZ; + private System.Windows.Forms.Label label38; + private System.Windows.Forms.NumericUpDown numRotationY; + private System.Windows.Forms.Label label39; + private System.Windows.Forms.NumericUpDown numRotationX; + private System.Windows.Forms.Label label40; + private System.Windows.Forms.NumericUpDown numRotationS; + private System.Windows.Forms.NumericUpDown numProfileHollow; + private System.Windows.Forms.NumericUpDown numPathCurve; + private System.Windows.Forms.NumericUpDown numProfileCurve; + private System.Windows.Forms.NumericUpDown numProfileBegin; + private System.Windows.Forms.NumericUpDown numProfileEnd; + private System.Windows.Forms.NumericUpDown numPathTwistBegin; + private System.Windows.Forms.NumericUpDown numPathTwist; + private System.Windows.Forms.NumericUpDown numPathTaperX; + private System.Windows.Forms.NumericUpDown numPathTaperY; + private System.Windows.Forms.NumericUpDown numPathShearX; + private System.Windows.Forms.NumericUpDown numPathShearY; + private System.Windows.Forms.NumericUpDown numPathScaleX; + private System.Windows.Forms.NumericUpDown numPathScaleY; + private System.Windows.Forms.NumericUpDown numPathRevolutions; + private System.Windows.Forms.NumericUpDown numPathRadiusOffset; + private System.Windows.Forms.NumericUpDown numPathBegin; + private System.Windows.Forms.NumericUpDown numPathEnd; + private System.Windows.Forms.NumericUpDown numMaterial; + private System.Windows.Forms.TextBox txtName; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.NumericUpDown numPositionZ; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.NumericUpDown numPositionY; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.NumericUpDown numPositionX; + private System.Windows.Forms.Label label41; + private System.Windows.Forms.NumericUpDown numPathSkew; + /// + /// Required designer variable. + /// + private System.ComponentModel.Container components = null; + + // + SecondLife Client; + + public frmPrimBuilder(SecondLife client) + { + // + // Required for Windows Form Designer support + // + InitializeComponent(); + + Client = client; + Client.Network.RegisterCallback("CoarseLocationUpdate", new PacketCallback(LocationHandler)); + } + + private void LocationHandler(Packet packet, Simulator simulator) + { + if (numPositionX.Value == 0) + { + numPositionX.Value = (decimal)Client.Avatar.Position.X; + } + + if (numPositionY.Value == 0) + { + numPositionY.Value = (decimal)Client.Avatar.Position.Y; + } + + if (numPositionZ.Value == 0) + { + numPositionZ.Value = (decimal)Client.Avatar.Position.Z; + } + } + + public void Connected() + { + ; + } + + /// + /// Clean up any resources being used. + /// + protected override void Dispose( bool disposing ) + { + if( disposing ) + { + if (components != null) + { + components.Dispose(); + } + } + base.Dispose( disposing ); + } + + #region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.cmdBuild = new System.Windows.Forms.Button(); + this.label4 = new System.Windows.Forms.Label(); + this.label5 = new System.Windows.Forms.Label(); + this.label6 = new System.Windows.Forms.Label(); + this.label8 = new System.Windows.Forms.Label(); + this.label9 = new System.Windows.Forms.Label(); + this.label10 = new System.Windows.Forms.Label(); + this.label7 = new System.Windows.Forms.Label(); + this.label11 = new System.Windows.Forms.Label(); + this.label12 = new System.Windows.Forms.Label(); + this.label13 = new System.Windows.Forms.Label(); + this.label14 = new System.Windows.Forms.Label(); + this.label15 = new System.Windows.Forms.Label(); + this.label16 = new System.Windows.Forms.Label(); + this.label19 = new System.Windows.Forms.Label(); + this.label20 = new System.Windows.Forms.Label(); + this.label21 = new System.Windows.Forms.Label(); + this.label22 = new System.Windows.Forms.Label(); + this.label23 = new System.Windows.Forms.Label(); + this.label24 = new System.Windows.Forms.Label(); + this.label25 = new System.Windows.Forms.Label(); + this.label28 = new System.Windows.Forms.Label(); + this.label26 = new System.Windows.Forms.Label(); + this.label27 = new System.Windows.Forms.Label(); + this.label29 = new System.Windows.Forms.Label(); + this.label30 = new System.Windows.Forms.Label(); + this.label31 = new System.Windows.Forms.Label(); + this.label32 = new System.Windows.Forms.Label(); + this.label33 = new System.Windows.Forms.Label(); + this.label34 = new System.Windows.Forms.Label(); + this.numScaleZ = new System.Windows.Forms.NumericUpDown(); + this.label35 = new System.Windows.Forms.Label(); + this.numScaleY = new System.Windows.Forms.NumericUpDown(); + this.label36 = new System.Windows.Forms.Label(); + this.numScaleX = new System.Windows.Forms.NumericUpDown(); + this.label37 = new System.Windows.Forms.Label(); + this.numRotationZ = new System.Windows.Forms.NumericUpDown(); + this.label38 = new System.Windows.Forms.Label(); + this.numRotationY = new System.Windows.Forms.NumericUpDown(); + this.label39 = new System.Windows.Forms.Label(); + this.numRotationX = new System.Windows.Forms.NumericUpDown(); + this.label40 = new System.Windows.Forms.Label(); + this.numRotationS = new System.Windows.Forms.NumericUpDown(); + this.numProfileHollow = new System.Windows.Forms.NumericUpDown(); + this.numPathCurve = new System.Windows.Forms.NumericUpDown(); + this.numProfileCurve = new System.Windows.Forms.NumericUpDown(); + this.numProfileBegin = new System.Windows.Forms.NumericUpDown(); + this.numProfileEnd = new System.Windows.Forms.NumericUpDown(); + this.numPathTwistBegin = new System.Windows.Forms.NumericUpDown(); + this.numPathTwist = new System.Windows.Forms.NumericUpDown(); + this.numPathTaperX = new System.Windows.Forms.NumericUpDown(); + this.numPathTaperY = new System.Windows.Forms.NumericUpDown(); + this.numPathShearX = new System.Windows.Forms.NumericUpDown(); + this.numPathShearY = new System.Windows.Forms.NumericUpDown(); + this.numPathSkew = new System.Windows.Forms.NumericUpDown(); + this.numPathScaleX = new System.Windows.Forms.NumericUpDown(); + this.numPathScaleY = new System.Windows.Forms.NumericUpDown(); + this.numPathRevolutions = new System.Windows.Forms.NumericUpDown(); + this.numPathRadiusOffset = new System.Windows.Forms.NumericUpDown(); + this.numPathBegin = new System.Windows.Forms.NumericUpDown(); + this.numPathEnd = new System.Windows.Forms.NumericUpDown(); + this.numMaterial = new System.Windows.Forms.NumericUpDown(); + this.txtName = new System.Windows.Forms.TextBox(); + this.label3 = new System.Windows.Forms.Label(); + this.numPositionZ = new System.Windows.Forms.NumericUpDown(); + this.label2 = new System.Windows.Forms.Label(); + this.numPositionY = new System.Windows.Forms.NumericUpDown(); + this.label1 = new System.Windows.Forms.Label(); + this.numPositionX = new System.Windows.Forms.NumericUpDown(); + this.label41 = new System.Windows.Forms.Label(); + ((System.ComponentModel.ISupportInitialize)(this.numScaleZ)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numScaleY)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numScaleX)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numRotationZ)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numRotationY)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numRotationX)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numRotationS)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numProfileHollow)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numPathCurve)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numProfileCurve)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numProfileBegin)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numProfileEnd)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numPathTwistBegin)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numPathTwist)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numPathTaperX)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numPathTaperY)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numPathShearX)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numPathShearY)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numPathSkew)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numPathScaleX)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numPathScaleY)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numPathRevolutions)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numPathRadiusOffset)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numPathBegin)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numPathEnd)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numMaterial)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numPositionZ)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numPositionY)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numPositionX)).BeginInit(); + this.SuspendLayout(); + // + // cmdBuild + // + this.cmdBuild.Location = new System.Drawing.Point(408, 536); + this.cmdBuild.Name = "cmdBuild"; + this.cmdBuild.Size = new System.Drawing.Size(104, 24); + this.cmdBuild.TabIndex = 31; + this.cmdBuild.Text = "Build Prim"; + this.cmdBuild.Click += new System.EventHandler(this.cmdBuild_Click); + // + // label4 + // + this.label4.Location = new System.Drawing.Point(16, 16); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(120, 20); + this.label4.TabIndex = 58; + this.label4.Text = "Name:"; + // + // label5 + // + this.label5.Location = new System.Drawing.Point(16, 48); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(120, 20); + this.label5.TabIndex = 59; + this.label5.Text = "Material:"; + // + // label6 + // + this.label6.Location = new System.Drawing.Point(16, 80); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(120, 20); + this.label6.TabIndex = 60; + this.label6.Text = "Path:"; + // + // label8 + // + this.label8.Location = new System.Drawing.Point(16, 112); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(120, 20); + this.label8.TabIndex = 62; + this.label8.Text = "Path Radius Offset:"; + // + // label9 + // + this.label9.Location = new System.Drawing.Point(16, 144); + this.label9.Name = "label9"; + this.label9.Size = new System.Drawing.Size(120, 20); + this.label9.TabIndex = 63; + this.label9.Text = "Path Revolutions:"; + // + // label10 + // + this.label10.Location = new System.Drawing.Point(16, 176); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(120, 20); + this.label10.TabIndex = 64; + this.label10.Text = "Path Scale:"; + // + // label7 + // + this.label7.Location = new System.Drawing.Point(136, 80); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(96, 20); + this.label7.TabIndex = 65; + this.label7.Text = "Begin:"; + // + // label11 + // + this.label11.Location = new System.Drawing.Point(328, 80); + this.label11.Name = "label11"; + this.label11.Size = new System.Drawing.Size(80, 20); + this.label11.TabIndex = 66; + this.label11.Text = "End:"; + // + // label12 + // + this.label12.Location = new System.Drawing.Point(136, 176); + this.label12.Name = "label12"; + this.label12.Size = new System.Drawing.Size(96, 20); + this.label12.TabIndex = 67; + this.label12.Text = "X:"; + // + // label13 + // + this.label13.Location = new System.Drawing.Point(328, 176); + this.label13.Name = "label13"; + this.label13.Size = new System.Drawing.Size(80, 20); + this.label13.TabIndex = 68; + this.label13.Text = "Y:"; + // + // label14 + // + this.label14.Location = new System.Drawing.Point(328, 208); + this.label14.Name = "label14"; + this.label14.Size = new System.Drawing.Size(80, 20); + this.label14.TabIndex = 71; + this.label14.Text = "Y:"; + // + // label15 + // + this.label15.Location = new System.Drawing.Point(136, 208); + this.label15.Name = "label15"; + this.label15.Size = new System.Drawing.Size(96, 20); + this.label15.TabIndex = 70; + this.label15.Text = "X:"; + // + // label16 + // + this.label16.Location = new System.Drawing.Point(16, 208); + this.label16.Name = "label16"; + this.label16.Size = new System.Drawing.Size(120, 20); + this.label16.TabIndex = 69; + this.label16.Text = "Path Shear:"; + // + // label19 + // + this.label19.Location = new System.Drawing.Point(16, 336); + this.label19.Name = "label19"; + this.label19.Size = new System.Drawing.Size(120, 20); + this.label19.TabIndex = 72; + this.label19.Text = "Path Skew:"; + // + // label20 + // + this.label20.Location = new System.Drawing.Point(328, 240); + this.label20.Name = "label20"; + this.label20.Size = new System.Drawing.Size(80, 20); + this.label20.TabIndex = 77; + this.label20.Text = "Y:"; + // + // label21 + // + this.label21.Location = new System.Drawing.Point(136, 240); + this.label21.Name = "label21"; + this.label21.Size = new System.Drawing.Size(96, 20); + this.label21.TabIndex = 76; + this.label21.Text = "X:"; + // + // label22 + // + this.label22.Location = new System.Drawing.Point(16, 240); + this.label22.Name = "label22"; + this.label22.Size = new System.Drawing.Size(120, 20); + this.label22.TabIndex = 75; + this.label22.Text = "Path Taper:"; + // + // label23 + // + this.label23.Location = new System.Drawing.Point(328, 272); + this.label23.Name = "label23"; + this.label23.Size = new System.Drawing.Size(80, 20); + this.label23.TabIndex = 80; + this.label23.Text = "Path Twist:"; + // + // label24 + // + this.label24.Location = new System.Drawing.Point(136, 272); + this.label24.Name = "label24"; + this.label24.Size = new System.Drawing.Size(96, 20); + this.label24.TabIndex = 79; + this.label24.Text = "Path Twist Begin:"; + // + // label25 + // + this.label25.Location = new System.Drawing.Point(16, 272); + this.label25.Name = "label25"; + this.label25.Size = new System.Drawing.Size(120, 20); + this.label25.TabIndex = 78; + this.label25.Text = "Twist:"; + // + // label28 + // + this.label28.Location = new System.Drawing.Point(16, 304); + this.label28.Name = "label28"; + this.label28.Size = new System.Drawing.Size(120, 20); + this.label28.TabIndex = 81; + this.label28.Text = "Profile:"; + // + // label26 + // + this.label26.Location = new System.Drawing.Point(328, 304); + this.label26.Name = "label26"; + this.label26.Size = new System.Drawing.Size(80, 20); + this.label26.TabIndex = 83; + this.label26.Text = "End:"; + // + // label27 + // + this.label27.Location = new System.Drawing.Point(136, 304); + this.label27.Name = "label27"; + this.label27.Size = new System.Drawing.Size(96, 20); + this.label27.TabIndex = 82; + this.label27.Text = "Begin:"; + // + // label29 + // + this.label29.Location = new System.Drawing.Point(288, 336); + this.label29.Name = "label29"; + this.label29.Size = new System.Drawing.Size(120, 20); + this.label29.TabIndex = 84; + this.label29.Text = "Profile Curve:"; + // + // label30 + // + this.label30.Location = new System.Drawing.Point(16, 368); + this.label30.Name = "label30"; + this.label30.Size = new System.Drawing.Size(120, 20); + this.label30.TabIndex = 85; + this.label30.Text = "Path Curve:"; + // + // label31 + // + this.label31.Location = new System.Drawing.Point(288, 368); + this.label31.Name = "label31"; + this.label31.Size = new System.Drawing.Size(120, 20); + this.label31.TabIndex = 86; + this.label31.Text = "Profile Hollow:"; + // + // label32 + // + this.label32.Location = new System.Drawing.Point(16, 400); + this.label32.Name = "label32"; + this.label32.Size = new System.Drawing.Size(120, 16); + this.label32.TabIndex = 87; + this.label32.Text = "Rotation:"; + // + // label33 + // + this.label33.Location = new System.Drawing.Point(16, 456); + this.label33.Name = "label33"; + this.label33.Size = new System.Drawing.Size(120, 20); + this.label33.TabIndex = 88; + this.label33.Text = "Scale:"; + // + // label34 + // + this.label34.Location = new System.Drawing.Point(272, 480); + this.label34.Name = "label34"; + this.label34.Size = new System.Drawing.Size(32, 20); + this.label34.TabIndex = 94; + this.label34.Text = "Z:"; + // + // numScaleZ + // + this.numScaleZ.DecimalPlaces = 5; + this.numScaleZ.Location = new System.Drawing.Point(304, 480); + this.numScaleZ.Maximum = new System.Decimal(new int[] { + 256, + 0, + 0, + 0}); + this.numScaleZ.Minimum = new System.Decimal(new int[] { + 10, + 0, + 0, + -2147483648}); + this.numScaleZ.Name = "numScaleZ"; + this.numScaleZ.Size = new System.Drawing.Size(80, 20); + this.numScaleZ.TabIndex = 27; + this.numScaleZ.Value = new System.Decimal(new int[] { + 5, + 0, + 0, + 65536}); + // + // label35 + // + this.label35.Location = new System.Drawing.Point(144, 480); + this.label35.Name = "label35"; + this.label35.Size = new System.Drawing.Size(32, 20); + this.label35.TabIndex = 92; + this.label35.Text = "Y:"; + // + // numScaleY + // + this.numScaleY.DecimalPlaces = 5; + this.numScaleY.Location = new System.Drawing.Point(176, 480); + this.numScaleY.Maximum = new System.Decimal(new int[] { + 256, + 0, + 0, + 0}); + this.numScaleY.Name = "numScaleY"; + this.numScaleY.Size = new System.Drawing.Size(80, 20); + this.numScaleY.TabIndex = 26; + this.numScaleY.Value = new System.Decimal(new int[] { + 5, + 0, + 0, + 65536}); + // + // label36 + // + this.label36.Location = new System.Drawing.Point(16, 480); + this.label36.Name = "label36"; + this.label36.Size = new System.Drawing.Size(32, 20); + this.label36.TabIndex = 90; + this.label36.Text = "X:"; + // + // numScaleX + // + this.numScaleX.DecimalPlaces = 5; + this.numScaleX.Location = new System.Drawing.Point(48, 480); + this.numScaleX.Maximum = new System.Decimal(new int[] { + 256, + 0, + 0, + 0}); + this.numScaleX.Name = "numScaleX"; + this.numScaleX.Size = new System.Drawing.Size(80, 20); + this.numScaleX.TabIndex = 25; + this.numScaleX.Value = new System.Decimal(new int[] { + 5, + 0, + 0, + 65536}); + // + // label37 + // + this.label37.Location = new System.Drawing.Point(272, 424); + this.label37.Name = "label37"; + this.label37.Size = new System.Drawing.Size(32, 20); + this.label37.TabIndex = 100; + this.label37.Text = "Z:"; + // + // numRotationZ + // + this.numRotationZ.DecimalPlaces = 5; + this.numRotationZ.Location = new System.Drawing.Point(304, 424); + this.numRotationZ.Maximum = new System.Decimal(new int[] { + 256, + 0, + 0, + 0}); + this.numRotationZ.Name = "numRotationZ"; + this.numRotationZ.Size = new System.Drawing.Size(80, 20); + this.numRotationZ.TabIndex = 23; + // + // label38 + // + this.label38.Location = new System.Drawing.Point(144, 424); + this.label38.Name = "label38"; + this.label38.Size = new System.Drawing.Size(32, 20); + this.label38.TabIndex = 98; + this.label38.Text = "Y:"; + // + // numRotationY + // + this.numRotationY.DecimalPlaces = 5; + this.numRotationY.Location = new System.Drawing.Point(176, 424); + this.numRotationY.Maximum = new System.Decimal(new int[] { + 256, + 0, + 0, + 0}); + this.numRotationY.Name = "numRotationY"; + this.numRotationY.Size = new System.Drawing.Size(80, 20); + this.numRotationY.TabIndex = 22; + // + // label39 + // + this.label39.Location = new System.Drawing.Point(16, 424); + this.label39.Name = "label39"; + this.label39.Size = new System.Drawing.Size(32, 20); + this.label39.TabIndex = 96; + this.label39.Text = "X:"; + // + // numRotationX + // + this.numRotationX.DecimalPlaces = 5; + this.numRotationX.Location = new System.Drawing.Point(48, 424); + this.numRotationX.Maximum = new System.Decimal(new int[] { + 256, + 0, + 0, + 0}); + this.numRotationX.Name = "numRotationX"; + this.numRotationX.Size = new System.Drawing.Size(80, 20); + this.numRotationX.TabIndex = 21; + // + // label40 + // + this.label40.Location = new System.Drawing.Point(400, 424); + this.label40.Name = "label40"; + this.label40.Size = new System.Drawing.Size(32, 20); + this.label40.TabIndex = 102; + this.label40.Text = "S:"; + // + // numRotationS + // + this.numRotationS.DecimalPlaces = 5; + this.numRotationS.Location = new System.Drawing.Point(432, 424); + this.numRotationS.Maximum = new System.Decimal(new int[] { + 256, + 0, + 0, + 0}); + this.numRotationS.Name = "numRotationS"; + this.numRotationS.Size = new System.Drawing.Size(80, 20); + this.numRotationS.TabIndex = 24; + // + // numProfileHollow + // + this.numProfileHollow.Location = new System.Drawing.Point(408, 368); + this.numProfileHollow.Maximum = new System.Decimal(new int[] { + 255, + 0, + 0, + 0}); + this.numProfileHollow.Name = "numProfileHollow"; + this.numProfileHollow.Size = new System.Drawing.Size(80, 20); + this.numProfileHollow.TabIndex = 20; + // + // numPathCurve + // + this.numPathCurve.Location = new System.Drawing.Point(136, 368); + this.numPathCurve.Maximum = new System.Decimal(new int[] { + 255, + 0, + 0, + 0}); + this.numPathCurve.Name = "numPathCurve"; + this.numPathCurve.Size = new System.Drawing.Size(80, 20); + this.numPathCurve.TabIndex = 19; + this.numPathCurve.Value = new System.Decimal(new int[] { + 16, + 0, + 0, + 0}); + // + // numProfileCurve + // + this.numProfileCurve.Location = new System.Drawing.Point(408, 336); + this.numProfileCurve.Maximum = new System.Decimal(new int[] { + 5, + 0, + 0, + 0}); + this.numProfileCurve.Name = "numProfileCurve"; + this.numProfileCurve.Size = new System.Drawing.Size(80, 20); + this.numProfileCurve.TabIndex = 18; + this.numProfileCurve.Value = new System.Decimal(new int[] { + 1, + 0, + 0, + 0}); + // + // numProfileBegin + // + this.numProfileBegin.Location = new System.Drawing.Point(232, 304); + this.numProfileBegin.Maximum = new System.Decimal(new int[] { + 1275, + 0, + 0, + 196608}); + this.numProfileBegin.Name = "numProfileBegin"; + this.numProfileBegin.Size = new System.Drawing.Size(80, 20); + this.numProfileBegin.TabIndex = 16; + // + // numProfileEnd + // + this.numProfileEnd.Location = new System.Drawing.Point(408, 304); + this.numProfileEnd.Maximum = new System.Decimal(new int[] { + 5, + 0, + 0, + 0}); + this.numProfileEnd.Minimum = new System.Decimal(new int[] { + 275, + 0, + 0, + -2147287040}); + this.numProfileEnd.Name = "numProfileEnd"; + this.numProfileEnd.Size = new System.Drawing.Size(80, 20); + this.numProfileEnd.TabIndex = 17; + // + // numPathTwistBegin + // + this.numPathTwistBegin.Location = new System.Drawing.Point(232, 272); + this.numPathTwistBegin.Maximum = new System.Decimal(new int[] { + 459, + 0, + 0, + 0}); + this.numPathTwistBegin.Minimum = new System.Decimal(new int[] { + 459, + 0, + 0, + -2147483648}); + this.numPathTwistBegin.Name = "numPathTwistBegin"; + this.numPathTwistBegin.Size = new System.Drawing.Size(80, 20); + this.numPathTwistBegin.TabIndex = 14; + // + // numPathTwist + // + this.numPathTwist.Location = new System.Drawing.Point(408, 272); + this.numPathTwist.Maximum = new System.Decimal(new int[] { + 459, + 0, + 0, + 0}); + this.numPathTwist.Minimum = new System.Decimal(new int[] { + 459, + 0, + 0, + -2147483648}); + this.numPathTwist.Name = "numPathTwist"; + this.numPathTwist.Size = new System.Drawing.Size(80, 20); + this.numPathTwist.TabIndex = 15; + // + // numPathTaperX + // + this.numPathTaperX.DecimalPlaces = 2; + this.numPathTaperX.Increment = new System.Decimal(new int[] { + 1, + 0, + 0, + 65536}); + this.numPathTaperX.Location = new System.Drawing.Point(232, 240); + this.numPathTaperX.Maximum = new System.Decimal(new int[] { + 255, + 0, + 0, + 131072}); + this.numPathTaperX.Minimum = new System.Decimal(new int[] { + 255, + 0, + 0, + -2147352576}); + this.numPathTaperX.Name = "numPathTaperX"; + this.numPathTaperX.Size = new System.Drawing.Size(80, 20); + this.numPathTaperX.TabIndex = 12; + // + // numPathTaperY + // + this.numPathTaperY.DecimalPlaces = 2; + this.numPathTaperY.Increment = new System.Decimal(new int[] { + 1, + 0, + 0, + 65536}); + this.numPathTaperY.Location = new System.Drawing.Point(408, 240); + this.numPathTaperY.Maximum = new System.Decimal(new int[] { + 255, + 0, + 0, + 131072}); + this.numPathTaperY.Minimum = new System.Decimal(new int[] { + 255, + 0, + 0, + -2147352576}); + this.numPathTaperY.Name = "numPathTaperY"; + this.numPathTaperY.Size = new System.Drawing.Size(80, 20); + this.numPathTaperY.TabIndex = 13; + // + // numPathShearX + // + this.numPathShearX.DecimalPlaces = 2; + this.numPathShearX.Increment = new System.Decimal(new int[] { + 1, + 0, + 0, + 65536}); + this.numPathShearX.Location = new System.Drawing.Point(232, 208); + this.numPathShearX.Maximum = new System.Decimal(new int[] { + 255, + 0, + 0, + 131072}); + this.numPathShearX.Minimum = new System.Decimal(new int[] { + 255, + 0, + 0, + -2147352576}); + this.numPathShearX.Name = "numPathShearX"; + this.numPathShearX.Size = new System.Drawing.Size(80, 20); + this.numPathShearX.TabIndex = 8; + // + // numPathShearY + // + this.numPathShearY.DecimalPlaces = 2; + this.numPathShearY.Increment = new System.Decimal(new int[] { + 1, + 0, + 0, + 65536}); + this.numPathShearY.Location = new System.Drawing.Point(408, 208); + this.numPathShearY.Maximum = new System.Decimal(new int[] { + 255, + 0, + 0, + 131072}); + this.numPathShearY.Minimum = new System.Decimal(new int[] { + 255, + 0, + 0, + -2147352576}); + this.numPathShearY.Name = "numPathShearY"; + this.numPathShearY.Size = new System.Drawing.Size(80, 20); + this.numPathShearY.TabIndex = 9; + // + // numPathSkew + // + this.numPathSkew.DecimalPlaces = 2; + this.numPathSkew.Increment = new System.Decimal(new int[] { + 1, + 0, + 0, + 65536}); + this.numPathSkew.Location = new System.Drawing.Point(136, 336); + this.numPathSkew.Maximum = new System.Decimal(new int[] { + 255, + 0, + 0, + 131072}); + this.numPathSkew.Minimum = new System.Decimal(new int[] { + 255, + 0, + 0, + -2147352576}); + this.numPathSkew.Name = "numPathSkew"; + this.numPathSkew.Size = new System.Drawing.Size(80, 20); + this.numPathSkew.TabIndex = 10; + // + // numPathScaleX + // + this.numPathScaleX.DecimalPlaces = 2; + this.numPathScaleX.Increment = new System.Decimal(new int[] { + 1, + 0, + 0, + 65536}); + this.numPathScaleX.Location = new System.Drawing.Point(232, 176); + this.numPathScaleX.Maximum = new System.Decimal(new int[] { + 155, + 0, + 0, + 131072}); + this.numPathScaleX.Name = "numPathScaleX"; + this.numPathScaleX.Size = new System.Drawing.Size(80, 20); + this.numPathScaleX.TabIndex = 6; + // + // numPathScaleY + // + this.numPathScaleY.DecimalPlaces = 2; + this.numPathScaleY.Increment = new System.Decimal(new int[] { + 1, + 0, + 0, + 65536}); + this.numPathScaleY.Location = new System.Drawing.Point(408, 176); + this.numPathScaleY.Maximum = new System.Decimal(new int[] { + 155, + 0, + 0, + 131072}); + this.numPathScaleY.Name = "numPathScaleY"; + this.numPathScaleY.Size = new System.Drawing.Size(80, 20); + this.numPathScaleY.TabIndex = 7; + // + // numPathRevolutions + // + this.numPathRevolutions.DecimalPlaces = 2; + this.numPathRevolutions.Increment = new System.Decimal(new int[] { + 1, + 0, + 0, + 65536}); + this.numPathRevolutions.Location = new System.Drawing.Point(136, 144); + this.numPathRevolutions.Maximum = new System.Decimal(new int[] { + 486, + 0, + 0, + 131072}); + this.numPathRevolutions.Name = "numPathRevolutions"; + this.numPathRevolutions.Size = new System.Drawing.Size(80, 20); + this.numPathRevolutions.TabIndex = 5; + this.numPathRevolutions.Value = new System.Decimal(new int[] { + 100, + 0, + 0, + 131072}); + // + // numPathRadiusOffset + // + this.numPathRadiusOffset.DecimalPlaces = 3; + this.numPathRadiusOffset.Increment = new System.Decimal(new int[] { + 1, + 0, + 0, + 65536}); + this.numPathRadiusOffset.Location = new System.Drawing.Point(136, 112); + this.numPathRadiusOffset.Maximum = new System.Decimal(new int[] { + 255, + 0, + 0, + 131072}); + this.numPathRadiusOffset.Minimum = new System.Decimal(new int[] { + 255, + 0, + 0, + -2147352576}); + this.numPathRadiusOffset.Name = "numPathRadiusOffset"; + this.numPathRadiusOffset.Size = new System.Drawing.Size(80, 20); + this.numPathRadiusOffset.TabIndex = 4; + // + // numPathBegin + // + this.numPathBegin.DecimalPlaces = 2; + this.numPathBegin.Increment = new System.Decimal(new int[] { + 1, + 0, + 0, + 65536}); + this.numPathBegin.Location = new System.Drawing.Point(232, 80); + this.numPathBegin.Maximum = new System.Decimal(new int[] { + 255, + 0, + 0, + 131072}); + this.numPathBegin.Name = "numPathBegin"; + this.numPathBegin.Size = new System.Drawing.Size(80, 20); + this.numPathBegin.TabIndex = 2; + // + // numPathEnd + // + this.numPathEnd.DecimalPlaces = 2; + this.numPathEnd.Increment = new System.Decimal(new int[] { + 1, + 0, + 0, + 65536}); + this.numPathEnd.Location = new System.Drawing.Point(408, 80); + this.numPathEnd.Maximum = new System.Decimal(new int[] { + 10, + 0, + 0, + 65536}); + this.numPathEnd.Minimum = new System.Decimal(new int[] { + 155, + 0, + 0, + -2147352576}); + this.numPathEnd.Name = "numPathEnd"; + this.numPathEnd.Size = new System.Drawing.Size(80, 20); + this.numPathEnd.TabIndex = 3; + this.numPathEnd.Value = new System.Decimal(new int[] { + 1, + 0, + 0, + 0}); + // + // numMaterial + // + this.numMaterial.Location = new System.Drawing.Point(136, 48); + this.numMaterial.Maximum = new System.Decimal(new int[] { + 255, + 0, + 0, + 0}); + this.numMaterial.Name = "numMaterial"; + this.numMaterial.Size = new System.Drawing.Size(80, 20); + this.numMaterial.TabIndex = 1; + // + // txtName + // + this.txtName.Location = new System.Drawing.Point(136, 16); + this.txtName.Name = "txtName"; + this.txtName.Size = new System.Drawing.Size(176, 20); + this.txtName.TabIndex = 0; + this.txtName.Text = ""; + // + // label3 + // + this.label3.Location = new System.Drawing.Point(272, 536); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(32, 16); + this.label3.TabIndex = 129; + this.label3.Text = "Z:"; + // + // numPositionZ + // + this.numPositionZ.DecimalPlaces = 5; + this.numPositionZ.Location = new System.Drawing.Point(304, 536); + this.numPositionZ.Maximum = new System.Decimal(new int[] { + 256, + 0, + 0, + 0}); + this.numPositionZ.Name = "numPositionZ"; + this.numPositionZ.Size = new System.Drawing.Size(80, 20); + this.numPositionZ.TabIndex = 30; + // + // label2 + // + this.label2.Location = new System.Drawing.Point(144, 536); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(32, 16); + this.label2.TabIndex = 127; + this.label2.Text = "Y:"; + // + // numPositionY + // + this.numPositionY.DecimalPlaces = 5; + this.numPositionY.Location = new System.Drawing.Point(176, 536); + this.numPositionY.Maximum = new System.Decimal(new int[] { + 256, + 0, + 0, + 0}); + this.numPositionY.Name = "numPositionY"; + this.numPositionY.Size = new System.Drawing.Size(80, 20); + this.numPositionY.TabIndex = 29; + // + // label1 + // + this.label1.Location = new System.Drawing.Point(16, 536); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(32, 16); + this.label1.TabIndex = 125; + this.label1.Text = "X:"; + // + // numPositionX + // + this.numPositionX.DecimalPlaces = 5; + this.numPositionX.Location = new System.Drawing.Point(48, 536); + this.numPositionX.Maximum = new System.Decimal(new int[] { + 256, + 0, + 0, + 0}); + this.numPositionX.Name = "numPositionX"; + this.numPositionX.Size = new System.Drawing.Size(80, 20); + this.numPositionX.TabIndex = 28; + // + // label41 + // + this.label41.Location = new System.Drawing.Point(16, 512); + this.label41.Name = "label41"; + this.label41.Size = new System.Drawing.Size(120, 20); + this.label41.TabIndex = 130; + this.label41.Text = "Sim Position:"; + // + // frmPrimBuilder + // + this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); + this.ClientSize = new System.Drawing.Size(528, 573); + this.Controls.Add(this.label41); + this.Controls.Add(this.label3); + this.Controls.Add(this.numPositionZ); + this.Controls.Add(this.label2); + this.Controls.Add(this.numPositionY); + this.Controls.Add(this.label1); + this.Controls.Add(this.numPositionX); + this.Controls.Add(this.txtName); + this.Controls.Add(this.numMaterial); + this.Controls.Add(this.numPathEnd); + this.Controls.Add(this.numPathBegin); + this.Controls.Add(this.numPathRadiusOffset); + this.Controls.Add(this.numPathRevolutions); + this.Controls.Add(this.numPathScaleY); + this.Controls.Add(this.numPathScaleX); + this.Controls.Add(this.numPathSkew); + this.Controls.Add(this.numPathShearY); + this.Controls.Add(this.numPathShearX); + this.Controls.Add(this.numPathTaperY); + this.Controls.Add(this.numPathTaperX); + this.Controls.Add(this.numPathTwist); + this.Controls.Add(this.numPathTwistBegin); + this.Controls.Add(this.numProfileEnd); + this.Controls.Add(this.numProfileBegin); + this.Controls.Add(this.numProfileCurve); + this.Controls.Add(this.numPathCurve); + this.Controls.Add(this.numProfileHollow); + this.Controls.Add(this.label40); + this.Controls.Add(this.numRotationS); + this.Controls.Add(this.label37); + this.Controls.Add(this.numRotationZ); + this.Controls.Add(this.label38); + this.Controls.Add(this.numRotationY); + this.Controls.Add(this.label39); + this.Controls.Add(this.numRotationX); + this.Controls.Add(this.label34); + this.Controls.Add(this.numScaleZ); + this.Controls.Add(this.label35); + this.Controls.Add(this.numScaleY); + this.Controls.Add(this.label36); + this.Controls.Add(this.numScaleX); + this.Controls.Add(this.label33); + this.Controls.Add(this.label32); + this.Controls.Add(this.label31); + this.Controls.Add(this.label30); + this.Controls.Add(this.label29); + this.Controls.Add(this.label26); + this.Controls.Add(this.label27); + this.Controls.Add(this.label28); + this.Controls.Add(this.label23); + this.Controls.Add(this.label24); + this.Controls.Add(this.label25); + this.Controls.Add(this.label20); + this.Controls.Add(this.label21); + this.Controls.Add(this.label22); + this.Controls.Add(this.label19); + this.Controls.Add(this.label14); + this.Controls.Add(this.label15); + this.Controls.Add(this.label16); + this.Controls.Add(this.label13); + this.Controls.Add(this.label12); + this.Controls.Add(this.label11); + this.Controls.Add(this.label7); + this.Controls.Add(this.label10); + this.Controls.Add(this.label9); + this.Controls.Add(this.label8); + this.Controls.Add(this.label6); + this.Controls.Add(this.label5); + this.Controls.Add(this.label4); + this.Controls.Add(this.cmdBuild); + this.Name = "frmPrimBuilder"; + this.Text = "Prim Builder"; + ((System.ComponentModel.ISupportInitialize)(this.numScaleZ)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numScaleY)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numScaleX)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numRotationZ)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numRotationY)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numRotationX)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numRotationS)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numProfileHollow)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numPathCurve)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numProfileCurve)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numProfileBegin)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numProfileEnd)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numPathTwistBegin)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numPathTwist)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numPathTaperX)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numPathTaperY)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numPathShearX)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numPathShearY)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numPathSkew)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numPathScaleX)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numPathScaleY)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numPathRevolutions)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numPathRadiusOffset)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numPathBegin)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numPathEnd)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numMaterial)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numPositionZ)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numPositionY)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numPositionX)).EndInit(); + this.ResumeLayout(false); + + } + #endregion + + private void cmdBuild_Click(object sender, System.EventArgs e) + { + cmdBuild.Enabled = false; + + PrimObject prim = new PrimObject(new LLUUID("8955674724cb43ed920b47caed15465f")); + + prim.Material = (uint)numMaterial.Value; + prim.PathBegin = PrimObject.PathBeginByte((float)numPathBegin.Value); + prim.PathEnd = PrimObject.PathEndByte((float)numPathEnd.Value); + prim.PathRadiusOffset = PrimObject.PathRadiusOffsetByte((float)numPathRadiusOffset.Value); + prim.PathRevolutions = PrimObject.PathRevolutionsByte((float)numPathRevolutions.Value); + prim.PathScaleX = PrimObject.PathScaleByte((float)numPathScaleX.Value); + prim.PathScaleY = PrimObject.PathScaleByte((float)numPathScaleY.Value); + prim.PathShearX = PrimObject.PathShearByte((float)numPathShearX.Value); + prim.PathShearY = PrimObject.PathShearByte((float)numPathShearY.Value); + prim.PathTaperX = PrimObject.PathTaperByte((float)numPathTaperX.Value); + prim.PathTaperY = PrimObject.PathTaperByte((float)numPathTaperY.Value); + prim.PathTwistBegin = PrimObject.PathTwistByte((float)numPathTwistBegin.Value); + prim.PathTwist = PrimObject.PathTwistByte((float)numPathTwist.Value); + prim.ProfileBegin = PrimObject.ProfileBeginByte((float)numProfileBegin.Value); + prim.ProfileEnd = PrimObject.ProfileEndByte((float)numProfileEnd.Value); + prim.PathSkew = PrimObject.PathSkewByte((float)numPathSkew.Value); + prim.ProfileCurve = (uint)numProfileCurve.Value; + prim.PathCurve = (uint)numPathCurve.Value; + prim.ProfileHollow = (uint)numProfileHollow.Value; + prim.Rotation.X = (float)numRotationX.Value; + prim.Rotation.Y = (float)numRotationY.Value; + prim.Rotation.Z = (float)numRotationZ.Value; + prim.Rotation.S = (float)numRotationS.Value; + prim.Scale.X = (float)numScaleX.Value; + prim.Scale.Y = (float)numScaleY.Value; + prim.Scale.Z = (float)numScaleZ.Value; + prim.Position.X = (float)numPositionX.Value; + prim.Position.Y = (float)numPositionY.Value; + prim.Position.Z = (float)numPositionZ.Value; + + Client.CurrentRegion.RezObject(prim, prim.Position, new LLVector3(Client.Avatar.Position)); + + // Rate limiting + System.Threading.Thread.Sleep(250); + + cmdBuild.Enabled = true; + } + } +} diff --git a/applications/SecondSuite/Plugins/PrimBuilder/frmPrimBuilder.resx b/applications/SecondSuite/Plugins/PrimBuilder/frmPrimBuilder.resx index efd551b6..247435d6 100644 --- a/applications/SecondSuite/Plugins/PrimBuilder/frmPrimBuilder.resx +++ b/applications/SecondSuite/Plugins/PrimBuilder/frmPrimBuilder.resx @@ -1,760 +1,760 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 1.3 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Private - - - False - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - Private - - - False - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - Private - - - False - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - (Default) - - - False - - - False - - - 8, 8 - - - True - - - 80 - - - True - - - Private - - - frmPrimBuilder - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Private + + + False + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + Private + + + False + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + Private + + + False + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + (Default) + + + False + + + False + + + 8, 8 + + + True + + + 80 + + + True + + + Private + + + frmPrimBuilder + \ No newline at end of file diff --git a/applications/SecondSuite/Plugins/PrimImporter/AssemblyInfo.cs b/applications/SecondSuite/Plugins/PrimImporter/AssemblyInfo.cs index 177a4f0e..9f89a328 100644 --- a/applications/SecondSuite/Plugins/PrimImporter/AssemblyInfo.cs +++ b/applications/SecondSuite/Plugins/PrimImporter/AssemblyInfo.cs @@ -1,58 +1,58 @@ -using System.Reflection; -using System.Runtime.CompilerServices; - -// -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -// -[assembly: AssemblyTitle("")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("")] -[assembly: AssemblyCopyright("")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Revision and Build Numbers -// by using the '*' as shown below: - -[assembly: AssemblyVersion("1.0.*")] - -// -// In order to sign your assembly you must specify a key to use. Refer to the -// Microsoft .NET Framework documentation for more information on assembly signing. -// -// Use the attributes below to control which key is used for signing. -// -// Notes: -// (*) If no key is specified, the assembly is not signed. -// (*) KeyName refers to a key that has been installed in the Crypto Service -// Provider (CSP) on your machine. KeyFile refers to a file which contains -// a key. -// (*) If the KeyFile and the KeyName values are both specified, the -// following processing occurs: -// (1) If the KeyName can be found in the CSP, that key is used. -// (2) If the KeyName does not exist and the KeyFile does exist, the key -// in the KeyFile is installed into the CSP and used. -// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. -// When specifying the KeyFile, the location of the KeyFile should be -// relative to the project output directory which is -// %Project Directory%\obj\. For example, if your KeyFile is -// located in the project directory, you would specify the AssemblyKeyFile -// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] -// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework -// documentation for more information on this. -// -[assembly: AssemblyDelaySign(false)] -[assembly: AssemblyKeyFile("")] -[assembly: AssemblyKeyName("")] +using System.Reflection; +using System.Runtime.CompilerServices; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly: AssemblyTitle("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly: AssemblyVersion("1.0.*")] + +// +// In order to sign your assembly you must specify a key to use. Refer to the +// Microsoft .NET Framework documentation for more information on assembly signing. +// +// Use the attributes below to control which key is used for signing. +// +// Notes: +// (*) If no key is specified, the assembly is not signed. +// (*) KeyName refers to a key that has been installed in the Crypto Service +// Provider (CSP) on your machine. KeyFile refers to a file which contains +// a key. +// (*) If the KeyFile and the KeyName values are both specified, the +// following processing occurs: +// (1) If the KeyName can be found in the CSP, that key is used. +// (2) If the KeyName does not exist and the KeyFile does exist, the key +// in the KeyFile is installed into the CSP and used. +// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. +// When specifying the KeyFile, the location of the KeyFile should be +// relative to the project output directory which is +// %Project Directory%\obj\. For example, if your KeyFile is +// located in the project directory, you would specify the AssemblyKeyFile +// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] +// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework +// documentation for more information on this. +// +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] +[assembly: AssemblyKeyName("")] diff --git a/applications/SecondSuite/Plugins/PrimImporter/PrimImporter.cs b/applications/SecondSuite/Plugins/PrimImporter/PrimImporter.cs index df8b703c..bcd570af 100644 --- a/applications/SecondSuite/Plugins/PrimImporter/PrimImporter.cs +++ b/applications/SecondSuite/Plugins/PrimImporter/PrimImporter.cs @@ -1,68 +1,68 @@ -/* - * Copyright (c) 2006, Second Life Reverse Engineering Team - * All rights reserved. - * - * - Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - Neither the name of the Second Life Reverse Engineering Team nor the names - * of its contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using libsecondlife; -using SecondSuite.Plugins; - -namespace SecondSuite.Plugins -{ - /// - /// Accountant plugin implementation - /// - public class PrimImporter : SSPlugin - { - public string Name { get { return "Prim Importer"; } } - public string Author { get { return "John Hurliman"; } } - public string Homepage { get { return "http://www.highenergychemistry.com/"; } } - public string Description { get { return "Import structures created with Prim.Blender"; } } - public bool SecondLifeClient { get { return true; } } - public ConnectionEvent ConnectionHandler { get { return OnConnection; } } - public override string ToString() { return Name; } - - private frmPrimImporter Form; - private ConnectionEvent OnConnection; - - public void Init(SecondLife client) - { - Form = new frmPrimImporter(client); - OnConnection = new ConnectionEvent(Form.Connected); - } - - public System.Windows.Forms.Form Load() - { - return Form; - } - - public void Shutdown() - { - if (Form != null) - { - Form.Close(); - } - } - } -} +/* + * Copyright (c) 2006, Second Life Reverse Engineering Team + * All rights reserved. + * + * - Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Neither the name of the Second Life Reverse Engineering Team nor the names + * of its contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using libsecondlife; +using SecondSuite.Plugins; + +namespace SecondSuite.Plugins +{ + /// + /// Accountant plugin implementation + /// + public class PrimImporter : SSPlugin + { + public string Name { get { return "Prim Importer"; } } + public string Author { get { return "John Hurliman"; } } + public string Homepage { get { return "http://www.highenergychemistry.com/"; } } + public string Description { get { return "Import structures created with Prim.Blender"; } } + public bool SecondLifeClient { get { return true; } } + public ConnectionEvent ConnectionHandler { get { return OnConnection; } } + public override string ToString() { return Name; } + + private frmPrimImporter Form; + private ConnectionEvent OnConnection; + + public void Init(SecondLife client) + { + Form = new frmPrimImporter(client); + OnConnection = new ConnectionEvent(Form.Connected); + } + + public System.Windows.Forms.Form Load() + { + return Form; + } + + public void Shutdown() + { + if (Form != null) + { + Form.Close(); + } + } + } +} diff --git a/applications/SecondSuite/Plugins/PrimImporter/PrimImporter.csproj b/applications/SecondSuite/Plugins/PrimImporter/PrimImporter.csproj index 8629fbdc..5101721d 100644 --- a/applications/SecondSuite/Plugins/PrimImporter/PrimImporter.csproj +++ b/applications/SecondSuite/Plugins/PrimImporter/PrimImporter.csproj @@ -1,130 +1,130 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/applications/SecondSuite/Plugins/PrimImporter/frmPrimImporter.cs b/applications/SecondSuite/Plugins/PrimImporter/frmPrimImporter.cs index ee4ae3ca..dfdc1976 100644 --- a/applications/SecondSuite/Plugins/PrimImporter/frmPrimImporter.cs +++ b/applications/SecondSuite/Plugins/PrimImporter/frmPrimImporter.cs @@ -1,351 +1,351 @@ -using System; -using System.Drawing; -using System.Collections; -using System.ComponentModel; -using System.Windows.Forms; -using System.Xml; -using System.Threading; -using libsecondlife; - -namespace SecondSuite.Plugins -{ - /// - /// Summary description for frmPrimImporter. - /// - public class frmPrimImporter : System.Windows.Forms.Form - { - private System.Windows.Forms.Button cmdImport; - private System.Windows.Forms.TextBox txtLog; - /// - /// Required designer variable. - /// - private System.ComponentModel.Container components = null; - - // libsecondlife instance - private SecondLife Client; - bool WaitingOnUpdate = false; - PrimObject CurrentPrim; - Mutex CurrentPrimMutex = new Mutex(false, "CurrentPrimMutex"); - - public frmPrimImporter(SecondLife client) - { - // - // Required for Windows Form Designer support - // - InitializeComponent(); - - Client = client; - - // Install our packet handlers - Client.Network.RegisterCallback("ObjectAdd", new PacketCallback(ObjectAddHandler)); - Client.Network.RegisterCallback("ObjectUpdate", new PacketCallback(ObjectUpdateHandler)); - } - - public void ObjectAddHandler(Packet packet, Simulator simulator) - { - LLVector3 position = null; - - if (WaitingOnUpdate) - { - CurrentPrimMutex.WaitOne(); - - foreach (Block block in packet.Blocks()) - { - foreach (Field field in block.Fields) - { - if (field.Layout.Name == "RayEnd") - { - position = (LLVector3)field.Data; - } - } - } - - txtLog.AppendText("Received an ObjectAdd, setting CurrentPrim position to " + position.ToString()); - CurrentPrim.Position = position; - - CurrentPrimMutex.ReleaseMutex(); - } - } - - public void ObjectUpdateHandler(Packet packet, Simulator simulator) - { - uint id = 0; - LLUUID uuid = null; - - if (WaitingOnUpdate) - { - CurrentPrimMutex.WaitOne(); - - foreach (Block block in packet.Blocks()) - { - foreach (Field field in block.Fields) - { - if (field.Layout.Name == "ID") - { - id = (uint)field.Data; - } - else if (field.Layout.Name == "FullID") - { - uuid = (LLUUID)field.Data; - } - else if (field.Layout.Name == "ObjectData") - { - byte[] byteArray = (byte[])field.Data; - LLVector3 position = new LLVector3(byteArray, 0); - if (CurrentPrim != null && position != CurrentPrim.Position) - { - txtLog.AppendText(position.ToString() + " doesn't match CurrentPrim.Position " + - CurrentPrim.Position.ToString() + "\n"/* + ", ignoring"*/); - //return; - } - } - } - } - - CurrentPrim.ID = id; - CurrentPrim.UUID = uuid; - - WaitingOnUpdate = false; - - CurrentPrimMutex.ReleaseMutex(); - } - } - - /// - /// Clean up any resources being used. - /// - protected override void Dispose( bool disposing ) - { - if( disposing ) - { - if(components != null) - { - components.Dispose(); - } - } - base.Dispose( disposing ); - } - - public void Connected() - { - ; - } - - #region Windows Form Designer generated code - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.cmdImport = new System.Windows.Forms.Button(); - this.txtLog = new System.Windows.Forms.TextBox(); - this.SuspendLayout(); - // - // cmdImport - // - this.cmdImport.Location = new System.Drawing.Point(376, 304); - this.cmdImport.Name = "cmdImport"; - this.cmdImport.Size = new System.Drawing.Size(104, 24); - this.cmdImport.TabIndex = 56; - this.cmdImport.Text = "Import Structure"; - this.cmdImport.Click += new System.EventHandler(this.cmdImport_Click); - // - // txtLog - // - this.txtLog.Location = new System.Drawing.Point(16, 16); - this.txtLog.Multiline = true; - this.txtLog.Name = "txtLog"; - this.txtLog.Size = new System.Drawing.Size(464, 232); - this.txtLog.TabIndex = 57; - this.txtLog.Text = ""; - // - // frmPrimImporter - // - this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); - this.ClientSize = new System.Drawing.Size(496, 349); - this.Controls.Add(this.txtLog); - this.Controls.Add(this.cmdImport); - this.MaximizeBox = false; - this.MinimumSize = new System.Drawing.Size(456, 320); - this.Name = "frmPrimImporter"; - this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; - this.Text = "Prim Importer"; - this.ResumeLayout(false); - - } - #endregion - - private void cmdImport_Click(object sender, System.EventArgs e) - { - OpenFileDialog openDialog = new OpenFileDialog(); - openDialog.Title = "Open Prim.Blender File"; - openDialog.Filter = "All files (*.*)|*.*|Prim files (*.prims)|*.prims" ; - openDialog.FilterIndex = 2; - - if(openDialog.ShowDialog() != DialogResult.OK) - { - return; - } - - XmlDocument xml = new XmlDocument(); - XmlNodeList list = null; - - try - { - // Try to load the xml file - xml.Load(openDialog.FileName); - - //If there is a document and it has children, - if(xml != null && xml.HasChildNodes) - { - //Get the children into the temp list - list = xml.GetElementsByTagName("primitive"); - } - else - { - txtLog.AppendText("ERROR: Failed to parse " + openDialog.FileName + "\n"); - return; - } - } - catch (Exception err) - { - txtLog.AppendText("ERROR: " + err.ToString() + "\n"); - return; - } - - foreach (XmlNode node in list) - { - txtLog.AppendText("Parsing primitive " + node.Attributes["key"].Value + "\n"); - - XmlNode properties = node["properties"]; - - PrimObject prim = new PrimObject(new LLUUID("8955674724cb43ed920b47caed15465f")); - - prim.Material = Convert.ToUInt16(properties["material"].Attributes["val"].Value); - prim.Name = node.Attributes["key"].Value; - // Either PathBegin/End or ProfileBegin/End should be dimple - prim.PathBegin = PrimObject.PathBeginByte(Convert.ToSingle(properties["cut"].Attributes["x"].Value)); - prim.PathEnd = PrimObject.PathEndByte(Convert.ToSingle(properties["cut"].Attributes["y"].Value)); - prim.PathRadiusOffset = PrimObject.PathRadiusOffsetByte(Convert.ToSingle(properties["radiusoffset"].Attributes["val"].Value)); - prim.PathRevolutions = PrimObject.PathRevolutionsByte(Convert.ToSingle(properties["revolutions"].Attributes["val"].Value)); - prim.PathScaleX = PrimObject.PathScaleByte(Convert.ToSingle(properties["topsize"].Attributes["x"].Value)); - prim.PathScaleY = PrimObject.PathScaleByte(Convert.ToSingle(properties["topsize"].Attributes["y"].Value)); - prim.PathShearX = PrimObject.PathShearByte(Convert.ToSingle(properties["topshear"].Attributes["x"].Value)); - prim.PathShearY = PrimObject.PathShearByte(Convert.ToSingle(properties["topshear"].Attributes["y"].Value)); - prim.PathSkew = PrimObject.PathSkewByte(Convert.ToSingle(properties["skew"].Attributes["val"].Value)); - prim.PathTaperX = PrimObject.PathTaperByte(Convert.ToSingle(properties["taper"].Attributes["x"].Value)); - prim.PathTaperY = PrimObject.PathTaperByte(Convert.ToSingle(properties["taper"].Attributes["y"].Value)); - prim.PathTwist = PrimObject.PathTwistByte(Convert.ToSingle(properties["twist"].Attributes["y"].Value)); - prim.PathTwistBegin = PrimObject.PathTwistByte(Convert.ToSingle(properties["twist"].Attributes["x"].Value)); - prim.ProfileBegin = PrimObject.ProfileBeginByte(Convert.ToSingle(properties["cut"].Attributes["x"].Value)); - prim.ProfileEnd = PrimObject.ProfileEndByte(Convert.ToSingle(properties["cut"].Attributes["y"].Value)); - ushort curve = Convert.ToUInt16(properties["type"].Attributes["val"].Value); - switch (curve) - { - case 0: - // Box - prim.ProfileCurve = 1; - prim.PathCurve = 16; - break; - case 1: - // Cylinder - prim.ProfileCurve = 0; - prim.PathCurve = 16; - break; - case 2: - // Prism - prim.ProfileCurve = 3; - prim.PathCurve = 16; - break; - case 3: - // Sphere - prim.ProfileCurve = 5; - prim.PathCurve = 32; - break; - case 4: - // Torus - prim.ProfileCurve = 0; - prim.PathCurve = 32; - break; - case 5: - // Tube - prim.ProfileCurve = 1; - prim.PathCurve = 32; - break; - case 6: - // Ring - prim.ProfileCurve = 3; - prim.PathCurve = 16; - break; - } - prim.ProfileHollow = Convert.ToUInt32(properties["hollow"].Attributes["val"].Value); - prim.Rotation = new LLQuaternion( - Convert.ToSingle(properties["rotation"].Attributes["x"].Value), - Convert.ToSingle(properties["rotation"].Attributes["y"].Value), - Convert.ToSingle(properties["rotation"].Attributes["z"].Value), - Convert.ToSingle(properties["rotation"].Attributes["s"].Value)); - prim.Scale = new LLVector3( - Convert.ToSingle(properties["size"].Attributes["x"].Value), - Convert.ToSingle(properties["size"].Attributes["y"].Value), - Convert.ToSingle(properties["size"].Attributes["z"].Value)); - - LLVector3 position = new LLVector3( - Convert.ToSingle(properties["position"].Attributes["x"].Value) + (float)Client.Avatar.Position.X, - Convert.ToSingle(properties["position"].Attributes["y"].Value) + (float)Client.Avatar.Position.Y, - Convert.ToSingle(properties["position"].Attributes["z"].Value) + (float)Client.Avatar.Position.Z + 50.0F); - prim.Position = position; - - CurrentPrim = prim; - WaitingOnUpdate = true; - - Client.CurrentRegion.RezObject(prim, position, new LLVector3(Client.Avatar.Position)); - - while (WaitingOnUpdate) - { - System.Threading.Thread.Sleep(100); - Application.DoEvents(); - } - - txtLog.AppendText("Rezzed primitive with UUID " + CurrentPrim.UUID + " and ID " + CurrentPrim.ID + " \n"); - - Hashtable blocks = new Hashtable(); - Hashtable fields = new Hashtable(); - - /*fields["ObjectLocalID"] = CurrentPrim.ID; - blocks[fields] = "ObjectData"; - - fields = new Hashtable(); - - fields["AgentID"] = Client.Network.AgentID; - blocks[fields] = "AgentData"; - - Packet packet = PacketBuilder.BuildPacket("ObjectSelect", Client.Protocol, blocks, Helpers.MSG_RELIABLE); - Client.Network.SendPacket(packet); - - System.Threading.Thread.Sleep(100);*/ - Packet packet; - - byte[] byteArray = new byte[12]; - Array.Copy(position.GetBytes(), byteArray, 12); - - fields["Data"] = byteArray; - fields["Type"] = (byte)9; - fields["ObjectLocalID"] = CurrentPrim.ID; - blocks[fields] = "ObjectData"; - - fields = new Hashtable(); - - fields["AgentID"] = Client.Network.AgentID; - blocks[fields] = "AgentData"; - - packet = PacketBuilder.BuildPacket("MultipleObjectUpdate", Client.Protocol, blocks, Helpers.MSG_RELIABLE); - Client.Network.SendPacket(packet); - Client.Network.SendPacket(packet); - Client.Network.SendPacket(packet); - - System.Threading.Thread.Sleep(500); - } - } - } -} +using System; +using System.Drawing; +using System.Collections; +using System.ComponentModel; +using System.Windows.Forms; +using System.Xml; +using System.Threading; +using libsecondlife; + +namespace SecondSuite.Plugins +{ + /// + /// Summary description for frmPrimImporter. + /// + public class frmPrimImporter : System.Windows.Forms.Form + { + private System.Windows.Forms.Button cmdImport; + private System.Windows.Forms.TextBox txtLog; + /// + /// Required designer variable. + /// + private System.ComponentModel.Container components = null; + + // libsecondlife instance + private SecondLife Client; + bool WaitingOnUpdate = false; + PrimObject CurrentPrim; + Mutex CurrentPrimMutex = new Mutex(false, "CurrentPrimMutex"); + + public frmPrimImporter(SecondLife client) + { + // + // Required for Windows Form Designer support + // + InitializeComponent(); + + Client = client; + + // Install our packet handlers + Client.Network.RegisterCallback("ObjectAdd", new PacketCallback(ObjectAddHandler)); + Client.Network.RegisterCallback("ObjectUpdate", new PacketCallback(ObjectUpdateHandler)); + } + + public void ObjectAddHandler(Packet packet, Simulator simulator) + { + LLVector3 position = null; + + if (WaitingOnUpdate) + { + CurrentPrimMutex.WaitOne(); + + foreach (Block block in packet.Blocks()) + { + foreach (Field field in block.Fields) + { + if (field.Layout.Name == "RayEnd") + { + position = (LLVector3)field.Data; + } + } + } + + txtLog.AppendText("Received an ObjectAdd, setting CurrentPrim position to " + position.ToString()); + CurrentPrim.Position = position; + + CurrentPrimMutex.ReleaseMutex(); + } + } + + public void ObjectUpdateHandler(Packet packet, Simulator simulator) + { + uint id = 0; + LLUUID uuid = null; + + if (WaitingOnUpdate) + { + CurrentPrimMutex.WaitOne(); + + foreach (Block block in packet.Blocks()) + { + foreach (Field field in block.Fields) + { + if (field.Layout.Name == "ID") + { + id = (uint)field.Data; + } + else if (field.Layout.Name == "FullID") + { + uuid = (LLUUID)field.Data; + } + else if (field.Layout.Name == "ObjectData") + { + byte[] byteArray = (byte[])field.Data; + LLVector3 position = new LLVector3(byteArray, 0); + if (CurrentPrim != null && position != CurrentPrim.Position) + { + txtLog.AppendText(position.ToString() + " doesn't match CurrentPrim.Position " + + CurrentPrim.Position.ToString() + "\n"/* + ", ignoring"*/); + //return; + } + } + } + } + + CurrentPrim.ID = id; + CurrentPrim.UUID = uuid; + + WaitingOnUpdate = false; + + CurrentPrimMutex.ReleaseMutex(); + } + } + + /// + /// Clean up any resources being used. + /// + protected override void Dispose( bool disposing ) + { + if( disposing ) + { + if(components != null) + { + components.Dispose(); + } + } + base.Dispose( disposing ); + } + + public void Connected() + { + ; + } + + #region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.cmdImport = new System.Windows.Forms.Button(); + this.txtLog = new System.Windows.Forms.TextBox(); + this.SuspendLayout(); + // + // cmdImport + // + this.cmdImport.Location = new System.Drawing.Point(376, 304); + this.cmdImport.Name = "cmdImport"; + this.cmdImport.Size = new System.Drawing.Size(104, 24); + this.cmdImport.TabIndex = 56; + this.cmdImport.Text = "Import Structure"; + this.cmdImport.Click += new System.EventHandler(this.cmdImport_Click); + // + // txtLog + // + this.txtLog.Location = new System.Drawing.Point(16, 16); + this.txtLog.Multiline = true; + this.txtLog.Name = "txtLog"; + this.txtLog.Size = new System.Drawing.Size(464, 232); + this.txtLog.TabIndex = 57; + this.txtLog.Text = ""; + // + // frmPrimImporter + // + this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); + this.ClientSize = new System.Drawing.Size(496, 349); + this.Controls.Add(this.txtLog); + this.Controls.Add(this.cmdImport); + this.MaximizeBox = false; + this.MinimumSize = new System.Drawing.Size(456, 320); + this.Name = "frmPrimImporter"; + this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; + this.Text = "Prim Importer"; + this.ResumeLayout(false); + + } + #endregion + + private void cmdImport_Click(object sender, System.EventArgs e) + { + OpenFileDialog openDialog = new OpenFileDialog(); + openDialog.Title = "Open Prim.Blender File"; + openDialog.Filter = "All files (*.*)|*.*|Prim files (*.prims)|*.prims" ; + openDialog.FilterIndex = 2; + + if(openDialog.ShowDialog() != DialogResult.OK) + { + return; + } + + XmlDocument xml = new XmlDocument(); + XmlNodeList list = null; + + try + { + // Try to load the xml file + xml.Load(openDialog.FileName); + + //If there is a document and it has children, + if(xml != null && xml.HasChildNodes) + { + //Get the children into the temp list + list = xml.GetElementsByTagName("primitive"); + } + else + { + txtLog.AppendText("ERROR: Failed to parse " + openDialog.FileName + "\n"); + return; + } + } + catch (Exception err) + { + txtLog.AppendText("ERROR: " + err.ToString() + "\n"); + return; + } + + foreach (XmlNode node in list) + { + txtLog.AppendText("Parsing primitive " + node.Attributes["key"].Value + "\n"); + + XmlNode properties = node["properties"]; + + PrimObject prim = new PrimObject(new LLUUID("8955674724cb43ed920b47caed15465f")); + + prim.Material = Convert.ToUInt16(properties["material"].Attributes["val"].Value); + prim.Name = node.Attributes["key"].Value; + // Either PathBegin/End or ProfileBegin/End should be dimple + prim.PathBegin = PrimObject.PathBeginByte(Convert.ToSingle(properties["cut"].Attributes["x"].Value)); + prim.PathEnd = PrimObject.PathEndByte(Convert.ToSingle(properties["cut"].Attributes["y"].Value)); + prim.PathRadiusOffset = PrimObject.PathRadiusOffsetByte(Convert.ToSingle(properties["radiusoffset"].Attributes["val"].Value)); + prim.PathRevolutions = PrimObject.PathRevolutionsByte(Convert.ToSingle(properties["revolutions"].Attributes["val"].Value)); + prim.PathScaleX = PrimObject.PathScaleByte(Convert.ToSingle(properties["topsize"].Attributes["x"].Value)); + prim.PathScaleY = PrimObject.PathScaleByte(Convert.ToSingle(properties["topsize"].Attributes["y"].Value)); + prim.PathShearX = PrimObject.PathShearByte(Convert.ToSingle(properties["topshear"].Attributes["x"].Value)); + prim.PathShearY = PrimObject.PathShearByte(Convert.ToSingle(properties["topshear"].Attributes["y"].Value)); + prim.PathSkew = PrimObject.PathSkewByte(Convert.ToSingle(properties["skew"].Attributes["val"].Value)); + prim.PathTaperX = PrimObject.PathTaperByte(Convert.ToSingle(properties["taper"].Attributes["x"].Value)); + prim.PathTaperY = PrimObject.PathTaperByte(Convert.ToSingle(properties["taper"].Attributes["y"].Value)); + prim.PathTwist = PrimObject.PathTwistByte(Convert.ToSingle(properties["twist"].Attributes["y"].Value)); + prim.PathTwistBegin = PrimObject.PathTwistByte(Convert.ToSingle(properties["twist"].Attributes["x"].Value)); + prim.ProfileBegin = PrimObject.ProfileBeginByte(Convert.ToSingle(properties["cut"].Attributes["x"].Value)); + prim.ProfileEnd = PrimObject.ProfileEndByte(Convert.ToSingle(properties["cut"].Attributes["y"].Value)); + ushort curve = Convert.ToUInt16(properties["type"].Attributes["val"].Value); + switch (curve) + { + case 0: + // Box + prim.ProfileCurve = 1; + prim.PathCurve = 16; + break; + case 1: + // Cylinder + prim.ProfileCurve = 0; + prim.PathCurve = 16; + break; + case 2: + // Prism + prim.ProfileCurve = 3; + prim.PathCurve = 16; + break; + case 3: + // Sphere + prim.ProfileCurve = 5; + prim.PathCurve = 32; + break; + case 4: + // Torus + prim.ProfileCurve = 0; + prim.PathCurve = 32; + break; + case 5: + // Tube + prim.ProfileCurve = 1; + prim.PathCurve = 32; + break; + case 6: + // Ring + prim.ProfileCurve = 3; + prim.PathCurve = 16; + break; + } + prim.ProfileHollow = Convert.ToUInt32(properties["hollow"].Attributes["val"].Value); + prim.Rotation = new LLQuaternion( + Convert.ToSingle(properties["rotation"].Attributes["x"].Value), + Convert.ToSingle(properties["rotation"].Attributes["y"].Value), + Convert.ToSingle(properties["rotation"].Attributes["z"].Value), + Convert.ToSingle(properties["rotation"].Attributes["s"].Value)); + prim.Scale = new LLVector3( + Convert.ToSingle(properties["size"].Attributes["x"].Value), + Convert.ToSingle(properties["size"].Attributes["y"].Value), + Convert.ToSingle(properties["size"].Attributes["z"].Value)); + + LLVector3 position = new LLVector3( + Convert.ToSingle(properties["position"].Attributes["x"].Value) + (float)Client.Avatar.Position.X, + Convert.ToSingle(properties["position"].Attributes["y"].Value) + (float)Client.Avatar.Position.Y, + Convert.ToSingle(properties["position"].Attributes["z"].Value) + (float)Client.Avatar.Position.Z + 50.0F); + prim.Position = position; + + CurrentPrim = prim; + WaitingOnUpdate = true; + + Client.CurrentRegion.RezObject(prim, position, new LLVector3(Client.Avatar.Position)); + + while (WaitingOnUpdate) + { + System.Threading.Thread.Sleep(100); + Application.DoEvents(); + } + + txtLog.AppendText("Rezzed primitive with UUID " + CurrentPrim.UUID + " and ID " + CurrentPrim.ID + " \n"); + + Hashtable blocks = new Hashtable(); + Hashtable fields = new Hashtable(); + + /*fields["ObjectLocalID"] = CurrentPrim.ID; + blocks[fields] = "ObjectData"; + + fields = new Hashtable(); + + fields["AgentID"] = Client.Network.AgentID; + blocks[fields] = "AgentData"; + + Packet packet = PacketBuilder.BuildPacket("ObjectSelect", Client.Protocol, blocks, Helpers.MSG_RELIABLE); + Client.Network.SendPacket(packet); + + System.Threading.Thread.Sleep(100);*/ + Packet packet; + + byte[] byteArray = new byte[12]; + Array.Copy(position.GetBytes(), byteArray, 12); + + fields["Data"] = byteArray; + fields["Type"] = (byte)9; + fields["ObjectLocalID"] = CurrentPrim.ID; + blocks[fields] = "ObjectData"; + + fields = new Hashtable(); + + fields["AgentID"] = Client.Network.AgentID; + blocks[fields] = "AgentData"; + + packet = PacketBuilder.BuildPacket("MultipleObjectUpdate", Client.Protocol, blocks, Helpers.MSG_RELIABLE); + Client.Network.SendPacket(packet); + Client.Network.SendPacket(packet); + Client.Network.SendPacket(packet); + + System.Threading.Thread.Sleep(500); + } + } + } +} diff --git a/applications/SecondSuite/Plugins/PrimImporter/frmPrimImporter.resx b/applications/SecondSuite/Plugins/PrimImporter/frmPrimImporter.resx index f469a013..2c5cf823 100644 --- a/applications/SecondSuite/Plugins/PrimImporter/frmPrimImporter.resx +++ b/applications/SecondSuite/Plugins/PrimImporter/frmPrimImporter.resx @@ -1,148 +1,148 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 1.3 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - False - - - Private - - - Private - - - Private - - - False - - - Private - - - False - - - (Default) - - - False - - - False - - - 8, 8 - - - True - - - frmPrimImporter - - - 80 - - - True - - - Private - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + False + + + Private + + + Private + + + Private + + + False + + + Private + + + False + + + (Default) + + + False + + + False + + + 8, 8 + + + True + + + frmPrimImporter + + + 80 + + + True + + + Private + \ No newline at end of file diff --git a/applications/SecondSuite/SecondSuite.csproj b/applications/SecondSuite/SecondSuite.csproj index d727768c..d50c266a 100644 --- a/applications/SecondSuite/SecondSuite.csproj +++ b/applications/SecondSuite/SecondSuite.csproj @@ -1,155 +1,155 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/applications/SecondSuite/SecondSuite.sln b/applications/SecondSuite/SecondSuite.sln index 65c9aa0b..700c46dc 100644 --- a/applications/SecondSuite/SecondSuite.sln +++ b/applications/SecondSuite/SecondSuite.sln @@ -1,53 +1,53 @@ -Microsoft Visual Studio Solution File, Format Version 8.00 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecondSuite", "SecondSuite.csproj", "{D1E859D8-70A6-471B-9EBF-7F5D8A4B8EFE}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecondSuiteSDK", "SecondSuiteSDK\SecondSuiteSDK.csproj", "{A1527BBD-7A90-42C6-956F-CA4FE7A7D7B7}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Accountant", "Plugins\Accountant\Accountant.csproj", "{2ED068B1-3922-4044-ABEF-B51547F64A53}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PrimImporter", "Plugins\PrimImporter\PrimImporter.csproj", "{1F9A11C3-5A68-4618-85CC-1BBC131EACB6}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PrimBuilder", "Plugins\PrimBuilder\PrimBuilder.csproj", "{16A48BFA-9B8B-4226-ACE7-BDABADB9E62D}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfiguration) = preSolution - Debug = Debug - Release = Release - EndGlobalSection - GlobalSection(ProjectConfiguration) = postSolution - {D1E859D8-70A6-471B-9EBF-7F5D8A4B8EFE}.Debug.ActiveCfg = Debug|.NET - {D1E859D8-70A6-471B-9EBF-7F5D8A4B8EFE}.Debug.Build.0 = Debug|.NET - {D1E859D8-70A6-471B-9EBF-7F5D8A4B8EFE}.Release.ActiveCfg = Release|.NET - {D1E859D8-70A6-471B-9EBF-7F5D8A4B8EFE}.Release.Build.0 = Release|.NET - {A1527BBD-7A90-42C6-956F-CA4FE7A7D7B7}.Debug.ActiveCfg = Debug|.NET - {A1527BBD-7A90-42C6-956F-CA4FE7A7D7B7}.Debug.Build.0 = Debug|.NET - {A1527BBD-7A90-42C6-956F-CA4FE7A7D7B7}.Release.ActiveCfg = Release|.NET - {A1527BBD-7A90-42C6-956F-CA4FE7A7D7B7}.Release.Build.0 = Release|.NET - {2ED068B1-3922-4044-ABEF-B51547F64A53}.Debug.ActiveCfg = Debug|.NET - {2ED068B1-3922-4044-ABEF-B51547F64A53}.Debug.Build.0 = Debug|.NET - {2ED068B1-3922-4044-ABEF-B51547F64A53}.Release.ActiveCfg = Release|.NET - {2ED068B1-3922-4044-ABEF-B51547F64A53}.Release.Build.0 = Release|.NET - {1F9A11C3-5A68-4618-85CC-1BBC131EACB6}.Debug.ActiveCfg = Debug|.NET - {1F9A11C3-5A68-4618-85CC-1BBC131EACB6}.Debug.Build.0 = Debug|.NET - {1F9A11C3-5A68-4618-85CC-1BBC131EACB6}.Release.ActiveCfg = Release|.NET - {1F9A11C3-5A68-4618-85CC-1BBC131EACB6}.Release.Build.0 = Release|.NET - {16A48BFA-9B8B-4226-ACE7-BDABADB9E62D}.Debug.ActiveCfg = Debug|.NET - {16A48BFA-9B8B-4226-ACE7-BDABADB9E62D}.Debug.Build.0 = Debug|.NET - {16A48BFA-9B8B-4226-ACE7-BDABADB9E62D}.Release.ActiveCfg = Release|.NET - {16A48BFA-9B8B-4226-ACE7-BDABADB9E62D}.Release.Build.0 = Release|.NET - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - EndGlobalSection - GlobalSection(ExtensibilityAddIns) = postSolution - EndGlobalSection -EndGlobal +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecondSuite", "SecondSuite.csproj", "{D1E859D8-70A6-471B-9EBF-7F5D8A4B8EFE}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SecondSuiteSDK", "SecondSuiteSDK\SecondSuiteSDK.csproj", "{A1527BBD-7A90-42C6-956F-CA4FE7A7D7B7}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Accountant", "Plugins\Accountant\Accountant.csproj", "{2ED068B1-3922-4044-ABEF-B51547F64A53}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PrimImporter", "Plugins\PrimImporter\PrimImporter.csproj", "{1F9A11C3-5A68-4618-85CC-1BBC131EACB6}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PrimBuilder", "Plugins\PrimBuilder\PrimBuilder.csproj", "{16A48BFA-9B8B-4226-ACE7-BDABADB9E62D}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {D1E859D8-70A6-471B-9EBF-7F5D8A4B8EFE}.Debug.ActiveCfg = Debug|.NET + {D1E859D8-70A6-471B-9EBF-7F5D8A4B8EFE}.Debug.Build.0 = Debug|.NET + {D1E859D8-70A6-471B-9EBF-7F5D8A4B8EFE}.Release.ActiveCfg = Release|.NET + {D1E859D8-70A6-471B-9EBF-7F5D8A4B8EFE}.Release.Build.0 = Release|.NET + {A1527BBD-7A90-42C6-956F-CA4FE7A7D7B7}.Debug.ActiveCfg = Debug|.NET + {A1527BBD-7A90-42C6-956F-CA4FE7A7D7B7}.Debug.Build.0 = Debug|.NET + {A1527BBD-7A90-42C6-956F-CA4FE7A7D7B7}.Release.ActiveCfg = Release|.NET + {A1527BBD-7A90-42C6-956F-CA4FE7A7D7B7}.Release.Build.0 = Release|.NET + {2ED068B1-3922-4044-ABEF-B51547F64A53}.Debug.ActiveCfg = Debug|.NET + {2ED068B1-3922-4044-ABEF-B51547F64A53}.Debug.Build.0 = Debug|.NET + {2ED068B1-3922-4044-ABEF-B51547F64A53}.Release.ActiveCfg = Release|.NET + {2ED068B1-3922-4044-ABEF-B51547F64A53}.Release.Build.0 = Release|.NET + {1F9A11C3-5A68-4618-85CC-1BBC131EACB6}.Debug.ActiveCfg = Debug|.NET + {1F9A11C3-5A68-4618-85CC-1BBC131EACB6}.Debug.Build.0 = Debug|.NET + {1F9A11C3-5A68-4618-85CC-1BBC131EACB6}.Release.ActiveCfg = Release|.NET + {1F9A11C3-5A68-4618-85CC-1BBC131EACB6}.Release.Build.0 = Release|.NET + {16A48BFA-9B8B-4226-ACE7-BDABADB9E62D}.Debug.ActiveCfg = Debug|.NET + {16A48BFA-9B8B-4226-ACE7-BDABADB9E62D}.Debug.Build.0 = Debug|.NET + {16A48BFA-9B8B-4226-ACE7-BDABADB9E62D}.Release.ActiveCfg = Release|.NET + {16A48BFA-9B8B-4226-ACE7-BDABADB9E62D}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/applications/SecondSuite/SecondSuiteSDK/AssemblyInfo.cs b/applications/SecondSuite/SecondSuiteSDK/AssemblyInfo.cs index a90514f5..55d014d4 100644 --- a/applications/SecondSuite/SecondSuiteSDK/AssemblyInfo.cs +++ b/applications/SecondSuite/SecondSuiteSDK/AssemblyInfo.cs @@ -1,58 +1,58 @@ -using System.Reflection; -using System.Runtime.CompilerServices; - -// -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -// -[assembly: AssemblyTitle("")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("")] -[assembly: AssemblyCopyright("")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Revision and Build Numbers -// by using the '*' as shown below: - -[assembly: AssemblyVersion("1.0.0")] - -// -// In order to sign your assembly you must specify a key to use. Refer to the -// Microsoft .NET Framework documentation for more information on assembly signing. -// -// Use the attributes below to control which key is used for signing. -// -// Notes: -// (*) If no key is specified, the assembly is not signed. -// (*) KeyName refers to a key that has been installed in the Crypto Service -// Provider (CSP) on your machine. KeyFile refers to a file which contains -// a key. -// (*) If the KeyFile and the KeyName values are both specified, the -// following processing occurs: -// (1) If the KeyName can be found in the CSP, that key is used. -// (2) If the KeyName does not exist and the KeyFile does exist, the key -// in the KeyFile is installed into the CSP and used. -// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. -// When specifying the KeyFile, the location of the KeyFile should be -// relative to the project output directory which is -// %Project Directory%\obj\. For example, if your KeyFile is -// located in the project directory, you would specify the AssemblyKeyFile -// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] -// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework -// documentation for more information on this. -// -[assembly: AssemblyDelaySign(false)] -[assembly: AssemblyKeyFile("")] -[assembly: AssemblyKeyName("")] +using System.Reflection; +using System.Runtime.CompilerServices; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly: AssemblyTitle("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly: AssemblyVersion("1.0.0")] + +// +// In order to sign your assembly you must specify a key to use. Refer to the +// Microsoft .NET Framework documentation for more information on assembly signing. +// +// Use the attributes below to control which key is used for signing. +// +// Notes: +// (*) If no key is specified, the assembly is not signed. +// (*) KeyName refers to a key that has been installed in the Crypto Service +// Provider (CSP) on your machine. KeyFile refers to a file which contains +// a key. +// (*) If the KeyFile and the KeyName values are both specified, the +// following processing occurs: +// (1) If the KeyName can be found in the CSP, that key is used. +// (2) If the KeyName does not exist and the KeyFile does exist, the key +// in the KeyFile is installed into the CSP and used. +// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. +// When specifying the KeyFile, the location of the KeyFile should be +// relative to the project output directory which is +// %Project Directory%\obj\. For example, if your KeyFile is +// located in the project directory, you would specify the AssemblyKeyFile +// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] +// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework +// documentation for more information on this. +// +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] +[assembly: AssemblyKeyName("")] diff --git a/applications/SecondSuite/SecondSuiteSDK/SSPlugin.cs b/applications/SecondSuite/SecondSuiteSDK/SSPlugin.cs index d210d2df..ba86f652 100644 --- a/applications/SecondSuite/SecondSuiteSDK/SSPlugin.cs +++ b/applications/SecondSuite/SecondSuiteSDK/SSPlugin.cs @@ -1,25 +1,25 @@ -using System; -using libsecondlife; - -namespace SecondSuite.Plugins -{ - public delegate void ConnectionEvent(); - - /// - /// A public interface for Second Suite plugins - /// - public interface SSPlugin - { - string Name{get;} - string Author{get;} - string Homepage{get;} - string Description{get;} - bool SecondLifeClient{get;} - - ConnectionEvent ConnectionHandler{get;} - - void Init(SecondLife client); - System.Windows.Forms.Form Load(); - void Shutdown(); - } -} +using System; +using libsecondlife; + +namespace SecondSuite.Plugins +{ + public delegate void ConnectionEvent(); + + /// + /// A public interface for Second Suite plugins + /// + public interface SSPlugin + { + string Name{get;} + string Author{get;} + string Homepage{get;} + string Description{get;} + bool SecondLifeClient{get;} + + ConnectionEvent ConnectionHandler{get;} + + void Init(SecondLife client); + System.Windows.Forms.Form Load(); + void Shutdown(); + } +} diff --git a/applications/SecondSuite/SecondSuiteSDK/SSPluginCollection.cs b/applications/SecondSuite/SecondSuiteSDK/SSPluginCollection.cs index 45900f3b..5cfa6623 100644 --- a/applications/SecondSuite/SecondSuiteSDK/SSPluginCollection.cs +++ b/applications/SecondSuite/SecondSuiteSDK/SSPluginCollection.cs @@ -1,142 +1,142 @@ -using System; -using System.Collections; - -namespace SecondSuite.Plugins -{ - public class PluginCollection : CollectionBase - { - public PluginCollection() - { - } - - public PluginCollection(PluginCollection value) - { - this.AddRange(value); - } - - public PluginCollection(SSPlugin[] value) - { - this.AddRange(value); - } - - public SSPlugin this[int index] - { - get {return ((SSPlugin)(this.List[index]));} - } - - public int Add(SSPlugin value) - { - return this.List.Add(value); - } - - public void AddRange(SSPlugin[] value) - { - for (int i = 0; (i < value.Length); i = (i + 1)) - { - this.Add(value[i]); - } - } - - public void AddRange(PluginCollection value) - { - for (int i = 0; (i < value.Count); i = (i + 1)) - { - this.Add((SSPlugin)value.List[i]); - } - } - - public bool Contains(SSPlugin value) - { - return this.List.Contains(value); - } - - public void CopyTo(SSPlugin[] array, int index) - { - this.List.CopyTo(array, index); - } - - public SSPlugin[] ToArray() - { - SSPlugin[] array = new SSPlugin[this.Count]; - this.CopyTo(array, 0); - - return array; - } - - public int IndexOf(SSPlugin value) - { - return this.List.IndexOf(value); - } - - public void Insert(int index, SSPlugin value) - { - List.Insert(index, value); - } - - public void Remove(SSPlugin value) - { - List.Remove(value); - } - - public new PluginCollectionEnumerator GetEnumerator() - { - return new PluginCollectionEnumerator(this); - } - - public class PluginCollectionEnumerator : IEnumerator - { - private IEnumerator _enumerator; - private IEnumerable _temp; - - /// - /// Initializes a new instance of the PluginCollectionEnumerator class referencing the specified PluginCollection object. - /// - /// The PluginCollection to enumerate. - public PluginCollectionEnumerator(PluginCollection mappings) - { - _temp = ((IEnumerable)(mappings)); - _enumerator = _temp.GetEnumerator(); - } - - /// - /// Gets the current element in the collection. - /// - public SSPlugin Current - { - get {return ((SSPlugin)(_enumerator.Current));} - } - - object IEnumerator.Current - { - get {return _enumerator.Current;} - } - - /// - /// Advances the enumerator to the next element of the collection. - /// - /// true if the enumerator was successfully advanced to the next element; false if the enumerator has passed the end of the collection. - public bool MoveNext() - { - return _enumerator.MoveNext(); - } - - bool IEnumerator.MoveNext() - { - return _enumerator.MoveNext(); - } - - /// - /// Sets the enumerator to its initial position, which is before the first element in the collection. - /// - public void Reset() - { - _enumerator.Reset(); - } - - void IEnumerator.Reset() - { - _enumerator.Reset(); - } - } - } -} +using System; +using System.Collections; + +namespace SecondSuite.Plugins +{ + public class PluginCollection : CollectionBase + { + public PluginCollection() + { + } + + public PluginCollection(PluginCollection value) + { + this.AddRange(value); + } + + public PluginCollection(SSPlugin[] value) + { + this.AddRange(value); + } + + public SSPlugin this[int index] + { + get {return ((SSPlugin)(this.List[index]));} + } + + public int Add(SSPlugin value) + { + return this.List.Add(value); + } + + public void AddRange(SSPlugin[] value) + { + for (int i = 0; (i < value.Length); i = (i + 1)) + { + this.Add(value[i]); + } + } + + public void AddRange(PluginCollection value) + { + for (int i = 0; (i < value.Count); i = (i + 1)) + { + this.Add((SSPlugin)value.List[i]); + } + } + + public bool Contains(SSPlugin value) + { + return this.List.Contains(value); + } + + public void CopyTo(SSPlugin[] array, int index) + { + this.List.CopyTo(array, index); + } + + public SSPlugin[] ToArray() + { + SSPlugin[] array = new SSPlugin[this.Count]; + this.CopyTo(array, 0); + + return array; + } + + public int IndexOf(SSPlugin value) + { + return this.List.IndexOf(value); + } + + public void Insert(int index, SSPlugin value) + { + List.Insert(index, value); + } + + public void Remove(SSPlugin value) + { + List.Remove(value); + } + + public new PluginCollectionEnumerator GetEnumerator() + { + return new PluginCollectionEnumerator(this); + } + + public class PluginCollectionEnumerator : IEnumerator + { + private IEnumerator _enumerator; + private IEnumerable _temp; + + /// + /// Initializes a new instance of the PluginCollectionEnumerator class referencing the specified PluginCollection object. + /// + /// The PluginCollection to enumerate. + public PluginCollectionEnumerator(PluginCollection mappings) + { + _temp = ((IEnumerable)(mappings)); + _enumerator = _temp.GetEnumerator(); + } + + /// + /// Gets the current element in the collection. + /// + public SSPlugin Current + { + get {return ((SSPlugin)(_enumerator.Current));} + } + + object IEnumerator.Current + { + get {return _enumerator.Current;} + } + + /// + /// Advances the enumerator to the next element of the collection. + /// + /// true if the enumerator was successfully advanced to the next element; false if the enumerator has passed the end of the collection. + public bool MoveNext() + { + return _enumerator.MoveNext(); + } + + bool IEnumerator.MoveNext() + { + return _enumerator.MoveNext(); + } + + /// + /// Sets the enumerator to its initial position, which is before the first element in the collection. + /// + public void Reset() + { + _enumerator.Reset(); + } + + void IEnumerator.Reset() + { + _enumerator.Reset(); + } + } + } +} diff --git a/applications/SecondSuite/SecondSuiteSDK/SSPluginContext.cs b/applications/SecondSuite/SecondSuiteSDK/SSPluginContext.cs index 17586844..f00d1c3d 100644 --- a/applications/SecondSuite/SecondSuiteSDK/SSPluginContext.cs +++ b/applications/SecondSuite/SecondSuiteSDK/SSPluginContext.cs @@ -1,12 +1,12 @@ -using System; - -namespace SecondSuite.Plugins -{ - /// - /// A public interface used to pass context to plugins - /// - public interface SSPluginContext - { - //string CurrentDocumentText{get;set;} - } -} +using System; + +namespace SecondSuite.Plugins +{ + /// + /// A public interface used to pass context to plugins + /// + public interface SSPluginContext + { + //string CurrentDocumentText{get;set;} + } +} diff --git a/applications/SecondSuite/SecondSuiteSDK/SecondSuiteSDK.csproj b/applications/SecondSuite/SecondSuiteSDK/SecondSuiteSDK.csproj index 1a8c9e3a..a57c4419 100644 --- a/applications/SecondSuite/SecondSuiteSDK/SecondSuiteSDK.csproj +++ b/applications/SecondSuite/SecondSuiteSDK/SecondSuiteSDK.csproj @@ -1,121 +1,121 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/applications/SecondSuite/frmLogin.cs b/applications/SecondSuite/frmLogin.cs index 01d64b4c..fa03decb 100644 --- a/applications/SecondSuite/frmLogin.cs +++ b/applications/SecondSuite/frmLogin.cs @@ -1,259 +1,259 @@ -using System; -using System.Drawing; -using System.Collections; -using System.ComponentModel; -using System.Windows.Forms; -using SecondSuite.Plugins; -using libsecondlife; - -namespace SecondSuite -{ - /// - /// Summary description for frmLogin. - /// - public class frmLogin : System.Windows.Forms.Form - { - private System.Windows.Forms.GroupBox grpLogin; - private System.Windows.Forms.Label label3; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.TextBox txtPassword; - private System.Windows.Forms.TextBox txtLastName; - private System.Windows.Forms.Button cmdConnect; - private System.Windows.Forms.TextBox txtFirstName; - public System.Windows.Forms.ListBox lstAvatars; - private System.Windows.Forms.Label label4; - private System.Windows.Forms.Button cmdSelect; - /// - /// Required designer variable. - /// - private System.ComponentModel.Container components = null; - - // - private frmSecondSuite SecondSuite; - private SSPlugin Plugin; - - public frmLogin(frmSecondSuite secondSuite, SSPlugin plugin) - { - // - // Required for Windows Form Designer support - // - InitializeComponent(); - - SecondSuite = secondSuite; - Plugin = plugin; - } - - /// - /// Clean up any resources being used. - /// - protected override void Dispose( bool disposing ) - { - if( disposing ) - { - if(components != null) - { - components.Dispose(); - } - } - base.Dispose( disposing ); - } - - #region Windows Form Designer generated code - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.grpLogin = new System.Windows.Forms.GroupBox(); - this.label3 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.label1 = new System.Windows.Forms.Label(); - this.txtPassword = new System.Windows.Forms.TextBox(); - this.txtLastName = new System.Windows.Forms.TextBox(); - this.cmdConnect = new System.Windows.Forms.Button(); - this.txtFirstName = new System.Windows.Forms.TextBox(); - this.lstAvatars = new System.Windows.Forms.ListBox(); - this.label4 = new System.Windows.Forms.Label(); - this.cmdSelect = new System.Windows.Forms.Button(); - this.grpLogin.SuspendLayout(); - this.SuspendLayout(); - // - // grpLogin - // - this.grpLogin.Controls.Add(this.label3); - this.grpLogin.Controls.Add(this.label2); - this.grpLogin.Controls.Add(this.label1); - this.grpLogin.Controls.Add(this.txtPassword); - this.grpLogin.Controls.Add(this.txtLastName); - this.grpLogin.Controls.Add(this.cmdConnect); - this.grpLogin.Controls.Add(this.txtFirstName); - this.grpLogin.Location = new System.Drawing.Point(16, 304); - this.grpLogin.Name = "grpLogin"; - this.grpLogin.Size = new System.Drawing.Size(552, 80); - this.grpLogin.TabIndex = 51; - this.grpLogin.TabStop = false; - // - // label3 - // - this.label3.Location = new System.Drawing.Point(280, 24); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(120, 16); - this.label3.TabIndex = 50; - this.label3.Text = "Password"; - // - // label2 - // - this.label2.Location = new System.Drawing.Point(152, 24); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(120, 16); - this.label2.TabIndex = 50; - this.label2.Text = "Last Name"; - // - // label1 - // - this.label1.Location = new System.Drawing.Point(16, 24); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(120, 16); - this.label1.TabIndex = 50; - this.label1.Text = "First Name"; - // - // txtPassword - // - this.txtPassword.Location = new System.Drawing.Point(280, 40); - this.txtPassword.Name = "txtPassword"; - this.txtPassword.PasswordChar = '*'; - this.txtPassword.Size = new System.Drawing.Size(120, 20); - this.txtPassword.TabIndex = 2; - this.txtPassword.Text = ""; - // - // txtLastName - // - this.txtLastName.Location = new System.Drawing.Point(152, 40); - this.txtLastName.Name = "txtLastName"; - this.txtLastName.Size = new System.Drawing.Size(112, 20); - this.txtLastName.TabIndex = 1; - this.txtLastName.Text = ""; - // - // cmdConnect - // - this.cmdConnect.Location = new System.Drawing.Point(416, 40); - this.cmdConnect.Name = "cmdConnect"; - this.cmdConnect.Size = new System.Drawing.Size(120, 24); - this.cmdConnect.TabIndex = 3; - this.cmdConnect.Text = "Connect"; - this.cmdConnect.Click += new System.EventHandler(this.cmdConnect_Click); - // - // txtFirstName - // - this.txtFirstName.Location = new System.Drawing.Point(16, 40); - this.txtFirstName.Name = "txtFirstName"; - this.txtFirstName.Size = new System.Drawing.Size(120, 20); - this.txtFirstName.TabIndex = 0; - this.txtFirstName.Text = ""; - // - // lstAvatars - // - this.lstAvatars.Location = new System.Drawing.Point(16, 40); - this.lstAvatars.Name = "lstAvatars"; - this.lstAvatars.Size = new System.Drawing.Size(216, 225); - this.lstAvatars.TabIndex = 52; - // - // label4 - // - this.label4.Location = new System.Drawing.Point(16, 16); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(216, 16); - this.label4.TabIndex = 53; - this.label4.Text = "Logged in Avatars:"; - // - // cmdSelect - // - this.cmdSelect.Enabled = false; - this.cmdSelect.Location = new System.Drawing.Point(112, 272); - this.cmdSelect.Name = "cmdSelect"; - this.cmdSelect.Size = new System.Drawing.Size(120, 24); - this.cmdSelect.TabIndex = 54; - this.cmdSelect.Text = "Select"; - this.cmdSelect.Click += new System.EventHandler(this.cmdSelect_Click); - // - // frmLogin - // - this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); - this.ClientSize = new System.Drawing.Size(584, 397); - this.Controls.Add(this.cmdSelect); - this.Controls.Add(this.label4); - this.Controls.Add(this.lstAvatars); - this.Controls.Add(this.grpLogin); - this.MaximizeBox = false; - this.MaximumSize = new System.Drawing.Size(592, 424); - this.MinimizeBox = false; - this.MinimumSize = new System.Drawing.Size(592, 424); - this.Name = "frmLogin"; - this.ShowInTaskbar = false; - this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; - this.Text = "New Plugin Connection"; - this.grpLogin.ResumeLayout(false); - this.ResumeLayout(false); - - } - #endregion - - private void cmdConnect_Click(object sender, System.EventArgs e) - { - SecondLife client = null; - - cmdConnect.Enabled = false; - cmdSelect.Enabled = false; - - try - { - client = new SecondLife("keywords.txt", "message_template.msg"); - } - catch (Exception error) - { - MessageBox.Show(this, error.ToString()); - this.Close(); - } - - // Initialize the plugin, to allow it to register callbacks and get ready - Plugin.Init(client); - - Hashtable loginParams = NetworkManager.DefaultLoginValues(txtFirstName.Text, - txtLastName.Text, txtPassword.Text, "00:00:00:00:00:00", "last", 1, 10, 10, 0, - "Win", "0", "accountant", "jhurliman@wsu.edu"); - - if (client.Network.Login(loginParams)) - { - // Register this logged in avatar - SecondSuite.AddClient(client); - - // Show the plugin form - Form form = Plugin.Load(); - form.MdiParent = SecondSuite; - form.Show(); - - Plugin.ConnectionHandler(); - - // Exit this form - this.Close(); - } - else - { - // Show an error - MessageBox.Show(this, "Error logging in: " + client.Network.LoginError); - cmdConnect.Enabled = true; - cmdSelect.Enabled = true; - } - } - - private void cmdSelect_Click(object sender, System.EventArgs e) - { - cmdConnect.Enabled = false; - cmdSelect.Enabled = false; - - // FIXME - } - } -} +using System; +using System.Drawing; +using System.Collections; +using System.ComponentModel; +using System.Windows.Forms; +using SecondSuite.Plugins; +using libsecondlife; + +namespace SecondSuite +{ + /// + /// Summary description for frmLogin. + /// + public class frmLogin : System.Windows.Forms.Form + { + private System.Windows.Forms.GroupBox grpLogin; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.TextBox txtPassword; + private System.Windows.Forms.TextBox txtLastName; + private System.Windows.Forms.Button cmdConnect; + private System.Windows.Forms.TextBox txtFirstName; + public System.Windows.Forms.ListBox lstAvatars; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Button cmdSelect; + /// + /// Required designer variable. + /// + private System.ComponentModel.Container components = null; + + // + private frmSecondSuite SecondSuite; + private SSPlugin Plugin; + + public frmLogin(frmSecondSuite secondSuite, SSPlugin plugin) + { + // + // Required for Windows Form Designer support + // + InitializeComponent(); + + SecondSuite = secondSuite; + Plugin = plugin; + } + + /// + /// Clean up any resources being used. + /// + protected override void Dispose( bool disposing ) + { + if( disposing ) + { + if(components != null) + { + components.Dispose(); + } + } + base.Dispose( disposing ); + } + + #region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.grpLogin = new System.Windows.Forms.GroupBox(); + this.label3 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.txtPassword = new System.Windows.Forms.TextBox(); + this.txtLastName = new System.Windows.Forms.TextBox(); + this.cmdConnect = new System.Windows.Forms.Button(); + this.txtFirstName = new System.Windows.Forms.TextBox(); + this.lstAvatars = new System.Windows.Forms.ListBox(); + this.label4 = new System.Windows.Forms.Label(); + this.cmdSelect = new System.Windows.Forms.Button(); + this.grpLogin.SuspendLayout(); + this.SuspendLayout(); + // + // grpLogin + // + this.grpLogin.Controls.Add(this.label3); + this.grpLogin.Controls.Add(this.label2); + this.grpLogin.Controls.Add(this.label1); + this.grpLogin.Controls.Add(this.txtPassword); + this.grpLogin.Controls.Add(this.txtLastName); + this.grpLogin.Controls.Add(this.cmdConnect); + this.grpLogin.Controls.Add(this.txtFirstName); + this.grpLogin.Location = new System.Drawing.Point(16, 304); + this.grpLogin.Name = "grpLogin"; + this.grpLogin.Size = new System.Drawing.Size(552, 80); + this.grpLogin.TabIndex = 51; + this.grpLogin.TabStop = false; + // + // label3 + // + this.label3.Location = new System.Drawing.Point(280, 24); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(120, 16); + this.label3.TabIndex = 50; + this.label3.Text = "Password"; + // + // label2 + // + this.label2.Location = new System.Drawing.Point(152, 24); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(120, 16); + this.label2.TabIndex = 50; + this.label2.Text = "Last Name"; + // + // label1 + // + this.label1.Location = new System.Drawing.Point(16, 24); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(120, 16); + this.label1.TabIndex = 50; + this.label1.Text = "First Name"; + // + // txtPassword + // + this.txtPassword.Location = new System.Drawing.Point(280, 40); + this.txtPassword.Name = "txtPassword"; + this.txtPassword.PasswordChar = '*'; + this.txtPassword.Size = new System.Drawing.Size(120, 20); + this.txtPassword.TabIndex = 2; + this.txtPassword.Text = ""; + // + // txtLastName + // + this.txtLastName.Location = new System.Drawing.Point(152, 40); + this.txtLastName.Name = "txtLastName"; + this.txtLastName.Size = new System.Drawing.Size(112, 20); + this.txtLastName.TabIndex = 1; + this.txtLastName.Text = ""; + // + // cmdConnect + // + this.cmdConnect.Location = new System.Drawing.Point(416, 40); + this.cmdConnect.Name = "cmdConnect"; + this.cmdConnect.Size = new System.Drawing.Size(120, 24); + this.cmdConnect.TabIndex = 3; + this.cmdConnect.Text = "Connect"; + this.cmdConnect.Click += new System.EventHandler(this.cmdConnect_Click); + // + // txtFirstName + // + this.txtFirstName.Location = new System.Drawing.Point(16, 40); + this.txtFirstName.Name = "txtFirstName"; + this.txtFirstName.Size = new System.Drawing.Size(120, 20); + this.txtFirstName.TabIndex = 0; + this.txtFirstName.Text = ""; + // + // lstAvatars + // + this.lstAvatars.Location = new System.Drawing.Point(16, 40); + this.lstAvatars.Name = "lstAvatars"; + this.lstAvatars.Size = new System.Drawing.Size(216, 225); + this.lstAvatars.TabIndex = 52; + // + // label4 + // + this.label4.Location = new System.Drawing.Point(16, 16); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(216, 16); + this.label4.TabIndex = 53; + this.label4.Text = "Logged in Avatars:"; + // + // cmdSelect + // + this.cmdSelect.Enabled = false; + this.cmdSelect.Location = new System.Drawing.Point(112, 272); + this.cmdSelect.Name = "cmdSelect"; + this.cmdSelect.Size = new System.Drawing.Size(120, 24); + this.cmdSelect.TabIndex = 54; + this.cmdSelect.Text = "Select"; + this.cmdSelect.Click += new System.EventHandler(this.cmdSelect_Click); + // + // frmLogin + // + this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); + this.ClientSize = new System.Drawing.Size(584, 397); + this.Controls.Add(this.cmdSelect); + this.Controls.Add(this.label4); + this.Controls.Add(this.lstAvatars); + this.Controls.Add(this.grpLogin); + this.MaximizeBox = false; + this.MaximumSize = new System.Drawing.Size(592, 424); + this.MinimizeBox = false; + this.MinimumSize = new System.Drawing.Size(592, 424); + this.Name = "frmLogin"; + this.ShowInTaskbar = false; + this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; + this.Text = "New Plugin Connection"; + this.grpLogin.ResumeLayout(false); + this.ResumeLayout(false); + + } + #endregion + + private void cmdConnect_Click(object sender, System.EventArgs e) + { + SecondLife client = null; + + cmdConnect.Enabled = false; + cmdSelect.Enabled = false; + + try + { + client = new SecondLife("keywords.txt", "message_template.msg"); + } + catch (Exception error) + { + MessageBox.Show(this, error.ToString()); + this.Close(); + } + + // Initialize the plugin, to allow it to register callbacks and get ready + Plugin.Init(client); + + Hashtable loginParams = NetworkManager.DefaultLoginValues(txtFirstName.Text, + txtLastName.Text, txtPassword.Text, "00:00:00:00:00:00", "last", 1, 10, 10, 0, + "Win", "0", "accountant", "jhurliman@wsu.edu"); + + if (client.Network.Login(loginParams)) + { + // Register this logged in avatar + SecondSuite.AddClient(client); + + // Show the plugin form + Form form = Plugin.Load(); + form.MdiParent = SecondSuite; + form.Show(); + + Plugin.ConnectionHandler(); + + // Exit this form + this.Close(); + } + else + { + // Show an error + MessageBox.Show(this, "Error logging in: " + client.Network.LoginError); + cmdConnect.Enabled = true; + cmdSelect.Enabled = true; + } + } + + private void cmdSelect_Click(object sender, System.EventArgs e) + { + cmdConnect.Enabled = false; + cmdSelect.Enabled = false; + + // FIXME + } + } +} diff --git a/applications/SecondSuite/frmLogin.resx b/applications/SecondSuite/frmLogin.resx index 6b3489e1..ebb7527b 100644 --- a/applications/SecondSuite/frmLogin.resx +++ b/applications/SecondSuite/frmLogin.resx @@ -1,238 +1,238 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 1.3 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Private - - - 8, 8 - - - True - - - False - - - True - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - False - - - Private - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Public - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - (Default) - - - False - - - frmLogin - - - False - - - 8, 8 - - - True - - - 80 - - - True - - - Private - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Private + + + 8, 8 + + + True + + + False + + + True + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + False + + + Private + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Public + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + (Default) + + + False + + + frmLogin + + + False + + + 8, 8 + + + True + + + 80 + + + True + + + Private + \ No newline at end of file diff --git a/applications/SecondSuite/frmOverview.cs b/applications/SecondSuite/frmOverview.cs index f2d18a35..2c8d001a 100644 --- a/applications/SecondSuite/frmOverview.cs +++ b/applications/SecondSuite/frmOverview.cs @@ -1,281 +1,281 @@ -using System; -using System.Drawing; -using System.Collections; -using System.ComponentModel; -using System.Windows.Forms; -using SecondSuite.Plugins; -using libsecondlife; - -namespace SecondSuite -{ - /// - /// Summary description for frmOverview. - /// - public class frmOverview : System.Windows.Forms.Form - { - private System.Windows.Forms.ListBox lstAvatars; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.Label label2; - public System.Windows.Forms.ListBox lstPlugins; - private System.Windows.Forms.GroupBox framePluginInfo; - private System.Windows.Forms.Label lblDescription; - private System.Windows.Forms.Label label4; - private System.Windows.Forms.Label label5; - private System.Windows.Forms.Label lblAuthor; - private System.Windows.Forms.LinkLabel lblHomepage; - private System.Windows.Forms.Label label7; - private System.Windows.Forms.Button cmdNewInstance; - private System.Windows.Forms.Button cmdDisconnect; - /// - /// Required designer variable. - /// - private System.ComponentModel.Container components = null; - - // - private frmSecondSuite SecondSuite; - - public frmOverview(frmSecondSuite secondSuite) - { - // - // Required for Windows Form Designer support - // - InitializeComponent(); - - SecondSuite = secondSuite; - } - - /// - /// Clean up any resources being used. - /// - protected override void Dispose( bool disposing ) - { - if( disposing ) - { - if(components != null) - { - components.Dispose(); - } - } - base.Dispose( disposing ); - } - - #region Windows Form Designer generated code - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.lstAvatars = new System.Windows.Forms.ListBox(); - this.label1 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.lstPlugins = new System.Windows.Forms.ListBox(); - this.framePluginInfo = new System.Windows.Forms.GroupBox(); - this.label7 = new System.Windows.Forms.Label(); - this.lblHomepage = new System.Windows.Forms.LinkLabel(); - this.lblAuthor = new System.Windows.Forms.Label(); - this.label5 = new System.Windows.Forms.Label(); - this.label4 = new System.Windows.Forms.Label(); - this.lblDescription = new System.Windows.Forms.Label(); - this.cmdNewInstance = new System.Windows.Forms.Button(); - this.cmdDisconnect = new System.Windows.Forms.Button(); - this.framePluginInfo.SuspendLayout(); - this.SuspendLayout(); - // - // lstAvatars - // - this.lstAvatars.Location = new System.Drawing.Point(16, 40); - this.lstAvatars.Name = "lstAvatars"; - this.lstAvatars.Size = new System.Drawing.Size(184, 277); - this.lstAvatars.TabIndex = 0; - this.lstAvatars.SelectedIndexChanged += new System.EventHandler(this.lstAvatars_SelectedIndexChanged); - // - // label1 - // - this.label1.Location = new System.Drawing.Point(16, 16); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(184, 16); - this.label1.TabIndex = 1; - this.label1.Text = "Online Avatars"; - // - // label2 - // - this.label2.Location = new System.Drawing.Point(208, 16); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(184, 16); - this.label2.TabIndex = 3; - this.label2.Text = "Loaded Plugins"; - // - // lstPlugins - // - this.lstPlugins.Location = new System.Drawing.Point(208, 40); - this.lstPlugins.Name = "lstPlugins"; - this.lstPlugins.Size = new System.Drawing.Size(184, 277); - this.lstPlugins.TabIndex = 2; - this.lstPlugins.SelectedIndexChanged += new System.EventHandler(this.lstPlugins_SelectedIndexChanged); - // - // framePluginInfo - // - this.framePluginInfo.Controls.Add(this.label7); - this.framePluginInfo.Controls.Add(this.lblHomepage); - this.framePluginInfo.Controls.Add(this.lblAuthor); - this.framePluginInfo.Controls.Add(this.label5); - this.framePluginInfo.Controls.Add(this.label4); - this.framePluginInfo.Controls.Add(this.lblDescription); - this.framePluginInfo.Location = new System.Drawing.Point(400, 32); - this.framePluginInfo.Name = "framePluginInfo"; - this.framePluginInfo.Size = new System.Drawing.Size(288, 288); - this.framePluginInfo.TabIndex = 4; - this.framePluginInfo.TabStop = false; - this.framePluginInfo.Text = "Plugin Information"; - // - // label7 - // - this.label7.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); - this.label7.Location = new System.Drawing.Point(8, 120); - this.label7.Name = "label7"; - this.label7.Size = new System.Drawing.Size(88, 16); - this.label7.TabIndex = 5; - this.label7.Text = "Description:"; - // - // lblHomepage - // - this.lblHomepage.Location = new System.Drawing.Point(8, 96); - this.lblHomepage.Name = "lblHomepage"; - this.lblHomepage.Size = new System.Drawing.Size(272, 16); - this.lblHomepage.TabIndex = 4; - // - // lblAuthor - // - this.lblAuthor.Location = new System.Drawing.Point(8, 48); - this.lblAuthor.Name = "lblAuthor"; - this.lblAuthor.Size = new System.Drawing.Size(272, 16); - this.lblAuthor.TabIndex = 3; - // - // label5 - // - this.label5.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); - this.label5.Location = new System.Drawing.Point(8, 72); - this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(88, 16); - this.label5.TabIndex = 2; - this.label5.Text = "Homepage:"; - // - // label4 - // - this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); - this.label4.Location = new System.Drawing.Point(8, 24); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(88, 16); - this.label4.TabIndex = 1; - this.label4.Text = "Author:"; - // - // lblDescription - // - this.lblDescription.Location = new System.Drawing.Point(8, 144); - this.lblDescription.Name = "lblDescription"; - this.lblDescription.Size = new System.Drawing.Size(272, 136); - this.lblDescription.TabIndex = 0; - // - // cmdNewInstance - // - this.cmdNewInstance.Enabled = false; - this.cmdNewInstance.Location = new System.Drawing.Point(280, 328); - this.cmdNewInstance.Name = "cmdNewInstance"; - this.cmdNewInstance.Size = new System.Drawing.Size(112, 24); - this.cmdNewInstance.TabIndex = 5; - this.cmdNewInstance.Text = "New Instance"; - this.cmdNewInstance.Click += new System.EventHandler(this.cmdNewInstance_Click); - // - // cmdDisconnect - // - this.cmdDisconnect.Enabled = false; - this.cmdDisconnect.Location = new System.Drawing.Point(88, 328); - this.cmdDisconnect.Name = "cmdDisconnect"; - this.cmdDisconnect.Size = new System.Drawing.Size(112, 24); - this.cmdDisconnect.TabIndex = 6; - this.cmdDisconnect.Text = "Disconnect"; - this.cmdDisconnect.Click += new System.EventHandler(this.cmdDisconnect_Click); - // - // frmOverview - // - this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); - this.ClientSize = new System.Drawing.Size(704, 365); - this.ControlBox = false; - this.Controls.Add(this.cmdDisconnect); - this.Controls.Add(this.cmdNewInstance); - this.Controls.Add(this.framePluginInfo); - this.Controls.Add(this.label2); - this.Controls.Add(this.lstPlugins); - this.Controls.Add(this.label1); - this.Controls.Add(this.lstAvatars); - this.MaximizeBox = false; - this.MaximumSize = new System.Drawing.Size(712, 392); - this.MinimumSize = new System.Drawing.Size(712, 392); - this.Name = "frmOverview"; - this.ShowInTaskbar = false; - this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; - this.Text = "Overview"; - this.Load += new System.EventHandler(this.frmOverview_Load); - this.framePluginInfo.ResumeLayout(false); - this.ResumeLayout(false); - - } - #endregion - - private void frmOverview_Load(object sender, System.EventArgs e) - { - } - - public void ClientAdded(SecondLife client) - { - lstAvatars.Items.Add(client); - } - - public void ClientRemoved(SecondLife client) - { - lstAvatars.Items.Remove(client); - - if (lstAvatars.SelectedIndex == -1) - { - cmdDisconnect.Enabled = false; - } - } - - private void lstPlugins_SelectedIndexChanged(object sender, System.EventArgs e) - { - SSPlugin plugin = (SSPlugin)lstPlugins.Items[lstPlugins.SelectedIndex]; - lblAuthor.Text = plugin.Author; - lblHomepage.Text = plugin.Homepage; - lblDescription.Text = plugin.Description; - - cmdNewInstance.Enabled = true; - } - - private void cmdNewInstance_Click(object sender, System.EventArgs e) - { - SSPlugin plugin = (SSPlugin)lstPlugins.Items[lstPlugins.SelectedIndex]; - - frmLogin login = new frmLogin(SecondSuite, plugin); - login.ShowDialog(this); - } - - private void cmdDisconnect_Click(object sender, System.EventArgs e) - { - if (lstAvatars.SelectedIndex >=0) - { - SecondSuite.RemoveClient((SecondLife)lstAvatars.Items[lstAvatars.SelectedIndex]); - } - - if (lstAvatars.SelectedIndex == -1) - { - cmdDisconnect.Enabled = false; - } - } - - private void lstAvatars_SelectedIndexChanged(object sender, System.EventArgs e) - { - cmdDisconnect.Enabled = true; - } - } -} +using System; +using System.Drawing; +using System.Collections; +using System.ComponentModel; +using System.Windows.Forms; +using SecondSuite.Plugins; +using libsecondlife; + +namespace SecondSuite +{ + /// + /// Summary description for frmOverview. + /// + public class frmOverview : System.Windows.Forms.Form + { + private System.Windows.Forms.ListBox lstAvatars; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + public System.Windows.Forms.ListBox lstPlugins; + private System.Windows.Forms.GroupBox framePluginInfo; + private System.Windows.Forms.Label lblDescription; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.Label lblAuthor; + private System.Windows.Forms.LinkLabel lblHomepage; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.Button cmdNewInstance; + private System.Windows.Forms.Button cmdDisconnect; + /// + /// Required designer variable. + /// + private System.ComponentModel.Container components = null; + + // + private frmSecondSuite SecondSuite; + + public frmOverview(frmSecondSuite secondSuite) + { + // + // Required for Windows Form Designer support + // + InitializeComponent(); + + SecondSuite = secondSuite; + } + + /// + /// Clean up any resources being used. + /// + protected override void Dispose( bool disposing ) + { + if( disposing ) + { + if(components != null) + { + components.Dispose(); + } + } + base.Dispose( disposing ); + } + + #region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.lstAvatars = new System.Windows.Forms.ListBox(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.lstPlugins = new System.Windows.Forms.ListBox(); + this.framePluginInfo = new System.Windows.Forms.GroupBox(); + this.label7 = new System.Windows.Forms.Label(); + this.lblHomepage = new System.Windows.Forms.LinkLabel(); + this.lblAuthor = new System.Windows.Forms.Label(); + this.label5 = new System.Windows.Forms.Label(); + this.label4 = new System.Windows.Forms.Label(); + this.lblDescription = new System.Windows.Forms.Label(); + this.cmdNewInstance = new System.Windows.Forms.Button(); + this.cmdDisconnect = new System.Windows.Forms.Button(); + this.framePluginInfo.SuspendLayout(); + this.SuspendLayout(); + // + // lstAvatars + // + this.lstAvatars.Location = new System.Drawing.Point(16, 40); + this.lstAvatars.Name = "lstAvatars"; + this.lstAvatars.Size = new System.Drawing.Size(184, 277); + this.lstAvatars.TabIndex = 0; + this.lstAvatars.SelectedIndexChanged += new System.EventHandler(this.lstAvatars_SelectedIndexChanged); + // + // label1 + // + this.label1.Location = new System.Drawing.Point(16, 16); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(184, 16); + this.label1.TabIndex = 1; + this.label1.Text = "Online Avatars"; + // + // label2 + // + this.label2.Location = new System.Drawing.Point(208, 16); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(184, 16); + this.label2.TabIndex = 3; + this.label2.Text = "Loaded Plugins"; + // + // lstPlugins + // + this.lstPlugins.Location = new System.Drawing.Point(208, 40); + this.lstPlugins.Name = "lstPlugins"; + this.lstPlugins.Size = new System.Drawing.Size(184, 277); + this.lstPlugins.TabIndex = 2; + this.lstPlugins.SelectedIndexChanged += new System.EventHandler(this.lstPlugins_SelectedIndexChanged); + // + // framePluginInfo + // + this.framePluginInfo.Controls.Add(this.label7); + this.framePluginInfo.Controls.Add(this.lblHomepage); + this.framePluginInfo.Controls.Add(this.lblAuthor); + this.framePluginInfo.Controls.Add(this.label5); + this.framePluginInfo.Controls.Add(this.label4); + this.framePluginInfo.Controls.Add(this.lblDescription); + this.framePluginInfo.Location = new System.Drawing.Point(400, 32); + this.framePluginInfo.Name = "framePluginInfo"; + this.framePluginInfo.Size = new System.Drawing.Size(288, 288); + this.framePluginInfo.TabIndex = 4; + this.framePluginInfo.TabStop = false; + this.framePluginInfo.Text = "Plugin Information"; + // + // label7 + // + this.label7.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); + this.label7.Location = new System.Drawing.Point(8, 120); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(88, 16); + this.label7.TabIndex = 5; + this.label7.Text = "Description:"; + // + // lblHomepage + // + this.lblHomepage.Location = new System.Drawing.Point(8, 96); + this.lblHomepage.Name = "lblHomepage"; + this.lblHomepage.Size = new System.Drawing.Size(272, 16); + this.lblHomepage.TabIndex = 4; + // + // lblAuthor + // + this.lblAuthor.Location = new System.Drawing.Point(8, 48); + this.lblAuthor.Name = "lblAuthor"; + this.lblAuthor.Size = new System.Drawing.Size(272, 16); + this.lblAuthor.TabIndex = 3; + // + // label5 + // + this.label5.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); + this.label5.Location = new System.Drawing.Point(8, 72); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(88, 16); + this.label5.TabIndex = 2; + this.label5.Text = "Homepage:"; + // + // label4 + // + this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0))); + this.label4.Location = new System.Drawing.Point(8, 24); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(88, 16); + this.label4.TabIndex = 1; + this.label4.Text = "Author:"; + // + // lblDescription + // + this.lblDescription.Location = new System.Drawing.Point(8, 144); + this.lblDescription.Name = "lblDescription"; + this.lblDescription.Size = new System.Drawing.Size(272, 136); + this.lblDescription.TabIndex = 0; + // + // cmdNewInstance + // + this.cmdNewInstance.Enabled = false; + this.cmdNewInstance.Location = new System.Drawing.Point(280, 328); + this.cmdNewInstance.Name = "cmdNewInstance"; + this.cmdNewInstance.Size = new System.Drawing.Size(112, 24); + this.cmdNewInstance.TabIndex = 5; + this.cmdNewInstance.Text = "New Instance"; + this.cmdNewInstance.Click += new System.EventHandler(this.cmdNewInstance_Click); + // + // cmdDisconnect + // + this.cmdDisconnect.Enabled = false; + this.cmdDisconnect.Location = new System.Drawing.Point(88, 328); + this.cmdDisconnect.Name = "cmdDisconnect"; + this.cmdDisconnect.Size = new System.Drawing.Size(112, 24); + this.cmdDisconnect.TabIndex = 6; + this.cmdDisconnect.Text = "Disconnect"; + this.cmdDisconnect.Click += new System.EventHandler(this.cmdDisconnect_Click); + // + // frmOverview + // + this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); + this.ClientSize = new System.Drawing.Size(704, 365); + this.ControlBox = false; + this.Controls.Add(this.cmdDisconnect); + this.Controls.Add(this.cmdNewInstance); + this.Controls.Add(this.framePluginInfo); + this.Controls.Add(this.label2); + this.Controls.Add(this.lstPlugins); + this.Controls.Add(this.label1); + this.Controls.Add(this.lstAvatars); + this.MaximizeBox = false; + this.MaximumSize = new System.Drawing.Size(712, 392); + this.MinimumSize = new System.Drawing.Size(712, 392); + this.Name = "frmOverview"; + this.ShowInTaskbar = false; + this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; + this.Text = "Overview"; + this.Load += new System.EventHandler(this.frmOverview_Load); + this.framePluginInfo.ResumeLayout(false); + this.ResumeLayout(false); + + } + #endregion + + private void frmOverview_Load(object sender, System.EventArgs e) + { + } + + public void ClientAdded(SecondLife client) + { + lstAvatars.Items.Add(client); + } + + public void ClientRemoved(SecondLife client) + { + lstAvatars.Items.Remove(client); + + if (lstAvatars.SelectedIndex == -1) + { + cmdDisconnect.Enabled = false; + } + } + + private void lstPlugins_SelectedIndexChanged(object sender, System.EventArgs e) + { + SSPlugin plugin = (SSPlugin)lstPlugins.Items[lstPlugins.SelectedIndex]; + lblAuthor.Text = plugin.Author; + lblHomepage.Text = plugin.Homepage; + lblDescription.Text = plugin.Description; + + cmdNewInstance.Enabled = true; + } + + private void cmdNewInstance_Click(object sender, System.EventArgs e) + { + SSPlugin plugin = (SSPlugin)lstPlugins.Items[lstPlugins.SelectedIndex]; + + frmLogin login = new frmLogin(SecondSuite, plugin); + login.ShowDialog(this); + } + + private void cmdDisconnect_Click(object sender, System.EventArgs e) + { + if (lstAvatars.SelectedIndex >=0) + { + SecondSuite.RemoveClient((SecondLife)lstAvatars.Items[lstAvatars.SelectedIndex]); + } + + if (lstAvatars.SelectedIndex == -1) + { + cmdDisconnect.Enabled = false; + } + } + + private void lstAvatars_SelectedIndexChanged(object sender, System.EventArgs e) + { + cmdDisconnect.Enabled = true; + } + } +} diff --git a/applications/SecondSuite/frmOverview.resx b/applications/SecondSuite/frmOverview.resx index a7f19839..fe8d1971 100644 --- a/applications/SecondSuite/frmOverview.resx +++ b/applications/SecondSuite/frmOverview.resx @@ -1,256 +1,256 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 1.3 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Private - - - False - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - Private - - - False - - - Public - - - Private - - - 8, 8 - - - True - - - False - - - True - - - Private - - - False - - - Private - - - Private - - - Private - - - Private - - - False - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - Private - - - False - - - Private - - - False - - - Private - - - Private - - - False - - - frmOverview - - - (Default) - - - False - - - False - - - 8, 8 - - - True - - - 80 - - - True - - - Private - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Private + + + False + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + Private + + + False + + + Public + + + Private + + + 8, 8 + + + True + + + False + + + True + + + Private + + + False + + + Private + + + Private + + + Private + + + Private + + + False + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + Private + + + False + + + Private + + + False + + + Private + + + Private + + + False + + + frmOverview + + + (Default) + + + False + + + False + + + 8, 8 + + + True + + + 80 + + + True + + + Private + \ No newline at end of file diff --git a/applications/SecondSuite/frmSecondSuite.cs b/applications/SecondSuite/frmSecondSuite.cs index 13581ac8..00606783 100644 --- a/applications/SecondSuite/frmSecondSuite.cs +++ b/applications/SecondSuite/frmSecondSuite.cs @@ -1,278 +1,278 @@ -using System; -using System.Drawing; -using System.Collections; -using System.ComponentModel; -using System.Windows.Forms; -using System.Data; -using System.IO; -using System.Reflection; -using libsecondlife; -using SecondSuite.Plugins; - -namespace SecondSuite -{ - public class frmSecondSuite : System.Windows.Forms.Form - { - /// - /// Required designer variable. - /// - private System.ComponentModel.Container components = null; - private System.Windows.Forms.StatusBar statusBar; - private System.Windows.Forms.MenuItem menuItem3; - private System.Windows.Forms.MainMenu mainMenu; - private System.Windows.Forms.MenuItem menuFile; - private System.Windows.Forms.MenuItem menuExit; - private System.Windows.Forms.MenuItem menuHelp; - private System.Windows.Forms.MenuItem menuAbout; - private System.Windows.Forms.MenuItem menuReload; - - // - private frmOverview Overview; - - public frmSecondSuite() - { - // - // Required for Windows Form Designer support - // - InitializeComponent(); - - Overview = new frmOverview(this); - Overview.MdiParent = this; - - FindPlugins(); - - Overview.Show(); - } - - /// - /// Clean up any resources being used. - /// - protected override void Dispose( bool disposing ) - { - // Kill all the clients and plugins - DisconnectAllClients(); - ShutdownAllPlugins(); - - if( disposing ) - { - if (components != null) - { - components.Dispose(); - } - } - base.Dispose( disposing ); - } - - public void AddClient(SecondLife client) - { - Global.ClientsMutex.WaitOne(); - Global.Clients.Add(client); - Global.ClientsMutex.ReleaseMutex(); - - Overview.ClientAdded(client); - } - - public void RemoveClient(SecondLife client) - { - Global.ClientsMutex.WaitOne(); - client.Network.Logout(); - Global.Clients.Remove(client); - Global.ClientsMutex.ReleaseMutex(); - - Overview.ClientRemoved(client); - } - - public void DisconnectAllClients() - { - Global.ClientsMutex.WaitOne(); - - foreach (SecondLife client in Global.Clients) - { - client.Network.Logout(); - } - - Global.Clients.Clear(); - - Global.ClientsMutex.ReleaseMutex(); - } - - public void ShutdownAllPlugins() - { - Global.PluginsMutex.WaitOne(); - - foreach (SSPlugin plugin in Global.Plugins) - { - plugin.Shutdown(); - } - - Global.Plugins.Clear(); - - Global.PluginsMutex.ReleaseMutex(); - } - - public void FindPlugins() - { - //First empty the collection, we're reloading them all - Global.PluginsMutex.WaitOne(); - Global.Plugins = new PluginCollection(); - Overview.lstPlugins.Items.Clear(); - Global.PluginsMutex.ReleaseMutex(); - - //Go through all the files in the plugin directory - foreach (string filename in Directory.GetFiles( - AppDomain.CurrentDomain.BaseDirectory + "\\plugins\\")) - { - FileInfo file = new FileInfo(filename); - - //Preliminary check, must be .dll - if (file.Extension.Equals(".dll")) - { - //Add the 'plugin' - this.AddPlugin(filename); - } - } - } - - private void AddPlugin(string filename) - { - SSPlugin plugin; - - try - { - Assembly pluginAssembly = Assembly.LoadFrom(filename); - - foreach (Type pluginType in pluginAssembly.GetTypes()) - { - if (pluginType.IsPublic && !pluginType.IsAbstract) - { - Type typeInterface = pluginType.GetInterface("SecondSuite.Plugins.SSPlugin", true); - - if (typeInterface != null) - { - plugin = (SSPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); - - Global.PluginsMutex.WaitOne(); - Global.Plugins.Add(plugin); - Global.PluginsMutex.ReleaseMutex(); - - Overview.lstPlugins.Items.Add(plugin); - } - } - } - } - catch (ReflectionTypeLoadException e) - { - MessageBox.Show(e.LoaderExceptions[0].ToString()); - } - } - - #region Windows Form Designer generated code - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.statusBar = new System.Windows.Forms.StatusBar(); - this.mainMenu = new System.Windows.Forms.MainMenu(); - this.menuFile = new System.Windows.Forms.MenuItem(); - this.menuReload = new System.Windows.Forms.MenuItem(); - this.menuItem3 = new System.Windows.Forms.MenuItem(); - this.menuExit = new System.Windows.Forms.MenuItem(); - this.menuHelp = new System.Windows.Forms.MenuItem(); - this.menuAbout = new System.Windows.Forms.MenuItem(); - this.SuspendLayout(); - // - // statusBar - // - this.statusBar.Location = new System.Drawing.Point(0, 681); - this.statusBar.Name = "statusBar"; - this.statusBar.ShowPanels = true; - this.statusBar.Size = new System.Drawing.Size(992, 22); - this.statusBar.TabIndex = 1; - // - // mainMenu - // - this.mainMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { - this.menuFile, - this.menuHelp}); - // - // menuFile - // - this.menuFile.Index = 0; - this.menuFile.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { - this.menuReload, - this.menuItem3, - this.menuExit}); - this.menuFile.Text = "File"; - // - // menuReload - // - this.menuReload.Index = 0; - this.menuReload.Text = "Reload Plugins"; - this.menuReload.Click += new System.EventHandler(this.menuReload_Click); - // - // menuItem3 - // - this.menuItem3.Index = 1; - this.menuItem3.Text = "-"; - // - // menuExit - // - this.menuExit.Index = 2; - this.menuExit.Text = "Exit"; - this.menuExit.Click += new System.EventHandler(this.menuExit_Click); - // - // menuHelp - // - this.menuHelp.Index = 1; - this.menuHelp.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { - this.menuAbout}); - this.menuHelp.Text = "Help"; - // - // menuAbout - // - this.menuAbout.Index = 0; - this.menuAbout.Text = "About"; - // - // frmSecondSuite - // - this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); - this.ClientSize = new System.Drawing.Size(992, 703); - this.Controls.Add(this.statusBar); - this.IsMdiContainer = true; - this.Menu = this.mainMenu; - this.Name = "frmSecondSuite"; - this.Text = "Second Suite"; - this.Load += new System.EventHandler(this.frmSecondSuite_Load); - this.ResumeLayout(false); - - } - #endregion - - /// - /// The main entry point for the application. - /// - [STAThread] - static void Main() - { - Application.Run(new frmSecondSuite()); - } - - private void frmSecondSuite_Load(object sender, System.EventArgs e) - { - - } - - private void menuExit_Click(object sender, System.EventArgs e) - { - this.Close(); - } - - private void menuReload_Click(object sender, System.EventArgs e) - { - ShutdownAllPlugins(); - FindPlugins(); - } - } -} +using System; +using System.Drawing; +using System.Collections; +using System.ComponentModel; +using System.Windows.Forms; +using System.Data; +using System.IO; +using System.Reflection; +using libsecondlife; +using SecondSuite.Plugins; + +namespace SecondSuite +{ + public class frmSecondSuite : System.Windows.Forms.Form + { + /// + /// Required designer variable. + /// + private System.ComponentModel.Container components = null; + private System.Windows.Forms.StatusBar statusBar; + private System.Windows.Forms.MenuItem menuItem3; + private System.Windows.Forms.MainMenu mainMenu; + private System.Windows.Forms.MenuItem menuFile; + private System.Windows.Forms.MenuItem menuExit; + private System.Windows.Forms.MenuItem menuHelp; + private System.Windows.Forms.MenuItem menuAbout; + private System.Windows.Forms.MenuItem menuReload; + + // + private frmOverview Overview; + + public frmSecondSuite() + { + // + // Required for Windows Form Designer support + // + InitializeComponent(); + + Overview = new frmOverview(this); + Overview.MdiParent = this; + + FindPlugins(); + + Overview.Show(); + } + + /// + /// Clean up any resources being used. + /// + protected override void Dispose( bool disposing ) + { + // Kill all the clients and plugins + DisconnectAllClients(); + ShutdownAllPlugins(); + + if( disposing ) + { + if (components != null) + { + components.Dispose(); + } + } + base.Dispose( disposing ); + } + + public void AddClient(SecondLife client) + { + Global.ClientsMutex.WaitOne(); + Global.Clients.Add(client); + Global.ClientsMutex.ReleaseMutex(); + + Overview.ClientAdded(client); + } + + public void RemoveClient(SecondLife client) + { + Global.ClientsMutex.WaitOne(); + client.Network.Logout(); + Global.Clients.Remove(client); + Global.ClientsMutex.ReleaseMutex(); + + Overview.ClientRemoved(client); + } + + public void DisconnectAllClients() + { + Global.ClientsMutex.WaitOne(); + + foreach (SecondLife client in Global.Clients) + { + client.Network.Logout(); + } + + Global.Clients.Clear(); + + Global.ClientsMutex.ReleaseMutex(); + } + + public void ShutdownAllPlugins() + { + Global.PluginsMutex.WaitOne(); + + foreach (SSPlugin plugin in Global.Plugins) + { + plugin.Shutdown(); + } + + Global.Plugins.Clear(); + + Global.PluginsMutex.ReleaseMutex(); + } + + public void FindPlugins() + { + //First empty the collection, we're reloading them all + Global.PluginsMutex.WaitOne(); + Global.Plugins = new PluginCollection(); + Overview.lstPlugins.Items.Clear(); + Global.PluginsMutex.ReleaseMutex(); + + //Go through all the files in the plugin directory + foreach (string filename in Directory.GetFiles( + AppDomain.CurrentDomain.BaseDirectory + "\\plugins\\")) + { + FileInfo file = new FileInfo(filename); + + //Preliminary check, must be .dll + if (file.Extension.Equals(".dll")) + { + //Add the 'plugin' + this.AddPlugin(filename); + } + } + } + + private void AddPlugin(string filename) + { + SSPlugin plugin; + + try + { + Assembly pluginAssembly = Assembly.LoadFrom(filename); + + foreach (Type pluginType in pluginAssembly.GetTypes()) + { + if (pluginType.IsPublic && !pluginType.IsAbstract) + { + Type typeInterface = pluginType.GetInterface("SecondSuite.Plugins.SSPlugin", true); + + if (typeInterface != null) + { + plugin = (SSPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + + Global.PluginsMutex.WaitOne(); + Global.Plugins.Add(plugin); + Global.PluginsMutex.ReleaseMutex(); + + Overview.lstPlugins.Items.Add(plugin); + } + } + } + } + catch (ReflectionTypeLoadException e) + { + MessageBox.Show(e.LoaderExceptions[0].ToString()); + } + } + + #region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.statusBar = new System.Windows.Forms.StatusBar(); + this.mainMenu = new System.Windows.Forms.MainMenu(); + this.menuFile = new System.Windows.Forms.MenuItem(); + this.menuReload = new System.Windows.Forms.MenuItem(); + this.menuItem3 = new System.Windows.Forms.MenuItem(); + this.menuExit = new System.Windows.Forms.MenuItem(); + this.menuHelp = new System.Windows.Forms.MenuItem(); + this.menuAbout = new System.Windows.Forms.MenuItem(); + this.SuspendLayout(); + // + // statusBar + // + this.statusBar.Location = new System.Drawing.Point(0, 681); + this.statusBar.Name = "statusBar"; + this.statusBar.ShowPanels = true; + this.statusBar.Size = new System.Drawing.Size(992, 22); + this.statusBar.TabIndex = 1; + // + // mainMenu + // + this.mainMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.menuFile, + this.menuHelp}); + // + // menuFile + // + this.menuFile.Index = 0; + this.menuFile.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.menuReload, + this.menuItem3, + this.menuExit}); + this.menuFile.Text = "File"; + // + // menuReload + // + this.menuReload.Index = 0; + this.menuReload.Text = "Reload Plugins"; + this.menuReload.Click += new System.EventHandler(this.menuReload_Click); + // + // menuItem3 + // + this.menuItem3.Index = 1; + this.menuItem3.Text = "-"; + // + // menuExit + // + this.menuExit.Index = 2; + this.menuExit.Text = "Exit"; + this.menuExit.Click += new System.EventHandler(this.menuExit_Click); + // + // menuHelp + // + this.menuHelp.Index = 1; + this.menuHelp.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { + this.menuAbout}); + this.menuHelp.Text = "Help"; + // + // menuAbout + // + this.menuAbout.Index = 0; + this.menuAbout.Text = "About"; + // + // frmSecondSuite + // + this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); + this.ClientSize = new System.Drawing.Size(992, 703); + this.Controls.Add(this.statusBar); + this.IsMdiContainer = true; + this.Menu = this.mainMenu; + this.Name = "frmSecondSuite"; + this.Text = "Second Suite"; + this.Load += new System.EventHandler(this.frmSecondSuite_Load); + this.ResumeLayout(false); + + } + #endregion + + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.Run(new frmSecondSuite()); + } + + private void frmSecondSuite_Load(object sender, System.EventArgs e) + { + + } + + private void menuExit_Click(object sender, System.EventArgs e) + { + this.Close(); + } + + private void menuReload_Click(object sender, System.EventArgs e) + { + ShutdownAllPlugins(); + FindPlugins(); + } + } +} diff --git a/applications/SecondSuite/frmSecondSuite.resx b/applications/SecondSuite/frmSecondSuite.resx index 1a8835a7..333b0287 100644 --- a/applications/SecondSuite/frmSecondSuite.resx +++ b/applications/SecondSuite/frmSecondSuite.resx @@ -1,184 +1,184 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 1.3 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - False - - - Private - - - Private - - - Private - - - 17, 17 - - - Private - - - Private - - - Private - - - Private - - - Private - - - Private - - - Private - - - Private - - - Private - - - Private - - - Private - - - Private - - - Private - - - False - - - (Default) - - - False - - - False - - - 8, 8 - - - frmSecondSuite - - - True - - - 80 - - - True - - - Private - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + False + + + Private + + + Private + + + Private + + + 17, 17 + + + Private + + + Private + + + Private + + + Private + + + Private + + + Private + + + Private + + + Private + + + Private + + + Private + + + Private + + + Private + + + Private + + + False + + + (Default) + + + False + + + False + + + 8, 8 + + + frmSecondSuite + + + True + + + 80 + + + True + + + Private + \ No newline at end of file diff --git a/applications/libjaspernet/Properties/AssemblyInfo.cs b/applications/libjaspernet/Properties/AssemblyInfo.cs index 9c6ee6fb..fa3a31da 100644 --- a/applications/libjaspernet/Properties/AssemblyInfo.cs +++ b/applications/libjaspernet/Properties/AssemblyInfo.cs @@ -1,35 +1,35 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("libjaspernet")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("libjaspernet")] -[assembly: AssemblyCopyright("Copyright © libsecondlife 2006")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("50d5e6b6-1a19-4095-9b8a-a46bd56f4223")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Revision and Build Numbers -// by using the '*' as shown below: -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("libjaspernet")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("libjaspernet")] +[assembly: AssemblyCopyright("Copyright © libsecondlife 2006")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("50d5e6b6-1a19-4095-9b8a-a46bd56f4223")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/applications/libjaspernet/libjaspernet.csproj b/applications/libjaspernet/libjaspernet.csproj index 29d35ced..36887432 100644 --- a/applications/libjaspernet/libjaspernet.csproj +++ b/applications/libjaspernet/libjaspernet.csproj @@ -1,49 +1,49 @@ - - - Debug - AnyCPU - 8.0.50727 - 2.0 - {7D4C4807-7705-48A7-9D82-F6689FBBCC8B} - Exe - Properties - libjaspernet - libjaspernet - - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {7D4C4807-7705-48A7-9D82-F6689FBBCC8B} + Exe + Properties + libjaspernet + libjaspernet + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + \ No newline at end of file diff --git a/applications/libjaspernet/libjaspernet.dll.config b/applications/libjaspernet/libjaspernet.dll.config index 85b4bf9c..380b4549 100644 --- a/applications/libjaspernet/libjaspernet.dll.config +++ b/applications/libjaspernet/libjaspernet.dll.config @@ -1,5 +1,5 @@ - - - - - + + + + + diff --git a/applications/libjaspernet/libjaspernet.sln b/applications/libjaspernet/libjaspernet.sln index 96cd755a..caf46990 100644 --- a/applications/libjaspernet/libjaspernet.sln +++ b/applications/libjaspernet/libjaspernet.sln @@ -1,20 +1,20 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "libjaspernet", "libjaspernet.csproj", "{7D4C4807-7705-48A7-9D82-F6689FBBCC8B}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {7D4C4807-7705-48A7-9D82-F6689FBBCC8B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7D4C4807-7705-48A7-9D82-F6689FBBCC8B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7D4C4807-7705-48A7-9D82-F6689FBBCC8B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7D4C4807-7705-48A7-9D82-F6689FBBCC8B}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "libjaspernet", "libjaspernet.csproj", "{7D4C4807-7705-48A7-9D82-F6689FBBCC8B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7D4C4807-7705-48A7-9D82-F6689FBBCC8B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7D4C4807-7705-48A7-9D82-F6689FBBCC8B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7D4C4807-7705-48A7-9D82-F6689FBBCC8B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7D4C4807-7705-48A7-9D82-F6689FBBCC8B}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/applications/sceneviewer/Camera.cs b/applications/sceneviewer/Camera.cs index fab78c4d..ec16f15d 100644 --- a/applications/sceneviewer/Camera.cs +++ b/applications/sceneviewer/Camera.cs @@ -1,188 +1,188 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Microsoft.Xna.Framework; - -namespace sceneviewer -{ - /// - /// Simple third-person camera class - /// - public class Camera - { - #region Constants - private static readonly float MAX_RADIANS = (float)(Math.PI * 2.0); - private static readonly float MAX_PHI = (float)((Math.PI) * 2.0); - private static readonly float MIN_PHI = 0; - #endregion Constants - - #region Private Fields - private Vector3 _cameraPosition; - private Vector3 _lookatPosition; - private Matrix _projection; - - private float _theta; - private float _phi; - private float _zoom; - #endregion Private Fields - - #region Constructors - /// - /// Default constructor. Assumes the camera should be oriented up. - /// - /// - /// - public Camera(GameWindow window, Vector3 pos, Vector3 lookAt) - { - _cameraPosition = pos; - _lookatPosition = lookAt; - - UpdateProjection(window); - } - #endregion Constructors - - #region Properties - /// - /// Generate the current view matrix for the camera - /// - public Matrix ViewMatrix - { - get - { - Vector3 newCameraPosition = _cameraPosition; - Matrix rotationMatrix; - - // Apply zoom - newCameraPosition += GetZoomVector(); - - // Apply Z rotation - rotationMatrix = Matrix.CreateRotationX(_phi); - newCameraPosition = Vector3.Transform(newCameraPosition, - rotationMatrix); - - // Apply Y rotation - rotationMatrix = Matrix.CreateRotationY( _theta); - newCameraPosition = Vector3.Transform(newCameraPosition, - rotationMatrix); - - return Matrix.CreateLookAt(newCameraPosition, _lookatPosition, - new Vector3(0.0f, 0.0f, 1.0f)); - } - } - - public Matrix ProjectionMatrix - { - get - { - return _projection; - } - } - - /// - /// Gets the view and projection matrices multiplied together - /// - public Matrix ViewProjectionMatrix - { - get - { - return ViewMatrix * _projection; - } - } - - /// - /// Gets the camera position - /// - public Vector3 Position - { - get - { - return _cameraPosition; - } - } - - /// - /// Get or set the current angle of rotation in radians about the - /// Y-axis for the camera. - /// - public float Theta - { - get { return _theta; } - set - { - _theta = value % MAX_RADIANS; - } - } - - /// - /// Get or set the current angle of rotation in radians about the - /// Z-axis for the camera. - /// - /// Applies a hard cap on the minimum or maximum values of phi. - /// - public float Phi - { - get { return _phi; } - set - { - if (value > MAX_PHI) - { - _phi = MAX_PHI; - } - else if (value < MIN_PHI) - { - _phi = MIN_PHI; - } - else - { - _phi = value; - } - } - } - - /// - /// Get or set the current zoom of the camera. - /// - /// TODO: I should set a hard value on how close - /// the camera can zoom in; it should never be able to go - /// through the look at point. - /// - public float Zoom - { - get { return _zoom; } - - // TODO: Add a hard limit on zoom amount. - set { _zoom = value; } - } - #endregion Properties - - /// - /// Call this method any time the client window changes. - /// - public void UpdateProjection(GameWindow window) - { - _projection = Matrix.CreatePerspectiveFieldOfView((float)Math.PI / 4.0f, - (float)window.ClientWidth / (float)window.ClientHeight, - 1.0f, 512.0f); - } - - /// - /// Determine how far the camera should move forward - /// or backward based on the current zoom value. - /// - /// This is calculated by finding the normal vector - /// between the camera's position and the LookAt - /// point and multiplying this vector by the zoom - /// amount. - /// - /// - private Vector3 GetZoomVector() - { - Vector3 diff = _cameraPosition - _lookatPosition; - - diff.Normalize(); - diff *= _zoom; - - return diff; - } - } +using System; +using System.Collections.Generic; +using System.Text; +using Microsoft.Xna.Framework; + +namespace sceneviewer +{ + /// + /// Simple third-person camera class + /// + public class Camera + { + #region Constants + private static readonly float MAX_RADIANS = (float)(Math.PI * 2.0); + private static readonly float MAX_PHI = (float)((Math.PI) * 2.0); + private static readonly float MIN_PHI = 0; + #endregion Constants + + #region Private Fields + private Vector3 _cameraPosition; + private Vector3 _lookatPosition; + private Matrix _projection; + + private float _theta; + private float _phi; + private float _zoom; + #endregion Private Fields + + #region Constructors + /// + /// Default constructor. Assumes the camera should be oriented up. + /// + /// + /// + public Camera(GameWindow window, Vector3 pos, Vector3 lookAt) + { + _cameraPosition = pos; + _lookatPosition = lookAt; + + UpdateProjection(window); + } + #endregion Constructors + + #region Properties + /// + /// Generate the current view matrix for the camera + /// + public Matrix ViewMatrix + { + get + { + Vector3 newCameraPosition = _cameraPosition; + Matrix rotationMatrix; + + // Apply zoom + newCameraPosition += GetZoomVector(); + + // Apply Z rotation + rotationMatrix = Matrix.CreateRotationX(_phi); + newCameraPosition = Vector3.Transform(newCameraPosition, + rotationMatrix); + + // Apply Y rotation + rotationMatrix = Matrix.CreateRotationY( _theta); + newCameraPosition = Vector3.Transform(newCameraPosition, + rotationMatrix); + + return Matrix.CreateLookAt(newCameraPosition, _lookatPosition, + new Vector3(0.0f, 0.0f, 1.0f)); + } + } + + public Matrix ProjectionMatrix + { + get + { + return _projection; + } + } + + /// + /// Gets the view and projection matrices multiplied together + /// + public Matrix ViewProjectionMatrix + { + get + { + return ViewMatrix * _projection; + } + } + + /// + /// Gets the camera position + /// + public Vector3 Position + { + get + { + return _cameraPosition; + } + } + + /// + /// Get or set the current angle of rotation in radians about the + /// Y-axis for the camera. + /// + public float Theta + { + get { return _theta; } + set + { + _theta = value % MAX_RADIANS; + } + } + + /// + /// Get or set the current angle of rotation in radians about the + /// Z-axis for the camera. + /// + /// Applies a hard cap on the minimum or maximum values of phi. + /// + public float Phi + { + get { return _phi; } + set + { + if (value > MAX_PHI) + { + _phi = MAX_PHI; + } + else if (value < MIN_PHI) + { + _phi = MIN_PHI; + } + else + { + _phi = value; + } + } + } + + /// + /// Get or set the current zoom of the camera. + /// + /// TODO: I should set a hard value on how close + /// the camera can zoom in; it should never be able to go + /// through the look at point. + /// + public float Zoom + { + get { return _zoom; } + + // TODO: Add a hard limit on zoom amount. + set { _zoom = value; } + } + #endregion Properties + + /// + /// Call this method any time the client window changes. + /// + public void UpdateProjection(GameWindow window) + { + _projection = Matrix.CreatePerspectiveFieldOfView((float)Math.PI / 4.0f, + (float)window.ClientWidth / (float)window.ClientHeight, + 1.0f, 512.0f); + } + + /// + /// Determine how far the camera should move forward + /// or backward based on the current zoom value. + /// + /// This is calculated by finding the normal vector + /// between the camera's position and the LookAt + /// point and multiplying this vector by the zoom + /// amount. + /// + /// + private Vector3 GetZoomVector() + { + Vector3 diff = _cameraPosition - _lookatPosition; + + diff.Normalize(); + diff *= _zoom; + + return diff; + } + } } \ No newline at end of file diff --git a/applications/sceneviewer/PrimVisual.cs b/applications/sceneviewer/PrimVisual.cs index 9bf0e5f2..b29bd564 100644 --- a/applications/sceneviewer/PrimVisual.cs +++ b/applications/sceneviewer/PrimVisual.cs @@ -1,31 +1,31 @@ -using System; -using System.Text; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; - -namespace sceneviewer -{ - class PrimVisual : GameComponent - { - //private World world; - private float scale; - - // effects and shaders - private CompiledEffect compiledEffect; - private Effect effect; - - // matrices for defining scale, world, and view projection - private Matrix scaleMatrix; - private Matrix worldMatrix; - private Matrix viewProjectionMatrix; - - public PrimVisual() - { - //InitializeComponent(); - - // initialize default values - scale = 1.0f; - worldMatrix = Matrix.Identity; - } - } -} +using System; +using System.Text; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +namespace sceneviewer +{ + class PrimVisual : GameComponent + { + //private World world; + private float scale; + + // effects and shaders + private CompiledEffect compiledEffect; + private Effect effect; + + // matrices for defining scale, world, and view projection + private Matrix scaleMatrix; + private Matrix worldMatrix; + private Matrix viewProjectionMatrix; + + public PrimVisual() + { + //InitializeComponent(); + + // initialize default values + scale = 1.0f; + worldMatrix = Matrix.Identity; + } + } +} diff --git a/applications/sceneviewer/Prims/CrossSection.cs b/applications/sceneviewer/Prims/CrossSection.cs index 556e940a..03d3bbf2 100644 --- a/applications/sceneviewer/Prims/CrossSection.cs +++ b/applications/sceneviewer/Prims/CrossSection.cs @@ -1,39 +1,39 @@ -using System; -using System.Text; -using System.Collections.Generic; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using libsecondlife; - -namespace sceneviewer.Prims -{ - public class CrossSection - { - private List Points; - - public CrossSection() - { - Points = new List(); - } - - public void AddPoint(Vector3 point) - { - Points.Add(point); - } - - public void RemoveAllPoints() - { - Points.Clear(); - } - - public int GetNumPoints() - { - return Points.Count; - } - - public Vector3 GetRawVertex(int index) - { - return Points[index]; - } - } -} +using System; +using System.Text; +using System.Collections.Generic; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using libsecondlife; + +namespace sceneviewer.Prims +{ + public class CrossSection + { + private List Points; + + public CrossSection() + { + Points = new List(); + } + + public void AddPoint(Vector3 point) + { + Points.Add(point); + } + + public void RemoveAllPoints() + { + Points.Clear(); + } + + public int GetNumPoints() + { + return Points.Count; + } + + public Vector3 GetRawVertex(int index) + { + return Points[index]; + } + } +} diff --git a/applications/sceneviewer/Prims/LinearPrimVisual.cs b/applications/sceneviewer/Prims/LinearPrimVisual.cs index 2e0df13b..2a9a60ec 100644 --- a/applications/sceneviewer/Prims/LinearPrimVisual.cs +++ b/applications/sceneviewer/Prims/LinearPrimVisual.cs @@ -1,520 +1,520 @@ -using System; -using System.Text; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using libsecondlife; - -namespace sceneviewer.Prims -{ - public abstract class LinearPrimVisual : PrimVisual - { - // Reference vertices of the unscaled/unrotated primitive - protected Vector3[] ReferenceVertices; - - protected CrossSection[] OuterFaces; // Section for each extruded outer face - protected CrossSection[] InnerFaces; // Section for each extruded inner face (hollow) - protected CrossSection[] CutFaces; // Two cut faces - - protected int NumberFaces; // Number of faces on the base primitive - protected int FirstOuterFace; // If we're cutting, this might not be 0 - protected int LastOuterFace; // If we're cutting, this might not be iNumberFaces - - protected Color color; - - // Accessors - protected int triangleCount = 0; - public override int TriangleCount - { - get { return triangleCount; } - } - - // Abstract functions - protected abstract int GetCutQuadrant(float cut); - protected abstract float GetAngleWithXAxis(float cut); - protected abstract void BuildEndCapHollow(bool top); - - public LinearPrimVisual(PrimObject prim) : base(prim) - { - // TODO: This is temporary, for debugging and entertainment purposes - Random rand = new Random((int)prim.LocalID + Environment.TickCount); - byte r = (byte)rand.Next(256); - byte g = (byte)rand.Next(256); - byte b = (byte)rand.Next(256); - color = new Color(r, g, b); - } - - protected override void BuildFaces() - { - Vector3 cutstartouterface = Vector3.Zero; - Vector3 cutendouterface = Vector3.Zero; - Vector3 cutstartinnerface = Vector3.Zero; - Vector3 cutendinnerface = Vector3.Zero; - int cutStartDiagQuadrant = cutStartDiagQuadrant = GetCutQuadrant(Prim.ProfileBegin); - int cutEndDiagQuadrant = cutEndDiagQuadrant = GetCutQuadrant(Prim.ProfileEnd); - float hollowRatio = (float)Prim.ProfileHollow / 100.0f; - - cutstartouterface = GetCutIntersect(Prim.ProfileBegin, 0.5f); // coordinates of where the cut starts - cutendouterface = GetCutIntersect(Prim.ProfileEnd, 0.5f); // coordinates of where the cut starts - - if (hollow) - { - float halfWidth = hollowRatio * 0.5f; - cutstartinnerface = GetCutIntersect(Prim.ProfileBegin, halfWidth); - cutendinnerface = GetCutIntersect(Prim.ProfileEnd, halfWidth); - } - - if (cut) - { - if (hollow) - { - BuildCutHollowFaces(cutstartouterface, cutstartinnerface, cutendouterface, cutendinnerface); - } - else - { - BuildCutFaces(cutstartouterface, cutendouterface); - } - } - - if (cutStartDiagQuadrant == cutEndDiagQuadrant) - { - FirstOuterFace = LastOuterFace = cutStartDiagQuadrant; - - OuterFaces[0].RemoveAllPoints(); - OuterFaces[0].AddPoint(cutstartouterface); - OuterFaces[0].AddPoint(cutendouterface); - //OuterFaces[0].TextureMapping = texturemapping; - - if (hollow) - { - InnerFaces[0].RemoveAllPoints(); - InnerFaces[0].AddPoint(cutendinnerface); - InnerFaces[0].AddPoint(cutstartinnerface); - //InnerFaces[0].TextureMapping = texturemapping; - } - } - else - { - FirstOuterFace = cutStartDiagQuadrant; - - float totalInnerLength = 0; - float startSideInnerLength = 0; - float wholeSideLength = 0; - - PopulateSingleCutFacePositiveDirection(ref OuterFaces[FirstOuterFace], cutstartouterface, cutStartDiagQuadrant, 0.5f, true); - //OuterFaces[FirstOuterFace].TextureMapping = texturemapping; - - if (hollow) - { - startSideInnerLength = PopulateSingleCutFacePositiveDirection(ref InnerFaces[FirstOuterFace], - cutstartinnerface, cutStartDiagQuadrant, hollowRatio * 0.5f, false); - //InnerFaces[FirstOuterFace].TextureMapping = texturemapping; - totalInnerLength += startSideInnerLength; - } - - int quadrant = cutStartDiagQuadrant + 1; - - while (quadrant < cutEndDiagQuadrant) - { - PopulateCompleteSide(ref OuterFaces[quadrant], quadrant, 0.5f, true); - //OuterFaces[quadrant].TextureMapping = texturemapping; - - if (hollow) - { - wholeSideLength = PopulateCompleteSide(ref InnerFaces[quadrant], quadrant, - hollowRatio * 0.5f, false); - //InnerFaces[quadrant].TextureMapping = texturemapping; - totalInnerLength += wholeSideLength; - } - - quadrant++; - } - - PopulateSingleCutFaceNegativeDirection(ref OuterFaces[quadrant], cutendouterface, - cutEndDiagQuadrant, 0.5f, true); - //OuterFaces[quadrant].TextureMapping = texturemapping; - - if (hollow) - { - float endSideInnerLength = PopulateSingleCutFaceNegativeDirection(ref InnerFaces[quadrant], - cutendinnerface, cutEndDiagQuadrant, hollowRatio * 0.5f, false); - //InnerFaces[quadrant].TextureMapping = texturemapping; - totalInnerLength += endSideInnerLength; - } - - LastOuterFace = quadrant; - - if (hollow) - { - //SetupInnerFaceTextureOffsets(startSideInnerLength, wholeSideLength, totalInnerLength); - } - } - - AssignFaces(); - - BuildVertexes(); - } - - protected void BuildCutFaces(Vector3 cutstartouterface, Vector3 cutendouterface) - { - CutFaces[0].RemoveAllPoints(); - - CutFaces[0].AddPoint(Vector3.Zero); - CutFaces[0].AddPoint(cutstartouterface); - //CutFaces[0].TextureMapping = texturemapping; - - CutFaces[1].RemoveAllPoints(); - - CutFaces[1].AddPoint(cutendouterface); - CutFaces[1].AddPoint(Vector3.Zero); - //CutFaces[1].TextureMapping = texturemapping; - } - - protected void BuildCutHollowFaces(Vector3 cutstartouterface, Vector3 cutstartinnerface, Vector3 cutendouterface, Vector3 cutendinnerface) - { - CutFaces[0].RemoveAllPoints(); - - CutFaces[0].AddPoint(cutstartinnerface); - CutFaces[0].AddPoint(cutstartouterface); - //CutFaces[0].TextureMapping = texturemapping; - - CutFaces[1].RemoveAllPoints(); - - CutFaces[1].AddPoint(cutendouterface); - CutFaces[1].AddPoint(cutendinnerface); - //CutFaces[1].TextureMapping = texturemapping; - } - - private Vector3 GetCutIntersect(float cut, float cubeHalfWidth) - { - int cutQuadrant = GetCutQuadrant(cut); - - Vector3 lineend; - Vector3 linestart = ReferenceVertices[cutQuadrant] * cubeHalfWidth; - linestart = Vector3.Divide(linestart, 0.5f); - if (cutQuadrant < NumberFaces - 1) - { - lineend = ReferenceVertices[cutQuadrant + 1] * cubeHalfWidth; - } - else - { - lineend = ReferenceVertices[0] * cubeHalfWidth; - } - lineend = Vector3.Divide(lineend, 0.5f); - - // - float angle = GetAngleWithXAxis(cut); - - // CutVectorPerp is perpendicular to the radius vector - Vector3 cutVectorPerp = new Vector3((float)-Math.Sin(angle), (float)Math.Cos(angle), 0); - Vector3 delta = lineend - linestart; - - // From http://softsurfer.com/Archive/algorithm_0104/algorithm_0104B.htm - Vector3 result = linestart - delta * Vector3.Dot(cutVectorPerp, linestart) / Vector3.Dot(cutVectorPerp, delta); - - return result; - } - - // Handles the first face in the cut, starting from cutstart, - // and running anticlockwise to first reference vertex - private float PopulateSingleCutFacePositiveDirection(ref CrossSection face, Vector3 cutPoint, int quadrant, - float halfCubeWidth, bool outer) - { - quadrant = NormalizeQuadrant(quadrant); - - face.RemoveAllPoints(); - - Vector3 startPoint = cutPoint; - Vector3 endPoint; - if (quadrant < NumberFaces - 1) - { - endPoint = ReferenceVertices[quadrant + 1] * halfCubeWidth / 0.5f; - } - else - { - endPoint = ReferenceVertices[0] * halfCubeWidth / 0.5f; - } - - if (outer) - { - face.AddPoint(startPoint); - face.AddPoint(endPoint); - } - else - { - face.AddPoint(endPoint); - face.AddPoint(startPoint); - } - - return Vector3.Distance(startPoint, endPoint); - } - - private float PopulateSingleCutFaceNegativeDirection(ref CrossSection face, Vector3 cutPoint, int quadrant, - float halfCubeWidth, bool outer) - { - quadrant = NormalizeQuadrant(quadrant); - - face.RemoveAllPoints(); - - Vector3 startPoint = ReferenceVertices[quadrant] * halfCubeWidth / 0.5f; - Vector3 endPoint = cutPoint; - - if (outer) - { - face.AddPoint(startPoint); - face.AddPoint(endPoint); - } - else - { - face.AddPoint(endPoint); - face.AddPoint(startPoint); - } - - return Vector3.Distance(startPoint, endPoint); - } - - private float PopulateCompleteSide(ref CrossSection face, int quadrant, float halfCubeWidth, bool outer) - { - quadrant = NormalizeQuadrant(quadrant); - - face.RemoveAllPoints(); - - Vector3 startPoint = ReferenceVertices[quadrant]; - Vector3 endPoint; - if (quadrant < NumberFaces - 1) - { - endPoint = ReferenceVertices[quadrant + 1]; - } - else - { - endPoint = ReferenceVertices[0]; - } - - startPoint = startPoint * halfCubeWidth / 0.5f; - endPoint = endPoint * halfCubeWidth / 0.5f; - - if (outer) - { - face.AddPoint(startPoint); - face.AddPoint(endPoint); - } - else - { - face.AddPoint(endPoint); - face.AddPoint(startPoint); - } - - return 2f * halfCubeWidth; - } - - protected void BuildVertexes() - { - // For prims with a linear extrusion path, we base the number of transformations on the amount of twist - int transforms = 1 + Math.Abs((int)((float)(Prim.PathTwist - Prim.PathTwistBegin) / 9f)); - - // Build the outer sides - BuildSideVertexes(OuterFaces, transforms); - - if (hollow) - { - // Build the inner sides - BuildSideVertexes(InnerFaces, transforms); - } - - if (cut) - { - // Build the cut sides (between the inner and outer) - BuildSideVertexes(CutFaces, transforms); - } - - // Build the top and bottom end caps - if (hollow) - { - BuildEndCapHollow(true); - BuildEndCapHollow(false); - } - else - { - if (cut) - { - BuildEndCapCutNoHollow(true); - BuildEndCapCutNoHollow(false); - } - else - { - BuildEndCapNoCutNoHollow(true); - BuildEndCapNoCutNoHollow(false); - } - } - - VertexArray = Vertexes.ToArray(); - } - - //private void BuildSideVertexes(CrossSection[] crossSection, int transforms) - //{ - // float transformOffset = 1.0f / (float)transforms; - // float currentOffset = -0.5f; - - // for (int i = 0; i < transforms; i++) - // { - // for (int j = 0; j < crossSection.Length; j++) - // { - // int pointCount = crossSection[j].GetNumPoints(); - - // if (pointCount > 0) - // { - // Vector3 lower1 = crossSection[j].GetRawVertex(0); - // Vector3 lower2 = crossSection[j].GetRawVertex(1); - - // lower1.Z = currentOffset; - // lower2.Z = currentOffset; - - // Vector3 upper1 = lower1; - // Vector3 upper2 = lower2; - - // upper1.Z = currentOffset + transformOffset; - // upper2.Z = currentOffset + transformOffset; - - // // FIXME: Perform skew, taper and twist transformations here - // //lower1 = Vector3.Transform(lower1, lowerTransform); - // //lower2 = Vector3.Transform(lower2, lowerTransform); - // //upper1 = Vector3.Transform(upper1, upperTransform); - // //upper2 = Vector3.Transform(upper2, upperTransform); - - // Vertexes.Add(new VertexPositionColor(lower1, color)); - // Vertexes.Add(new VertexPositionColor(lower2, color)); - // Vertexes.Add(new VertexPositionColor(upper2, color)); - - // Vertexes.Add(new VertexPositionColor(lower1, color)); - // Vertexes.Add(new VertexPositionColor(upper2, color)); - // Vertexes.Add(new VertexPositionColor(upper1, color)); - // } - // } - - // currentOffset += transformOffset; - // } - //} - - protected void BuildSideVertexes(CrossSection[] crossSection, int transforms) - { - float transformOffset = 1.0f / (float)transforms; - float currentOffset = -0.5f; - - for (int i = 0; i < transforms; i++) - { - for (int j = 0; j < crossSection.Length; j++) - { - int pointCount = crossSection[j].GetNumPoints(); - - if (pointCount > 0) - { - for (int k = 0; k < pointCount - 1; k++) - { - Vector3 lower1, lower2, upper1, upper2; - - lower1 = crossSection[j].GetRawVertex(k); - lower2 = crossSection[j].GetRawVertex(k + 1); - - lower1.Z = currentOffset; - lower2.Z = currentOffset; - - upper1 = lower1; - upper2 = lower2; - - upper1.Z = currentOffset + transformOffset; - upper2.Z = currentOffset + transformOffset; - - // FIXME: Perform skew, taper and twist transformations here - //lower1 = Vector3.Transform(lower1, lowerTransform); - //lower2 = Vector3.Transform(lower2, lowerTransform); - //upper1 = Vector3.Transform(upper1, upperTransform); - //upper2 = Vector3.Transform(upper2, upperTransform); - - Vertexes.Add(new VertexPositionColor(lower1, color)); - Vertexes.Add(new VertexPositionColor(lower2, color)); - Vertexes.Add(new VertexPositionColor(upper2, color)); - - Vertexes.Add(new VertexPositionColor(lower1, color)); - Vertexes.Add(new VertexPositionColor(upper2, color)); - Vertexes.Add(new VertexPositionColor(upper1, color)); - } - } - } - - currentOffset += transformOffset; - } - } - - protected void BuildEndCapNoCutNoHollow(bool top) - { - float z = top ? 0.5f : -0.5f; - - for (int i = 0; i < OuterFaces.Length; i++) - { - int pointCount = OuterFaces[i].GetNumPoints(); - - if (pointCount > 0) - { - for (int j = 0; j < pointCount - 1; j++) - { - Vector3 first = OuterFaces[i].GetRawVertex(j); - first.Z = z; - Vector3 second = OuterFaces[i].GetRawVertex(j + 1); - second.Z = z; - - // FIXME: Perform skew, taper and twist transformations here - if (top) - { - ; - } - else - { - ; - } - - Vertexes.Add(new VertexPositionColor(first, color)); - Vertexes.Add(new VertexPositionColor(second, color)); - Vertexes.Add(new VertexPositionColor(new Vector3(0, 0, z), color)); - } - } - } - } - - protected void BuildEndCapCutNoHollow(bool top) - { - float z = top ? 0.5f : -0.5f; - - // FIXME: Apply transformations to the center point - Vector3 center = Vector3.Zero; - - for (int i = FirstOuterFace; i <= LastOuterFace; i++) - { - int pointCount = OuterFaces[i].GetNumPoints(); - - for (int j = 0; j < pointCount - 1; j++) - { - Vector3 p1 = OuterFaces[i].GetRawVertex(j); - Vector3 p2 = OuterFaces[i].GetRawVertex(j + 1); - - center.Z = p1.Z = p2.Z = z; - - // TODO: Texturemapping stuff - //Vector2 t1 = texturemapping.GetTextureCoordinate(new Vector2(1 - (p1.x + 0.5), p1.y + 0.5)); - //Vector2 t2 = texturemapping.GetTextureCoordinate(new Vector2(1 - (p2.x + 0.5), p2.y + 0.5)); - - // FIXME: Perform skew, taper and twist transformations here - //p1 = Vector3.Transform(p1, transform); - //p2 = Vector3.Transform(p2, transform); - - Vertexes.Add(new VertexPositionColor(p2, color)); - Vertexes.Add(new VertexPositionColor(p1, color)); - Vertexes.Add(new VertexPositionColor(center, color)); - } - } - } - - private int NormalizeQuadrant(int quadrant) - { - return ((quadrant % NumberFaces) + NumberFaces) % NumberFaces; - } - } -} +using System; +using System.Text; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using libsecondlife; + +namespace sceneviewer.Prims +{ + public abstract class LinearPrimVisual : PrimVisual + { + // Reference vertices of the unscaled/unrotated primitive + protected Vector3[] ReferenceVertices; + + protected CrossSection[] OuterFaces; // Section for each extruded outer face + protected CrossSection[] InnerFaces; // Section for each extruded inner face (hollow) + protected CrossSection[] CutFaces; // Two cut faces + + protected int NumberFaces; // Number of faces on the base primitive + protected int FirstOuterFace; // If we're cutting, this might not be 0 + protected int LastOuterFace; // If we're cutting, this might not be iNumberFaces + + protected Color color; + + // Accessors + protected int triangleCount = 0; + public override int TriangleCount + { + get { return triangleCount; } + } + + // Abstract functions + protected abstract int GetCutQuadrant(float cut); + protected abstract float GetAngleWithXAxis(float cut); + protected abstract void BuildEndCapHollow(bool top); + + public LinearPrimVisual(PrimObject prim) : base(prim) + { + // TODO: This is temporary, for debugging and entertainment purposes + Random rand = new Random((int)prim.LocalID + Environment.TickCount); + byte r = (byte)rand.Next(256); + byte g = (byte)rand.Next(256); + byte b = (byte)rand.Next(256); + color = new Color(r, g, b); + } + + protected override void BuildFaces() + { + Vector3 cutstartouterface = Vector3.Zero; + Vector3 cutendouterface = Vector3.Zero; + Vector3 cutstartinnerface = Vector3.Zero; + Vector3 cutendinnerface = Vector3.Zero; + int cutStartDiagQuadrant = cutStartDiagQuadrant = GetCutQuadrant(Prim.ProfileBegin); + int cutEndDiagQuadrant = cutEndDiagQuadrant = GetCutQuadrant(Prim.ProfileEnd); + float hollowRatio = (float)Prim.ProfileHollow / 100.0f; + + cutstartouterface = GetCutIntersect(Prim.ProfileBegin, 0.5f); // coordinates of where the cut starts + cutendouterface = GetCutIntersect(Prim.ProfileEnd, 0.5f); // coordinates of where the cut starts + + if (hollow) + { + float halfWidth = hollowRatio * 0.5f; + cutstartinnerface = GetCutIntersect(Prim.ProfileBegin, halfWidth); + cutendinnerface = GetCutIntersect(Prim.ProfileEnd, halfWidth); + } + + if (cut) + { + if (hollow) + { + BuildCutHollowFaces(cutstartouterface, cutstartinnerface, cutendouterface, cutendinnerface); + } + else + { + BuildCutFaces(cutstartouterface, cutendouterface); + } + } + + if (cutStartDiagQuadrant == cutEndDiagQuadrant) + { + FirstOuterFace = LastOuterFace = cutStartDiagQuadrant; + + OuterFaces[0].RemoveAllPoints(); + OuterFaces[0].AddPoint(cutstartouterface); + OuterFaces[0].AddPoint(cutendouterface); + //OuterFaces[0].TextureMapping = texturemapping; + + if (hollow) + { + InnerFaces[0].RemoveAllPoints(); + InnerFaces[0].AddPoint(cutendinnerface); + InnerFaces[0].AddPoint(cutstartinnerface); + //InnerFaces[0].TextureMapping = texturemapping; + } + } + else + { + FirstOuterFace = cutStartDiagQuadrant; + + float totalInnerLength = 0; + float startSideInnerLength = 0; + float wholeSideLength = 0; + + PopulateSingleCutFacePositiveDirection(ref OuterFaces[FirstOuterFace], cutstartouterface, cutStartDiagQuadrant, 0.5f, true); + //OuterFaces[FirstOuterFace].TextureMapping = texturemapping; + + if (hollow) + { + startSideInnerLength = PopulateSingleCutFacePositiveDirection(ref InnerFaces[FirstOuterFace], + cutstartinnerface, cutStartDiagQuadrant, hollowRatio * 0.5f, false); + //InnerFaces[FirstOuterFace].TextureMapping = texturemapping; + totalInnerLength += startSideInnerLength; + } + + int quadrant = cutStartDiagQuadrant + 1; + + while (quadrant < cutEndDiagQuadrant) + { + PopulateCompleteSide(ref OuterFaces[quadrant], quadrant, 0.5f, true); + //OuterFaces[quadrant].TextureMapping = texturemapping; + + if (hollow) + { + wholeSideLength = PopulateCompleteSide(ref InnerFaces[quadrant], quadrant, + hollowRatio * 0.5f, false); + //InnerFaces[quadrant].TextureMapping = texturemapping; + totalInnerLength += wholeSideLength; + } + + quadrant++; + } + + PopulateSingleCutFaceNegativeDirection(ref OuterFaces[quadrant], cutendouterface, + cutEndDiagQuadrant, 0.5f, true); + //OuterFaces[quadrant].TextureMapping = texturemapping; + + if (hollow) + { + float endSideInnerLength = PopulateSingleCutFaceNegativeDirection(ref InnerFaces[quadrant], + cutendinnerface, cutEndDiagQuadrant, hollowRatio * 0.5f, false); + //InnerFaces[quadrant].TextureMapping = texturemapping; + totalInnerLength += endSideInnerLength; + } + + LastOuterFace = quadrant; + + if (hollow) + { + //SetupInnerFaceTextureOffsets(startSideInnerLength, wholeSideLength, totalInnerLength); + } + } + + AssignFaces(); + + BuildVertexes(); + } + + protected void BuildCutFaces(Vector3 cutstartouterface, Vector3 cutendouterface) + { + CutFaces[0].RemoveAllPoints(); + + CutFaces[0].AddPoint(Vector3.Zero); + CutFaces[0].AddPoint(cutstartouterface); + //CutFaces[0].TextureMapping = texturemapping; + + CutFaces[1].RemoveAllPoints(); + + CutFaces[1].AddPoint(cutendouterface); + CutFaces[1].AddPoint(Vector3.Zero); + //CutFaces[1].TextureMapping = texturemapping; + } + + protected void BuildCutHollowFaces(Vector3 cutstartouterface, Vector3 cutstartinnerface, Vector3 cutendouterface, Vector3 cutendinnerface) + { + CutFaces[0].RemoveAllPoints(); + + CutFaces[0].AddPoint(cutstartinnerface); + CutFaces[0].AddPoint(cutstartouterface); + //CutFaces[0].TextureMapping = texturemapping; + + CutFaces[1].RemoveAllPoints(); + + CutFaces[1].AddPoint(cutendouterface); + CutFaces[1].AddPoint(cutendinnerface); + //CutFaces[1].TextureMapping = texturemapping; + } + + private Vector3 GetCutIntersect(float cut, float cubeHalfWidth) + { + int cutQuadrant = GetCutQuadrant(cut); + + Vector3 lineend; + Vector3 linestart = ReferenceVertices[cutQuadrant] * cubeHalfWidth; + linestart = Vector3.Divide(linestart, 0.5f); + if (cutQuadrant < NumberFaces - 1) + { + lineend = ReferenceVertices[cutQuadrant + 1] * cubeHalfWidth; + } + else + { + lineend = ReferenceVertices[0] * cubeHalfWidth; + } + lineend = Vector3.Divide(lineend, 0.5f); + + // + float angle = GetAngleWithXAxis(cut); + + // CutVectorPerp is perpendicular to the radius vector + Vector3 cutVectorPerp = new Vector3((float)-Math.Sin(angle), (float)Math.Cos(angle), 0); + Vector3 delta = lineend - linestart; + + // From http://softsurfer.com/Archive/algorithm_0104/algorithm_0104B.htm + Vector3 result = linestart - delta * Vector3.Dot(cutVectorPerp, linestart) / Vector3.Dot(cutVectorPerp, delta); + + return result; + } + + // Handles the first face in the cut, starting from cutstart, + // and running anticlockwise to first reference vertex + private float PopulateSingleCutFacePositiveDirection(ref CrossSection face, Vector3 cutPoint, int quadrant, + float halfCubeWidth, bool outer) + { + quadrant = NormalizeQuadrant(quadrant); + + face.RemoveAllPoints(); + + Vector3 startPoint = cutPoint; + Vector3 endPoint; + if (quadrant < NumberFaces - 1) + { + endPoint = ReferenceVertices[quadrant + 1] * halfCubeWidth / 0.5f; + } + else + { + endPoint = ReferenceVertices[0] * halfCubeWidth / 0.5f; + } + + if (outer) + { + face.AddPoint(startPoint); + face.AddPoint(endPoint); + } + else + { + face.AddPoint(endPoint); + face.AddPoint(startPoint); + } + + return Vector3.Distance(startPoint, endPoint); + } + + private float PopulateSingleCutFaceNegativeDirection(ref CrossSection face, Vector3 cutPoint, int quadrant, + float halfCubeWidth, bool outer) + { + quadrant = NormalizeQuadrant(quadrant); + + face.RemoveAllPoints(); + + Vector3 startPoint = ReferenceVertices[quadrant] * halfCubeWidth / 0.5f; + Vector3 endPoint = cutPoint; + + if (outer) + { + face.AddPoint(startPoint); + face.AddPoint(endPoint); + } + else + { + face.AddPoint(endPoint); + face.AddPoint(startPoint); + } + + return Vector3.Distance(startPoint, endPoint); + } + + private float PopulateCompleteSide(ref CrossSection face, int quadrant, float halfCubeWidth, bool outer) + { + quadrant = NormalizeQuadrant(quadrant); + + face.RemoveAllPoints(); + + Vector3 startPoint = ReferenceVertices[quadrant]; + Vector3 endPoint; + if (quadrant < NumberFaces - 1) + { + endPoint = ReferenceVertices[quadrant + 1]; + } + else + { + endPoint = ReferenceVertices[0]; + } + + startPoint = startPoint * halfCubeWidth / 0.5f; + endPoint = endPoint * halfCubeWidth / 0.5f; + + if (outer) + { + face.AddPoint(startPoint); + face.AddPoint(endPoint); + } + else + { + face.AddPoint(endPoint); + face.AddPoint(startPoint); + } + + return 2f * halfCubeWidth; + } + + protected void BuildVertexes() + { + // For prims with a linear extrusion path, we base the number of transformations on the amount of twist + int transforms = 1 + Math.Abs((int)((float)(Prim.PathTwist - Prim.PathTwistBegin) / 9f)); + + // Build the outer sides + BuildSideVertexes(OuterFaces, transforms); + + if (hollow) + { + // Build the inner sides + BuildSideVertexes(InnerFaces, transforms); + } + + if (cut) + { + // Build the cut sides (between the inner and outer) + BuildSideVertexes(CutFaces, transforms); + } + + // Build the top and bottom end caps + if (hollow) + { + BuildEndCapHollow(true); + BuildEndCapHollow(false); + } + else + { + if (cut) + { + BuildEndCapCutNoHollow(true); + BuildEndCapCutNoHollow(false); + } + else + { + BuildEndCapNoCutNoHollow(true); + BuildEndCapNoCutNoHollow(false); + } + } + + VertexArray = Vertexes.ToArray(); + } + + //private void BuildSideVertexes(CrossSection[] crossSection, int transforms) + //{ + // float transformOffset = 1.0f / (float)transforms; + // float currentOffset = -0.5f; + + // for (int i = 0; i < transforms; i++) + // { + // for (int j = 0; j < crossSection.Length; j++) + // { + // int pointCount = crossSection[j].GetNumPoints(); + + // if (pointCount > 0) + // { + // Vector3 lower1 = crossSection[j].GetRawVertex(0); + // Vector3 lower2 = crossSection[j].GetRawVertex(1); + + // lower1.Z = currentOffset; + // lower2.Z = currentOffset; + + // Vector3 upper1 = lower1; + // Vector3 upper2 = lower2; + + // upper1.Z = currentOffset + transformOffset; + // upper2.Z = currentOffset + transformOffset; + + // // FIXME: Perform skew, taper and twist transformations here + // //lower1 = Vector3.Transform(lower1, lowerTransform); + // //lower2 = Vector3.Transform(lower2, lowerTransform); + // //upper1 = Vector3.Transform(upper1, upperTransform); + // //upper2 = Vector3.Transform(upper2, upperTransform); + + // Vertexes.Add(new VertexPositionColor(lower1, color)); + // Vertexes.Add(new VertexPositionColor(lower2, color)); + // Vertexes.Add(new VertexPositionColor(upper2, color)); + + // Vertexes.Add(new VertexPositionColor(lower1, color)); + // Vertexes.Add(new VertexPositionColor(upper2, color)); + // Vertexes.Add(new VertexPositionColor(upper1, color)); + // } + // } + + // currentOffset += transformOffset; + // } + //} + + protected void BuildSideVertexes(CrossSection[] crossSection, int transforms) + { + float transformOffset = 1.0f / (float)transforms; + float currentOffset = -0.5f; + + for (int i = 0; i < transforms; i++) + { + for (int j = 0; j < crossSection.Length; j++) + { + int pointCount = crossSection[j].GetNumPoints(); + + if (pointCount > 0) + { + for (int k = 0; k < pointCount - 1; k++) + { + Vector3 lower1, lower2, upper1, upper2; + + lower1 = crossSection[j].GetRawVertex(k); + lower2 = crossSection[j].GetRawVertex(k + 1); + + lower1.Z = currentOffset; + lower2.Z = currentOffset; + + upper1 = lower1; + upper2 = lower2; + + upper1.Z = currentOffset + transformOffset; + upper2.Z = currentOffset + transformOffset; + + // FIXME: Perform skew, taper and twist transformations here + //lower1 = Vector3.Transform(lower1, lowerTransform); + //lower2 = Vector3.Transform(lower2, lowerTransform); + //upper1 = Vector3.Transform(upper1, upperTransform); + //upper2 = Vector3.Transform(upper2, upperTransform); + + Vertexes.Add(new VertexPositionColor(lower1, color)); + Vertexes.Add(new VertexPositionColor(lower2, color)); + Vertexes.Add(new VertexPositionColor(upper2, color)); + + Vertexes.Add(new VertexPositionColor(lower1, color)); + Vertexes.Add(new VertexPositionColor(upper2, color)); + Vertexes.Add(new VertexPositionColor(upper1, color)); + } + } + } + + currentOffset += transformOffset; + } + } + + protected void BuildEndCapNoCutNoHollow(bool top) + { + float z = top ? 0.5f : -0.5f; + + for (int i = 0; i < OuterFaces.Length; i++) + { + int pointCount = OuterFaces[i].GetNumPoints(); + + if (pointCount > 0) + { + for (int j = 0; j < pointCount - 1; j++) + { + Vector3 first = OuterFaces[i].GetRawVertex(j); + first.Z = z; + Vector3 second = OuterFaces[i].GetRawVertex(j + 1); + second.Z = z; + + // FIXME: Perform skew, taper and twist transformations here + if (top) + { + ; + } + else + { + ; + } + + Vertexes.Add(new VertexPositionColor(first, color)); + Vertexes.Add(new VertexPositionColor(second, color)); + Vertexes.Add(new VertexPositionColor(new Vector3(0, 0, z), color)); + } + } + } + } + + protected void BuildEndCapCutNoHollow(bool top) + { + float z = top ? 0.5f : -0.5f; + + // FIXME: Apply transformations to the center point + Vector3 center = Vector3.Zero; + + for (int i = FirstOuterFace; i <= LastOuterFace; i++) + { + int pointCount = OuterFaces[i].GetNumPoints(); + + for (int j = 0; j < pointCount - 1; j++) + { + Vector3 p1 = OuterFaces[i].GetRawVertex(j); + Vector3 p2 = OuterFaces[i].GetRawVertex(j + 1); + + center.Z = p1.Z = p2.Z = z; + + // TODO: Texturemapping stuff + //Vector2 t1 = texturemapping.GetTextureCoordinate(new Vector2(1 - (p1.x + 0.5), p1.y + 0.5)); + //Vector2 t2 = texturemapping.GetTextureCoordinate(new Vector2(1 - (p2.x + 0.5), p2.y + 0.5)); + + // FIXME: Perform skew, taper and twist transformations here + //p1 = Vector3.Transform(p1, transform); + //p2 = Vector3.Transform(p2, transform); + + Vertexes.Add(new VertexPositionColor(p2, color)); + Vertexes.Add(new VertexPositionColor(p1, color)); + Vertexes.Add(new VertexPositionColor(center, color)); + } + } + } + + private int NormalizeQuadrant(int quadrant) + { + return ((quadrant % NumberFaces) + NumberFaces) % NumberFaces; + } + } +} diff --git a/applications/sceneviewer/Prims/PrimVisual.cs b/applications/sceneviewer/Prims/PrimVisual.cs index cef1fa4b..a7b55511 100644 --- a/applications/sceneviewer/Prims/PrimVisual.cs +++ b/applications/sceneviewer/Prims/PrimVisual.cs @@ -1,124 +1,124 @@ -using System; -using System.Text; -using System.Collections.Generic; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using libsecondlife; - -namespace sceneviewer.Prims -{ - public abstract class PrimVisual - { - // Constants - public const int MaxCut = 200; - - public Matrix Matrix; - public VertexPositionColor[] VertexArray; - public PrimObject Prim; - public Vector3 Acceleration; - public Vector3 Velocity; - public Vector3 RotationVelocity; - public int LevelOfDetail = 16; - - // Accessors - public abstract int TriangleCount { get; } - //public abstract int Twist { set; get; } - //public abstract double Shear { set; get; } - //public abstract double TopSizeX { set; get;} - //public abstract double TopSizeY { set; get; } - //public abstract int CutStart { set; get; } - //public abstract int CutEnd { set; get; } - //public virtual int AdvancedCutStart { set { } get { return 0; } } - //public virtual int AdvancedCutEnd { set { } get { return 0; } } - //public abstract int Hollow { set; get; } - - protected const int MaxFaces = 9; - - protected bool hollow; - protected bool cut; - - protected List Vertexes; - protected Color[] FaceColors = new Color[MaxFaces]; - - // Abstract methods - protected abstract void BuildFaces(); - protected abstract void AssignFaces(); - - public PrimVisual(PrimObject prim) - { - Prim = prim; - Vertexes = new List(); - VertexArray = Vertexes.ToArray(); - - Acceleration = Vector3.Zero; - Velocity = Vector3.Zero; - RotationVelocity = Vector3.Zero; - - BuildMatrix(); - } - - public void Update(PrimUpdate primUpdate) - { - Prim.Position = primUpdate.Position; - Prim.Rotation = primUpdate.Rotation; - Acceleration = new Vector3(primUpdate.Acceleration.X, primUpdate.Acceleration.Y, primUpdate.Acceleration.Z); - Velocity = new Vector3(primUpdate.Velocity.X, primUpdate.Velocity.Y, primUpdate.Velocity.Z); - RotationVelocity = new Vector3(primUpdate.RotationVelocity.X, primUpdate.RotationVelocity.Y, primUpdate.RotationVelocity.Z); - - BuildMatrix(); - } - - private void BuildMatrix() - { - Matrix offset = Matrix.CreateTranslation(new Vector3(Prim.Position.X, Prim.Position.Y, Prim.Position.Z)); - Matrix rotation = Matrix.FromQuaternion(new Quaternion(Prim.Rotation.X, Prim.Rotation.Y, Prim.Rotation.Z, - Prim.Rotation.W)); - Matrix scaling = Matrix.CreateScale(Prim.Scale.X, Prim.Scale.Y, Prim.Scale.Z); - - Matrix = scaling * rotation * offset; - } - - public static PrimVisual BuildPrimVisual(PrimObject prim) - { - if (prim.ProfileCurve == 1 && prim.PathCurve == 16) - { - // PRIM_TYPE_BOX - return new PrimVisualBox(prim); - } - else if (prim.ProfileCurve == 0 && prim.PathCurve == 16) - { - // PRIM_TYPE_CYLINDER - return new PrimVisualCylinder(prim); - } - else if (prim.ProfileCurve == 3 && prim.PathCurve == 16) - { - // PRIM_TYPE_PRISM - return new PrimVisualPrism(prim); - } - else if (prim.ProfileCurve == 5 && prim.PathCurve == 32) - { - // PRIM_TYPE_SPHERE - return new PrimVisualSphere(prim); - } - else if (prim.ProfileCurve == 0 && prim.PathCurve == 32) - { - // PRIM_TYPE_TORUS - return new PrimVisualTorus(prim); - } - else if (prim.ProfileCurve == 1 && prim.PathCurve == 32) - { - // PRIM_TYPE_TUBE - return new PrimVisualTube(prim); - } - else if (prim.ProfileCurve == 3 && prim.PathCurve == 32) - { - // PRIM_TYPE_RING - return new PrimVisualRing(prim); - } - else - { - return null; - } - } - } -} +using System; +using System.Text; +using System.Collections.Generic; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using libsecondlife; + +namespace sceneviewer.Prims +{ + public abstract class PrimVisual + { + // Constants + public const int MaxCut = 200; + + public Matrix Matrix; + public VertexPositionColor[] VertexArray; + public PrimObject Prim; + public Vector3 Acceleration; + public Vector3 Velocity; + public Vector3 RotationVelocity; + public int LevelOfDetail = 16; + + // Accessors + public abstract int TriangleCount { get; } + //public abstract int Twist { set; get; } + //public abstract double Shear { set; get; } + //public abstract double TopSizeX { set; get;} + //public abstract double TopSizeY { set; get; } + //public abstract int CutStart { set; get; } + //public abstract int CutEnd { set; get; } + //public virtual int AdvancedCutStart { set { } get { return 0; } } + //public virtual int AdvancedCutEnd { set { } get { return 0; } } + //public abstract int Hollow { set; get; } + + protected const int MaxFaces = 9; + + protected bool hollow; + protected bool cut; + + protected List Vertexes; + protected Color[] FaceColors = new Color[MaxFaces]; + + // Abstract methods + protected abstract void BuildFaces(); + protected abstract void AssignFaces(); + + public PrimVisual(PrimObject prim) + { + Prim = prim; + Vertexes = new List(); + VertexArray = Vertexes.ToArray(); + + Acceleration = Vector3.Zero; + Velocity = Vector3.Zero; + RotationVelocity = Vector3.Zero; + + BuildMatrix(); + } + + public void Update(PrimUpdate primUpdate) + { + Prim.Position = primUpdate.Position; + Prim.Rotation = primUpdate.Rotation; + Acceleration = new Vector3(primUpdate.Acceleration.X, primUpdate.Acceleration.Y, primUpdate.Acceleration.Z); + Velocity = new Vector3(primUpdate.Velocity.X, primUpdate.Velocity.Y, primUpdate.Velocity.Z); + RotationVelocity = new Vector3(primUpdate.RotationVelocity.X, primUpdate.RotationVelocity.Y, primUpdate.RotationVelocity.Z); + + BuildMatrix(); + } + + private void BuildMatrix() + { + Matrix offset = Matrix.CreateTranslation(new Vector3(Prim.Position.X, Prim.Position.Y, Prim.Position.Z)); + Matrix rotation = Matrix.FromQuaternion(new Quaternion(Prim.Rotation.X, Prim.Rotation.Y, Prim.Rotation.Z, + Prim.Rotation.W)); + Matrix scaling = Matrix.CreateScale(Prim.Scale.X, Prim.Scale.Y, Prim.Scale.Z); + + Matrix = scaling * rotation * offset; + } + + public static PrimVisual BuildPrimVisual(PrimObject prim) + { + if (prim.ProfileCurve == 1 && prim.PathCurve == 16) + { + // PRIM_TYPE_BOX + return new PrimVisualBox(prim); + } + else if (prim.ProfileCurve == 0 && prim.PathCurve == 16) + { + // PRIM_TYPE_CYLINDER + return new PrimVisualCylinder(prim); + } + else if (prim.ProfileCurve == 3 && prim.PathCurve == 16) + { + // PRIM_TYPE_PRISM + return new PrimVisualPrism(prim); + } + else if (prim.ProfileCurve == 5 && prim.PathCurve == 32) + { + // PRIM_TYPE_SPHERE + return new PrimVisualSphere(prim); + } + else if (prim.ProfileCurve == 0 && prim.PathCurve == 32) + { + // PRIM_TYPE_TORUS + return new PrimVisualTorus(prim); + } + else if (prim.ProfileCurve == 1 && prim.PathCurve == 32) + { + // PRIM_TYPE_TUBE + return new PrimVisualTube(prim); + } + else if (prim.ProfileCurve == 3 && prim.PathCurve == 32) + { + // PRIM_TYPE_RING + return new PrimVisualRing(prim); + } + else + { + return null; + } + } + } +} diff --git a/applications/sceneviewer/Prims/PrimVisualBox.cs b/applications/sceneviewer/Prims/PrimVisualBox.cs index 0cae5be9..0dc6fc73 100644 --- a/applications/sceneviewer/Prims/PrimVisualBox.cs +++ b/applications/sceneviewer/Prims/PrimVisualBox.cs @@ -1,100 +1,100 @@ -using System; -using System.Text; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using libsecondlife; - -namespace sceneviewer.Prims -{ - public class PrimVisualBox : LinearPrimVisual - { - public PrimVisualBox(PrimObject prim) : base(prim) - { - NumberFaces = 4; - FirstOuterFace = 0; - LastOuterFace = 3; - - ReferenceVertices = new Vector3[4]; - - ReferenceVertices[1] = new Vector3(0.5f, -0.5f, 0f); - ReferenceVertices[2] = new Vector3(0.5f, 0.5f, 0f); - ReferenceVertices[3] = new Vector3(-0.5f, 0.5f, 0f); - ReferenceVertices[0] = new Vector3(-0.5f, -0.5f, 0f); - - OuterFaces = new CrossSection[4]; - for (int i = 0; i < 4; i++) - { - OuterFaces[i] = new CrossSection(); - } - - if (prim.ProfileHollow != 0) - { - hollow = true; - InnerFaces = new CrossSection[4]; - for (int i = 0; i < 4; i++) - { - InnerFaces[i] = new CrossSection(); - } - } - - if (prim.ProfileBegin != 0 || prim.ProfileEnd != 1) - { - cut = true; - CutFaces = new CrossSection[2]; - for (int i = 0; i < 2; i++) - { - CutFaces[i] = new CrossSection(); - } - } - - BuildFaces(); - } - - protected override void AssignFaces() - { - } - - protected override int GetCutQuadrant(float cut) - { - if (cut == 1) { return 3; } - else { return (int)(cut * 4.0); } - } - - protected override float GetAngleWithXAxis(float cut) - { - //return (cut - 0.125f) * 2f * (float)Math.PI; - return (cut + 0.125f) * 2f * (float)Math.PI; - } - - protected override void BuildEndCapHollow(bool top) - { - float z = top ? 0.5f : -0.5f; - - for (int i = FirstOuterFace; i <= LastOuterFace; i++) - { - int pointCount = OuterFaces[i].GetNumPoints(); - - Vector3 p1 = OuterFaces[i].GetRawVertex(0); - Vector3 p2 = OuterFaces[i].GetRawVertex(1); - Vector3 p3 = InnerFaces[i].GetRawVertex(0); - Vector3 p4 = InnerFaces[i].GetRawVertex(1); - - p1.Z = p2.Z = p3.Z = p4.Z = z; - - // TODO: Texturemapping - //Vector2 t1 = texturemapping.GetTextureCoordinate(new Vector2(1 - (r1.x + 0.5), r1.y + 0.5)); - //Vector2 t2 = texturemapping.GetTextureCoordinate(new Vector2(1 - (r2.x + 0.5), r2.y + 0.5)); - //Vector2 t3 = texturemapping.GetTextureCoordinate(new Vector2(1 - (r3.x + 0.5), r3.y + 0.5)); - //Vector2 t4 = texturemapping.GetTextureCoordinate(new Vector2(1 - (r4.x + 0.5), r4.y + 0.5)); - - Vertexes.Add(new VertexPositionColor(p4, color)); - Vertexes.Add(new VertexPositionColor(p3, color)); - Vertexes.Add(new VertexPositionColor(p2, color)); - - Vertexes.Add(new VertexPositionColor(p4, color)); - Vertexes.Add(new VertexPositionColor(p2, color)); - Vertexes.Add(new VertexPositionColor(p1, color)); - } - } - } -} +using System; +using System.Text; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using libsecondlife; + +namespace sceneviewer.Prims +{ + public class PrimVisualBox : LinearPrimVisual + { + public PrimVisualBox(PrimObject prim) : base(prim) + { + NumberFaces = 4; + FirstOuterFace = 0; + LastOuterFace = 3; + + ReferenceVertices = new Vector3[4]; + + ReferenceVertices[1] = new Vector3(0.5f, -0.5f, 0f); + ReferenceVertices[2] = new Vector3(0.5f, 0.5f, 0f); + ReferenceVertices[3] = new Vector3(-0.5f, 0.5f, 0f); + ReferenceVertices[0] = new Vector3(-0.5f, -0.5f, 0f); + + OuterFaces = new CrossSection[4]; + for (int i = 0; i < 4; i++) + { + OuterFaces[i] = new CrossSection(); + } + + if (prim.ProfileHollow != 0) + { + hollow = true; + InnerFaces = new CrossSection[4]; + for (int i = 0; i < 4; i++) + { + InnerFaces[i] = new CrossSection(); + } + } + + if (prim.ProfileBegin != 0 || prim.ProfileEnd != 1) + { + cut = true; + CutFaces = new CrossSection[2]; + for (int i = 0; i < 2; i++) + { + CutFaces[i] = new CrossSection(); + } + } + + BuildFaces(); + } + + protected override void AssignFaces() + { + } + + protected override int GetCutQuadrant(float cut) + { + if (cut == 1) { return 3; } + else { return (int)(cut * 4.0); } + } + + protected override float GetAngleWithXAxis(float cut) + { + //return (cut - 0.125f) * 2f * (float)Math.PI; + return (cut + 0.125f) * 2f * (float)Math.PI; + } + + protected override void BuildEndCapHollow(bool top) + { + float z = top ? 0.5f : -0.5f; + + for (int i = FirstOuterFace; i <= LastOuterFace; i++) + { + int pointCount = OuterFaces[i].GetNumPoints(); + + Vector3 p1 = OuterFaces[i].GetRawVertex(0); + Vector3 p2 = OuterFaces[i].GetRawVertex(1); + Vector3 p3 = InnerFaces[i].GetRawVertex(0); + Vector3 p4 = InnerFaces[i].GetRawVertex(1); + + p1.Z = p2.Z = p3.Z = p4.Z = z; + + // TODO: Texturemapping + //Vector2 t1 = texturemapping.GetTextureCoordinate(new Vector2(1 - (r1.x + 0.5), r1.y + 0.5)); + //Vector2 t2 = texturemapping.GetTextureCoordinate(new Vector2(1 - (r2.x + 0.5), r2.y + 0.5)); + //Vector2 t3 = texturemapping.GetTextureCoordinate(new Vector2(1 - (r3.x + 0.5), r3.y + 0.5)); + //Vector2 t4 = texturemapping.GetTextureCoordinate(new Vector2(1 - (r4.x + 0.5), r4.y + 0.5)); + + Vertexes.Add(new VertexPositionColor(p4, color)); + Vertexes.Add(new VertexPositionColor(p3, color)); + Vertexes.Add(new VertexPositionColor(p2, color)); + + Vertexes.Add(new VertexPositionColor(p4, color)); + Vertexes.Add(new VertexPositionColor(p2, color)); + Vertexes.Add(new VertexPositionColor(p1, color)); + } + } + } +} diff --git a/applications/sceneviewer/Prims/PrimVisualCylinder.cs b/applications/sceneviewer/Prims/PrimVisualCylinder.cs index 103302c0..245aa48f 100644 --- a/applications/sceneviewer/Prims/PrimVisualCylinder.cs +++ b/applications/sceneviewer/Prims/PrimVisualCylinder.cs @@ -1,163 +1,163 @@ -using System; -using System.Text; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using libsecondlife; - -namespace sceneviewer.Prims -{ - public class PrimVisualCylinder : LinearPrimVisual - { - public PrimVisualCylinder(PrimObject prim) - : base(prim) - { - NumberFaces = 1; - FirstOuterFace = 0; - LastOuterFace = 0; - - OuterFaces = new CrossSection[1]; - OuterFaces[0] = new CrossSection(); - - if (prim.ProfileHollow != 0) - { - hollow = true; - InnerFaces = new CrossSection[1]; - InnerFaces[0] = new CrossSection(); - - //for (int i = 0; i < 4; i++) - //{ - // InnerFaces[i] = new CrossSection(); - //} - } - - if (prim.ProfileBegin != 0 || prim.ProfileEnd != 1) - { - cut = true; - CutFaces = new CrossSection[2]; - for (int i = 0; i < 2; i++) - { - CutFaces[i] = new CrossSection(); - } - } - - BuildFaces(); - } - - protected override void AssignFaces() - { - } - - protected Vector3 GetCutIntersect(float cut, float primHalfWidth) - { - double angle = cut * 2 * Math.PI; - return new Vector3((float)(primHalfWidth * Math.Cos(angle)), (float)(primHalfWidth * Math.Sin(angle)), 0); - } - - protected override float GetAngleWithXAxis(float cut) - { - return cut * 2 * (float)Math.PI; - } - - protected override int GetCutQuadrant(float cut) - { - return 0; - } - - protected override void BuildFaces() - { - float hollowRatio = Prim.ProfileHollow / 100.0f; - - Vector3 cutstartinnerface; - Vector3 cutendinnerface; - - Vector3 cutstartouterface = GetCutIntersect(Prim.ProfileBegin, 0.5f); - Vector3 cutendouterface = GetCutIntersect(Prim.ProfileEnd, 0.5f); - - OuterFaces[0].RemoveAllPoints(); - - if (hollow) - { - InnerFaces[0].RemoveAllPoints(); - - cutstartinnerface = GetCutIntersect(Prim.ProfileBegin, hollowRatio * 0.5f); - cutendinnerface = GetCutIntersect(Prim.ProfileEnd, hollowRatio * 0.5f); - - if (cut) - { - BuildCutHollowFaces(cutstartouterface, cutstartinnerface, cutendouterface, cutendinnerface); - } - } - else if (cut) - { - BuildCutFaces(cutstartouterface, cutendouterface); - } - - double angle = 0; - double startAngle = Prim.ProfileBegin * 2 * Math.PI; - double endAngle = Prim.ProfileEnd * 2 * Math.PI; - - Vector3 nextOuterPoint = Vector3.Zero; - Vector3 nextInnerPoint = Vector3.Zero; - - for (int facePoint = 0; facePoint <= LevelOfDetail; facePoint++) - { - angle = startAngle + ((double)facePoint / (double)LevelOfDetail) * (endAngle - startAngle); - - nextOuterPoint.X = (float)(0.5 * Math.Cos(angle)); - nextOuterPoint.Y = (float)(0.5 * Math.Sin(angle)); - OuterFaces[0].AddPoint(nextOuterPoint); - } - - if (hollow) - { - //for (int facePoint = LevelOfDetail; facePoint >= 0; facePoint--) - for (int facePoint = 0; facePoint <= LevelOfDetail; facePoint++) - { - angle = startAngle + ((double)facePoint / (double)LevelOfDetail) * (endAngle - startAngle); - - nextInnerPoint.X = (float)(0.5 * Math.Cos(angle) * hollowRatio); - nextInnerPoint.Y = (float)(0.5 * Math.Sin(angle) * hollowRatio); - InnerFaces[0].AddPoint(nextInnerPoint); - } - } - - // TODO: Texturemapping - - AssignFaces(); - - BuildVertexes(); - } - - protected override void BuildEndCapHollow(bool top) - { - float z = top ? 0.5f : -0.5f; - - // We assume the innerfaces and outerfaces point counts are the same - int pointCount = OuterFaces[0].GetNumPoints(); - - for (int j = 0; j < pointCount - 1; j++) - { - Vector3 p1 = OuterFaces[0].GetRawVertex(j); - Vector3 p2 = OuterFaces[0].GetRawVertex(j + 1); - Vector3 p3 = InnerFaces[0].GetRawVertex(j); - Vector3 p4 = InnerFaces[0].GetRawVertex(j + 1); - - p1.Z = p2.Z = p3.Z = p4.Z = z; - - // TODO: Texturemapping - //Vector2 t1 = texturemapping.GetTextureCoordinate(new Vector2(1 - (r1.x + 0.5), r1.y + 0.5)); - //Vector2 t2 = texturemapping.GetTextureCoordinate(new Vector2(1 - (r2.x + 0.5), r2.y + 0.5)); - //Vector2 t3 = texturemapping.GetTextureCoordinate(new Vector2(1 - (r3.x + 0.5), r3.y + 0.5)); - //Vector2 t4 = texturemapping.GetTextureCoordinate(new Vector2(1 - (r4.x + 0.5), r4.y + 0.5)); - - Vertexes.Add(new VertexPositionColor(p4, color)); - Vertexes.Add(new VertexPositionColor(p3, color)); - Vertexes.Add(new VertexPositionColor(p2, color)); - - Vertexes.Add(new VertexPositionColor(p3, color)); - Vertexes.Add(new VertexPositionColor(p2, color)); - Vertexes.Add(new VertexPositionColor(p1, color)); - } - } - } -} +using System; +using System.Text; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using libsecondlife; + +namespace sceneviewer.Prims +{ + public class PrimVisualCylinder : LinearPrimVisual + { + public PrimVisualCylinder(PrimObject prim) + : base(prim) + { + NumberFaces = 1; + FirstOuterFace = 0; + LastOuterFace = 0; + + OuterFaces = new CrossSection[1]; + OuterFaces[0] = new CrossSection(); + + if (prim.ProfileHollow != 0) + { + hollow = true; + InnerFaces = new CrossSection[1]; + InnerFaces[0] = new CrossSection(); + + //for (int i = 0; i < 4; i++) + //{ + // InnerFaces[i] = new CrossSection(); + //} + } + + if (prim.ProfileBegin != 0 || prim.ProfileEnd != 1) + { + cut = true; + CutFaces = new CrossSection[2]; + for (int i = 0; i < 2; i++) + { + CutFaces[i] = new CrossSection(); + } + } + + BuildFaces(); + } + + protected override void AssignFaces() + { + } + + protected Vector3 GetCutIntersect(float cut, float primHalfWidth) + { + double angle = cut * 2 * Math.PI; + return new Vector3((float)(primHalfWidth * Math.Cos(angle)), (float)(primHalfWidth * Math.Sin(angle)), 0); + } + + protected override float GetAngleWithXAxis(float cut) + { + return cut * 2 * (float)Math.PI; + } + + protected override int GetCutQuadrant(float cut) + { + return 0; + } + + protected override void BuildFaces() + { + float hollowRatio = Prim.ProfileHollow / 100.0f; + + Vector3 cutstartinnerface; + Vector3 cutendinnerface; + + Vector3 cutstartouterface = GetCutIntersect(Prim.ProfileBegin, 0.5f); + Vector3 cutendouterface = GetCutIntersect(Prim.ProfileEnd, 0.5f); + + OuterFaces[0].RemoveAllPoints(); + + if (hollow) + { + InnerFaces[0].RemoveAllPoints(); + + cutstartinnerface = GetCutIntersect(Prim.ProfileBegin, hollowRatio * 0.5f); + cutendinnerface = GetCutIntersect(Prim.ProfileEnd, hollowRatio * 0.5f); + + if (cut) + { + BuildCutHollowFaces(cutstartouterface, cutstartinnerface, cutendouterface, cutendinnerface); + } + } + else if (cut) + { + BuildCutFaces(cutstartouterface, cutendouterface); + } + + double angle = 0; + double startAngle = Prim.ProfileBegin * 2 * Math.PI; + double endAngle = Prim.ProfileEnd * 2 * Math.PI; + + Vector3 nextOuterPoint = Vector3.Zero; + Vector3 nextInnerPoint = Vector3.Zero; + + for (int facePoint = 0; facePoint <= LevelOfDetail; facePoint++) + { + angle = startAngle + ((double)facePoint / (double)LevelOfDetail) * (endAngle - startAngle); + + nextOuterPoint.X = (float)(0.5 * Math.Cos(angle)); + nextOuterPoint.Y = (float)(0.5 * Math.Sin(angle)); + OuterFaces[0].AddPoint(nextOuterPoint); + } + + if (hollow) + { + //for (int facePoint = LevelOfDetail; facePoint >= 0; facePoint--) + for (int facePoint = 0; facePoint <= LevelOfDetail; facePoint++) + { + angle = startAngle + ((double)facePoint / (double)LevelOfDetail) * (endAngle - startAngle); + + nextInnerPoint.X = (float)(0.5 * Math.Cos(angle) * hollowRatio); + nextInnerPoint.Y = (float)(0.5 * Math.Sin(angle) * hollowRatio); + InnerFaces[0].AddPoint(nextInnerPoint); + } + } + + // TODO: Texturemapping + + AssignFaces(); + + BuildVertexes(); + } + + protected override void BuildEndCapHollow(bool top) + { + float z = top ? 0.5f : -0.5f; + + // We assume the innerfaces and outerfaces point counts are the same + int pointCount = OuterFaces[0].GetNumPoints(); + + for (int j = 0; j < pointCount - 1; j++) + { + Vector3 p1 = OuterFaces[0].GetRawVertex(j); + Vector3 p2 = OuterFaces[0].GetRawVertex(j + 1); + Vector3 p3 = InnerFaces[0].GetRawVertex(j); + Vector3 p4 = InnerFaces[0].GetRawVertex(j + 1); + + p1.Z = p2.Z = p3.Z = p4.Z = z; + + // TODO: Texturemapping + //Vector2 t1 = texturemapping.GetTextureCoordinate(new Vector2(1 - (r1.x + 0.5), r1.y + 0.5)); + //Vector2 t2 = texturemapping.GetTextureCoordinate(new Vector2(1 - (r2.x + 0.5), r2.y + 0.5)); + //Vector2 t3 = texturemapping.GetTextureCoordinate(new Vector2(1 - (r3.x + 0.5), r3.y + 0.5)); + //Vector2 t4 = texturemapping.GetTextureCoordinate(new Vector2(1 - (r4.x + 0.5), r4.y + 0.5)); + + Vertexes.Add(new VertexPositionColor(p4, color)); + Vertexes.Add(new VertexPositionColor(p3, color)); + Vertexes.Add(new VertexPositionColor(p2, color)); + + Vertexes.Add(new VertexPositionColor(p3, color)); + Vertexes.Add(new VertexPositionColor(p2, color)); + Vertexes.Add(new VertexPositionColor(p1, color)); + } + } + } +} diff --git a/applications/sceneviewer/Prims/PrimVisualPrism.cs b/applications/sceneviewer/Prims/PrimVisualPrism.cs index 09f5eb18..789dd54c 100644 --- a/applications/sceneviewer/Prims/PrimVisualPrism.cs +++ b/applications/sceneviewer/Prims/PrimVisualPrism.cs @@ -1,38 +1,38 @@ -using System; -using System.Text; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using libsecondlife; - -namespace sceneviewer.Prims -{ - public class PrimVisualPrism : LinearPrimVisual - { - public PrimVisualPrism(PrimObject prim) - : base(prim) - { - ; - } - - protected override void AssignFaces() - { - } - - protected override int GetCutQuadrant(float cut) - { - // FIXME - //return cut / 67; - return 0; - } - - // should return angle in radians for a given cut ratio (?) - protected override float GetAngleWithXAxis(float cut) - { - return (cut - (30f / 360f)) * 2 * (float)Math.PI; - } - - protected override void BuildEndCapHollow(bool top) - { - } - } +using System; +using System.Text; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using libsecondlife; + +namespace sceneviewer.Prims +{ + public class PrimVisualPrism : LinearPrimVisual + { + public PrimVisualPrism(PrimObject prim) + : base(prim) + { + ; + } + + protected override void AssignFaces() + { + } + + protected override int GetCutQuadrant(float cut) + { + // FIXME + //return cut / 67; + return 0; + } + + // should return angle in radians for a given cut ratio (?) + protected override float GetAngleWithXAxis(float cut) + { + return (cut - (30f / 360f)) * 2 * (float)Math.PI; + } + + protected override void BuildEndCapHollow(bool top) + { + } + } } \ No newline at end of file diff --git a/applications/sceneviewer/Prims/PrimVisualRing.cs b/applications/sceneviewer/Prims/PrimVisualRing.cs index 278c9fda..ea1ab9b4 100644 --- a/applications/sceneviewer/Prims/PrimVisualRing.cs +++ b/applications/sceneviewer/Prims/PrimVisualRing.cs @@ -1,37 +1,37 @@ -using System; -using System.Text; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using libsecondlife; - -namespace sceneviewer.Prims -{ - public class PrimVisualRing : LinearPrimVisual - { - public PrimVisualRing(PrimObject prim) - : base(prim) - { - ; - } - - protected override void AssignFaces() - { - } - - protected override int GetCutQuadrant(float cut) - { - // FIXME: Our cut is already normalized, so this function won't work - //return ((cut / 67) % 3 + 3) % 3; - return 0; - } - - protected override float GetAngleWithXAxis(float cut) - { - return (cut - 0.125f) * 2 * (float)Math.PI; - } - - protected override void BuildEndCapHollow(bool top) - { - } - } +using System; +using System.Text; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using libsecondlife; + +namespace sceneviewer.Prims +{ + public class PrimVisualRing : LinearPrimVisual + { + public PrimVisualRing(PrimObject prim) + : base(prim) + { + ; + } + + protected override void AssignFaces() + { + } + + protected override int GetCutQuadrant(float cut) + { + // FIXME: Our cut is already normalized, so this function won't work + //return ((cut / 67) % 3 + 3) % 3; + return 0; + } + + protected override float GetAngleWithXAxis(float cut) + { + return (cut - 0.125f) * 2 * (float)Math.PI; + } + + protected override void BuildEndCapHollow(bool top) + { + } + } } \ No newline at end of file diff --git a/applications/sceneviewer/Prims/PrimVisualSphere.cs b/applications/sceneviewer/Prims/PrimVisualSphere.cs index a071e8a6..02a90754 100644 --- a/applications/sceneviewer/Prims/PrimVisualSphere.cs +++ b/applications/sceneviewer/Prims/PrimVisualSphere.cs @@ -1,37 +1,37 @@ -using System; -using System.Text; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using libsecondlife; - -namespace sceneviewer.Prims -{ - public class PrimVisualSphere : LinearPrimVisual - { - public PrimVisualSphere(PrimObject prim) - : base(prim) - { - ; - } - - protected override void AssignFaces() - { - } - - protected override int GetCutQuadrant(float cut) - { - // FIXME: ? - return 0; - } - - protected override float GetAngleWithXAxis(float cut) - { - // FIXME: Is this correct? - return (cut - 0.125f) * 2 * (float)Math.PI; - } - - protected override void BuildEndCapHollow(bool top) - { - } - } -} +using System; +using System.Text; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using libsecondlife; + +namespace sceneviewer.Prims +{ + public class PrimVisualSphere : LinearPrimVisual + { + public PrimVisualSphere(PrimObject prim) + : base(prim) + { + ; + } + + protected override void AssignFaces() + { + } + + protected override int GetCutQuadrant(float cut) + { + // FIXME: ? + return 0; + } + + protected override float GetAngleWithXAxis(float cut) + { + // FIXME: Is this correct? + return (cut - 0.125f) * 2 * (float)Math.PI; + } + + protected override void BuildEndCapHollow(bool top) + { + } + } +} diff --git a/applications/sceneviewer/Prims/PrimVisualTorus.cs b/applications/sceneviewer/Prims/PrimVisualTorus.cs index d191ab50..3612c2f7 100644 --- a/applications/sceneviewer/Prims/PrimVisualTorus.cs +++ b/applications/sceneviewer/Prims/PrimVisualTorus.cs @@ -1,35 +1,35 @@ -using System; -using System.Text; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using libsecondlife; - -namespace sceneviewer.Prims -{ - public class PrimVisualTorus : LinearPrimVisual - { - public PrimVisualTorus(PrimObject prim) - : base(prim) - { - ; - } - - protected override void AssignFaces() - { - } - - protected override int GetCutQuadrant(float cut) - { - return 0; - } - - protected override float GetAngleWithXAxis(float cut) - { - return cut * 2 * (float)Math.PI; - } - - protected override void BuildEndCapHollow(bool top) - { - } - } -} +using System; +using System.Text; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using libsecondlife; + +namespace sceneviewer.Prims +{ + public class PrimVisualTorus : LinearPrimVisual + { + public PrimVisualTorus(PrimObject prim) + : base(prim) + { + ; + } + + protected override void AssignFaces() + { + } + + protected override int GetCutQuadrant(float cut) + { + return 0; + } + + protected override float GetAngleWithXAxis(float cut) + { + return cut * 2 * (float)Math.PI; + } + + protected override void BuildEndCapHollow(bool top) + { + } + } +} diff --git a/applications/sceneviewer/Prims/PrimVisualTube.cs b/applications/sceneviewer/Prims/PrimVisualTube.cs index 796da02b..086e57aa 100644 --- a/applications/sceneviewer/Prims/PrimVisualTube.cs +++ b/applications/sceneviewer/Prims/PrimVisualTube.cs @@ -1,37 +1,37 @@ -using System; -using System.Text; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using libsecondlife; - -namespace sceneviewer.Prims -{ - public class PrimVisualTube : LinearPrimVisual - { - public PrimVisualTube(PrimObject prim) - : base(prim) - { - ; - } - - protected override void AssignFaces() - { - } - - protected override int GetCutQuadrant(float cut) - { - // FIXME: This is wrong - //return ((cut / 50) % 4 + 4) % 4; - return 0; - } - - protected override float GetAngleWithXAxis(float cut) - { - return (cut - 0.125f) * 2 * (float)Math.PI; - } - - protected override void BuildEndCapHollow(bool top) - { - } - } +using System; +using System.Text; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using libsecondlife; + +namespace sceneviewer.Prims +{ + public class PrimVisualTube : LinearPrimVisual + { + public PrimVisualTube(PrimObject prim) + : base(prim) + { + ; + } + + protected override void AssignFaces() + { + } + + protected override int GetCutQuadrant(float cut) + { + // FIXME: This is wrong + //return ((cut / 50) % 4 + 4) % 4; + return 0; + } + + protected override float GetAngleWithXAxis(float cut) + { + return (cut - 0.125f) * 2 * (float)Math.PI; + } + + protected override void BuildEndCapHollow(bool top) + { + } + } } \ No newline at end of file diff --git a/applications/sceneviewer/Properties/AssemblyInfo.cs b/applications/sceneviewer/Properties/AssemblyInfo.cs index 0af0de6e..bcf8c83b 100644 --- a/applications/sceneviewer/Properties/AssemblyInfo.cs +++ b/applications/sceneviewer/Properties/AssemblyInfo.cs @@ -1,32 +1,32 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("sceneviewer")] -[assembly: AssemblyProduct("sceneviewer")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyCopyright("Copyright © 2006")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("2deeb61c-062f-4ebf-837d-50924e6145e6")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("sceneviewer")] +[assembly: AssemblyProduct("sceneviewer")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyCopyright("Copyright © 2006")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("2deeb61c-062f-4ebf-837d-50924e6145e6")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/applications/sceneviewer/README.txt b/applications/sceneviewer/README.txt index 58787d70..f731de2f 100644 --- a/applications/sceneviewer/README.txt +++ b/applications/sceneviewer/README.txt @@ -1,7 +1,7 @@ -sceneviewer uses XNA, a Microsoft DirectX technology for the .NET framework. -Currently the XNA framework requires Visual C# Express (it can be installed -alongside VS2005 or any other IDE), and the XNA Game Studio Express (XGE). - -C# Express: http://msdn.microsoft.com/vstudio/express/visualcsharp/ -XNA: http://msdn.microsoft.com/directx/XNA/default.aspx +sceneviewer uses XNA, a Microsoft DirectX technology for the .NET framework. +Currently the XNA framework requires Visual C# Express (it can be installed +alongside VS2005 or any other IDE), and the XNA Game Studio Express (XGE). + +C# Express: http://msdn.microsoft.com/vstudio/express/visualcsharp/ +XNA: http://msdn.microsoft.com/directx/XNA/default.aspx XGE: http://msdn.microsoft.com/directx/xna/gse/ \ No newline at end of file diff --git a/applications/sceneviewer/ReallySimpleEffect.fx b/applications/sceneviewer/ReallySimpleEffect.fx index 258a8771..1d309d60 100644 --- a/applications/sceneviewer/ReallySimpleEffect.fx +++ b/applications/sceneviewer/ReallySimpleEffect.fx @@ -1,27 +1,27 @@ -uniform extern float4x4 WorldViewProj : WORLDVIEWPROJECTION; - -struct VS_OUTPUT -{ - float4 position : POSITION; - float4 color : COLOR0; -}; - -VS_OUTPUT Transform( - float4 Pos : POSITION, - float4 Color : COLOR0 ) -{ - VS_OUTPUT Out = (VS_OUTPUT)0; - - Out.position = mul(Pos, WorldViewProj); - Out.color = Color; - - return Out; -} - -technique TransformTechnique -{ - pass P0 - { - vertexShader = compile vs_2_0 Transform(); - } -} +uniform extern float4x4 WorldViewProj : WORLDVIEWPROJECTION; + +struct VS_OUTPUT +{ + float4 position : POSITION; + float4 color : COLOR0; +}; + +VS_OUTPUT Transform( + float4 Pos : POSITION, + float4 Color : COLOR0 ) +{ + VS_OUTPUT Out = (VS_OUTPUT)0; + + Out.position = mul(Pos, WorldViewProj); + Out.color = Color; + + return Out; +} + +technique TransformTechnique +{ + pass P0 + { + vertexShader = compile vs_2_0 Transform(); + } +} diff --git a/applications/sceneviewer/SceneViewer.cs b/applications/sceneviewer/SceneViewer.cs index 8702bcbe..58753c94 100644 --- a/applications/sceneviewer/SceneViewer.cs +++ b/applications/sceneviewer/SceneViewer.cs @@ -1,19 +1,19 @@ -using System; - -namespace sceneviewer -{ - static class SceneViewer - { - /// - /// The main entry point for the application. - /// - static void Main(string[] args) - { - using (Viewer game = new Viewer()) - { - game.Run(); - } - } - } -} - +using System; + +namespace sceneviewer +{ + static class SceneViewer + { + /// + /// The main entry point for the application. + /// + static void Main(string[] args) + { + using (Viewer game = new Viewer()) + { + game.Run(); + } + } + } +} + diff --git a/applications/sceneviewer/Skybox/Skybox.cs b/applications/sceneviewer/Skybox/Skybox.cs index 9e733285..403468df 100644 --- a/applications/sceneviewer/Skybox/Skybox.cs +++ b/applications/sceneviewer/Skybox/Skybox.cs @@ -1,10 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace sceneviewer.Skybox -{ - class Skybox - { - } -} +using System; +using System.Collections.Generic; +using System.Text; + +namespace sceneviewer.Skybox +{ + class Skybox + { + } +} diff --git a/applications/sceneviewer/Viewer.Designer.cs b/applications/sceneviewer/Viewer.Designer.cs index 919c7f5d..18f5b2b9 100644 --- a/applications/sceneviewer/Viewer.Designer.cs +++ b/applications/sceneviewer/Viewer.Designer.cs @@ -1,21 +1,21 @@ -using System; - -namespace sceneviewer -{ - partial class Viewer - { - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.graphics = new Microsoft.Xna.Framework.Components.GraphicsComponent(); - - this.GameComponents.Add(this.graphics); - - } - - private Microsoft.Xna.Framework.Components.GraphicsComponent graphics; - } -} +using System; + +namespace sceneviewer +{ + partial class Viewer + { + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.graphics = new Microsoft.Xna.Framework.Components.GraphicsComponent(); + + this.GameComponents.Add(this.graphics); + + } + + private Microsoft.Xna.Framework.Components.GraphicsComponent graphics; + } +} diff --git a/applications/sceneviewer/Viewer.cs b/applications/sceneviewer/Viewer.cs index 119e0081..a083858b 100644 --- a/applications/sceneviewer/Viewer.cs +++ b/applications/sceneviewer/Viewer.cs @@ -1,375 +1,375 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Threading; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using Microsoft.Xna.Framework.Input; -using libsecondlife; -using sceneviewer.Prims; - -namespace sceneviewer -{ - /// - /// This is the main type for your game - /// - partial class Viewer : Microsoft.Xna.Framework.Game - { - private SecondLife Client; - private Dictionary Prims; - - // The shader effect that we're loading - private Effect effect; - - // Variables describing the shapes being drawn - private VertexDeclaration vertexDeclaration; - - private Camera Camera; - private Matrix World; - //private WaterSurface Water; - - // Variables for keeping track of the state of the mouse - private ButtonState PreviousLeftButton; - private Vector2 PreviousMousePosition; - - // Keyboard stuff - Keys[] KeysHeldDown; - List KeysPressedThisFrame = new List(); - List KeysReleasedThisFrame = new List(); - - // State tracking - bool Wireframe = false; - - // - private Timer CameraUpdateTimer; - - public Viewer() - { - //this.AllowUserResizing = true; - this.IsMouseVisible = true; - - KeysHeldDown = Keyboard.GetState().GetPressedKeys(); - - Window.ClientSizeChanged += new EventHandler(Window_ClientSizeChanged); - this.Exiting += new EventHandler(Viewer_Exiting); - - Camera = new Camera(this.Window, new Vector3(0, 0, 40), new Vector3(256, 256, 0)); - PreviousLeftButton = ButtonState.Released; - - Prims = new Dictionary(); - - Hashtable loginParams = NetworkManager.DefaultLoginValues("Ron", "Hubbard", - "radishman", "00:00:00:00:00:00", "last", 1, 50, 50, 50, "Win", "0", - "botmanager", "contact@libsecondlife.org"); - - Client = new SecondLife(); - - Client.Objects.OnNewPrim += new NewPrimCallback(OnNewPrim); - Client.Objects.OnPrimMoved += new PrimMovedCallback(OnPrimMoved); - Client.Objects.OnObjectKilled += new KillObjectCallback(OnObjectKilled); - - if (!Client.Network.Login(loginParams)) - { - Exit(); - } - - InitializeComponent(); - InitializeTransform(); - InitializeEffect(); - InitializeScene(); - - // Start the timer - CameraUpdateTimer = new Timer(new TimerCallback(SendCameraUpdate), null, 0, - 500); - } - - bool KeyPressedThisFrame(Keys key) - { - if (KeysPressedThisFrame.Contains(key)) - { - return true; - } - return false; - } - - bool KeyReleasedThisFrame(Keys key) - { - if (KeysReleasedThisFrame.Contains(key)) - { - return true; - } - return false; - } - - Keys[] KeysHeldDownThisFrame() - { - return KeysHeldDown; - } - - void Viewer_Exiting(object sender, GameEventArgs e) - { - Client.Network.Logout(); - } - - void Window_ClientSizeChanged(object sender, EventArgs e) - { - Camera.UpdateProjection(this.Window); - } - - void SendCameraUpdate(object obj) - { - Client.Avatar.UpdateCamera(false); - } - - void OnNewPrim(Simulator simulator, PrimObject prim, ulong regionHandle, ushort timeDilation) - { - PrimVisual primVisual = PrimVisual.BuildPrimVisual(prim); - - if (primVisual.GetType() == typeof(PrimVisualBox) || primVisual.GetType() == typeof(PrimVisualCylinder)) - { - lock (Prims) - { - if (Prims.ContainsKey(prim.LocalID)) - { - Prims.Remove(prim.LocalID); - } - - Prims.Add(prim.LocalID, primVisual); - } - } - } - - void OnPrimMoved(Simulator simulator, PrimUpdate primUpdate, ulong regionHandle, ushort timeDilation) - { - if (Prims.ContainsKey(primUpdate.LocalID)) - { - Prims[primUpdate.LocalID].Update(primUpdate); - } - else - { - Client.Objects.RequestObject(simulator, primUpdate.LocalID); - } - } - - void OnObjectKilled(Simulator simulator, uint localID) - { - lock (Prims) - { - Prims.Remove(localID); - } - } - - private void InitializeTransform() - { - World = Matrix.CreateTranslation(Vector3.Zero); - } - - private void InitializeEffect() - { - CompiledEffect compiledEffect = Effect.CompileEffectFromFile( - "ReallySimpleEffect.fx", null, null, - CompilerOptions.Debug | - CompilerOptions.SkipOptimization, - TargetPlatform.Windows); - - effect = new Effect(graphics.GraphicsDevice, - compiledEffect.GetShaderCode(), CompilerOptions.None, - null); - } - - private void InitializeScene() - { - vertexDeclaration = new VertexDeclaration( - graphics.GraphicsDevice, VertexPositionColor.VertexElements); - - //Water = new WaterSurface(graphics.GraphicsDevice, Camera, new Vector3(0, 0, 1), 0, 128, 256); - } - - void UpdateInput() - { - // Clear our pressed and released lists. - KeysPressedThisFrame.Clear(); - KeysReleasedThisFrame.Clear(); - - // Interpret pressed key data between arrays to - // figure out just-pressed and just-released keys. - KeyboardState currentState = Keyboard.GetState(); - Keys[] currentKeys = currentState.GetPressedKeys(); - - // First loop, looking for keys just pressed. - for (int currentKey = 0; currentKey < currentKeys.Length; currentKey++) - { - bool found = false; - for (int previousKey = 0; previousKey < KeysHeldDown.Length; previousKey++) - { - if (currentKeys[currentKey] == KeysHeldDown[previousKey]) - { - // The key was pressed both this frame and last; ignore. - found = true; - break; - } - } - if (!found) - { - // The key was pressed this frame, but not last frame; it was just pressed. - KeysPressedThisFrame.Add(currentKeys[currentKey]); - } - } - - // Second loop, looking for keys just released. - for (int previousKey = 0; previousKey < KeysHeldDown.Length; previousKey++) - { - bool found = false; - for (int currentKey = 0; currentKey < currentKeys.Length; currentKey++) - { - if (KeysHeldDown[previousKey] == currentKeys[currentKey]) - { - // The key was pressed both this frame and last; ignore. - found = true; - break; - } - } - if (!found) - { - // The key was pressed last frame, but not this frame; it was just released. - KeysReleasedThisFrame.Add(KeysHeldDown[previousKey]); - } - } - - // Set the held state to the current state. - KeysHeldDown = currentKeys; - } - - protected override void Update() - { - // The time since Update was called last - float elapsed = (float)ElapsedTime.TotalSeconds; - - MouseState currentState = Mouse.GetState(); - - Camera.Zoom = currentState.ScrollWheelValue * 0.005f; - - if (currentState.LeftButton == ButtonState.Pressed && - PreviousLeftButton == ButtonState.Pressed) - { - Vector2 curMouse = new Vector2(currentState.X, currentState.Y); - Vector2 deltaMouse = PreviousMousePosition - curMouse; - - Camera.Theta += deltaMouse.X * 0.01f; - Camera.Phi -= deltaMouse.Y * 0.005f; - PreviousMousePosition = curMouse; - } - // It's implied that the leftPreviousState is unpressed in this situation. - else if (currentState.LeftButton == ButtonState.Pressed) - { - PreviousMousePosition = new Vector2(currentState.X, currentState.Y); - } - - PreviousLeftButton = currentState.LeftButton; - - UpdateInput(); - CheckGameKeys(); - - // Let the GameComponents update - UpdateComponents(); - } - - void CheckGameKeys() - { - if (KeyPressedThisFrame(Keys.W)) - { - Wireframe = !Wireframe; - } - } - - protected override void Draw() - { - Matrix ViewProjectionMatrix = Camera.ViewProjectionMatrix; - - // Make sure we have a valid device - if (!graphics.EnsureDevice()) - return; - - graphics.GraphicsDevice.Clear(Color.CornflowerBlue); - graphics.GraphicsDevice.BeginScene(); - - // Let the GameComponents draw - DrawComponents(); - - //effect.Parameters["WorldViewProj"].SetValue(World * ViewProjectionMatrix); - //effect.CurrentTechnique = effect.Techniques["TransformTechnique"]; - //effect.CommitChanges(); - - graphics.GraphicsDevice.VertexDeclaration = vertexDeclaration; - graphics.GraphicsDevice.RenderState.CullMode = CullMode.None; - - graphics.GraphicsDevice.RenderState.FillMode = (Wireframe) ? FillMode.WireFrame : FillMode.Solid; - - //graphics.GraphicsDevice.RenderState.MultiSampleAntiAlias = true; - - effect.Begin(EffectStateOptions.Default); - foreach (EffectPass pass in effect.CurrentTechnique.Passes) - { - pass.Begin(); - - //Water.Prepare(); - //Water.RenderCutter(); - - //pass.End(); - - //pass.Begin(); - - lock (Prims) - { - foreach (PrimVisual prim in Prims.Values) - { - if (prim.Prim.ParentID != 0) - { - if (!Prims.ContainsKey(prim.Prim.ParentID)) - { - // We don't have the base position for this child prim, can't render it - continue; - } - else - { - // Child prim in a linkset - - // Add the base position of the parent prim and the offset position of this child - LLVector3 llBasePosition = Prims[prim.Prim.ParentID].Prim.Position; - LLQuaternion llBaseRotation = Prims[prim.Prim.ParentID].Prim.Rotation; - - Vector3 basePosition = new Vector3(llBasePosition.X, llBasePosition.Y, llBasePosition.Z); - - Matrix worldOffset = Matrix.CreateTranslation(basePosition); - Matrix rootRotation = Matrix.FromQuaternion(new Quaternion(llBaseRotation.X, llBaseRotation.Y, - llBaseRotation.Z, llBaseRotation.W)); - - effect.Parameters["WorldViewProj"].SetValue(prim.Matrix * rootRotation * worldOffset * ViewProjectionMatrix); - effect.CommitChanges(); - - graphics.GraphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, - prim.VertexArray.Length / 3, prim.VertexArray); - } - } - else - { - // Root prim or not part of a linkset - - effect.Parameters["WorldViewProj"].SetValue(prim.Matrix * ViewProjectionMatrix); - effect.CommitChanges(); - - graphics.GraphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, - prim.VertexArray.Length / 3, prim.VertexArray); - } - } - } - - pass.End(); - } - effect.End(); - - graphics.GraphicsDevice.EndScene(); - graphics.GraphicsDevice.Present(); - } - } -} +using System; +using System.Collections; +using System.Collections.Generic; +using System.Threading; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework.Input; +using libsecondlife; +using sceneviewer.Prims; + +namespace sceneviewer +{ + /// + /// This is the main type for your game + /// + partial class Viewer : Microsoft.Xna.Framework.Game + { + private SecondLife Client; + private Dictionary Prims; + + // The shader effect that we're loading + private Effect effect; + + // Variables describing the shapes being drawn + private VertexDeclaration vertexDeclaration; + + private Camera Camera; + private Matrix World; + //private WaterSurface Water; + + // Variables for keeping track of the state of the mouse + private ButtonState PreviousLeftButton; + private Vector2 PreviousMousePosition; + + // Keyboard stuff + Keys[] KeysHeldDown; + List KeysPressedThisFrame = new List(); + List KeysReleasedThisFrame = new List(); + + // State tracking + bool Wireframe = false; + + // + private Timer CameraUpdateTimer; + + public Viewer() + { + //this.AllowUserResizing = true; + this.IsMouseVisible = true; + + KeysHeldDown = Keyboard.GetState().GetPressedKeys(); + + Window.ClientSizeChanged += new EventHandler(Window_ClientSizeChanged); + this.Exiting += new EventHandler(Viewer_Exiting); + + Camera = new Camera(this.Window, new Vector3(0, 0, 40), new Vector3(256, 256, 0)); + PreviousLeftButton = ButtonState.Released; + + Prims = new Dictionary(); + + Hashtable loginParams = NetworkManager.DefaultLoginValues("Ron", "Hubbard", + "radishman", "00:00:00:00:00:00", "last", 1, 50, 50, 50, "Win", "0", + "botmanager", "contact@libsecondlife.org"); + + Client = new SecondLife(); + + Client.Objects.OnNewPrim += new NewPrimCallback(OnNewPrim); + Client.Objects.OnPrimMoved += new PrimMovedCallback(OnPrimMoved); + Client.Objects.OnObjectKilled += new KillObjectCallback(OnObjectKilled); + + if (!Client.Network.Login(loginParams)) + { + Exit(); + } + + InitializeComponent(); + InitializeTransform(); + InitializeEffect(); + InitializeScene(); + + // Start the timer + CameraUpdateTimer = new Timer(new TimerCallback(SendCameraUpdate), null, 0, + 500); + } + + bool KeyPressedThisFrame(Keys key) + { + if (KeysPressedThisFrame.Contains(key)) + { + return true; + } + return false; + } + + bool KeyReleasedThisFrame(Keys key) + { + if (KeysReleasedThisFrame.Contains(key)) + { + return true; + } + return false; + } + + Keys[] KeysHeldDownThisFrame() + { + return KeysHeldDown; + } + + void Viewer_Exiting(object sender, GameEventArgs e) + { + Client.Network.Logout(); + } + + void Window_ClientSizeChanged(object sender, EventArgs e) + { + Camera.UpdateProjection(this.Window); + } + + void SendCameraUpdate(object obj) + { + Client.Avatar.UpdateCamera(false); + } + + void OnNewPrim(Simulator simulator, PrimObject prim, ulong regionHandle, ushort timeDilation) + { + PrimVisual primVisual = PrimVisual.BuildPrimVisual(prim); + + if (primVisual.GetType() == typeof(PrimVisualBox) || primVisual.GetType() == typeof(PrimVisualCylinder)) + { + lock (Prims) + { + if (Prims.ContainsKey(prim.LocalID)) + { + Prims.Remove(prim.LocalID); + } + + Prims.Add(prim.LocalID, primVisual); + } + } + } + + void OnPrimMoved(Simulator simulator, PrimUpdate primUpdate, ulong regionHandle, ushort timeDilation) + { + if (Prims.ContainsKey(primUpdate.LocalID)) + { + Prims[primUpdate.LocalID].Update(primUpdate); + } + else + { + Client.Objects.RequestObject(simulator, primUpdate.LocalID); + } + } + + void OnObjectKilled(Simulator simulator, uint localID) + { + lock (Prims) + { + Prims.Remove(localID); + } + } + + private void InitializeTransform() + { + World = Matrix.CreateTranslation(Vector3.Zero); + } + + private void InitializeEffect() + { + CompiledEffect compiledEffect = Effect.CompileEffectFromFile( + "ReallySimpleEffect.fx", null, null, + CompilerOptions.Debug | + CompilerOptions.SkipOptimization, + TargetPlatform.Windows); + + effect = new Effect(graphics.GraphicsDevice, + compiledEffect.GetShaderCode(), CompilerOptions.None, + null); + } + + private void InitializeScene() + { + vertexDeclaration = new VertexDeclaration( + graphics.GraphicsDevice, VertexPositionColor.VertexElements); + + //Water = new WaterSurface(graphics.GraphicsDevice, Camera, new Vector3(0, 0, 1), 0, 128, 256); + } + + void UpdateInput() + { + // Clear our pressed and released lists. + KeysPressedThisFrame.Clear(); + KeysReleasedThisFrame.Clear(); + + // Interpret pressed key data between arrays to + // figure out just-pressed and just-released keys. + KeyboardState currentState = Keyboard.GetState(); + Keys[] currentKeys = currentState.GetPressedKeys(); + + // First loop, looking for keys just pressed. + for (int currentKey = 0; currentKey < currentKeys.Length; currentKey++) + { + bool found = false; + for (int previousKey = 0; previousKey < KeysHeldDown.Length; previousKey++) + { + if (currentKeys[currentKey] == KeysHeldDown[previousKey]) + { + // The key was pressed both this frame and last; ignore. + found = true; + break; + } + } + if (!found) + { + // The key was pressed this frame, but not last frame; it was just pressed. + KeysPressedThisFrame.Add(currentKeys[currentKey]); + } + } + + // Second loop, looking for keys just released. + for (int previousKey = 0; previousKey < KeysHeldDown.Length; previousKey++) + { + bool found = false; + for (int currentKey = 0; currentKey < currentKeys.Length; currentKey++) + { + if (KeysHeldDown[previousKey] == currentKeys[currentKey]) + { + // The key was pressed both this frame and last; ignore. + found = true; + break; + } + } + if (!found) + { + // The key was pressed last frame, but not this frame; it was just released. + KeysReleasedThisFrame.Add(KeysHeldDown[previousKey]); + } + } + + // Set the held state to the current state. + KeysHeldDown = currentKeys; + } + + protected override void Update() + { + // The time since Update was called last + float elapsed = (float)ElapsedTime.TotalSeconds; + + MouseState currentState = Mouse.GetState(); + + Camera.Zoom = currentState.ScrollWheelValue * 0.005f; + + if (currentState.LeftButton == ButtonState.Pressed && + PreviousLeftButton == ButtonState.Pressed) + { + Vector2 curMouse = new Vector2(currentState.X, currentState.Y); + Vector2 deltaMouse = PreviousMousePosition - curMouse; + + Camera.Theta += deltaMouse.X * 0.01f; + Camera.Phi -= deltaMouse.Y * 0.005f; + PreviousMousePosition = curMouse; + } + // It's implied that the leftPreviousState is unpressed in this situation. + else if (currentState.LeftButton == ButtonState.Pressed) + { + PreviousMousePosition = new Vector2(currentState.X, currentState.Y); + } + + PreviousLeftButton = currentState.LeftButton; + + UpdateInput(); + CheckGameKeys(); + + // Let the GameComponents update + UpdateComponents(); + } + + void CheckGameKeys() + { + if (KeyPressedThisFrame(Keys.W)) + { + Wireframe = !Wireframe; + } + } + + protected override void Draw() + { + Matrix ViewProjectionMatrix = Camera.ViewProjectionMatrix; + + // Make sure we have a valid device + if (!graphics.EnsureDevice()) + return; + + graphics.GraphicsDevice.Clear(Color.CornflowerBlue); + graphics.GraphicsDevice.BeginScene(); + + // Let the GameComponents draw + DrawComponents(); + + //effect.Parameters["WorldViewProj"].SetValue(World * ViewProjectionMatrix); + //effect.CurrentTechnique = effect.Techniques["TransformTechnique"]; + //effect.CommitChanges(); + + graphics.GraphicsDevice.VertexDeclaration = vertexDeclaration; + graphics.GraphicsDevice.RenderState.CullMode = CullMode.None; + + graphics.GraphicsDevice.RenderState.FillMode = (Wireframe) ? FillMode.WireFrame : FillMode.Solid; + + //graphics.GraphicsDevice.RenderState.MultiSampleAntiAlias = true; + + effect.Begin(EffectStateOptions.Default); + foreach (EffectPass pass in effect.CurrentTechnique.Passes) + { + pass.Begin(); + + //Water.Prepare(); + //Water.RenderCutter(); + + //pass.End(); + + //pass.Begin(); + + lock (Prims) + { + foreach (PrimVisual prim in Prims.Values) + { + if (prim.Prim.ParentID != 0) + { + if (!Prims.ContainsKey(prim.Prim.ParentID)) + { + // We don't have the base position for this child prim, can't render it + continue; + } + else + { + // Child prim in a linkset + + // Add the base position of the parent prim and the offset position of this child + LLVector3 llBasePosition = Prims[prim.Prim.ParentID].Prim.Position; + LLQuaternion llBaseRotation = Prims[prim.Prim.ParentID].Prim.Rotation; + + Vector3 basePosition = new Vector3(llBasePosition.X, llBasePosition.Y, llBasePosition.Z); + + Matrix worldOffset = Matrix.CreateTranslation(basePosition); + Matrix rootRotation = Matrix.FromQuaternion(new Quaternion(llBaseRotation.X, llBaseRotation.Y, + llBaseRotation.Z, llBaseRotation.W)); + + effect.Parameters["WorldViewProj"].SetValue(prim.Matrix * rootRotation * worldOffset * ViewProjectionMatrix); + effect.CommitChanges(); + + graphics.GraphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, + prim.VertexArray.Length / 3, prim.VertexArray); + } + } + else + { + // Root prim or not part of a linkset + + effect.Parameters["WorldViewProj"].SetValue(prim.Matrix * ViewProjectionMatrix); + effect.CommitChanges(); + + graphics.GraphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, + prim.VertexArray.Length / 3, prim.VertexArray); + } + } + } + + pass.End(); + } + effect.End(); + + graphics.GraphicsDevice.EndScene(); + graphics.GraphicsDevice.Present(); + } + } +} diff --git a/applications/sceneviewer/Water/NoiseMaker.cs b/applications/sceneviewer/Water/NoiseMaker.cs index 877f51e1..e1413bbb 100644 --- a/applications/sceneviewer/Water/NoiseMaker.cs +++ b/applications/sceneviewer/Water/NoiseMaker.cs @@ -1,525 +1,525 @@ -using System; -using System.Text; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; - -namespace sceneviewer -{ - class NoiseMaker - { - // Constants - public const int nbits = 5; - public const int nsize = 1 << (nbits - 1); - public const int nsizem1 = nsize - 1; - public const int nsizesq = nsize * nsize; - public const int nsizesqm1 = nsizesq - 1; - - public const int npacksize = 4; - - public const int npbits = nbits + npacksize - 1; - public const int npsize = 1 << (npbits - 1); - public const int npsizem1 = npsize - 1; - public const int npsizesq = npsize * npsize; - public const int npsizesqm1 = npsizesq - 1; - - public const int ndecbits = 12; - public const int ndecmagn = 4096; - public const int ndecmagnm1 = 4095; - - public const int maxoctaves = 8; - - public const int noiseframes = 256; - public const int noiseframesm1 = noiseframes - 1; - - public const int noisedecbits = 15; - public const int noisemagnitude = 1 << (noisedecbits - 1); - - public const int scaledecbits = 15; - public const int scalemagnitude = 1 << (scaledecbits - 1); - - public const int nmapsizex = 512; - public const int nmapsizey = 1024; - - public const float FALLOFF = 0.607f; - public const float ANIMSPEED = 1.4f; - public const float TIMEMULTI = 1.27f; - public const float ELEVATION = 7.0f; - public const float SCALE = 0.38f; - public const bool SMOOTH = false; - public const bool DISPLACE = false; - - // Public members - public VertexPositionNormalTexture[] Vertices; - public Texture2D HeightMap; - public Texture2D NormalMap; - public Texture2D[] PackedNoise; - public Surface DepthStencil; - - private GraphicsDevice Device; - private int Octaves; - private float[] Multitable; - private int then; - private double time; - private int[] Onoise; - private int[] Pnoise; - private Vector3 eu, ev; - private Vector4 tcorners0, tcorners1, tcorners2, tcorners3; - private int sizeX, sizeY; // framebuffer size - private int fsizeX, fsizeY; - - public NoiseMaker(GraphicsDevice device, int gridSizeX, int gridSizeY) - { - Device = device; - Multitable = new float[maxoctaves]; - Onoise = new int[nsizesq * maxoctaves]; - Pnoise = new int[npsizesq * (maxoctaves >> (npacksize - 1))]; - - sizeX = gridSizeX; - sizeY = gridSizeY; - time = 0.0d; - then = Environment.TickCount; - Octaves = 0; // Don't want to have the noise accessed before it's calculated - fsizeX = sizeX; - fsizeY = sizeY; - - // Reset normals - Vertices = new VertexPositionNormalTexture[sizeX * sizeY]; - for (int v = 0; v < sizeY; v++) - { - for (int u = 0; u < sizeX; u++) - { - // FIXME: Should this be UnitZ? - Vertices[v * sizeX + u].Normal = Vector3.UnitY; - Vertices[v * sizeX + u].TextureCoordinate = new Vector2((float)u / (sizeX - 1), (float)v / (sizeY - 1)); - } - } - - InitNoise(); - LoadEffects(); - InitTextures(); - } - - public bool RenderGeometry(Matrix m) - { - CalculateNoise(); - - float magnitude = ndecmagn * SCALE; - float invmagnitudesq = 1.0f / (SCALE * SCALE); - - Matrix minv = Matrix.Invert(m); - eu = Vector3.Normalize(Vector3.TransformNormal(Vector3.UnitX, m)); - ev = Vector3.Normalize(Vector3.TransformNormal(Vector3.UnitY, m)); - - tcorners0 = CalculateWorldPos(Vector2.Zero, m); - tcorners1 = CalculateWorldPos(Vector2.UnitX, m); - tcorners2 = CalculateWorldPos(Vector2.UnitY, m); - tcorners3 = CalculateWorldPos(Vector2.One, m); - - Matrix surfacetoworld; - - float du = 1.0f / (float)(sizeX - 1); - float dv = 1.0f / (float)(sizeY - 1); - float u = 0; - float v = 0; - Vector4 result; - int i = 0; - - for(int iv = 0; iv < sizeY; iv++) - { - u = 0; - - for(int iu = 0; iu < sizeX; iu++) - { - result.X = (1 - v) * ( (1 - u) * tcorners0.X + u * tcorners1.X ) + - v * ((1 - u) * tcorners2.X + u * tcorners3.X); - result.Z = (1 - v) * ( (1 - u) * tcorners0.Z + u * tcorners1.Z ) + - v * ((1 - u) * tcorners2.Z + u * tcorners3.Z); - result.W = (1 - v) * ( (1 - u) * tcorners0.W + u * tcorners1.W ) + - v * ((1 - u) * tcorners2.W + u * tcorners3.W); - - float divide = 1 / result.W; - result.X *= divide; - result.Z *= divide; - - // FIXME: The GetHeightDual should return a Z value instead? - Vertices[i].Position = new Vector3(result.X, - GetHeightDual((int)(magnitude * result.X), (int)(magnitude * result.Z)), result.Z); - - i++; - u += du; - } - - v += dv; - } - - // smooth the heightdata - if(SMOOTH) - { - for(int v1 = 1; v1 < (sizeY - 1); v1++) - { - for(int u1 = 1; u1 < (sizeX - 1); u1++) - { - // FIXME: We should be smoothing the Z values instead - Vector3 v1sizeXu1 = Vertices[v1 * sizeX + u1].Position; - v1sizeXu1.Y = 0.2f * (Vertices[v1 * sizeX + u1].Position.Y + - Vertices[v1 * sizeX + (u1 + 1)].Position.Y + - Vertices[v1 * sizeX + (u1 - 1)].Position.Y + - Vertices[(v1 + 1) * sizeX + u1].Position.Y + - Vertices[(v1 - 1) * sizeX + u1].Position.Y); - Vertices[v1 * sizeX + u1].Position = v1sizeXu1; - } - } - } - - if(!DISPLACE) - { - // Reset height to 0 - for(int u1 = 0; u1 < (sizeX * sizeY); u1++) - { - // FIXME: Should be Z? - Vertices[u1].Position = new Vector3(Vertices[u1].Position.X, 0, Vertices[u1].Position.Z); - } - } - - UploadNoise(); - - return true; - } - - public void GenerateNormalMap() - { - // Do the heightmap thingy - Surface bb = Device.GetRenderTarget(0); - Surface target = HeightMap.GetSurfaceLevel(0); - Surface olddepthstencil = Device.DepthStencilSurface; - - //hr = device->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW ); - //device->SetStreamSource( 0, surf_software_vertices, 0, sizeof(SOFTWARESURFACEVERTEX) ); - //hr = device->SetFVF( D3DFVF_SOFTWARESURFACEVERTEX); - //device->SetIndices(surf->surf_indicies); - hr = hmap_effect->Begin(NULL,NULL); - hmap_effect->BeginPass(0); - - hmap_effect->SetTexture("noise0",packed_noise_texture[0]); - hmap_effect->SetTexture("noise1",packed_noise_texture[1]); - - hr = device->SetRenderTarget( 0, target ); - device->SetDepthStencilSurface( depthstencil ); - //device->Clear( 0, NULL,D3DCLEAR_TARGET, D3DCOLOR_XRGB(255,128,28), 1.0f, 0 ); - device->SetRenderState( D3DRS_ZENABLE, D3DZB_FALSE ); - device->DrawIndexedPrimitive( D3DPT_TRIANGLELIST, 0, 0, sizeX*sizeY, 0, 2*(sizeX-1)*(sizeY-1) ); - hmap_effect->EndPass(); - hmap_effect->End(); - - // calculate normalmap - - hr = normalmap->GetSurfaceLevel( 0,&target ); - hr = device->SetRenderTarget( 0, target ); - hr = nmap_effect->Begin(NULL,NULL); - nmap_effect->BeginPass(0); - nmap_effect->SetFloat("inv_mapsize_x", 1.0f/nmapsize_x); - nmap_effect->SetFloat("inv_mapsize_y", 1.0f/nmapsize_y); - nmap_effect->SetVector("corner00", &t_corners0 ); - nmap_effect->SetVector("corner01", &t_corners1 ); - nmap_effect->SetVector("corner10", &t_corners2 ); - nmap_effect->SetVector("corner11", &t_corners3 ); - nmap_effect->SetFloat("amplitude", 2 * STRENGTH); - nmap_effect->SetTexture("hmap",heightmap); - device->DrawIndexedPrimitive( D3DPT_TRIANGLELIST, 0, 0, sizeX*sizeY, 0, 2*(sizeX-1)*(sizeY-1) ); - nmap_effect->EndPass(); - nmap_effect->End(); - - // restore the device - device->SetRenderState( D3DRS_ZENABLE, D3DZB_TRUE ); - device->SetRenderTarget( 0, bb ); - device->SetDepthStencilSurface( old_depthstencil ); - } - - private void InitNoise() - { - Random rand = new Random(); - - // create noise (uniform) - float[] tempnoise = new float[nsizesq * noiseframes]; - for(int i = 0; i < (nsizesq * noiseframes); i++) - { - float temp = (float)rand.NextDouble(RANDMAX); - tempnoise[i] = 4 * (temp - 0.5f); - } - - for(int frame = 0; frame < noiseframes; frame++) - { - for(int v = 0; v < nsize; v++) - { - for(int u = 0; u < nsize; u++) - { - int v0 = ((v - 1) & nsizem1) * nsize, - v1 = v * nsize, - v2 = ((v + 1) & nsizem1) * nsize, - u0 = ((u - 1) & nsizem1), - u1 = u, - u2 = ((u + 1) & nsizem1), - f = frame * nsizesq; - float temp = (1.0f / 14.0f) * (tempnoise[f + v0 + u0] + tempnoise[f + v0 + u1] + tempnoise[f + v0 + u2] + - tempnoise[f + v1 + u0] + 6.0f * tempnoise[f + v1 + u1] + tempnoise[f + v1 + u2] + - tempnoise[f + v2 + u0] + tempnoise[f + v2 + u1] + tempnoise[f + v2 + u2]); - - noise[frame * nsizesq + v * nsize + u] = noisemagnitude * temp; - } - } - } - } - - private void InitTextures() - { - PackedNoise = new Texture2D[2]; - PackedNoise[0] = new Texture2D(Device, npsize, npsize, 0, ResourceUsage.Dynamic, SurfaceFormat.Luminance16, - ResourcePool.Default); - PackedNoise[1] = new Texture2D(Device, npsize, npsize, 0, ResourceUsage.Dynamic, SurfaceFormat.Luminance16, - ResourcePool.Default); - - HeightMap = new Texture2D(Device, nmapsizex, nmapsizey, 1, ResourceUsage.RenderTarget, SurfaceFormat.Rgba64, - ResourcePool.Default); - NormalMap = new Texture2D(Device, nmapsizex, nmapsizey, 1, ResourceUsage.AutoGenerateMipMap | - ResourceUsage.RenderTarget, SurfaceFormat.Rgba64, ResourcePool.Default); - - // Create the stencil buffer - DepthStencil = Device.CreateDepthStencilSurface(nmapsizex, nmapsizey, DepthFormat.Depth24Stencil8, - MultiSampleType.None, 0, true); - } - - private void LoadEffects() - { - char* errortext; - LPD3DXBUFFER errors; - D3DXHANDLE hTechnique; - - // load effect - D3DXCreateEffectFromFile(device, "v2_heightmapgen.fx", - NULL, NULL, 0, NULL, &hmap_effect, &errors); - - if (errors != NULL) - { - errortext = (char*)errors->GetBufferPointer(); - MessageBox(NULL, errortext, "hmap_effect", MB_OK); - } - - hmap_effect->FindNextValidTechnique(NULL, &hTechnique); - hmap_effect->SetTechnique(hTechnique); - - // load effect - D3DXCreateEffectFromFile(device, "v2_normalmapgen.fx", - NULL, NULL, 0, NULL, &nmap_effect, &errors); - - if (errors != NULL) - { - errortext = (char*)errors->GetBufferPointer(); - MessageBox(NULL, errortext, "nmap_effect", MB_OK); - } - - nmap_effect->FindNextValidTechnique(NULL, &hTechnique); - nmap_effect->SetTechnique(hTechnique); - } - - // FIXME: Should this be (0,0,1,0) ? - // Check the point of intersection with the plane (0,1,0,0) and return the position in homogenous coordinates - private Vector4 CalculateWorldPos(Vector2 uv, Matrix m) - { - Vector4 origin = new Vector4(uv.X, uv.Y, -1, 1); - Vector4 direction = new Vector4(uv.X, uv.Y, 1, 1); - - origin = Vector4.Transform(origin, m); - direction = Vector4.Transform(direction, m); - - float l = -origin.Y / direction.Y; - - Vector4 worldpos = origin + direction * l; - return worldpos; - } - - private void CalculateNoise() - { - Octaves = maxoctaves; - - // Calculate the strength of each octave - float sum = 0; - - for (int i = 0; i < Octaves; i++) - { - Multitable[i] = (float)Math.Pow(FALLOFF, 1 * i); - sum += Multitable[i]; - } - - for (int i = 0; i < Octaves; i++) - { - Multitable[i] /= sum; - } - - for (int i = 0; i < Octaves; i++) - { - Multitable[i] = scalemagnitude * Multitable[i]; - } - - int now = Environment.TickCount; - double timechange = (double)(now - then); - then = now; - timechange *= 0.001d * ANIMSPEED; - double lptimechange = 0.99d * lptimechange + 0.01d * timechange; - time += lptimechange; - - double rtimemulti = 1; - - for(int o = 0; o < Octaves; o++) - { - uint[] image = new uint[3]; - int[] amount = new int[3]; - int iimage = (int)(time * rtimemulti); - double fraction = (time * rtimemulti) - (double)iimage; - - amount[0] = scalemagnitude * Multitable[o] * (Math.Pow(Math.Sin((fraction + 2) * Math.PI / 3), 2) / 1.5d); - amount[1] = scalemagnitude * Multitable[o] * (Math.Pow(Math.Sin((fraction + 1) * Math.PI / 3), 2) / 1.5d); - amount[2] = scalemagnitude * Multitable[o] * (Math.Pow(Math.Sin((fraction) * Math.PI / 3), 2) / 1.5d); - image[0] = (iimage) & noiseframesm1; - image[1] = (iimage + 1) & noiseframesm1; - image[2] = (iimage + 2) & noiseframesm1; - { - for(int i = 0; i < nsizesq; i++) - { - o_noise[i + nsizesq*o] = (((amount[0] * noise[i + nsizesq * image[0]])>>scaledecimalbits) + - ((amount[1] * noise[i + nsizesq * image[1]])>>scaledecimalbits) + - ((amount[2] * noise[i + nsizesq * image[2]])>>scaledecimalbits)); - } - } - - rtimemulti *= TIMEMULTI; - } - - if (packednoise) - { - int octavepack = 0; - - for (int o = 0; o < Octaves; o += npacksize) - { - for (int v = 0; v < npsize; v++) - for (int u = 0; u < npsize; u++) - { - Pnoise[v*npsize+u+octavepack*npsize_sq] = o_noise[(o+3)*nsizesq + (v&nsizem1)*nsize + (u&nsizem1)]; - Pnoise[v*npsize+u+octavepack*npsize_sq] += mapsample( u, v, 3, o); - Pnoise[v*npsize+u+octavepack*npsize_sq] += mapsample( u, v, 2, o+1); - Pnoise[v*npsize+u+octavepack*npsize_sq] += mapsample( u, v, 1, o+2); - } - - octavepack++; - } - } - } - - //private void CalculateNormals() - //{ - // ; - //} - - private void UploadNoise() - { - D3DLOCKED_RECT locked; - ushort data; - int[] tempdata = new int[npsizesq]; - - for(int t = 0; t < 2; t++) - { - int offset = npsizesq * t; - // upload the first level - packed_noise_texture[t]->LockRect( 0, &locked, NULL, D3DLOCK_DISCARD ); - data = (ushort*)locked.pBits; - for(int i=0; iUnlockRect( 0 ); - - int c = packed_noise_texture[t]->GetLevelCount(); - - // calculate the second level, and upload it - HRESULT hr = packed_noise_texture[t]->LockRect( 1, &locked, NULL, 0 ); - data = (ushort*)locked.pBits; - int sz = npsize>>1; - for(int v=0; v>2; - data[v*sz+u] = 32768+tempdata[v*npsize + u]; - } - } - - packed_noise_texture[t]->UnlockRect( 1 ); - - for(int j=2; jLockRect( j, &locked, NULL, 0 ); - data = (ushort*)locked.pBits; - int pitch = (locked.Pitch)>>1; - sz = npsize>>j; - for(int v=0; v>2; - data[v*pitch+u] = 32768+tempdata[v*npsize + u]; - } - } - packed_noise_texture[t]->UnlockRect( j ); - } - } - } - - private int MapSample(int u, int v, int upsamplepower, int octave) - { - ; - } - - private float ReadtexelNearest(int u, int v) - { - int lu, lv; - lu = (u>>ndecbits)&nsizem1; - lv = (v>>ndecbits)&nsizem1; - - return (float)noise[lv*nsize + lu]; - } - - private int ReadtexelLinearDual(int u, int v, int o) - { - int iu, iup, iv, ivp, fu, fv; - iu = (u>>ndecbits)&npsizem1; - iv = ((v>>ndecbits)&npsizem1)*npsize; - - iup = ((u>>ndecbits) + 1)&npsizem1; - ivp = (((v>>ndecbits) + 1)&npsizem1)*npsize; - - fu = u & ndecmagn_m1; - fv = v & ndecmagn_m1; - - int ut01 = ((ndecmagn-fu)*Rnoise[iv + iu] + fu*Rnoise[iv + iup])>>ndecbits; - int ut23 = ((ndecmagn-fu)*Rnoise[ivp + iu] + fu*Rnoise[ivp + iup])>>ndecbits; - int ut = ((ndecmagn-fv)*ut01 + fv*ut23) >> ndecbits; - - return ut; - } - - // FIXME: This function uses pointer magic that needs to be fixed for C# - private float GetHeightDual(int u, int v) - { - int value = 0; - Rnoise = Pnoise; // pointer to the current noise source octave - int hoct = Octaves / npacksize; - - for(int i = 0; i < hoct; i++) - { - value += ReadtexelLinearDual(u, v, 0); - u = u << npacksize; - v = v << npacksize; - Rnoise += npsizesq; - } - - return value * STRENGTH / noisemagnitude; - } - } -} +using System; +using System.Text; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +namespace sceneviewer +{ + class NoiseMaker + { + // Constants + public const int nbits = 5; + public const int nsize = 1 << (nbits - 1); + public const int nsizem1 = nsize - 1; + public const int nsizesq = nsize * nsize; + public const int nsizesqm1 = nsizesq - 1; + + public const int npacksize = 4; + + public const int npbits = nbits + npacksize - 1; + public const int npsize = 1 << (npbits - 1); + public const int npsizem1 = npsize - 1; + public const int npsizesq = npsize * npsize; + public const int npsizesqm1 = npsizesq - 1; + + public const int ndecbits = 12; + public const int ndecmagn = 4096; + public const int ndecmagnm1 = 4095; + + public const int maxoctaves = 8; + + public const int noiseframes = 256; + public const int noiseframesm1 = noiseframes - 1; + + public const int noisedecbits = 15; + public const int noisemagnitude = 1 << (noisedecbits - 1); + + public const int scaledecbits = 15; + public const int scalemagnitude = 1 << (scaledecbits - 1); + + public const int nmapsizex = 512; + public const int nmapsizey = 1024; + + public const float FALLOFF = 0.607f; + public const float ANIMSPEED = 1.4f; + public const float TIMEMULTI = 1.27f; + public const float ELEVATION = 7.0f; + public const float SCALE = 0.38f; + public const bool SMOOTH = false; + public const bool DISPLACE = false; + + // Public members + public VertexPositionNormalTexture[] Vertices; + public Texture2D HeightMap; + public Texture2D NormalMap; + public Texture2D[] PackedNoise; + public Surface DepthStencil; + + private GraphicsDevice Device; + private int Octaves; + private float[] Multitable; + private int then; + private double time; + private int[] Onoise; + private int[] Pnoise; + private Vector3 eu, ev; + private Vector4 tcorners0, tcorners1, tcorners2, tcorners3; + private int sizeX, sizeY; // framebuffer size + private int fsizeX, fsizeY; + + public NoiseMaker(GraphicsDevice device, int gridSizeX, int gridSizeY) + { + Device = device; + Multitable = new float[maxoctaves]; + Onoise = new int[nsizesq * maxoctaves]; + Pnoise = new int[npsizesq * (maxoctaves >> (npacksize - 1))]; + + sizeX = gridSizeX; + sizeY = gridSizeY; + time = 0.0d; + then = Environment.TickCount; + Octaves = 0; // Don't want to have the noise accessed before it's calculated + fsizeX = sizeX; + fsizeY = sizeY; + + // Reset normals + Vertices = new VertexPositionNormalTexture[sizeX * sizeY]; + for (int v = 0; v < sizeY; v++) + { + for (int u = 0; u < sizeX; u++) + { + // FIXME: Should this be UnitZ? + Vertices[v * sizeX + u].Normal = Vector3.UnitY; + Vertices[v * sizeX + u].TextureCoordinate = new Vector2((float)u / (sizeX - 1), (float)v / (sizeY - 1)); + } + } + + InitNoise(); + LoadEffects(); + InitTextures(); + } + + public bool RenderGeometry(Matrix m) + { + CalculateNoise(); + + float magnitude = ndecmagn * SCALE; + float invmagnitudesq = 1.0f / (SCALE * SCALE); + + Matrix minv = Matrix.Invert(m); + eu = Vector3.Normalize(Vector3.TransformNormal(Vector3.UnitX, m)); + ev = Vector3.Normalize(Vector3.TransformNormal(Vector3.UnitY, m)); + + tcorners0 = CalculateWorldPos(Vector2.Zero, m); + tcorners1 = CalculateWorldPos(Vector2.UnitX, m); + tcorners2 = CalculateWorldPos(Vector2.UnitY, m); + tcorners3 = CalculateWorldPos(Vector2.One, m); + + Matrix surfacetoworld; + + float du = 1.0f / (float)(sizeX - 1); + float dv = 1.0f / (float)(sizeY - 1); + float u = 0; + float v = 0; + Vector4 result; + int i = 0; + + for(int iv = 0; iv < sizeY; iv++) + { + u = 0; + + for(int iu = 0; iu < sizeX; iu++) + { + result.X = (1 - v) * ( (1 - u) * tcorners0.X + u * tcorners1.X ) + + v * ((1 - u) * tcorners2.X + u * tcorners3.X); + result.Z = (1 - v) * ( (1 - u) * tcorners0.Z + u * tcorners1.Z ) + + v * ((1 - u) * tcorners2.Z + u * tcorners3.Z); + result.W = (1 - v) * ( (1 - u) * tcorners0.W + u * tcorners1.W ) + + v * ((1 - u) * tcorners2.W + u * tcorners3.W); + + float divide = 1 / result.W; + result.X *= divide; + result.Z *= divide; + + // FIXME: The GetHeightDual should return a Z value instead? + Vertices[i].Position = new Vector3(result.X, + GetHeightDual((int)(magnitude * result.X), (int)(magnitude * result.Z)), result.Z); + + i++; + u += du; + } + + v += dv; + } + + // smooth the heightdata + if(SMOOTH) + { + for(int v1 = 1; v1 < (sizeY - 1); v1++) + { + for(int u1 = 1; u1 < (sizeX - 1); u1++) + { + // FIXME: We should be smoothing the Z values instead + Vector3 v1sizeXu1 = Vertices[v1 * sizeX + u1].Position; + v1sizeXu1.Y = 0.2f * (Vertices[v1 * sizeX + u1].Position.Y + + Vertices[v1 * sizeX + (u1 + 1)].Position.Y + + Vertices[v1 * sizeX + (u1 - 1)].Position.Y + + Vertices[(v1 + 1) * sizeX + u1].Position.Y + + Vertices[(v1 - 1) * sizeX + u1].Position.Y); + Vertices[v1 * sizeX + u1].Position = v1sizeXu1; + } + } + } + + if(!DISPLACE) + { + // Reset height to 0 + for(int u1 = 0; u1 < (sizeX * sizeY); u1++) + { + // FIXME: Should be Z? + Vertices[u1].Position = new Vector3(Vertices[u1].Position.X, 0, Vertices[u1].Position.Z); + } + } + + UploadNoise(); + + return true; + } + + public void GenerateNormalMap() + { + // Do the heightmap thingy + Surface bb = Device.GetRenderTarget(0); + Surface target = HeightMap.GetSurfaceLevel(0); + Surface olddepthstencil = Device.DepthStencilSurface; + + //hr = device->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW ); + //device->SetStreamSource( 0, surf_software_vertices, 0, sizeof(SOFTWARESURFACEVERTEX) ); + //hr = device->SetFVF( D3DFVF_SOFTWARESURFACEVERTEX); + //device->SetIndices(surf->surf_indicies); + hr = hmap_effect->Begin(NULL,NULL); + hmap_effect->BeginPass(0); + + hmap_effect->SetTexture("noise0",packed_noise_texture[0]); + hmap_effect->SetTexture("noise1",packed_noise_texture[1]); + + hr = device->SetRenderTarget( 0, target ); + device->SetDepthStencilSurface( depthstencil ); + //device->Clear( 0, NULL,D3DCLEAR_TARGET, D3DCOLOR_XRGB(255,128,28), 1.0f, 0 ); + device->SetRenderState( D3DRS_ZENABLE, D3DZB_FALSE ); + device->DrawIndexedPrimitive( D3DPT_TRIANGLELIST, 0, 0, sizeX*sizeY, 0, 2*(sizeX-1)*(sizeY-1) ); + hmap_effect->EndPass(); + hmap_effect->End(); + + // calculate normalmap + + hr = normalmap->GetSurfaceLevel( 0,&target ); + hr = device->SetRenderTarget( 0, target ); + hr = nmap_effect->Begin(NULL,NULL); + nmap_effect->BeginPass(0); + nmap_effect->SetFloat("inv_mapsize_x", 1.0f/nmapsize_x); + nmap_effect->SetFloat("inv_mapsize_y", 1.0f/nmapsize_y); + nmap_effect->SetVector("corner00", &t_corners0 ); + nmap_effect->SetVector("corner01", &t_corners1 ); + nmap_effect->SetVector("corner10", &t_corners2 ); + nmap_effect->SetVector("corner11", &t_corners3 ); + nmap_effect->SetFloat("amplitude", 2 * STRENGTH); + nmap_effect->SetTexture("hmap",heightmap); + device->DrawIndexedPrimitive( D3DPT_TRIANGLELIST, 0, 0, sizeX*sizeY, 0, 2*(sizeX-1)*(sizeY-1) ); + nmap_effect->EndPass(); + nmap_effect->End(); + + // restore the device + device->SetRenderState( D3DRS_ZENABLE, D3DZB_TRUE ); + device->SetRenderTarget( 0, bb ); + device->SetDepthStencilSurface( old_depthstencil ); + } + + private void InitNoise() + { + Random rand = new Random(); + + // create noise (uniform) + float[] tempnoise = new float[nsizesq * noiseframes]; + for(int i = 0; i < (nsizesq * noiseframes); i++) + { + float temp = (float)rand.NextDouble(RANDMAX); + tempnoise[i] = 4 * (temp - 0.5f); + } + + for(int frame = 0; frame < noiseframes; frame++) + { + for(int v = 0; v < nsize; v++) + { + for(int u = 0; u < nsize; u++) + { + int v0 = ((v - 1) & nsizem1) * nsize, + v1 = v * nsize, + v2 = ((v + 1) & nsizem1) * nsize, + u0 = ((u - 1) & nsizem1), + u1 = u, + u2 = ((u + 1) & nsizem1), + f = frame * nsizesq; + float temp = (1.0f / 14.0f) * (tempnoise[f + v0 + u0] + tempnoise[f + v0 + u1] + tempnoise[f + v0 + u2] + + tempnoise[f + v1 + u0] + 6.0f * tempnoise[f + v1 + u1] + tempnoise[f + v1 + u2] + + tempnoise[f + v2 + u0] + tempnoise[f + v2 + u1] + tempnoise[f + v2 + u2]); + + noise[frame * nsizesq + v * nsize + u] = noisemagnitude * temp; + } + } + } + } + + private void InitTextures() + { + PackedNoise = new Texture2D[2]; + PackedNoise[0] = new Texture2D(Device, npsize, npsize, 0, ResourceUsage.Dynamic, SurfaceFormat.Luminance16, + ResourcePool.Default); + PackedNoise[1] = new Texture2D(Device, npsize, npsize, 0, ResourceUsage.Dynamic, SurfaceFormat.Luminance16, + ResourcePool.Default); + + HeightMap = new Texture2D(Device, nmapsizex, nmapsizey, 1, ResourceUsage.RenderTarget, SurfaceFormat.Rgba64, + ResourcePool.Default); + NormalMap = new Texture2D(Device, nmapsizex, nmapsizey, 1, ResourceUsage.AutoGenerateMipMap | + ResourceUsage.RenderTarget, SurfaceFormat.Rgba64, ResourcePool.Default); + + // Create the stencil buffer + DepthStencil = Device.CreateDepthStencilSurface(nmapsizex, nmapsizey, DepthFormat.Depth24Stencil8, + MultiSampleType.None, 0, true); + } + + private void LoadEffects() + { + char* errortext; + LPD3DXBUFFER errors; + D3DXHANDLE hTechnique; + + // load effect + D3DXCreateEffectFromFile(device, "v2_heightmapgen.fx", + NULL, NULL, 0, NULL, &hmap_effect, &errors); + + if (errors != NULL) + { + errortext = (char*)errors->GetBufferPointer(); + MessageBox(NULL, errortext, "hmap_effect", MB_OK); + } + + hmap_effect->FindNextValidTechnique(NULL, &hTechnique); + hmap_effect->SetTechnique(hTechnique); + + // load effect + D3DXCreateEffectFromFile(device, "v2_normalmapgen.fx", + NULL, NULL, 0, NULL, &nmap_effect, &errors); + + if (errors != NULL) + { + errortext = (char*)errors->GetBufferPointer(); + MessageBox(NULL, errortext, "nmap_effect", MB_OK); + } + + nmap_effect->FindNextValidTechnique(NULL, &hTechnique); + nmap_effect->SetTechnique(hTechnique); + } + + // FIXME: Should this be (0,0,1,0) ? + // Check the point of intersection with the plane (0,1,0,0) and return the position in homogenous coordinates + private Vector4 CalculateWorldPos(Vector2 uv, Matrix m) + { + Vector4 origin = new Vector4(uv.X, uv.Y, -1, 1); + Vector4 direction = new Vector4(uv.X, uv.Y, 1, 1); + + origin = Vector4.Transform(origin, m); + direction = Vector4.Transform(direction, m); + + float l = -origin.Y / direction.Y; + + Vector4 worldpos = origin + direction * l; + return worldpos; + } + + private void CalculateNoise() + { + Octaves = maxoctaves; + + // Calculate the strength of each octave + float sum = 0; + + for (int i = 0; i < Octaves; i++) + { + Multitable[i] = (float)Math.Pow(FALLOFF, 1 * i); + sum += Multitable[i]; + } + + for (int i = 0; i < Octaves; i++) + { + Multitable[i] /= sum; + } + + for (int i = 0; i < Octaves; i++) + { + Multitable[i] = scalemagnitude * Multitable[i]; + } + + int now = Environment.TickCount; + double timechange = (double)(now - then); + then = now; + timechange *= 0.001d * ANIMSPEED; + double lptimechange = 0.99d * lptimechange + 0.01d * timechange; + time += lptimechange; + + double rtimemulti = 1; + + for(int o = 0; o < Octaves; o++) + { + uint[] image = new uint[3]; + int[] amount = new int[3]; + int iimage = (int)(time * rtimemulti); + double fraction = (time * rtimemulti) - (double)iimage; + + amount[0] = scalemagnitude * Multitable[o] * (Math.Pow(Math.Sin((fraction + 2) * Math.PI / 3), 2) / 1.5d); + amount[1] = scalemagnitude * Multitable[o] * (Math.Pow(Math.Sin((fraction + 1) * Math.PI / 3), 2) / 1.5d); + amount[2] = scalemagnitude * Multitable[o] * (Math.Pow(Math.Sin((fraction) * Math.PI / 3), 2) / 1.5d); + image[0] = (iimage) & noiseframesm1; + image[1] = (iimage + 1) & noiseframesm1; + image[2] = (iimage + 2) & noiseframesm1; + { + for(int i = 0; i < nsizesq; i++) + { + o_noise[i + nsizesq*o] = (((amount[0] * noise[i + nsizesq * image[0]])>>scaledecimalbits) + + ((amount[1] * noise[i + nsizesq * image[1]])>>scaledecimalbits) + + ((amount[2] * noise[i + nsizesq * image[2]])>>scaledecimalbits)); + } + } + + rtimemulti *= TIMEMULTI; + } + + if (packednoise) + { + int octavepack = 0; + + for (int o = 0; o < Octaves; o += npacksize) + { + for (int v = 0; v < npsize; v++) + for (int u = 0; u < npsize; u++) + { + Pnoise[v*npsize+u+octavepack*npsize_sq] = o_noise[(o+3)*nsizesq + (v&nsizem1)*nsize + (u&nsizem1)]; + Pnoise[v*npsize+u+octavepack*npsize_sq] += mapsample( u, v, 3, o); + Pnoise[v*npsize+u+octavepack*npsize_sq] += mapsample( u, v, 2, o+1); + Pnoise[v*npsize+u+octavepack*npsize_sq] += mapsample( u, v, 1, o+2); + } + + octavepack++; + } + } + } + + //private void CalculateNormals() + //{ + // ; + //} + + private void UploadNoise() + { + D3DLOCKED_RECT locked; + ushort data; + int[] tempdata = new int[npsizesq]; + + for(int t = 0; t < 2; t++) + { + int offset = npsizesq * t; + // upload the first level + packed_noise_texture[t]->LockRect( 0, &locked, NULL, D3DLOCK_DISCARD ); + data = (ushort*)locked.pBits; + for(int i=0; iUnlockRect( 0 ); + + int c = packed_noise_texture[t]->GetLevelCount(); + + // calculate the second level, and upload it + HRESULT hr = packed_noise_texture[t]->LockRect( 1, &locked, NULL, 0 ); + data = (ushort*)locked.pBits; + int sz = npsize>>1; + for(int v=0; v>2; + data[v*sz+u] = 32768+tempdata[v*npsize + u]; + } + } + + packed_noise_texture[t]->UnlockRect( 1 ); + + for(int j=2; jLockRect( j, &locked, NULL, 0 ); + data = (ushort*)locked.pBits; + int pitch = (locked.Pitch)>>1; + sz = npsize>>j; + for(int v=0; v>2; + data[v*pitch+u] = 32768+tempdata[v*npsize + u]; + } + } + packed_noise_texture[t]->UnlockRect( j ); + } + } + } + + private int MapSample(int u, int v, int upsamplepower, int octave) + { + ; + } + + private float ReadtexelNearest(int u, int v) + { + int lu, lv; + lu = (u>>ndecbits)&nsizem1; + lv = (v>>ndecbits)&nsizem1; + + return (float)noise[lv*nsize + lu]; + } + + private int ReadtexelLinearDual(int u, int v, int o) + { + int iu, iup, iv, ivp, fu, fv; + iu = (u>>ndecbits)&npsizem1; + iv = ((v>>ndecbits)&npsizem1)*npsize; + + iup = ((u>>ndecbits) + 1)&npsizem1; + ivp = (((v>>ndecbits) + 1)&npsizem1)*npsize; + + fu = u & ndecmagn_m1; + fv = v & ndecmagn_m1; + + int ut01 = ((ndecmagn-fu)*Rnoise[iv + iu] + fu*Rnoise[iv + iup])>>ndecbits; + int ut23 = ((ndecmagn-fu)*Rnoise[ivp + iu] + fu*Rnoise[ivp + iup])>>ndecbits; + int ut = ((ndecmagn-fv)*ut01 + fv*ut23) >> ndecbits; + + return ut; + } + + // FIXME: This function uses pointer magic that needs to be fixed for C# + private float GetHeightDual(int u, int v) + { + int value = 0; + Rnoise = Pnoise; // pointer to the current noise source octave + int hoct = Octaves / npacksize; + + for(int i = 0; i < hoct; i++) + { + value += ReadtexelLinearDual(u, v, 0); + u = u << npacksize; + v = v << npacksize; + Rnoise += npsizesq; + } + + return value * STRENGTH / noisemagnitude; + } + } +} diff --git a/applications/sceneviewer/Water/WaterSurface.cs b/applications/sceneviewer/Water/WaterSurface.cs index a19a9346..3c416c77 100644 --- a/applications/sceneviewer/Water/WaterSurface.cs +++ b/applications/sceneviewer/Water/WaterSurface.cs @@ -1,355 +1,355 @@ -using System; -using System.Text; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; - -namespace sceneviewer -{ - class WaterSurface - { - public const int REFLREFRDETAIL = 512; - public const float SUNSHININESS = 84.0f; - public const float SUNSTRENGTH = 12.0f; - public const float REFLREFROFFSET = 0.1f; - - public bool Initialized; - public Color WaterColor; - public Matrix Range; - - GraphicsDevice Device; - Plane Plane, UpperBound, LowerBound; - Vector3 Normal, U, V; - float Position; - int GridSizeX, GridSizeY; - NoiseMaker NoiseMaker; - Texture2D Fresnel, XYNoise, Reflection, Refraction; - Surface DepthStencil; - Effect WaterEffect; - VertexBuffer Vertices; - IndexBuffer Indices; - Camera Camera; - bool PlaneWithinFrustum; - - public WaterSurface(GraphicsDevice device, Camera camera, Vector3 normal, float position, int sizeX, int sizeY) - { - Vector3 x; - - Device = device; - Camera = camera; - Normal = normal; - Position = position; - Plane = new Plane(normal, position); - NoiseMaker = new NoiseMaker(Device, GridSizeX, GridSizeY); - PlaneWithinFrustum = false; - - // Set the initial water color - WaterColor = Color.Aquamarine; - - // Calculate the U and V vectors - if (Math.Abs(Vector3.Dot(Vector3.UnitX, normal)) < Math.Abs(Vector3.Dot(Vector3.UnitY, normal))) - { - x = Vector3.UnitX; - } - else - { - x = Vector3.UnitY; - } - - U = x - normal * Vector3.Dot(normal, x); - U = Vector3.Normalize(U); - - // Get V (cross) - V = Vector3.Cross(U, normal); - - GridSizeX = sizeX + 1; - GridSizeY = sizeY + 1; - - SetDisplacementAmplitude(0); - - if (!InitializeBuffers()) - { - return; - } - - // Load the textures - if ((Fresnel = Texture2D.FromFile(Device, "textures/fresnel_water_linear.bmp")) == null) - { - return; - } - if ((XYNoise = Texture2D.FromFile(Device, "textures/xynoise.png")) == null) - { - return; - } - - // Initialize the reflection and refraction textures, and the depth stencil - Reflection = new Texture2D(Device, REFLREFRDETAIL, REFLREFRDETAIL, 1, ResourceUsage.RenderTarget, - SurfaceFormat.Color, ResourcePool.Default); - Refraction = new Texture2D(Device, REFLREFRDETAIL, REFLREFRDETAIL, 1, ResourceUsage.RenderTarget, - SurfaceFormat.Color, ResourcePool.Default); - DepthStencil = Device.CreateDepthStencilSurface(REFLREFRDETAIL, REFLREFRDETAIL, DepthFormat.Depth24Stencil8, - MultiSampleType.None, 0, true); - - // Load the effect - CompiledEffect water = Effect.CompileEffectFromFile("shaders/watereffect.fx", null, null, - CompilerOptions.Debug | CompilerOptions.SkipOptimization, TargetPlatform.Windows); - if (!water.Success) - { - return; - } - else - { - WaterEffect = new Effect(Device, water.GetShaderCode(), CompilerOptions.None, null); - } - - Initialized = true; - } - - public bool Prepare() - { - if (!Initialized) return false; - - // Check if the water plane is within the viewing frustum - //BoundingFrustum frustum = new BoundingFrustum(Camera.ViewProjectionMatrix); - - //if ((frustum.Intersects(UpperBound) == PlaneIntersectionType.Intersecting) || - // (frustum.Intersects(LowerBound) == PlaneIntersectionType.Intersecting)) - //{ - // PlaneWithinFrustum = true; - - // NoiseMaker.RenderGeometry(out Range); - //} - - PlaneWithinFrustum = GetMinMax(out Range); - - if (PlaneWithinFrustum) - { - NoiseMaker.RenderGeometry(Range); - - Vertices.SetData(NoiseMaker.Vertices); - } - - return true; - } - - public void RenderCutter() - { - if (PlaneWithinFrustum) - { - Device.VertexDeclaration = new VertexDeclaration(Device, VertexPositionNormalTexture.VertexElements); - Device.Vertices[0].SetSource(Vertices, 0, VertexPositionNormalTexture.SizeInBytes); - Device.Indices = Indices; - Device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, GridSizeX * GridSizeY, - 0, 2 * (GridSizeX - 1) * (GridSizeY - 1)); - } - } - - public void Render(Vector4 sunVector) - { - if (PlaneWithinFrustum) - { - Device.RenderState.CullMode = CullMode.None; - Device.VertexDeclaration = new VertexDeclaration(Device, VertexPositionNormalTexture.VertexElements); - Device.Vertices[0].SetSource(Vertices, 0, VertexPositionNormalTexture.SizeInBytes); - Device.Indices = Indices; - - NoiseMaker.GenerateNormalMap(); - - Device.RenderState.CullMode = CullMode.CullClockwiseFace; - WaterEffect.Begin(EffectStateOptions.Default); - WaterEffect.CurrentTechnique.Passes[0].Begin(); - // Beginning of the water rendering pass - - WaterEffect.Parameters["mViewProj"].SetValue(Camera.ViewProjectionMatrix); - WaterEffect.Parameters["mView"].SetValue(Camera.ViewMatrix); - WaterEffect.Parameters["sun_vec"].SetValue(sunVector); - WaterEffect.Parameters["sun_shininess"].SetValue(SUNSHININESS); - WaterEffect.Parameters["sun_strength"].SetValue(SUNSTRENGTH); - WaterEffect.Parameters["reflrefr_offset"].SetValue(REFLREFROFFSET); - WaterEffect.Parameters["diffuseSkyRef"].SetValue(true); - WaterEffect.Parameters["watercolour"].SetValue(WaterColor.ToVector4()); - WaterEffect.Parameters["LODbias"].SetValue(0.0f); - WaterEffect.Parameters["view_position"].SetValue(new Vector4(Camera.Position, 1)); - //WaterEffect.Parameters["EnvironmentMap", SkyboxCubemap); - WaterEffect.Parameters["FresnelMap"].SetValue(Fresnel); - WaterEffect.Parameters["Heightmap"].SetValue(NoiseMaker.HeightMap); - WaterEffect.Parameters["Normalmap"].SetValue(NoiseMaker.NormalMap); - WaterEffect.Parameters["Refractionmap"].SetValue(Refraction); - WaterEffect.Parameters["Reflectionmap"].SetValue(Reflection); - - Device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, GridSizeX * GridSizeY, 0, - 2 * (GridSizeX - 1) * (GridSizeY - 1)); - - // End of the water rendering pass - WaterEffect.CurrentTechnique.Passes[0].End(); - WaterEffect.End(); - } - } - - public void SetDisplacementAmplitude(float amplitude) - { - UpperBound = new Plane(Normal, Position + amplitude); - LowerBound = new Plane(Normal, Position - amplitude); - } - - private bool InitializeBuffers() - { - if ((Vertices = new VertexBuffer(Device, GridSizeX * GridSizeY * VertexPositionNormalTexture.SizeInBytes, - ResourceUsage.WriteOnly | ResourceUsage.Dynamic, ResourcePool.Default)) == null) - { - return false; - } - - if ((Indices = new IndexBuffer(Device, sizeof(int) * 6 * (GridSizeX - 1) * (GridSizeY - 1), - ResourceUsage.WriteOnly, ResourcePool.Default, IndexElementSize.ThirtyTwoBits)) == null) - { - return false; - } - - // Fill the index buffer - for (int v = 0; v < GridSizeY - 1; v++) - { - for (int u = 0; u < GridSizeX - 1; u++) - { - int[] indexes = new int[6]; - - // Face 1 |/ - indexes[0] = v * GridSizeX + u; - indexes[1] = v * GridSizeX + u + 1; - indexes[2] = (v + 1) * GridSizeX + u; - - // Face 2 /| - indexes[3] = (v + 1) * GridSizeX + u; - indexes[4] = v * GridSizeX + u + 1; - indexes[5] = (v + 1) * GridSizeX + u + 1; - - Indices.SetData(indexes); - } - } - - return true; - } - - private bool GetMinMax(out Matrix range) - { - // FIXME: - range = new Matrix(); - return false; - } - - /*private bool GetMinMax(out Matrix range) - { - BoundingFrustum frustum = new BoundingFrustum(Camera.ViewMatrix); - Vector3[] corners = frustum.GetCorners(); - range = Matrix.CreateOrthographic(frustum. - - float xmin, ymin, xmax, ymax; - // Frustum to check the camera against - //Vector3[] frustum = new Vector3[8]; - Vector3[] projPoints = new Vector3[24]; - int npoints = 0; - // Which frustum points are connected together? - //int[] cube = { 0,1, 0,2, 2,3, 1,3, - // 0,4, 2,6, 3,7, 1,5, - // 4,6, 4,5, 5,7, 6,7 - // }; - - // Transform frustum points to worldspace - //Matrix invView = Matrix.Invert(Camera.ViewMatrix); - //frustum[0] = Vector3.Transform(new Vector3(-1, -1, -1), invView); - //frustum[1] = Vector3.Transform(new Vector3(+1, -1, -1), invView); - //frustum[2] = Vector3.Transform(new Vector3(-1, +1, -1), invView); - //frustum[3] = Vector3.Transform(new Vector3(+1, +1, -1), invView); - //frustum[4] = Vector3.Transform(new Vector3(-1, -1, +1), invView); - //frustum[5] = Vector3.Transform(new Vector3(+1, -1, +1), invView); - //frustum[6] = Vector3.Transform(new Vector3(-1, +1, +1), invView); - //frustum[7] = Vector3.Transform(new Vector3(+1, +1, +1), invView); - - // Check intersections with UpperBound and LowerBound - for (int i = 0; i < 12; i++) - { - int src = cube[i * 2]; - int dst = cube[i * 2 + 1]; - - // FIXME: Since Z is up in our world we may need to fix some things here - if ((UpperBound.A * frustum[src].X + UpperBound.B * frustum[src].Y + UpperBound.C * frustum[src].Z + UpperBound.D * 1) / - (UpperBound.A * frustum[dst].X + UpperBound.B * frustum[dst].Y + UpperBound.C * frustum[dst].Z + UpperBound.D * 1) < 0) - { - BoundingFrustum f = new BoundingFrustum( - //projPoints[npoints++] = - Plane.Intersects( - D3DXPlaneIntersectLine(&proj_points[n_points++], &upper_bound, &frustum[src], &frustum[dst]); - } - if ((LowerBound.A * frustum[src].X + LowerBound.B * frustum[src].Y + LowerBound.C * frustum[src].Z + LowerBound.D * 1) / - (LowerBound.A * frustum[dst].X + LowerBound.B * frustum[dst].Y + LowerBound.C * frustum[dst].Z + LowerBound.D * 1) < 0) - { - D3DXPlaneIntersectLine(&proj_points[n_points++], &lower_bound, &frustum[src], &frustum[dst]); - } - } - - // Check if any of the frustums vertices lie between the upper_bound and lower_bound planes - for (int i = 0; i < 8; i++) - { - if ((UpperBound.A * frustum[i].X + UpperBound.B * frustum[i].Y + UpperBound.C * frustum[i].Z + UpperBound.D * 1) / - (LowerBound.A * frustum[i].X + LowerBound.B * frustum[i].Y + LowerBound.C * frustum[i].Z + LowerBound.D * 1) < 0) - { - projPoints[npoints++] = frustum[i]; - } - } - - // TODO: Advanced camera stuff? - // - - for (int i = 0; i < npoints; i++) - { - projPoints[i] = Vector3.Transform(projPoints[i], Camera.ViewMatrix); - projPoints[i] = Vector3.Transform(projPoints[i], Camera.ProjectionMatrix); - } - - // Get max/min x & y-values to determine how big the "projection window" must be - if (npoints > 0) - { - xmin = projPoints[0].X; - xmax = projPoints[0].X; - ymin = projPoints[0].Y; - ymax = projPoints[0].Y; - - for(int i = 1; i < npoints; i++) - { - if (projPoints[i].X > xmax) xmax = projPoints[i].X; - if (projPoints[i].X < xmin) xmin = projPoints[i].X; - if (projPoints[i].Y > ymax) ymax = projPoints[i].Y; - if (projPoints[i].Y < ymin) ymin = projPoints[i].Y; - } - - // Build the packing matrix that spreads the grid across the "projection window" - Matrix pack = new Matrix(xmax-xmin, 0, 0, xmin, - 0, ymax-ymin, 0, ymin, - 0, 0, 1, 0, - 0, 0, 0, 1); - - pack = Matrix.Transpose(pack); - range = pack * invView; - - return true; - } - else - { - return false; - } - }*/ - - private bool WithinFrustum(Vector3 position) - { - Vector3 test = Vector3.Transform(position, Camera.ViewProjectionMatrix); - - if ((Math.Abs(test.X) < 1.00001f) && (Math.Abs(test.Y) < 1.00001f) && (Math.Abs(test.Z) < 1.00001f)) - { - return true; - } - else - { - return false; - } - } - } -} +using System; +using System.Text; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +namespace sceneviewer +{ + class WaterSurface + { + public const int REFLREFRDETAIL = 512; + public const float SUNSHININESS = 84.0f; + public const float SUNSTRENGTH = 12.0f; + public const float REFLREFROFFSET = 0.1f; + + public bool Initialized; + public Color WaterColor; + public Matrix Range; + + GraphicsDevice Device; + Plane Plane, UpperBound, LowerBound; + Vector3 Normal, U, V; + float Position; + int GridSizeX, GridSizeY; + NoiseMaker NoiseMaker; + Texture2D Fresnel, XYNoise, Reflection, Refraction; + Surface DepthStencil; + Effect WaterEffect; + VertexBuffer Vertices; + IndexBuffer Indices; + Camera Camera; + bool PlaneWithinFrustum; + + public WaterSurface(GraphicsDevice device, Camera camera, Vector3 normal, float position, int sizeX, int sizeY) + { + Vector3 x; + + Device = device; + Camera = camera; + Normal = normal; + Position = position; + Plane = new Plane(normal, position); + NoiseMaker = new NoiseMaker(Device, GridSizeX, GridSizeY); + PlaneWithinFrustum = false; + + // Set the initial water color + WaterColor = Color.Aquamarine; + + // Calculate the U and V vectors + if (Math.Abs(Vector3.Dot(Vector3.UnitX, normal)) < Math.Abs(Vector3.Dot(Vector3.UnitY, normal))) + { + x = Vector3.UnitX; + } + else + { + x = Vector3.UnitY; + } + + U = x - normal * Vector3.Dot(normal, x); + U = Vector3.Normalize(U); + + // Get V (cross) + V = Vector3.Cross(U, normal); + + GridSizeX = sizeX + 1; + GridSizeY = sizeY + 1; + + SetDisplacementAmplitude(0); + + if (!InitializeBuffers()) + { + return; + } + + // Load the textures + if ((Fresnel = Texture2D.FromFile(Device, "textures/fresnel_water_linear.bmp")) == null) + { + return; + } + if ((XYNoise = Texture2D.FromFile(Device, "textures/xynoise.png")) == null) + { + return; + } + + // Initialize the reflection and refraction textures, and the depth stencil + Reflection = new Texture2D(Device, REFLREFRDETAIL, REFLREFRDETAIL, 1, ResourceUsage.RenderTarget, + SurfaceFormat.Color, ResourcePool.Default); + Refraction = new Texture2D(Device, REFLREFRDETAIL, REFLREFRDETAIL, 1, ResourceUsage.RenderTarget, + SurfaceFormat.Color, ResourcePool.Default); + DepthStencil = Device.CreateDepthStencilSurface(REFLREFRDETAIL, REFLREFRDETAIL, DepthFormat.Depth24Stencil8, + MultiSampleType.None, 0, true); + + // Load the effect + CompiledEffect water = Effect.CompileEffectFromFile("shaders/watereffect.fx", null, null, + CompilerOptions.Debug | CompilerOptions.SkipOptimization, TargetPlatform.Windows); + if (!water.Success) + { + return; + } + else + { + WaterEffect = new Effect(Device, water.GetShaderCode(), CompilerOptions.None, null); + } + + Initialized = true; + } + + public bool Prepare() + { + if (!Initialized) return false; + + // Check if the water plane is within the viewing frustum + //BoundingFrustum frustum = new BoundingFrustum(Camera.ViewProjectionMatrix); + + //if ((frustum.Intersects(UpperBound) == PlaneIntersectionType.Intersecting) || + // (frustum.Intersects(LowerBound) == PlaneIntersectionType.Intersecting)) + //{ + // PlaneWithinFrustum = true; + + // NoiseMaker.RenderGeometry(out Range); + //} + + PlaneWithinFrustum = GetMinMax(out Range); + + if (PlaneWithinFrustum) + { + NoiseMaker.RenderGeometry(Range); + + Vertices.SetData(NoiseMaker.Vertices); + } + + return true; + } + + public void RenderCutter() + { + if (PlaneWithinFrustum) + { + Device.VertexDeclaration = new VertexDeclaration(Device, VertexPositionNormalTexture.VertexElements); + Device.Vertices[0].SetSource(Vertices, 0, VertexPositionNormalTexture.SizeInBytes); + Device.Indices = Indices; + Device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, GridSizeX * GridSizeY, + 0, 2 * (GridSizeX - 1) * (GridSizeY - 1)); + } + } + + public void Render(Vector4 sunVector) + { + if (PlaneWithinFrustum) + { + Device.RenderState.CullMode = CullMode.None; + Device.VertexDeclaration = new VertexDeclaration(Device, VertexPositionNormalTexture.VertexElements); + Device.Vertices[0].SetSource(Vertices, 0, VertexPositionNormalTexture.SizeInBytes); + Device.Indices = Indices; + + NoiseMaker.GenerateNormalMap(); + + Device.RenderState.CullMode = CullMode.CullClockwiseFace; + WaterEffect.Begin(EffectStateOptions.Default); + WaterEffect.CurrentTechnique.Passes[0].Begin(); + // Beginning of the water rendering pass + + WaterEffect.Parameters["mViewProj"].SetValue(Camera.ViewProjectionMatrix); + WaterEffect.Parameters["mView"].SetValue(Camera.ViewMatrix); + WaterEffect.Parameters["sun_vec"].SetValue(sunVector); + WaterEffect.Parameters["sun_shininess"].SetValue(SUNSHININESS); + WaterEffect.Parameters["sun_strength"].SetValue(SUNSTRENGTH); + WaterEffect.Parameters["reflrefr_offset"].SetValue(REFLREFROFFSET); + WaterEffect.Parameters["diffuseSkyRef"].SetValue(true); + WaterEffect.Parameters["watercolour"].SetValue(WaterColor.ToVector4()); + WaterEffect.Parameters["LODbias"].SetValue(0.0f); + WaterEffect.Parameters["view_position"].SetValue(new Vector4(Camera.Position, 1)); + //WaterEffect.Parameters["EnvironmentMap", SkyboxCubemap); + WaterEffect.Parameters["FresnelMap"].SetValue(Fresnel); + WaterEffect.Parameters["Heightmap"].SetValue(NoiseMaker.HeightMap); + WaterEffect.Parameters["Normalmap"].SetValue(NoiseMaker.NormalMap); + WaterEffect.Parameters["Refractionmap"].SetValue(Refraction); + WaterEffect.Parameters["Reflectionmap"].SetValue(Reflection); + + Device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, GridSizeX * GridSizeY, 0, + 2 * (GridSizeX - 1) * (GridSizeY - 1)); + + // End of the water rendering pass + WaterEffect.CurrentTechnique.Passes[0].End(); + WaterEffect.End(); + } + } + + public void SetDisplacementAmplitude(float amplitude) + { + UpperBound = new Plane(Normal, Position + amplitude); + LowerBound = new Plane(Normal, Position - amplitude); + } + + private bool InitializeBuffers() + { + if ((Vertices = new VertexBuffer(Device, GridSizeX * GridSizeY * VertexPositionNormalTexture.SizeInBytes, + ResourceUsage.WriteOnly | ResourceUsage.Dynamic, ResourcePool.Default)) == null) + { + return false; + } + + if ((Indices = new IndexBuffer(Device, sizeof(int) * 6 * (GridSizeX - 1) * (GridSizeY - 1), + ResourceUsage.WriteOnly, ResourcePool.Default, IndexElementSize.ThirtyTwoBits)) == null) + { + return false; + } + + // Fill the index buffer + for (int v = 0; v < GridSizeY - 1; v++) + { + for (int u = 0; u < GridSizeX - 1; u++) + { + int[] indexes = new int[6]; + + // Face 1 |/ + indexes[0] = v * GridSizeX + u; + indexes[1] = v * GridSizeX + u + 1; + indexes[2] = (v + 1) * GridSizeX + u; + + // Face 2 /| + indexes[3] = (v + 1) * GridSizeX + u; + indexes[4] = v * GridSizeX + u + 1; + indexes[5] = (v + 1) * GridSizeX + u + 1; + + Indices.SetData(indexes); + } + } + + return true; + } + + private bool GetMinMax(out Matrix range) + { + // FIXME: + range = new Matrix(); + return false; + } + + /*private bool GetMinMax(out Matrix range) + { + BoundingFrustum frustum = new BoundingFrustum(Camera.ViewMatrix); + Vector3[] corners = frustum.GetCorners(); + range = Matrix.CreateOrthographic(frustum. + + float xmin, ymin, xmax, ymax; + // Frustum to check the camera against + //Vector3[] frustum = new Vector3[8]; + Vector3[] projPoints = new Vector3[24]; + int npoints = 0; + // Which frustum points are connected together? + //int[] cube = { 0,1, 0,2, 2,3, 1,3, + // 0,4, 2,6, 3,7, 1,5, + // 4,6, 4,5, 5,7, 6,7 + // }; + + // Transform frustum points to worldspace + //Matrix invView = Matrix.Invert(Camera.ViewMatrix); + //frustum[0] = Vector3.Transform(new Vector3(-1, -1, -1), invView); + //frustum[1] = Vector3.Transform(new Vector3(+1, -1, -1), invView); + //frustum[2] = Vector3.Transform(new Vector3(-1, +1, -1), invView); + //frustum[3] = Vector3.Transform(new Vector3(+1, +1, -1), invView); + //frustum[4] = Vector3.Transform(new Vector3(-1, -1, +1), invView); + //frustum[5] = Vector3.Transform(new Vector3(+1, -1, +1), invView); + //frustum[6] = Vector3.Transform(new Vector3(-1, +1, +1), invView); + //frustum[7] = Vector3.Transform(new Vector3(+1, +1, +1), invView); + + // Check intersections with UpperBound and LowerBound + for (int i = 0; i < 12; i++) + { + int src = cube[i * 2]; + int dst = cube[i * 2 + 1]; + + // FIXME: Since Z is up in our world we may need to fix some things here + if ((UpperBound.A * frustum[src].X + UpperBound.B * frustum[src].Y + UpperBound.C * frustum[src].Z + UpperBound.D * 1) / + (UpperBound.A * frustum[dst].X + UpperBound.B * frustum[dst].Y + UpperBound.C * frustum[dst].Z + UpperBound.D * 1) < 0) + { + BoundingFrustum f = new BoundingFrustum( + //projPoints[npoints++] = + Plane.Intersects( + D3DXPlaneIntersectLine(&proj_points[n_points++], &upper_bound, &frustum[src], &frustum[dst]); + } + if ((LowerBound.A * frustum[src].X + LowerBound.B * frustum[src].Y + LowerBound.C * frustum[src].Z + LowerBound.D * 1) / + (LowerBound.A * frustum[dst].X + LowerBound.B * frustum[dst].Y + LowerBound.C * frustum[dst].Z + LowerBound.D * 1) < 0) + { + D3DXPlaneIntersectLine(&proj_points[n_points++], &lower_bound, &frustum[src], &frustum[dst]); + } + } + + // Check if any of the frustums vertices lie between the upper_bound and lower_bound planes + for (int i = 0; i < 8; i++) + { + if ((UpperBound.A * frustum[i].X + UpperBound.B * frustum[i].Y + UpperBound.C * frustum[i].Z + UpperBound.D * 1) / + (LowerBound.A * frustum[i].X + LowerBound.B * frustum[i].Y + LowerBound.C * frustum[i].Z + LowerBound.D * 1) < 0) + { + projPoints[npoints++] = frustum[i]; + } + } + + // TODO: Advanced camera stuff? + // + + for (int i = 0; i < npoints; i++) + { + projPoints[i] = Vector3.Transform(projPoints[i], Camera.ViewMatrix); + projPoints[i] = Vector3.Transform(projPoints[i], Camera.ProjectionMatrix); + } + + // Get max/min x & y-values to determine how big the "projection window" must be + if (npoints > 0) + { + xmin = projPoints[0].X; + xmax = projPoints[0].X; + ymin = projPoints[0].Y; + ymax = projPoints[0].Y; + + for(int i = 1; i < npoints; i++) + { + if (projPoints[i].X > xmax) xmax = projPoints[i].X; + if (projPoints[i].X < xmin) xmin = projPoints[i].X; + if (projPoints[i].Y > ymax) ymax = projPoints[i].Y; + if (projPoints[i].Y < ymin) ymin = projPoints[i].Y; + } + + // Build the packing matrix that spreads the grid across the "projection window" + Matrix pack = new Matrix(xmax-xmin, 0, 0, xmin, + 0, ymax-ymin, 0, ymin, + 0, 0, 1, 0, + 0, 0, 0, 1); + + pack = Matrix.Transpose(pack); + range = pack * invView; + + return true; + } + else + { + return false; + } + }*/ + + private bool WithinFrustum(Vector3 position) + { + Vector3 test = Vector3.Transform(position, Camera.ViewProjectionMatrix); + + if ((Math.Abs(test.X) < 1.00001f) && (Math.Abs(test.Y) < 1.00001f) && (Math.Abs(test.Z) < 1.00001f)) + { + return true; + } + else + { + return false; + } + } + } +} diff --git a/applications/sceneviewer/sceneviewer.csproj b/applications/sceneviewer/sceneviewer.csproj index a6dedeb5..757da4c9 100644 --- a/applications/sceneviewer/sceneviewer.csproj +++ b/applications/sceneviewer/sceneviewer.csproj @@ -1,88 +1,88 @@ - - - {21C7E365-F32E-4912-9E6A-50A5BD02AC29} - {9F340DF3-2AED-4330-AC16-78AC2D9B4738};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - Debug - AnyCPU - WinExe - Properties - sceneviewer - sceneviewer - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - true - false - - - pdbonly - true - ..\..\bin\ - TRACE - prompt - 4 - true - false - - - - False - ..\..\bin\libsecondlife.dll - - - true - - - true - - - - - - - - - - - - - - - - - - - - - - - Viewer.cs - - - - - Component - - - - - - - - - - - + + + {21C7E365-F32E-4912-9E6A-50A5BD02AC29} + {9F340DF3-2AED-4330-AC16-78AC2D9B4738};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Debug + AnyCPU + WinExe + Properties + sceneviewer + sceneviewer + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + true + false + + + pdbonly + true + ..\..\bin\ + TRACE + prompt + 4 + true + false + + + + False + ..\..\bin\libsecondlife.dll + + + true + + + true + + + + + + + + + + + + + + + + + + + + + + + Viewer.cs + + + + + Component + + + + + + + + + + + \ No newline at end of file diff --git a/applications/sceneviewer/sceneviewer.sln b/applications/sceneviewer/sceneviewer.sln index fd8c1ac7..ee9ba6ed 100644 --- a/applications/sceneviewer/sceneviewer.sln +++ b/applications/sceneviewer/sceneviewer.sln @@ -1,20 +1,20 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual C# Express 2005 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "sceneviewer", "sceneviewer.csproj", "{21C7E365-F32E-4912-9E6A-50A5BD02AC29}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {21C7E365-F32E-4912-9E6A-50A5BD02AC29}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {21C7E365-F32E-4912-9E6A-50A5BD02AC29}.Debug|Any CPU.Build.0 = Debug|Any CPU - {21C7E365-F32E-4912-9E6A-50A5BD02AC29}.Release|Any CPU.ActiveCfg = Release|Any CPU - {21C7E365-F32E-4912-9E6A-50A5BD02AC29}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual C# Express 2005 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "sceneviewer", "sceneviewer.csproj", "{21C7E365-F32E-4912-9E6A-50A5BD02AC29}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {21C7E365-F32E-4912-9E6A-50A5BD02AC29}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {21C7E365-F32E-4912-9E6A-50A5BD02AC29}.Debug|Any CPU.Build.0 = Debug|Any CPU + {21C7E365-F32E-4912-9E6A-50A5BD02AC29}.Release|Any CPU.ActiveCfg = Release|Any CPU + {21C7E365-F32E-4912-9E6A-50A5BD02AC29}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/applications/snowcrash/snowcrash.sln b/applications/snowcrash/snowcrash.sln index 62a8ab97..c8a14483 100644 --- a/applications/snowcrash/snowcrash.sln +++ b/applications/snowcrash/snowcrash.sln @@ -1,30 +1,30 @@ -Microsoft Visual Studio Solution File, Format Version 8.00 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "snowcrash", "snowcrash\snowcrash.vcproj", "{2105B930-471B-4E1B-A52E-C9DF97A4D8A0}" - ProjectSection(ProjectDependencies) = postProject - {99CC21CC-D63D-49D3-9CFF-FEC3FE7B60E4} = {99CC21CC-D63D-49D3-9CFF-FEC3FE7B60E4} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "snowflake", "snowflake\snowflake.vcproj", "{99CC21CC-D63D-49D3-9CFF-FEC3FE7B60E4}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfiguration) = preSolution - Debug = Debug - Release = Release - EndGlobalSection - GlobalSection(ProjectConfiguration) = postSolution - {2105B930-471B-4E1B-A52E-C9DF97A4D8A0}.Debug.ActiveCfg = Debug|Win32 - {2105B930-471B-4E1B-A52E-C9DF97A4D8A0}.Debug.Build.0 = Debug|Win32 - {2105B930-471B-4E1B-A52E-C9DF97A4D8A0}.Release.ActiveCfg = Release|Win32 - {2105B930-471B-4E1B-A52E-C9DF97A4D8A0}.Release.Build.0 = Release|Win32 - {99CC21CC-D63D-49D3-9CFF-FEC3FE7B60E4}.Debug.ActiveCfg = Debug|Win32 - {99CC21CC-D63D-49D3-9CFF-FEC3FE7B60E4}.Debug.Build.0 = Debug|Win32 - {99CC21CC-D63D-49D3-9CFF-FEC3FE7B60E4}.Release.ActiveCfg = Release|Win32 - {99CC21CC-D63D-49D3-9CFF-FEC3FE7B60E4}.Release.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - EndGlobalSection - GlobalSection(ExtensibilityAddIns) = postSolution - EndGlobalSection -EndGlobal +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "snowcrash", "snowcrash\snowcrash.vcproj", "{2105B930-471B-4E1B-A52E-C9DF97A4D8A0}" + ProjectSection(ProjectDependencies) = postProject + {99CC21CC-D63D-49D3-9CFF-FEC3FE7B60E4} = {99CC21CC-D63D-49D3-9CFF-FEC3FE7B60E4} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "snowflake", "snowflake\snowflake.vcproj", "{99CC21CC-D63D-49D3-9CFF-FEC3FE7B60E4}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {2105B930-471B-4E1B-A52E-C9DF97A4D8A0}.Debug.ActiveCfg = Debug|Win32 + {2105B930-471B-4E1B-A52E-C9DF97A4D8A0}.Debug.Build.0 = Debug|Win32 + {2105B930-471B-4E1B-A52E-C9DF97A4D8A0}.Release.ActiveCfg = Release|Win32 + {2105B930-471B-4E1B-A52E-C9DF97A4D8A0}.Release.Build.0 = Release|Win32 + {99CC21CC-D63D-49D3-9CFF-FEC3FE7B60E4}.Debug.ActiveCfg = Debug|Win32 + {99CC21CC-D63D-49D3-9CFF-FEC3FE7B60E4}.Debug.Build.0 = Debug|Win32 + {99CC21CC-D63D-49D3-9CFF-FEC3FE7B60E4}.Release.ActiveCfg = Release|Win32 + {99CC21CC-D63D-49D3-9CFF-FEC3FE7B60E4}.Release.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/applications/snowcrash/snowcrash/MainFrame.cpp b/applications/snowcrash/snowcrash/MainFrame.cpp index e53ece2b..69b3054d 100644 --- a/applications/snowcrash/snowcrash/MainFrame.cpp +++ b/applications/snowcrash/snowcrash/MainFrame.cpp @@ -1,54 +1,54 @@ -// MainFrame.cpp : implmentation of the CMainFrame class -// -///////////////////////////////////////////////////////////////////////////// - -#include "stdafx.h" -#include "resource.h" - -#include "MainFrame.h" - -BOOL CMainFrame::PreTranslateMessage(MSG* pMsg) -{ - return CFrameWindowImpl::PreTranslateMessage(pMsg); -} - -BOOL CMainFrame::OnIdle() -{ - return FALSE; -} - -LRESULT CMainFrame::OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) -{ - m_bEnabled = TRUE; - - // register object for message filtering and idle updates - CMessageLoop* pLoop = _Module.GetMessageLoop(); - ATLASSERT(pLoop != NULL); - pLoop->AddMessageFilter(this); - pLoop->AddIdleHandler(this); - - // install tray icon - InstallIcon("Snowcrash", ::LoadIcon(_Module.m_hInstResource, MAKEINTRESOURCE(IDI_SNOWCRASH)), IDC_TRAY); -// SetDefaultItem(ID_APP_SHOW); - - InstallSystemHook(); - - return 0; -} - -LRESULT CMainFrame::OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) -{ - dprintf("OnDestroy\n"); - RemoveSystemHook(); - PostQuitMessage(0); - - return 0; -} - -LRESULT CMainFrame::OnAppExit(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) -{ - dprintf("OnAppExit\n"); - DestroyWindow(); - - return 0; -} +// MainFrame.cpp : implmentation of the CMainFrame class +// +///////////////////////////////////////////////////////////////////////////// + +#include "stdafx.h" +#include "resource.h" + +#include "MainFrame.h" + +BOOL CMainFrame::PreTranslateMessage(MSG* pMsg) +{ + return CFrameWindowImpl::PreTranslateMessage(pMsg); +} + +BOOL CMainFrame::OnIdle() +{ + return FALSE; +} + +LRESULT CMainFrame::OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) +{ + m_bEnabled = TRUE; + + // register object for message filtering and idle updates + CMessageLoop* pLoop = _Module.GetMessageLoop(); + ATLASSERT(pLoop != NULL); + pLoop->AddMessageFilter(this); + pLoop->AddIdleHandler(this); + + // install tray icon + InstallIcon("Snowcrash", ::LoadIcon(_Module.m_hInstResource, MAKEINTRESOURCE(IDI_SNOWCRASH)), IDC_TRAY); +// SetDefaultItem(ID_APP_SHOW); + + InstallSystemHook(); + + return 0; +} + +LRESULT CMainFrame::OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) +{ + dprintf("OnDestroy\n"); + RemoveSystemHook(); + PostQuitMessage(0); + + return 0; +} + +LRESULT CMainFrame::OnAppExit(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) +{ + dprintf("OnAppExit\n"); + DestroyWindow(); + + return 0; +} diff --git a/applications/snowcrash/snowcrash/MainFrame.h b/applications/snowcrash/snowcrash/MainFrame.h index 0442b1ff..4d339fde 100644 --- a/applications/snowcrash/snowcrash/MainFrame.h +++ b/applications/snowcrash/snowcrash/MainFrame.h @@ -1,41 +1,41 @@ -// MainFrame.h : interface of the CMainFrame class -// -///////////////////////////////////////////////////////////////////////////// - -#pragma once - -#include "TrayIconImpl.h" - -class CMainFrame : public CFrameWindowImpl, public CUpdateUI, - public CMessageFilter, public CIdleHandler, public CTrayIconImpl -{ -public: - DECLARE_FRAME_WND_CLASS(NULL, IDI_SNOWCRASH) - - virtual BOOL PreTranslateMessage(MSG* pMsg); - virtual BOOL OnIdle(); - - BEGIN_UPDATE_UI_MAP(CMainFrame) - END_UPDATE_UI_MAP() - - BEGIN_MSG_MAP(CMainFrame) - COMMAND_ID_HANDLER(ID_APP_EXIT, OnAppExit) - MESSAGE_HANDLER(WM_CREATE, OnCreate) - MESSAGE_HANDLER(WM_DESTROY, OnDestroy) - CHAIN_MSG_MAP(CTrayIconImpl) - CHAIN_MSG_MAP(CUpdateUI) - CHAIN_MSG_MAP(CFrameWindowImpl) - END_MSG_MAP() - -// Handler prototypes (uncomment arguments if needed): -// LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) -// LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) -// LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/) - - LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); - LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); - LRESULT OnAppExit(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); - -private: - BOOL m_bEnabled; -}; +// MainFrame.h : interface of the CMainFrame class +// +///////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "TrayIconImpl.h" + +class CMainFrame : public CFrameWindowImpl, public CUpdateUI, + public CMessageFilter, public CIdleHandler, public CTrayIconImpl +{ +public: + DECLARE_FRAME_WND_CLASS(NULL, IDI_SNOWCRASH) + + virtual BOOL PreTranslateMessage(MSG* pMsg); + virtual BOOL OnIdle(); + + BEGIN_UPDATE_UI_MAP(CMainFrame) + END_UPDATE_UI_MAP() + + BEGIN_MSG_MAP(CMainFrame) + COMMAND_ID_HANDLER(ID_APP_EXIT, OnAppExit) + MESSAGE_HANDLER(WM_CREATE, OnCreate) + MESSAGE_HANDLER(WM_DESTROY, OnDestroy) + CHAIN_MSG_MAP(CTrayIconImpl) + CHAIN_MSG_MAP(CUpdateUI) + CHAIN_MSG_MAP(CFrameWindowImpl) + END_MSG_MAP() + +// Handler prototypes (uncomment arguments if needed): +// LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) +// LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) +// LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/) + + LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); + LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); + LRESULT OnAppExit(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); + +private: + BOOL m_bEnabled; +}; diff --git a/applications/snowcrash/snowcrash/TrayIconImpl.h b/applications/snowcrash/snowcrash/TrayIconImpl.h index 9aaa998c..d5be5a06 100644 --- a/applications/snowcrash/snowcrash/TrayIconImpl.h +++ b/applications/snowcrash/snowcrash/TrayIconImpl.h @@ -1,112 +1,112 @@ -#ifndef TRAYICONIMPL_H -#define TRAYICONIMPL_H - -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -class CNotifyIconData : public NOTIFYICONDATA -{ -public: - CNotifyIconData() - { - ZeroMemory(this, sizeof(NOTIFYICONDATA)); - cbSize = sizeof(NOTIFYICONDATA); - } -}; - -template -class CTrayIconImpl -{ -private: - UINT WM_TRAYICON; - CNotifyIconData m_NID; - BOOL m_bInstalled; - UINT m_nDefaultItem; -public: - CTrayIconImpl() : m_bInstalled(FALSE), m_nDefaultItem(0) - { - WM_TRAYICON = RegisterWindowMessage(_T("WM_TRAYICON")); - } - - ~CTrayIconImpl() - { - RemoveIcon(); - } - - BOOL InstallIcon(TCHAR* strToolTip, HICON hIcon, UINT nID) - { - T* pT = static_cast(this); - m_NID.hWnd = pT->m_hWnd; - m_NID.uID = nID; - m_NID.hIcon = hIcon; - m_NID.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; - m_NID.uCallbackMessage = WM_TRAYICON; - _tcscpy(m_NID.szTip, strToolTip); - m_bInstalled = Shell_NotifyIcon(NIM_ADD, &m_NID); - - return m_bInstalled; - } - - BOOL RemoveIcon() - { - if (!m_bInstalled) return FALSE; - - m_NID.uFlags = 0; - return Shell_NotifyIcon(NIM_DELETE, &m_NID); - } - - BOOL SetToolTipText(TCHAR* strToolTipText) - { - if (strToolTipText == NULL) - return FALSE; - - m_NID.uFlags = NIF_TIP; - _tcscpy(m_NID.szTip, strToolTipText); - - return Shell_NotifyIcon(NIM_MODIFY, &m_NID); - } - - inline void SetDefaultItem(UINT nID) { m_nDefaultItem = nID; } - - BEGIN_MSG_MAP(CTrayIcon) - MESSAGE_HANDLER(WM_TRAYICON, OnTrayIcon) - END_MSG_MAP() - - LRESULT OnTrayIcon(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) - { - if (wParam != m_NID.uID) return 0; - - T* pT = static_cast(this); - - if (LOWORD(lParam) == WM_RBUTTONUP) - { - CMenu menu; - - if (!menu.LoadMenu(m_NID.uID)) - return 0; - - CMenuHandle submenu(menu.GetSubMenu(0)); - CPoint pos; - GetCursorPos(&pos); - - SetForegroundWindow(pT->m_hWnd); - - submenu.SetMenuDefaultItem(m_nDefaultItem); - submenu.TrackPopupMenu(TPM_LEFTALIGN, pos.x, pos.y, pT->m_hWnd); - - pT->PostMessage(WM_NULL); - menu.DestroyMenu(); - } else if (LOWORD(lParam) == WM_LBUTTONDBLCLK) - { - SetForegroundWindow(pT->m_hWnd); - - pT->PostMessage(WM_COMMAND, m_nDefaultItem, 0); - } - - return 0; - } -}; - -#endif /* TRAYICONIMPL_H */ - +#ifndef TRAYICONIMPL_H +#define TRAYICONIMPL_H + +#if _MSC_VER >= 1000 +#pragma once +#endif // _MSC_VER >= 1000 + +class CNotifyIconData : public NOTIFYICONDATA +{ +public: + CNotifyIconData() + { + ZeroMemory(this, sizeof(NOTIFYICONDATA)); + cbSize = sizeof(NOTIFYICONDATA); + } +}; + +template +class CTrayIconImpl +{ +private: + UINT WM_TRAYICON; + CNotifyIconData m_NID; + BOOL m_bInstalled; + UINT m_nDefaultItem; +public: + CTrayIconImpl() : m_bInstalled(FALSE), m_nDefaultItem(0) + { + WM_TRAYICON = RegisterWindowMessage(_T("WM_TRAYICON")); + } + + ~CTrayIconImpl() + { + RemoveIcon(); + } + + BOOL InstallIcon(TCHAR* strToolTip, HICON hIcon, UINT nID) + { + T* pT = static_cast(this); + m_NID.hWnd = pT->m_hWnd; + m_NID.uID = nID; + m_NID.hIcon = hIcon; + m_NID.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; + m_NID.uCallbackMessage = WM_TRAYICON; + _tcscpy(m_NID.szTip, strToolTip); + m_bInstalled = Shell_NotifyIcon(NIM_ADD, &m_NID); + + return m_bInstalled; + } + + BOOL RemoveIcon() + { + if (!m_bInstalled) return FALSE; + + m_NID.uFlags = 0; + return Shell_NotifyIcon(NIM_DELETE, &m_NID); + } + + BOOL SetToolTipText(TCHAR* strToolTipText) + { + if (strToolTipText == NULL) + return FALSE; + + m_NID.uFlags = NIF_TIP; + _tcscpy(m_NID.szTip, strToolTipText); + + return Shell_NotifyIcon(NIM_MODIFY, &m_NID); + } + + inline void SetDefaultItem(UINT nID) { m_nDefaultItem = nID; } + + BEGIN_MSG_MAP(CTrayIcon) + MESSAGE_HANDLER(WM_TRAYICON, OnTrayIcon) + END_MSG_MAP() + + LRESULT OnTrayIcon(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/) + { + if (wParam != m_NID.uID) return 0; + + T* pT = static_cast(this); + + if (LOWORD(lParam) == WM_RBUTTONUP) + { + CMenu menu; + + if (!menu.LoadMenu(m_NID.uID)) + return 0; + + CMenuHandle submenu(menu.GetSubMenu(0)); + CPoint pos; + GetCursorPos(&pos); + + SetForegroundWindow(pT->m_hWnd); + + submenu.SetMenuDefaultItem(m_nDefaultItem); + submenu.TrackPopupMenu(TPM_LEFTALIGN, pos.x, pos.y, pT->m_hWnd); + + pT->PostMessage(WM_NULL); + menu.DestroyMenu(); + } else if (LOWORD(lParam) == WM_LBUTTONDBLCLK) + { + SetForegroundWindow(pT->m_hWnd); + + pT->PostMessage(WM_COMMAND, m_nDefaultItem, 0); + } + + return 0; + } +}; + +#endif /* TRAYICONIMPL_H */ + diff --git a/applications/snowcrash/snowcrash/resource.h b/applications/snowcrash/snowcrash/resource.h index b8550136..4e49c0de 100644 --- a/applications/snowcrash/snowcrash/resource.h +++ b/applications/snowcrash/snowcrash/resource.h @@ -1,22 +1,22 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by snowcrash.rc -// -#define IDS_APP_TITLE 103 -#define IDM_ABOUT 104 -#define IDI_SNOWCRASH 107 -#define IDI_SMALL 108 -#define IDC_SNOWCRASH 109 -#define IDC_TRAY 109 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NO_MFC 1 -#define _APS_NEXT_RESOURCE_VALUE 129 -#define _APS_NEXT_COMMAND_VALUE 32772 -#define _APS_NEXT_CONTROL_VALUE 1000 -#define _APS_NEXT_SYMED_VALUE 110 -#endif -#endif +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by snowcrash.rc +// +#define IDS_APP_TITLE 103 +#define IDM_ABOUT 104 +#define IDI_SNOWCRASH 107 +#define IDI_SMALL 108 +#define IDC_SNOWCRASH 109 +#define IDC_TRAY 109 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NO_MFC 1 +#define _APS_NEXT_RESOURCE_VALUE 129 +#define _APS_NEXT_COMMAND_VALUE 32772 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 110 +#endif +#endif diff --git a/applications/snowcrash/snowcrash/snowcrash.cpp b/applications/snowcrash/snowcrash/snowcrash.cpp index a8ef7cb3..837aad90 100644 --- a/applications/snowcrash/snowcrash/snowcrash.cpp +++ b/applications/snowcrash/snowcrash/snowcrash.cpp @@ -1,62 +1,62 @@ -// snowcrash.cpp : main source file for snowcrash.exe -// - -#include "stdafx.h" - -#include "resource.h" - -#include "MainFrame.h" - -CAppModule _Module; - -int Run(LPTSTR /*lpstrCmdLine*/ = NULL, int nCmdShow = SW_SHOWDEFAULT) -{ - CMessageLoop theLoop; - _Module.AddMessageLoop(&theLoop); - - CMainFrame wndMain; - - if(wndMain.CreateEx() == NULL) - { - ATLTRACE(_T("Main window creation failed!\n")); - return 0; - } - - wndMain.ShowWindow(SW_HIDE); - - int nRet = theLoop.Run(); - - _Module.RemoveMessageLoop(); - return nRet; -} - -int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int nCmdShow) -{ -#ifdef ECHO - AllocConsole(); -#endif - - HRESULT hRes = ::CoInitialize(NULL); -// If you are running on NT 4.0 or higher you can use the following call instead to -// make the EXE free threaded. This means that calls come in on a random RPC thread. -// HRESULT hRes = ::CoInitializeEx(NULL, COINIT_MULTITHREADED); - ATLASSERT(SUCCEEDED(hRes)); - - // this resolves ATL window thunking problem when Microsoft Layer for Unicode (MSLU) is used - ::DefWindowProc(NULL, 0, 0, 0L); - - AtlInitCommonControls(ICC_BAR_CLASSES); // add flags to support other controls - - hRes = _Module.Init(NULL, hInstance); - ATLASSERT(SUCCEEDED(hRes)); - - int nRet = Run(lpstrCmdLine, nCmdShow); - - _Module.Term(); - ::CoUninitialize(); - -#ifdef ECHO - FreeConsole(); -#endif - return nRet; -} +// snowcrash.cpp : main source file for snowcrash.exe +// + +#include "stdafx.h" + +#include "resource.h" + +#include "MainFrame.h" + +CAppModule _Module; + +int Run(LPTSTR /*lpstrCmdLine*/ = NULL, int nCmdShow = SW_SHOWDEFAULT) +{ + CMessageLoop theLoop; + _Module.AddMessageLoop(&theLoop); + + CMainFrame wndMain; + + if(wndMain.CreateEx() == NULL) + { + ATLTRACE(_T("Main window creation failed!\n")); + return 0; + } + + wndMain.ShowWindow(SW_HIDE); + + int nRet = theLoop.Run(); + + _Module.RemoveMessageLoop(); + return nRet; +} + +int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int nCmdShow) +{ +#ifdef ECHO + AllocConsole(); +#endif + + HRESULT hRes = ::CoInitialize(NULL); +// If you are running on NT 4.0 or higher you can use the following call instead to +// make the EXE free threaded. This means that calls come in on a random RPC thread. +// HRESULT hRes = ::CoInitializeEx(NULL, COINIT_MULTITHREADED); + ATLASSERT(SUCCEEDED(hRes)); + + // this resolves ATL window thunking problem when Microsoft Layer for Unicode (MSLU) is used + ::DefWindowProc(NULL, 0, 0, 0L); + + AtlInitCommonControls(ICC_BAR_CLASSES); // add flags to support other controls + + hRes = _Module.Init(NULL, hInstance); + ATLASSERT(SUCCEEDED(hRes)); + + int nRet = Run(lpstrCmdLine, nCmdShow); + + _Module.Term(); + ::CoUninitialize(); + +#ifdef ECHO + FreeConsole(); +#endif + return nRet; +} diff --git a/applications/snowcrash/snowcrash/snowcrash.h b/applications/snowcrash/snowcrash/snowcrash.h index e60f2eb7..d00d47e7 100644 --- a/applications/snowcrash/snowcrash/snowcrash.h +++ b/applications/snowcrash/snowcrash/snowcrash.h @@ -1,3 +1,3 @@ -#pragma once - -#include "resource.h" +#pragma once + +#include "resource.h" diff --git a/applications/snowcrash/snowcrash/snowcrash.rc b/applications/snowcrash/snowcrash/snowcrash.rc index 8da52f75..0a2f0b7f 100644 --- a/applications/snowcrash/snowcrash/snowcrash.rc +++ b/applications/snowcrash/snowcrash/snowcrash.rc @@ -1,115 +1,115 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#define APSTUDIO_HIDDEN_SYMBOLS -#include "windows.h" -#undef APSTUDIO_HIDDEN_SYMBOLS -#include "atlres.h" -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -#ifdef _WIN32 -LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US -#pragma code_page(1252) -#endif //_WIN32 - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDI_SNOWCRASH ICON "snowcrash.ico" -IDI_SMALL ICON "small.ico" - -///////////////////////////////////////////////////////////////////////////// -// -// Menu -// - -IDC_TRAY MENU -BEGIN - POPUP "_POPUP_" - BEGIN - MENUITEM "E&xit", ID_APP_EXIT - END -END - - -///////////////////////////////////////////////////////////////////////////// -// -// Accelerator -// - -IDC_SNOWCRASH ACCELERATORS -BEGIN - "?", IDM_ABOUT, ASCII, ALT - "/", IDM_ABOUT, ASCII, ALT -END - - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#define APSTUDIO_HIDDEN_SYMBOLS\r\n" - "#include ""windows.h""\r\n" - "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n" - "#include ""atlres.h""\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// String Table -// - -STRINGTABLE -BEGIN - IDS_APP_TITLE "snowcrash" - IDC_SNOWCRASH "SNOWCRASH" -END - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#define APSTUDIO_HIDDEN_SYMBOLS +#include "windows.h" +#undef APSTUDIO_HIDDEN_SYMBOLS +#include "atlres.h" +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_SNOWCRASH ICON "snowcrash.ico" +IDI_SMALL ICON "small.ico" + +///////////////////////////////////////////////////////////////////////////// +// +// Menu +// + +IDC_TRAY MENU +BEGIN + POPUP "_POPUP_" + BEGIN + MENUITEM "E&xit", ID_APP_EXIT + END +END + + +///////////////////////////////////////////////////////////////////////////// +// +// Accelerator +// + +IDC_SNOWCRASH ACCELERATORS +BEGIN + "?", IDM_ABOUT, ASCII, ALT + "/", IDM_ABOUT, ASCII, ALT +END + + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#define APSTUDIO_HIDDEN_SYMBOLS\r\n" + "#include ""windows.h""\r\n" + "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n" + "#include ""atlres.h""\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE +BEGIN + IDS_APP_TITLE "snowcrash" + IDC_SNOWCRASH "SNOWCRASH" +END + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/applications/snowcrash/snowcrash/snowcrash.vcproj b/applications/snowcrash/snowcrash/snowcrash.vcproj index 7cb1036d..c32523ae 100644 --- a/applications/snowcrash/snowcrash/snowcrash.vcproj +++ b/applications/snowcrash/snowcrash/snowcrash.vcproj @@ -1,181 +1,181 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/applications/snowcrash/snowcrash/stdafx.cpp b/applications/snowcrash/snowcrash/stdafx.cpp index 3d483850..b62bf170 100644 --- a/applications/snowcrash/snowcrash/stdafx.cpp +++ b/applications/snowcrash/snowcrash/stdafx.cpp @@ -1,32 +1,32 @@ -// stdafx.cpp : source file that includes just the standard includes -// snowcrash.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - -#if (_ATL_VER < 0x0700) -#include -#endif //(_ATL_VER < 0x0700) - -#ifdef ECHO -void dprintf(char *format, ...) -{ - LPSTR pBuffer = new TCHAR[8192]; - - if (pBuffer != NULL) - { - va_list args; - DWORD dwWrote; - - va_start(args, format); - _vsnprintf(pBuffer, 8192, format, args); - va_end(args); - - WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), pBuffer, (DWORD)strlen(pBuffer), &dwWrote, NULL); - - delete [] pBuffer; - } -} -#else -#define dprintf +// stdafx.cpp : source file that includes just the standard includes +// snowcrash.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + +#if (_ATL_VER < 0x0700) +#include +#endif //(_ATL_VER < 0x0700) + +#ifdef ECHO +void dprintf(char *format, ...) +{ + LPSTR pBuffer = new TCHAR[8192]; + + if (pBuffer != NULL) + { + va_list args; + DWORD dwWrote; + + va_start(args, format); + _vsnprintf(pBuffer, 8192, format, args); + va_end(args); + + WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), pBuffer, (DWORD)strlen(pBuffer), &dwWrote, NULL); + + delete [] pBuffer; + } +} +#else +#define dprintf #endif \ No newline at end of file diff --git a/applications/snowcrash/snowcrash/stdafx.h b/applications/snowcrash/snowcrash/stdafx.h index 4bb7563f..c562b18a 100644 --- a/applications/snowcrash/snowcrash/stdafx.h +++ b/applications/snowcrash/snowcrash/stdafx.h @@ -1,35 +1,35 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#pragma once - - -// Change these values to use different versions -#define WINVER 0x0400 -//#define _WIN32_WINNT 0x0400 - -#include -#include -#include - -extern CAppModule _Module; - -#include -#include -#include -#include -#include -#include -#include "../snowflake/snowflake.h" - -#ifdef _DEBUG -#define ECHO -#endif - -#ifdef ECHO -void dprintf(char *format, ...); -#else -#define dprintf -#endif +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#pragma once + + +// Change these values to use different versions +#define WINVER 0x0400 +//#define _WIN32_WINNT 0x0400 + +#include +#include +#include + +extern CAppModule _Module; + +#include +#include +#include +#include +#include +#include +#include "../snowflake/snowflake.h" + +#ifdef _DEBUG +#define ECHO +#endif + +#ifdef ECHO +void dprintf(char *format, ...); +#else +#define dprintf +#endif diff --git a/applications/snowcrash/snowflake/Block.cpp b/applications/snowcrash/snowflake/Block.cpp index 0c2dea87..9f82a21b 100644 --- a/applications/snowcrash/snowflake/Block.cpp +++ b/applications/snowcrash/snowflake/Block.cpp @@ -1,131 +1,131 @@ -#include "StdAfx.h" -#include ".\Block.h" -#include ".\keywords.h" - -CBlock::CBlock(void) -{ - m_lpVars = NULL; - - m_lpPrev = NULL; - m_lpNext = NULL; -} - -CBlock::~CBlock(void) -{ -} - -void CBlock::FreeVars(void) -{ - CVar *var = m_lpVars; - - while (var) - { - if (var->m_lpNext) - { - var = var->m_lpNext; - - if (var->m_lpPrev) - SAFE_DELETE(var->m_lpPrev); - } - else - SAFE_DELETE(var); - } - - m_lpVars = NULL; -} - -bool CBlock::AddVar(CVar *lpVar) -{ - CVar *var = NULL; - - if (m_lpVars) - { - var = m_lpVars; - - while (var->m_lpNext) - var = var->m_lpNext; - - var->m_lpNext = lpVar; - - if (!var->m_lpNext) return false; - - var->m_lpNext->m_lpNext = NULL; - var->m_lpNext->m_lpPrev = var; - - return true; - } - else - { - var = lpVar; - - if (!var) return false; - - m_lpVars = var; - m_lpVars->m_lpNext = NULL; - m_lpVars->m_lpPrev = NULL; - - return true; - } - - return false; -} - -CVar *CBlock::FindVar(char *lpszVar) -{ - CVar *var= m_lpVars; - - while (var) - { - if (var->m_lpszVar && !stricmp(lpszVar, var->m_lpszVar)) - return var; - - var = var->m_lpNext; - } - - return NULL; -} - -int CBlock::CountVar(char *lpszVar) -{ - CVar *var= m_lpVars; - int nCount = 0; - - while (var) - { - if (var->m_lpszVar && !stricmp(lpszVar, var->m_lpszVar)) - nCount++; - - var = var->m_lpNext; - } - - return nCount; -} - -void CBlock::Dump(void) -{ - CVar *var = m_lpVars; - - while (var) - { - var->Dump(); - var = var->m_lpNext; - } -} - -int CBlock::Pack(LPBYTE lpData) -{ - int nTotalWrote = 0; - int nWrote = 0; - LPBYTE lpPtr = lpData; - CVar *var = m_lpVars; - - while (var) - { - nWrote = var->Pack(lpPtr); - lpPtr += nWrote; - nTotalWrote += nWrote; - var = var->m_lpNext; - } - - return nTotalWrote; +#include "StdAfx.h" +#include ".\Block.h" +#include ".\keywords.h" + +CBlock::CBlock(void) +{ + m_lpVars = NULL; + + m_lpPrev = NULL; + m_lpNext = NULL; +} + +CBlock::~CBlock(void) +{ +} + +void CBlock::FreeVars(void) +{ + CVar *var = m_lpVars; + + while (var) + { + if (var->m_lpNext) + { + var = var->m_lpNext; + + if (var->m_lpPrev) + SAFE_DELETE(var->m_lpPrev); + } + else + SAFE_DELETE(var); + } + + m_lpVars = NULL; +} + +bool CBlock::AddVar(CVar *lpVar) +{ + CVar *var = NULL; + + if (m_lpVars) + { + var = m_lpVars; + + while (var->m_lpNext) + var = var->m_lpNext; + + var->m_lpNext = lpVar; + + if (!var->m_lpNext) return false; + + var->m_lpNext->m_lpNext = NULL; + var->m_lpNext->m_lpPrev = var; + + return true; + } + else + { + var = lpVar; + + if (!var) return false; + + m_lpVars = var; + m_lpVars->m_lpNext = NULL; + m_lpVars->m_lpPrev = NULL; + + return true; + } + + return false; +} + +CVar *CBlock::FindVar(char *lpszVar) +{ + CVar *var= m_lpVars; + + while (var) + { + if (var->m_lpszVar && !stricmp(lpszVar, var->m_lpszVar)) + return var; + + var = var->m_lpNext; + } + + return NULL; +} + +int CBlock::CountVar(char *lpszVar) +{ + CVar *var= m_lpVars; + int nCount = 0; + + while (var) + { + if (var->m_lpszVar && !stricmp(lpszVar, var->m_lpszVar)) + nCount++; + + var = var->m_lpNext; + } + + return nCount; +} + +void CBlock::Dump(void) +{ + CVar *var = m_lpVars; + + while (var) + { + var->Dump(); + var = var->m_lpNext; + } +} + +int CBlock::Pack(LPBYTE lpData) +{ + int nTotalWrote = 0; + int nWrote = 0; + LPBYTE lpPtr = lpData; + CVar *var = m_lpVars; + + while (var) + { + nWrote = var->Pack(lpPtr); + lpPtr += nWrote; + nTotalWrote += nWrote; + var = var->m_lpNext; + } + + return nTotalWrote; } \ No newline at end of file diff --git a/applications/snowcrash/snowflake/Block.h b/applications/snowcrash/snowflake/Block.h index c79fe029..1d1cd9c1 100644 --- a/applications/snowcrash/snowflake/Block.h +++ b/applications/snowcrash/snowflake/Block.h @@ -1,24 +1,24 @@ -#pragma once - -#include ".\Var.h" - -class CBlock -{ -public: - CBlock(void); - ~CBlock(void); - - BYTE cItems; - - CVar *m_lpVars; - - CBlock *m_lpNext; - CBlock *m_lpPrev; - - void FreeVars(void); - bool AddVar(CVar *lpVar); - CVar *FindVar(char *lpszVar); - int CountVar(char *lpszVar); - void Dump(void); - int Pack(LPBYTE lpData); -}; +#pragma once + +#include ".\Var.h" + +class CBlock +{ +public: + CBlock(void); + ~CBlock(void); + + BYTE cItems; + + CVar *m_lpVars; + + CBlock *m_lpNext; + CBlock *m_lpPrev; + + void FreeVars(void); + bool AddVar(CVar *lpVar); + CVar *FindVar(char *lpszVar); + int CountVar(char *lpszVar); + void Dump(void); + int Pack(LPBYTE lpData); +}; diff --git a/applications/snowcrash/snowflake/BlockList.cpp b/applications/snowcrash/snowflake/BlockList.cpp index f69b618b..bf4fe2ee 100644 --- a/applications/snowcrash/snowflake/BlockList.cpp +++ b/applications/snowcrash/snowflake/BlockList.cpp @@ -1,175 +1,175 @@ -#include "StdAfx.h" -#include ".\Blocklist.h" -#include ".\keywords.h" - -CBlockList::CBlockList(void) -{ - int m_nType = 0; - m_lpBlocks = NULL; - m_lpszBlock = NULL; - - m_lpPrev = NULL; - m_lpNext = NULL; -} - -CBlockList::~CBlockList(void) -{ - SAFE_FREE(m_lpszBlock); -} - -void CBlockList::FreeBlocks(void) -{ - CBlock *block = m_lpBlocks; - - while (block) - { - if (block->m_lpNext) - { - block = block->m_lpNext; - - if (block->m_lpPrev) - SAFE_DELETE(block->m_lpPrev); - } - else - SAFE_DELETE(block); - } - - m_lpBlocks = NULL; -} - -bool CBlockList::AddBlock(CBlock *lpBlock) -{ - CBlock *block = NULL; - - if (m_lpBlocks) - { - block = m_lpBlocks; - - while (block->m_lpNext) - block = block->m_lpNext; - - block->m_lpNext = lpBlock; - - if (!block->m_lpNext) return false; - - block->m_lpNext->m_lpNext = NULL; - block->m_lpNext->m_lpPrev = block; - - return true; - } - else - { - block = lpBlock; - - if (!block) return false; - - m_lpBlocks = block; - m_lpBlocks->m_lpNext = NULL; - m_lpBlocks->m_lpPrev = NULL; - - return true; - } - - return false; -} - - -void CBlockList::SetBlock(char *lpszBlock) -{ - if (lpszBlock) - { - size_t stLen = strlen(lpszBlock); - - if (stLen > 0) - { - SAFE_FREE(m_lpszBlock); - m_lpszBlock = (char *)malloc(stLen + 1); - - if (m_lpszBlock) - { - strncpy(m_lpszBlock, lpszBlock, stLen); - m_lpszBlock[stLen] = '\0'; - } - } - } -} - -void CBlockList::SetType(int nType) -{ - m_nType = nType; -} - -CBlock *CBlockList::GetBlock(int nIndex) -{ - CBlock *block = m_lpBlocks; - int i = 0; - - while (block) - { - if (i == nIndex) - return block; - - block = block->m_lpNext; - i++; - } - - return NULL; -} - -int CBlockList::CountBlock(void) -{ - CBlock *block = m_lpBlocks; - int nCount = 0; - - while (block) - { - nCount++; - block = block->m_lpNext; - } - - return nCount; -} - -void CBlockList::Dump(void) -{ - if (m_lpszBlock) - dprintf("%s\n", m_lpszBlock); - - CBlock *block = m_lpBlocks; - - while (block) - { - block->Dump(); - block = block->m_lpNext; - } -} - - -int CBlockList::Pack(LPBYTE lpData) -{ - int nTotalWrote = 0; - int nWrote = 0; - LPBYTE lpPtr = lpData; - CBlock *block = m_lpBlocks; - - if (m_nType == LLTYPE_VARIABLE) - { - BYTE cItems; - - cItems = CountBlock(); - - memcpy(lpPtr, &cItems, sizeof(cItems)); - nTotalWrote = sizeof(cItems); - lpPtr += sizeof(cItems); - } - - while (block) - { - nWrote = block->Pack(lpPtr); - lpPtr += nWrote; - nTotalWrote += nWrote; - block = block->m_lpNext; - } - - return nTotalWrote; +#include "StdAfx.h" +#include ".\Blocklist.h" +#include ".\keywords.h" + +CBlockList::CBlockList(void) +{ + int m_nType = 0; + m_lpBlocks = NULL; + m_lpszBlock = NULL; + + m_lpPrev = NULL; + m_lpNext = NULL; +} + +CBlockList::~CBlockList(void) +{ + SAFE_FREE(m_lpszBlock); +} + +void CBlockList::FreeBlocks(void) +{ + CBlock *block = m_lpBlocks; + + while (block) + { + if (block->m_lpNext) + { + block = block->m_lpNext; + + if (block->m_lpPrev) + SAFE_DELETE(block->m_lpPrev); + } + else + SAFE_DELETE(block); + } + + m_lpBlocks = NULL; +} + +bool CBlockList::AddBlock(CBlock *lpBlock) +{ + CBlock *block = NULL; + + if (m_lpBlocks) + { + block = m_lpBlocks; + + while (block->m_lpNext) + block = block->m_lpNext; + + block->m_lpNext = lpBlock; + + if (!block->m_lpNext) return false; + + block->m_lpNext->m_lpNext = NULL; + block->m_lpNext->m_lpPrev = block; + + return true; + } + else + { + block = lpBlock; + + if (!block) return false; + + m_lpBlocks = block; + m_lpBlocks->m_lpNext = NULL; + m_lpBlocks->m_lpPrev = NULL; + + return true; + } + + return false; +} + + +void CBlockList::SetBlock(char *lpszBlock) +{ + if (lpszBlock) + { + size_t stLen = strlen(lpszBlock); + + if (stLen > 0) + { + SAFE_FREE(m_lpszBlock); + m_lpszBlock = (char *)malloc(stLen + 1); + + if (m_lpszBlock) + { + strncpy(m_lpszBlock, lpszBlock, stLen); + m_lpszBlock[stLen] = '\0'; + } + } + } +} + +void CBlockList::SetType(int nType) +{ + m_nType = nType; +} + +CBlock *CBlockList::GetBlock(int nIndex) +{ + CBlock *block = m_lpBlocks; + int i = 0; + + while (block) + { + if (i == nIndex) + return block; + + block = block->m_lpNext; + i++; + } + + return NULL; +} + +int CBlockList::CountBlock(void) +{ + CBlock *block = m_lpBlocks; + int nCount = 0; + + while (block) + { + nCount++; + block = block->m_lpNext; + } + + return nCount; +} + +void CBlockList::Dump(void) +{ + if (m_lpszBlock) + dprintf("%s\n", m_lpszBlock); + + CBlock *block = m_lpBlocks; + + while (block) + { + block->Dump(); + block = block->m_lpNext; + } +} + + +int CBlockList::Pack(LPBYTE lpData) +{ + int nTotalWrote = 0; + int nWrote = 0; + LPBYTE lpPtr = lpData; + CBlock *block = m_lpBlocks; + + if (m_nType == LLTYPE_VARIABLE) + { + BYTE cItems; + + cItems = CountBlock(); + + memcpy(lpPtr, &cItems, sizeof(cItems)); + nTotalWrote = sizeof(cItems); + lpPtr += sizeof(cItems); + } + + while (block) + { + nWrote = block->Pack(lpPtr); + lpPtr += nWrote; + nTotalWrote += nWrote; + block = block->m_lpNext; + } + + return nTotalWrote; } \ No newline at end of file diff --git a/applications/snowcrash/snowflake/BlockList.h b/applications/snowcrash/snowflake/BlockList.h index 21414874..b6f6813d 100644 --- a/applications/snowcrash/snowflake/BlockList.h +++ b/applications/snowcrash/snowflake/BlockList.h @@ -1,28 +1,28 @@ -#pragma once - -#include ".\Block.h" - -class CBlockList -{ -public: - CBlockList(void); - ~CBlockList(void); - - CBlock *m_lpBlocks; - char *m_lpszBlock; - int m_nType; - BYTE cItems; - - CBlockList *m_lpNext; - CBlockList *m_lpPrev; - - void FreeBlocks(void); - bool AddBlock(CBlock *lpBlock); - CBlock *GetBlock(int nIndex = 0); - int CountBlock(void); - void Dump(void); - int Pack(LPBYTE lpData); - void SetBlock(char *lpszBlock); - void SetType(int nType); -// bool GetString(char *lpszBlock, int nIndex, char *lpszVar, char &lpszStr); -}; +#pragma once + +#include ".\Block.h" + +class CBlockList +{ +public: + CBlockList(void); + ~CBlockList(void); + + CBlock *m_lpBlocks; + char *m_lpszBlock; + int m_nType; + BYTE cItems; + + CBlockList *m_lpNext; + CBlockList *m_lpPrev; + + void FreeBlocks(void); + bool AddBlock(CBlock *lpBlock); + CBlock *GetBlock(int nIndex = 0); + int CountBlock(void); + void Dump(void); + int Pack(LPBYTE lpData); + void SetBlock(char *lpszBlock); + void SetType(int nType); +// bool GetString(char *lpszBlock, int nIndex, char *lpszVar, char &lpszStr); +}; diff --git a/applications/snowcrash/snowflake/Config.cpp b/applications/snowcrash/snowflake/Config.cpp index 2be2e8f9..4a68eaad 100644 --- a/applications/snowcrash/snowflake/Config.cpp +++ b/applications/snowcrash/snowflake/Config.cpp @@ -1,73 +1,73 @@ -#include "StdAfx.h" -#include ".\Config.h" - -CConfig::CConfig() -{ - LoadConfig(); -} - -CConfig::~CConfig() -{ - -} - -void CConfig::LoadConfig() -{ - TCHAR szItem[1024]; - TCHAR lpszPath[MAX_PATH] = {0}; - - HKEY hKey; - if (RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Linden Research, Inc.\\SecondLife", &hKey) == ERROR_SUCCESS) - { - DWORD dwType = REG_SZ, dwLength = sizeof(szItem); - if (RegQueryValueEx(hKey, NULL, NULL, &dwType, (LPBYTE)&szItem, &dwLength) == ERROR_SUCCESS) - { - ::PathCombine(lpszPath, szItem, "app_settings\\comm.dat"); - m_pCommDatPath = lpszPath; - - ::PathCombine(lpszPath, szItem, "app_settings\\message_template.msg"); - m_pMessageTemplatePath = lpszPath; - - ::PathCombine(lpszPath, szItem, "snowcrash.txt"); - m_pSnowcrashTxtPath = lpszPath; - } - RegCloseKey(hKey); - } -} - -void CConfig::GetConfigString(LPSTR lpSection, LPSTR lpSubKey, LPSTR lpBuffer, UINT *len, LPSTR lpDefault) -{ - HKEY hKey; - char szPath[256]; - - strncpy(lpBuffer, lpDefault, *len); - wsprintf(szPath, "Software\\thirty4 interactive\\Snowcrash\\%s", lpSection); - if (RegOpenKeyEx(HKEY_CURRENT_USER, szPath, 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) - { - RegQueryValueEx(hKey, lpSubKey, NULL, NULL, (BYTE *)lpBuffer, (unsigned long *)len); - RegCloseKey(hKey); - } -} - -BOOL CConfig::GetConfigBool(LPSTR lpSection, LPSTR lpSubKey, BOOL bDefault) -{ - char szBuffer[256]; - UINT len; - len = sizeof(szBuffer); - ZeroMemory(&szBuffer, sizeof(szBuffer)); - GetConfigString(lpSection, lpSubKey, szBuffer, &len, bDefault==TRUE?"Yes":"No"); - return stricmp(szBuffer, "Yes")==0?TRUE:FALSE; -} - -unsigned int CConfig::GetConfigInt(LPSTR lpSection, LPSTR lpSubKey, UINT iDefault) -{ - char szBuffer[256], szDefault[20]; - UINT len; - len = sizeof(szBuffer); - ZeroMemory(&szBuffer, sizeof(szBuffer)); - ZeroMemory(&szDefault, sizeof(szDefault)); - wsprintf(szDefault, "%d", iDefault); - GetConfigString(lpSection, lpSubKey, szBuffer, &len, szDefault); - - return atoi(szBuffer); -} +#include "StdAfx.h" +#include ".\Config.h" + +CConfig::CConfig() +{ + LoadConfig(); +} + +CConfig::~CConfig() +{ + +} + +void CConfig::LoadConfig() +{ + TCHAR szItem[1024]; + TCHAR lpszPath[MAX_PATH] = {0}; + + HKEY hKey; + if (RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Linden Research, Inc.\\SecondLife", &hKey) == ERROR_SUCCESS) + { + DWORD dwType = REG_SZ, dwLength = sizeof(szItem); + if (RegQueryValueEx(hKey, NULL, NULL, &dwType, (LPBYTE)&szItem, &dwLength) == ERROR_SUCCESS) + { + ::PathCombine(lpszPath, szItem, "app_settings\\comm.dat"); + m_pCommDatPath = lpszPath; + + ::PathCombine(lpszPath, szItem, "app_settings\\message_template.msg"); + m_pMessageTemplatePath = lpszPath; + + ::PathCombine(lpszPath, szItem, "snowcrash.txt"); + m_pSnowcrashTxtPath = lpszPath; + } + RegCloseKey(hKey); + } +} + +void CConfig::GetConfigString(LPSTR lpSection, LPSTR lpSubKey, LPSTR lpBuffer, UINT *len, LPSTR lpDefault) +{ + HKEY hKey; + char szPath[256]; + + strncpy(lpBuffer, lpDefault, *len); + wsprintf(szPath, "Software\\thirty4 interactive\\Snowcrash\\%s", lpSection); + if (RegOpenKeyEx(HKEY_CURRENT_USER, szPath, 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS) + { + RegQueryValueEx(hKey, lpSubKey, NULL, NULL, (BYTE *)lpBuffer, (unsigned long *)len); + RegCloseKey(hKey); + } +} + +BOOL CConfig::GetConfigBool(LPSTR lpSection, LPSTR lpSubKey, BOOL bDefault) +{ + char szBuffer[256]; + UINT len; + len = sizeof(szBuffer); + ZeroMemory(&szBuffer, sizeof(szBuffer)); + GetConfigString(lpSection, lpSubKey, szBuffer, &len, bDefault==TRUE?"Yes":"No"); + return stricmp(szBuffer, "Yes")==0?TRUE:FALSE; +} + +unsigned int CConfig::GetConfigInt(LPSTR lpSection, LPSTR lpSubKey, UINT iDefault) +{ + char szBuffer[256], szDefault[20]; + UINT len; + len = sizeof(szBuffer); + ZeroMemory(&szBuffer, sizeof(szBuffer)); + ZeroMemory(&szDefault, sizeof(szDefault)); + wsprintf(szDefault, "%d", iDefault); + GetConfigString(lpSection, lpSubKey, szBuffer, &len, szDefault); + + return atoi(szBuffer); +} diff --git a/applications/snowcrash/snowflake/Config.h b/applications/snowcrash/snowflake/Config.h index 4199bb72..1cc25722 100644 --- a/applications/snowcrash/snowflake/Config.h +++ b/applications/snowcrash/snowflake/Config.h @@ -1,17 +1,17 @@ -#pragma once - -class CConfig -{ -public: - CString m_pCommDatPath; - CString m_pMessageTemplatePath; - CString m_pSnowcrashTxtPath; - - unsigned int GetConfigInt(LPSTR lpSection, LPSTR lpSubKey, UINT iDefault); - BOOL GetConfigBool(LPSTR lpSection, LPSTR lpSubKey, BOOL bDefault); - void GetConfigString(LPSTR lpSection, LPSTR lpSubKey, LPSTR lpBuffer, UINT *len, LPSTR lpDefault); - void LoadConfig(); - CConfig(); - virtual ~CConfig(); - -}; +#pragma once + +class CConfig +{ +public: + CString m_pCommDatPath; + CString m_pMessageTemplatePath; + CString m_pSnowcrashTxtPath; + + unsigned int GetConfigInt(LPSTR lpSection, LPSTR lpSubKey, UINT iDefault); + BOOL GetConfigBool(LPSTR lpSection, LPSTR lpSubKey, BOOL bDefault); + void GetConfigString(LPSTR lpSection, LPSTR lpSubKey, LPSTR lpBuffer, UINT *len, LPSTR lpDefault); + void LoadConfig(); + CConfig(); + virtual ~CConfig(); + +}; diff --git a/applications/snowcrash/snowflake/MainFrame.cpp b/applications/snowcrash/snowflake/MainFrame.cpp index 0c4d942d..bf3ed14e 100644 --- a/applications/snowcrash/snowflake/MainFrame.cpp +++ b/applications/snowcrash/snowflake/MainFrame.cpp @@ -1,119 +1,119 @@ -#include "StdAfx.h" -#include ".\MainFrame.h" - -CMainFrame::CMainFrame() -{ -} - -CMainFrame::~CMainFrame() -{ -} - -BOOL CMainFrame::PreTranslateMessage(MSG* pMsg) -{ - if(CFrameWindowImpl::PreTranslateMessage(pMsg)) - return TRUE; - - return FALSE; -} - -BOOL CMainFrame::OnIdle() -{ - dprintf(_T("idle\n")); - return FALSE; -} - -LRESULT CMainFrame::OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) -{ - LRESULT lResult = baseClass::DefWindowProc(); - - bHandled = TRUE; - - Initialize(); - - return lResult; -} - -BOOL CMainFrame::SubclassWindow(HWND hwnd) -{ - dprintf(_T("Subclassing %08x\n"), hwnd); - - if (baseClass::SubclassWindow(hwnd)) - { - Initialize(); - return TRUE; - } - - return FALSE; -} - -HWND CMainFrame::UnsubclassWindow(BOOL bForce) -{ - HWND hwnd = baseClass::UnsubclassWindow(bForce); - dprintf(_T("Unsubclassing %08x\n"), hwnd); - UnpatchWnds(); - - return hwnd; -} - -BOOL CMainFrame::Initialize() -{ - if (!PatchWnds()) - return FALSE; - - return TRUE; -} - -LRESULT CMainFrame::OnParentNotify(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled) -{ - switch(LOWORD(wParam)) - { - case WM_CREATE: - { - PatchWnds(); - } - break; - } - - return 0; -} - -LRESULT CMainFrame::OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) -{ - PostQuitMessage(0); - - return 0; -} - -BOOL CMainFrame::PatchWnds() -{ - return TRUE; -} - -void CMainFrame::UnpatchWnds() -{ -} - -LRESULT CMainFrame::OnWindowPosChanging(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled) -{ - LRESULT lResult = baseClass::DefWindowProc(); - return lResult; -} - -LRESULT CMainFrame::OnWindowPosChanged(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled) -{ - LRESULT lResult = baseClass::DefWindowProc(); - return lResult; -} - -LRESULT CMainFrame::OnSizing(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled) -{ - LRESULT lResult = baseClass::DefWindowProc(); - return lResult; -} - -LRESULT CMainFrame::OnSize(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled) -{ - LRESULT lResult = baseClass::DefWindowProc(); - return lResult; +#include "StdAfx.h" +#include ".\MainFrame.h" + +CMainFrame::CMainFrame() +{ +} + +CMainFrame::~CMainFrame() +{ +} + +BOOL CMainFrame::PreTranslateMessage(MSG* pMsg) +{ + if(CFrameWindowImpl::PreTranslateMessage(pMsg)) + return TRUE; + + return FALSE; +} + +BOOL CMainFrame::OnIdle() +{ + dprintf(_T("idle\n")); + return FALSE; +} + +LRESULT CMainFrame::OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) +{ + LRESULT lResult = baseClass::DefWindowProc(); + + bHandled = TRUE; + + Initialize(); + + return lResult; +} + +BOOL CMainFrame::SubclassWindow(HWND hwnd) +{ + dprintf(_T("Subclassing %08x\n"), hwnd); + + if (baseClass::SubclassWindow(hwnd)) + { + Initialize(); + return TRUE; + } + + return FALSE; +} + +HWND CMainFrame::UnsubclassWindow(BOOL bForce) +{ + HWND hwnd = baseClass::UnsubclassWindow(bForce); + dprintf(_T("Unsubclassing %08x\n"), hwnd); + UnpatchWnds(); + + return hwnd; +} + +BOOL CMainFrame::Initialize() +{ + if (!PatchWnds()) + return FALSE; + + return TRUE; +} + +LRESULT CMainFrame::OnParentNotify(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled) +{ + switch(LOWORD(wParam)) + { + case WM_CREATE: + { + PatchWnds(); + } + break; + } + + return 0; +} + +LRESULT CMainFrame::OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) +{ + PostQuitMessage(0); + + return 0; +} + +BOOL CMainFrame::PatchWnds() +{ + return TRUE; +} + +void CMainFrame::UnpatchWnds() +{ +} + +LRESULT CMainFrame::OnWindowPosChanging(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled) +{ + LRESULT lResult = baseClass::DefWindowProc(); + return lResult; +} + +LRESULT CMainFrame::OnWindowPosChanged(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled) +{ + LRESULT lResult = baseClass::DefWindowProc(); + return lResult; +} + +LRESULT CMainFrame::OnSizing(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled) +{ + LRESULT lResult = baseClass::DefWindowProc(); + return lResult; +} + +LRESULT CMainFrame::OnSize(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled) +{ + LRESULT lResult = baseClass::DefWindowProc(); + return lResult; } \ No newline at end of file diff --git a/applications/snowcrash/snowflake/MainFrame.h b/applications/snowcrash/snowflake/MainFrame.h index 1157bd78..8e71481b 100644 --- a/applications/snowcrash/snowflake/MainFrame.h +++ b/applications/snowcrash/snowflake/MainFrame.h @@ -1,47 +1,47 @@ -#pragma once - -class CMainFrame : public CFrameWindowImpl, - public CMessageFilter, public CIdleHandler -{ - typedef CMainFrame thisClass; - typedef CFrameWindowImpl baseClass; -public: - CMainFrame(); - ~CMainFrame(); - - virtual BOOL PreTranslateMessage(MSG* pMsg); - virtual BOOL OnIdle(); - - BEGIN_MSG_MAP(thisClass) -// MESSAGE_HANDLER(WM_CREATE, OnCreate) -// MESSAGE_HANDLER(WM_DESTROY, OnDestroy) -// MESSAGE_HANDLER(WM_PARENTNOTIFY, OnParentNotify) -// MESSAGE_HANDLER(WM_WINDOWPOSCHANGING, OnWindowPosChanging) -// MESSAGE_HANDLER(WM_WINDOWPOSCHANGED, OnWindowPosChanged) -// MESSAGE_HANDLER(WM_SIZING, OnSizing) -// MESSAGE_HANDLER(WM_SIZE, OnSize) - - CHAIN_MSG_MAP(CFrameWindowImpl) - END_MSG_MAP() - - // Handler prototypes (uncomment arguments if needed): -// LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) -// LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) -// LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/) - - LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); - LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); - LRESULT OnParentNotify(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); - LRESULT OnWindowPosChanging(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); - LRESULT OnWindowPosChanged(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); - LRESULT OnSizing(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); - LRESULT OnSize(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); - - BOOL SubclassWindow(HWND hwnd); - HWND UnsubclassWindow(BOOL bForce); - -protected: - BOOL Initialize(); - BOOL PatchWnds(); - void UnpatchWnds(); -}; +#pragma once + +class CMainFrame : public CFrameWindowImpl, + public CMessageFilter, public CIdleHandler +{ + typedef CMainFrame thisClass; + typedef CFrameWindowImpl baseClass; +public: + CMainFrame(); + ~CMainFrame(); + + virtual BOOL PreTranslateMessage(MSG* pMsg); + virtual BOOL OnIdle(); + + BEGIN_MSG_MAP(thisClass) +// MESSAGE_HANDLER(WM_CREATE, OnCreate) +// MESSAGE_HANDLER(WM_DESTROY, OnDestroy) +// MESSAGE_HANDLER(WM_PARENTNOTIFY, OnParentNotify) +// MESSAGE_HANDLER(WM_WINDOWPOSCHANGING, OnWindowPosChanging) +// MESSAGE_HANDLER(WM_WINDOWPOSCHANGED, OnWindowPosChanged) +// MESSAGE_HANDLER(WM_SIZING, OnSizing) +// MESSAGE_HANDLER(WM_SIZE, OnSize) + + CHAIN_MSG_MAP(CFrameWindowImpl) + END_MSG_MAP() + + // Handler prototypes (uncomment arguments if needed): +// LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) +// LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) +// LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/) + + LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); + LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); + LRESULT OnParentNotify(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); + LRESULT OnWindowPosChanging(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); + LRESULT OnWindowPosChanged(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); + LRESULT OnSizing(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); + LRESULT OnSize(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); + + BOOL SubclassWindow(HWND hwnd); + HWND UnsubclassWindow(BOOL bForce); + +protected: + BOOL Initialize(); + BOOL PatchWnds(); + void UnpatchWnds(); +}; diff --git a/applications/snowcrash/snowflake/Message.cpp b/applications/snowcrash/snowflake/Message.cpp index 3de532a8..d228560e 100644 --- a/applications/snowcrash/snowflake/Message.cpp +++ b/applications/snowcrash/snowflake/Message.cpp @@ -1,218 +1,218 @@ -#include "StdAfx.h" -#include ".\Message.h" - -CMessage::CMessage(void) -{ - m_lpBlocks = NULL; - m_lpszCommand = NULL; -} - -CMessage::~CMessage(void) -{ - FreeBlocks(); - SAFE_FREE(m_lpszCommand); -} - -void CMessage::FreeBlocks(void) -{ - CBlockList *blocks = m_lpBlocks; - - while (blocks) - { - if (blocks->m_lpNext) - { - blocks = blocks->m_lpNext; - - if (blocks->m_lpPrev) - SAFE_DELETE(blocks->m_lpPrev); - } - else - SAFE_DELETE(blocks); - } - - m_lpBlocks = NULL; -} - -bool CMessage::AddBlock(char *lpszBlock, int nType, CBlock *lpBlock) -{ - CBlockList *blocks = FindBlock(lpszBlock); - - if (blocks) - { - return blocks->AddBlock(lpBlock); - } - else - { - if (m_lpBlocks) - { - blocks = m_lpBlocks; - - while (blocks->m_lpNext) - blocks = blocks->m_lpNext; - - blocks->m_lpNext = new CBlockList; - - if (!blocks->m_lpNext) return false; - - blocks->m_lpNext->m_lpNext = NULL; - blocks->m_lpNext->m_lpPrev = blocks; - blocks->m_lpNext->SetBlock(lpszBlock); - blocks->m_lpNext->SetType(nType); - blocks->m_lpNext->AddBlock(lpBlock); - - return true; - } - else - { - blocks = new CBlockList; - - if (!blocks) return false; - - m_lpBlocks = blocks; - m_lpBlocks->m_lpNext = NULL; - m_lpBlocks->m_lpPrev = NULL; - m_lpBlocks->SetBlock(lpszBlock); - m_lpBlocks->SetType(nType); - m_lpBlocks->AddBlock(lpBlock); - - return true; - } - - return false; - } -} - -CBlock *CMessage::GetBlock(char *lpszBlock, int nIndex) -{ - CBlockList *blocks = m_lpBlocks; - - while (blocks) - { - if (blocks->m_lpszBlock && !stricmp(lpszBlock, blocks->m_lpszBlock)) - { - CBlock *block = blocks->GetBlock(nIndex); - return block; - } - - blocks = blocks->m_lpNext; - } - - return NULL; -} - -CBlockList *CMessage::FindBlock(char *lpszBlock) -{ - CBlockList *blocks = m_lpBlocks; - - while (blocks) - { - if (blocks->m_lpszBlock && !stricmp(lpszBlock, blocks->m_lpszBlock)) - return blocks; - - blocks = blocks->m_lpNext; - } - - return NULL; -} - -int CMessage::CountBlock(char *lpszBlock) -{ - CBlockList *blocks = FindBlock(lpszBlock); - - if (blocks) - { - return blocks->CountBlock(); - } - - return 0; -} - -bool CMessage::GetString(char *lpszBlock, int nIndex, char *lpszVar, char &lpszStr) -{ - CBlock *block = GetBlock(lpszBlock, nIndex); - - if (block) - { - CVar *var = block->FindVar(lpszVar); - - if (var) - { - var->GetString(lpszStr); - - return true; - } - } - - return false; -} - -bool CMessage::GetBool(char *lpszBlock, int nIndex, char *lpszVar, bool &lpbBool) -{ - CBlock *block = GetBlock(lpszBlock, nIndex); - - if (block) - { - CVar *var = block->FindVar(lpszVar); - - if (var) - { - var->GetBool(lpbBool); - - return true; - } - } - - return false; -} - -void CMessage::SetCommand(char *lpszCommand) -{ - if (lpszCommand) - { - size_t stLen = strlen(lpszCommand); - - if (stLen > 0) - { - SAFE_FREE(m_lpszCommand); - m_lpszCommand = (char *)malloc(stLen + 1); - - if (m_lpszCommand) - { - strncpy(m_lpszCommand, lpszCommand, stLen); - m_lpszCommand[stLen] = '\0'; - } - } - } -} - -void CMessage::Dump(void) -{ - if (m_lpszCommand) - dprintf("----- %s -----\n", m_lpszCommand); - - CBlockList *blocks = m_lpBlocks; - - while (blocks) - { - blocks->Dump(); - blocks = blocks->m_lpNext; - } -} - -int CMessage::Pack(LPBYTE lpData) -{ - int nTotalWrote = 0; - int nWrote = 0; - LPBYTE lpPtr = lpData; - CBlockList *blocks = m_lpBlocks; - - while (blocks) - { - nWrote = blocks->Pack(lpPtr); - lpPtr += nWrote; - nTotalWrote += nWrote; - blocks = blocks->m_lpNext; - } - - return nTotalWrote; +#include "StdAfx.h" +#include ".\Message.h" + +CMessage::CMessage(void) +{ + m_lpBlocks = NULL; + m_lpszCommand = NULL; +} + +CMessage::~CMessage(void) +{ + FreeBlocks(); + SAFE_FREE(m_lpszCommand); +} + +void CMessage::FreeBlocks(void) +{ + CBlockList *blocks = m_lpBlocks; + + while (blocks) + { + if (blocks->m_lpNext) + { + blocks = blocks->m_lpNext; + + if (blocks->m_lpPrev) + SAFE_DELETE(blocks->m_lpPrev); + } + else + SAFE_DELETE(blocks); + } + + m_lpBlocks = NULL; +} + +bool CMessage::AddBlock(char *lpszBlock, int nType, CBlock *lpBlock) +{ + CBlockList *blocks = FindBlock(lpszBlock); + + if (blocks) + { + return blocks->AddBlock(lpBlock); + } + else + { + if (m_lpBlocks) + { + blocks = m_lpBlocks; + + while (blocks->m_lpNext) + blocks = blocks->m_lpNext; + + blocks->m_lpNext = new CBlockList; + + if (!blocks->m_lpNext) return false; + + blocks->m_lpNext->m_lpNext = NULL; + blocks->m_lpNext->m_lpPrev = blocks; + blocks->m_lpNext->SetBlock(lpszBlock); + blocks->m_lpNext->SetType(nType); + blocks->m_lpNext->AddBlock(lpBlock); + + return true; + } + else + { + blocks = new CBlockList; + + if (!blocks) return false; + + m_lpBlocks = blocks; + m_lpBlocks->m_lpNext = NULL; + m_lpBlocks->m_lpPrev = NULL; + m_lpBlocks->SetBlock(lpszBlock); + m_lpBlocks->SetType(nType); + m_lpBlocks->AddBlock(lpBlock); + + return true; + } + + return false; + } +} + +CBlock *CMessage::GetBlock(char *lpszBlock, int nIndex) +{ + CBlockList *blocks = m_lpBlocks; + + while (blocks) + { + if (blocks->m_lpszBlock && !stricmp(lpszBlock, blocks->m_lpszBlock)) + { + CBlock *block = blocks->GetBlock(nIndex); + return block; + } + + blocks = blocks->m_lpNext; + } + + return NULL; +} + +CBlockList *CMessage::FindBlock(char *lpszBlock) +{ + CBlockList *blocks = m_lpBlocks; + + while (blocks) + { + if (blocks->m_lpszBlock && !stricmp(lpszBlock, blocks->m_lpszBlock)) + return blocks; + + blocks = blocks->m_lpNext; + } + + return NULL; +} + +int CMessage::CountBlock(char *lpszBlock) +{ + CBlockList *blocks = FindBlock(lpszBlock); + + if (blocks) + { + return blocks->CountBlock(); + } + + return 0; +} + +bool CMessage::GetString(char *lpszBlock, int nIndex, char *lpszVar, char &lpszStr) +{ + CBlock *block = GetBlock(lpszBlock, nIndex); + + if (block) + { + CVar *var = block->FindVar(lpszVar); + + if (var) + { + var->GetString(lpszStr); + + return true; + } + } + + return false; +} + +bool CMessage::GetBool(char *lpszBlock, int nIndex, char *lpszVar, bool &lpbBool) +{ + CBlock *block = GetBlock(lpszBlock, nIndex); + + if (block) + { + CVar *var = block->FindVar(lpszVar); + + if (var) + { + var->GetBool(lpbBool); + + return true; + } + } + + return false; +} + +void CMessage::SetCommand(char *lpszCommand) +{ + if (lpszCommand) + { + size_t stLen = strlen(lpszCommand); + + if (stLen > 0) + { + SAFE_FREE(m_lpszCommand); + m_lpszCommand = (char *)malloc(stLen + 1); + + if (m_lpszCommand) + { + strncpy(m_lpszCommand, lpszCommand, stLen); + m_lpszCommand[stLen] = '\0'; + } + } + } +} + +void CMessage::Dump(void) +{ + if (m_lpszCommand) + dprintf("----- %s -----\n", m_lpszCommand); + + CBlockList *blocks = m_lpBlocks; + + while (blocks) + { + blocks->Dump(); + blocks = blocks->m_lpNext; + } +} + +int CMessage::Pack(LPBYTE lpData) +{ + int nTotalWrote = 0; + int nWrote = 0; + LPBYTE lpPtr = lpData; + CBlockList *blocks = m_lpBlocks; + + while (blocks) + { + nWrote = blocks->Pack(lpPtr); + lpPtr += nWrote; + nTotalWrote += nWrote; + blocks = blocks->m_lpNext; + } + + return nTotalWrote; } \ No newline at end of file diff --git a/applications/snowcrash/snowflake/Message.h b/applications/snowcrash/snowflake/Message.h index 995a05ef..9fdf825a 100644 --- a/applications/snowcrash/snowflake/Message.h +++ b/applications/snowcrash/snowflake/Message.h @@ -1,25 +1,25 @@ -#pragma once - -#include ".\BlockList.h" - -class CMessage -{ -public: - CMessage(void); - ~CMessage(void); - - CBlockList *m_lpBlocks; - char *m_lpszCommand; - - void FreeBlocks(void); - bool AddBlock(char *lpszBlock, int nType, CBlock *lpBlock); - CBlockList *FindBlock(char *lpszBlock); - CBlock *GetBlock(char *lpszBlock, int nIndex); - int CountBlock(char *lpszBlock); - void SetCommand(char *lpszCommand); - void Dump(void); - int Pack(LPBYTE lpData); - bool GetString(char *lpszBlock, int nIndex, char *lpszVar, char &lpszStr); - bool GetBool(char *lpszBlock, int nIndex, char *lpszVar, bool &lpbBool); -}; - +#pragma once + +#include ".\BlockList.h" + +class CMessage +{ +public: + CMessage(void); + ~CMessage(void); + + CBlockList *m_lpBlocks; + char *m_lpszCommand; + + void FreeBlocks(void); + bool AddBlock(char *lpszBlock, int nType, CBlock *lpBlock); + CBlockList *FindBlock(char *lpszBlock); + CBlock *GetBlock(char *lpszBlock, int nIndex); + int CountBlock(char *lpszBlock); + void SetCommand(char *lpszCommand); + void Dump(void); + int Pack(LPBYTE lpData); + bool GetString(char *lpszBlock, int nIndex, char *lpszVar, char &lpszStr); + bool GetBool(char *lpszBlock, int nIndex, char *lpszVar, bool &lpbBool); +}; + diff --git a/applications/snowcrash/snowflake/Sequence.cpp b/applications/snowcrash/snowflake/Sequence.cpp index 71f61aa2..299d1419 100644 --- a/applications/snowcrash/snowflake/Sequence.cpp +++ b/applications/snowcrash/snowflake/Sequence.cpp @@ -1,16 +1,16 @@ -#include "StdAfx.h" -#include ".\Sequence.h" - -CSequence::CSequence(void) -{ - m_wKey = 0; - m_wValue = 0; - m_wState = SEQ_STATE_UNACKED; - - m_lpPrev = NULL; - m_lpNext = NULL; -} - -CSequence::~CSequence(void) -{ -} +#include "StdAfx.h" +#include ".\Sequence.h" + +CSequence::CSequence(void) +{ + m_wKey = 0; + m_wValue = 0; + m_wState = SEQ_STATE_UNACKED; + + m_lpPrev = NULL; + m_lpNext = NULL; +} + +CSequence::~CSequence(void) +{ +} diff --git a/applications/snowcrash/snowflake/Sequence.h b/applications/snowcrash/snowflake/Sequence.h index 35784e7b..3cb62d7b 100644 --- a/applications/snowcrash/snowflake/Sequence.h +++ b/applications/snowcrash/snowflake/Sequence.h @@ -1,19 +1,19 @@ -#pragma once - -#define SEQ_STATE_UNACKED 0 -#define SEQ_STATE_ACKED 1 -#define SEQ_STATE_RESENT 2 - -class CSequence -{ -public: - CSequence(void); - ~CSequence(void); - - WORD m_wKey; - WORD m_wValue; - WORD m_wState; - - CSequence *m_lpPrev; - CSequence *m_lpNext; -}; +#pragma once + +#define SEQ_STATE_UNACKED 0 +#define SEQ_STATE_ACKED 1 +#define SEQ_STATE_RESENT 2 + +class CSequence +{ +public: + CSequence(void); + ~CSequence(void); + + WORD m_wKey; + WORD m_wValue; + WORD m_wState; + + CSequence *m_lpPrev; + CSequence *m_lpNext; +}; diff --git a/applications/snowcrash/snowflake/SequenceList.cpp b/applications/snowcrash/snowflake/SequenceList.cpp index 4703db25..ecd95552 100644 --- a/applications/snowcrash/snowflake/SequenceList.cpp +++ b/applications/snowcrash/snowflake/SequenceList.cpp @@ -1,161 +1,161 @@ -#include "StdAfx.h" -#include ".\SequenceList.h" - -CSequenceList::CSequenceList(void) -{ - m_lpSequences = NULL; -} - -CSequenceList::~CSequenceList(void) -{ - FreeSequences(); -} - -void CSequenceList::FreeSequences(void) -{ - CSequence *sequence = m_lpSequences; - - while (sequence) - { - if (sequence->m_lpNext) - { - sequence = sequence->m_lpNext; - - if (sequence->m_lpPrev) - SAFE_DELETE(sequence->m_lpPrev); - } - else - SAFE_DELETE(sequence); - } - - m_lpSequences = NULL; -} - -bool CSequenceList::AddSequence(CSequence *lpSequence) -{ - CSequence *sequence = NULL; - - if (m_lpSequences) - { - sequence = m_lpSequences; - - while (sequence->m_lpNext) - sequence = sequence->m_lpNext; - - sequence->m_lpNext = lpSequence; - - if (!sequence->m_lpNext) return false; - - sequence->m_lpNext->m_lpNext = NULL; - sequence->m_lpNext->m_lpPrev = sequence; - - return true; - } - else - { - sequence = lpSequence; - - if (!sequence) return false; - - m_lpSequences = sequence; - m_lpSequences->m_lpNext = NULL; - m_lpSequences->m_lpPrev = NULL; - - return true; - } - - return false; -} - -void CSequenceList::RemoveSequence(CSequence *lpSequence) -{ - if (lpSequence->m_lpNext) - { - if (lpSequence->m_lpPrev) - { - lpSequence->m_lpPrev->m_lpNext = lpSequence->m_lpNext; - lpSequence->m_lpNext->m_lpPrev = lpSequence->m_lpPrev; - } - else - { - lpSequence->m_lpNext->m_lpPrev = NULL; - m_lpSequences = lpSequence->m_lpNext; - } - } - else - { - if (lpSequence->m_lpPrev) - { - lpSequence->m_lpPrev->m_lpNext = NULL; - } - else - { - m_lpSequences = NULL; - } - } - - SAFE_DELETE(lpSequence); -} - -CSequence *CSequenceList::FindSequenceByKey(WORD wKey) -{ - CSequence *sequence = m_lpSequences; - - while (sequence) - { - if (sequence->m_wKey == wKey) - return sequence; - sequence = sequence->m_lpNext; - } - - return NULL; -} - -CSequence *CSequenceList::FindSequenceByValue(WORD wValue) -{ - CSequence *sequence = m_lpSequences; - - while (sequence) - { - if (sequence->m_wValue == wValue) - return sequence; - sequence = sequence->m_lpNext; - } - - return NULL; -} - -void CSequenceList::WalkSequences(void) -{ - CSequence *sequence = m_lpSequences; - - while (sequence) - { - dprintf("SEQ WALK: %hu ==> %hu\n", sequence->m_wKey, sequence->m_wValue); - sequence = sequence->m_lpNext; - } -} - -BYTE CSequenceList::WriteAckedSequences(char *buf) -{ - CSequence *sequence = m_lpSequences; - BYTE cAcked = 0; - - while (sequence) - { - if (sequence->m_wState == SEQ_STATE_ACKED) - { - DWORD dwID = (DWORD)sequence->m_wKey; - dprintf("WROTE ACKED SEQ: %lu\n", dwID); - memcpy(&buf[cAcked * sizeof(dwID)], &dwID, sizeof(dwID)); - cAcked++; - CSequence *remove = sequence; - sequence = sequence->m_lpNext; - RemoveSequence(remove); - } - else - sequence = sequence->m_lpNext; - } - - return cAcked; +#include "StdAfx.h" +#include ".\SequenceList.h" + +CSequenceList::CSequenceList(void) +{ + m_lpSequences = NULL; +} + +CSequenceList::~CSequenceList(void) +{ + FreeSequences(); +} + +void CSequenceList::FreeSequences(void) +{ + CSequence *sequence = m_lpSequences; + + while (sequence) + { + if (sequence->m_lpNext) + { + sequence = sequence->m_lpNext; + + if (sequence->m_lpPrev) + SAFE_DELETE(sequence->m_lpPrev); + } + else + SAFE_DELETE(sequence); + } + + m_lpSequences = NULL; +} + +bool CSequenceList::AddSequence(CSequence *lpSequence) +{ + CSequence *sequence = NULL; + + if (m_lpSequences) + { + sequence = m_lpSequences; + + while (sequence->m_lpNext) + sequence = sequence->m_lpNext; + + sequence->m_lpNext = lpSequence; + + if (!sequence->m_lpNext) return false; + + sequence->m_lpNext->m_lpNext = NULL; + sequence->m_lpNext->m_lpPrev = sequence; + + return true; + } + else + { + sequence = lpSequence; + + if (!sequence) return false; + + m_lpSequences = sequence; + m_lpSequences->m_lpNext = NULL; + m_lpSequences->m_lpPrev = NULL; + + return true; + } + + return false; +} + +void CSequenceList::RemoveSequence(CSequence *lpSequence) +{ + if (lpSequence->m_lpNext) + { + if (lpSequence->m_lpPrev) + { + lpSequence->m_lpPrev->m_lpNext = lpSequence->m_lpNext; + lpSequence->m_lpNext->m_lpPrev = lpSequence->m_lpPrev; + } + else + { + lpSequence->m_lpNext->m_lpPrev = NULL; + m_lpSequences = lpSequence->m_lpNext; + } + } + else + { + if (lpSequence->m_lpPrev) + { + lpSequence->m_lpPrev->m_lpNext = NULL; + } + else + { + m_lpSequences = NULL; + } + } + + SAFE_DELETE(lpSequence); +} + +CSequence *CSequenceList::FindSequenceByKey(WORD wKey) +{ + CSequence *sequence = m_lpSequences; + + while (sequence) + { + if (sequence->m_wKey == wKey) + return sequence; + sequence = sequence->m_lpNext; + } + + return NULL; +} + +CSequence *CSequenceList::FindSequenceByValue(WORD wValue) +{ + CSequence *sequence = m_lpSequences; + + while (sequence) + { + if (sequence->m_wValue == wValue) + return sequence; + sequence = sequence->m_lpNext; + } + + return NULL; +} + +void CSequenceList::WalkSequences(void) +{ + CSequence *sequence = m_lpSequences; + + while (sequence) + { + dprintf("SEQ WALK: %hu ==> %hu\n", sequence->m_wKey, sequence->m_wValue); + sequence = sequence->m_lpNext; + } +} + +BYTE CSequenceList::WriteAckedSequences(char *buf) +{ + CSequence *sequence = m_lpSequences; + BYTE cAcked = 0; + + while (sequence) + { + if (sequence->m_wState == SEQ_STATE_ACKED) + { + DWORD dwID = (DWORD)sequence->m_wKey; + dprintf("WROTE ACKED SEQ: %lu\n", dwID); + memcpy(&buf[cAcked * sizeof(dwID)], &dwID, sizeof(dwID)); + cAcked++; + CSequence *remove = sequence; + sequence = sequence->m_lpNext; + RemoveSequence(remove); + } + else + sequence = sequence->m_lpNext; + } + + return cAcked; } \ No newline at end of file diff --git a/applications/snowcrash/snowflake/SequenceList.h b/applications/snowcrash/snowflake/SequenceList.h index e4302abe..b47d6c44 100644 --- a/applications/snowcrash/snowflake/SequenceList.h +++ b/applications/snowcrash/snowflake/SequenceList.h @@ -1,19 +1,19 @@ -#pragma once - -#include ".\Sequence.h" - -class CSequenceList -{ -public: - CSequenceList(void); - ~CSequenceList(void); - - CSequence *m_lpSequences; - void FreeSequences(void); - bool AddSequence(CSequence *lpSequence); - void RemoveSequence(CSequence *lpSequence); - CSequence *FindSequenceByKey(WORD wKey); - CSequence *FindSequenceByValue(WORD wValue); - void WalkSequences(void); - BYTE WriteAckedSequences(char *buf); -}; +#pragma once + +#include ".\Sequence.h" + +class CSequenceList +{ +public: + CSequenceList(void); + ~CSequenceList(void); + + CSequence *m_lpSequences; + void FreeSequences(void); + bool AddSequence(CSequence *lpSequence); + void RemoveSequence(CSequence *lpSequence); + CSequence *FindSequenceByKey(WORD wKey); + CSequence *FindSequenceByValue(WORD wValue); + void WalkSequences(void); + BYTE WriteAckedSequences(char *buf); +}; diff --git a/applications/snowcrash/snowflake/Server.cpp b/applications/snowcrash/snowflake/Server.cpp index 5ab92469..53f769f6 100644 --- a/applications/snowcrash/snowflake/Server.cpp +++ b/applications/snowcrash/snowflake/Server.cpp @@ -1,54 +1,54 @@ -#include "StdAfx.h" -#include ".\Server.h" - -CServer::CServer(void) -{ - ZeroMemory(&m_address, sizeof(m_address)); - m_lpszSimName = NULL; - m_nType = SERVER_TYPE_UNKNOWN; - m_ulX = 0; - m_ulY = 0; - m_ullHandle = 0; - - m_wSequenceSentIndex = 1; - m_wSequenceRecvIndex = 1; - - m_lpPrev = NULL; - m_lpNext = NULL; -} - -CServer::CServer(struct sockaddr_in *address) -{ - memcpy(&m_address, address, sizeof(m_address)); - m_lpszSimName = NULL; - m_nType = SERVER_TYPE_UNKNOWN; - m_ulX = 0; - m_ulY = 0; - m_ullHandle = 0; - - m_wSequenceSentIndex = 1; - m_wSequenceRecvIndex = 1; - - m_lpPrev = NULL; - m_lpNext = NULL; -} - -CServer::~CServer(void) -{ - SAFE_FREE(m_lpszSimName); -} - -void CServer::SetSimName(char *lpszSimName) -{ - SAFE_FREE(m_lpszSimName); - - size_t stLen = strlen(lpszSimName); - - if (stLen > 0) - { - m_lpszSimName = (char *)malloc(stLen + 1); - - if (m_lpszSimName) - memcpy(m_lpszSimName, lpszSimName, stLen + 1); - } +#include "StdAfx.h" +#include ".\Server.h" + +CServer::CServer(void) +{ + ZeroMemory(&m_address, sizeof(m_address)); + m_lpszSimName = NULL; + m_nType = SERVER_TYPE_UNKNOWN; + m_ulX = 0; + m_ulY = 0; + m_ullHandle = 0; + + m_wSequenceSentIndex = 1; + m_wSequenceRecvIndex = 1; + + m_lpPrev = NULL; + m_lpNext = NULL; +} + +CServer::CServer(struct sockaddr_in *address) +{ + memcpy(&m_address, address, sizeof(m_address)); + m_lpszSimName = NULL; + m_nType = SERVER_TYPE_UNKNOWN; + m_ulX = 0; + m_ulY = 0; + m_ullHandle = 0; + + m_wSequenceSentIndex = 1; + m_wSequenceRecvIndex = 1; + + m_lpPrev = NULL; + m_lpNext = NULL; +} + +CServer::~CServer(void) +{ + SAFE_FREE(m_lpszSimName); +} + +void CServer::SetSimName(char *lpszSimName) +{ + SAFE_FREE(m_lpszSimName); + + size_t stLen = strlen(lpszSimName); + + if (stLen > 0) + { + m_lpszSimName = (char *)malloc(stLen + 1); + + if (m_lpszSimName) + memcpy(m_lpszSimName, lpszSimName, stLen + 1); + } } \ No newline at end of file diff --git a/applications/snowcrash/snowflake/Server.h b/applications/snowcrash/snowflake/Server.h index 4b491054..78ea36bc 100644 --- a/applications/snowcrash/snowflake/Server.h +++ b/applications/snowcrash/snowflake/Server.h @@ -1,33 +1,33 @@ -#pragma once - -#include ".\SequenceList.h" - -#define SERVER_TYPE_UNKNOWN 0 -#define SERVER_TYPE_USER 1 -#define SERVER_TYPE_DATA 2 -#define SERVER_TYPE_SIMULATOR 3 - -class CServer -{ -public: - CServer(void); - CServer(struct sockaddr_in *address); - ~CServer(void); - void SetSimName(char *lpszSimName); - - struct sockaddr_in m_address; - char *m_lpszSimName; - int m_nType; - ULONG m_ulX; - ULONG m_ulY; - ULONG m_ullHandle; - - CSequenceList m_sequencesSent; - WORD m_wSequenceSentIndex; - - CSequenceList m_sequencesRecv; - WORD m_wSequenceRecvIndex; - - CServer *m_lpNext; - CServer *m_lpPrev; -}; +#pragma once + +#include ".\SequenceList.h" + +#define SERVER_TYPE_UNKNOWN 0 +#define SERVER_TYPE_USER 1 +#define SERVER_TYPE_DATA 2 +#define SERVER_TYPE_SIMULATOR 3 + +class CServer +{ +public: + CServer(void); + CServer(struct sockaddr_in *address); + ~CServer(void); + void SetSimName(char *lpszSimName); + + struct sockaddr_in m_address; + char *m_lpszSimName; + int m_nType; + ULONG m_ulX; + ULONG m_ulY; + ULONG m_ullHandle; + + CSequenceList m_sequencesSent; + WORD m_wSequenceSentIndex; + + CSequenceList m_sequencesRecv; + WORD m_wSequenceRecvIndex; + + CServer *m_lpNext; + CServer *m_lpPrev; +}; diff --git a/applications/snowcrash/snowflake/ServerList.cpp b/applications/snowcrash/snowflake/ServerList.cpp index eda21739..51fa8e16 100644 --- a/applications/snowcrash/snowflake/ServerList.cpp +++ b/applications/snowcrash/snowflake/ServerList.cpp @@ -1,111 +1,111 @@ -#include "StdAfx.h" -#include ".\ServerList.h" - -CServerList::CServerList(void) -{ - m_lpServers = NULL; - m_bAddedUserServer = false; -} - -CServerList::~CServerList(void) -{ - FreeServers(); -} - -void CServerList::FreeServers(void) -{ - CServer *server = m_lpServers; - - while (server) - { - if (server->m_lpNext) - { - server = server->m_lpNext; - - if (server->m_lpPrev) - SAFE_DELETE(server->m_lpPrev); - } - else - SAFE_DELETE(server); - } - - m_lpServers = NULL; -} - -bool CServerList::AddServer(CServer *lpServer) -{ - CServer *server = NULL; - - if (m_lpServers) - { - server = m_lpServers; - - while (server->m_lpNext) - server = server->m_lpNext; - - server->m_lpNext = lpServer; - - if (!server->m_lpNext) return false; - - server->m_lpNext->m_lpNext = NULL; - server->m_lpNext->m_lpPrev = server; - - if (!m_bAddedUserServer) - { - m_bAddedUserServer = true; - lpServer->m_nType = SERVER_TYPE_USER; - lpServer->SetSimName("User Server"); - } - - return true; - } - else - { - server = lpServer; - - if (!server) return false; - - m_lpServers = server; - m_lpServers->m_lpNext = NULL; - m_lpServers->m_lpPrev = NULL; - - if (!m_bAddedUserServer) - { - m_bAddedUserServer = true; - lpServer->m_nType = SERVER_TYPE_USER; - lpServer->SetSimName("User Server"); - } - - return true; - } - - return false; -} - -CServer *CServerList::FindServer(struct sockaddr_in *address) -{ - CServer *server = m_lpServers; - - while (server) - { - if (!memcmp(&server->m_address, address, sizeof(server->m_address))) - return server; - server = server->m_lpNext; - } - - return NULL; -} - -CServer *CServerList::FindServer(int nType) -{ - CServer *server = m_lpServers; - - while (server) - { - if (server->m_nType == nType) - return server; - server = server->m_lpNext; - } - - return NULL; +#include "StdAfx.h" +#include ".\ServerList.h" + +CServerList::CServerList(void) +{ + m_lpServers = NULL; + m_bAddedUserServer = false; +} + +CServerList::~CServerList(void) +{ + FreeServers(); +} + +void CServerList::FreeServers(void) +{ + CServer *server = m_lpServers; + + while (server) + { + if (server->m_lpNext) + { + server = server->m_lpNext; + + if (server->m_lpPrev) + SAFE_DELETE(server->m_lpPrev); + } + else + SAFE_DELETE(server); + } + + m_lpServers = NULL; +} + +bool CServerList::AddServer(CServer *lpServer) +{ + CServer *server = NULL; + + if (m_lpServers) + { + server = m_lpServers; + + while (server->m_lpNext) + server = server->m_lpNext; + + server->m_lpNext = lpServer; + + if (!server->m_lpNext) return false; + + server->m_lpNext->m_lpNext = NULL; + server->m_lpNext->m_lpPrev = server; + + if (!m_bAddedUserServer) + { + m_bAddedUserServer = true; + lpServer->m_nType = SERVER_TYPE_USER; + lpServer->SetSimName("User Server"); + } + + return true; + } + else + { + server = lpServer; + + if (!server) return false; + + m_lpServers = server; + m_lpServers->m_lpNext = NULL; + m_lpServers->m_lpPrev = NULL; + + if (!m_bAddedUserServer) + { + m_bAddedUserServer = true; + lpServer->m_nType = SERVER_TYPE_USER; + lpServer->SetSimName("User Server"); + } + + return true; + } + + return false; +} + +CServer *CServerList::FindServer(struct sockaddr_in *address) +{ + CServer *server = m_lpServers; + + while (server) + { + if (!memcmp(&server->m_address, address, sizeof(server->m_address))) + return server; + server = server->m_lpNext; + } + + return NULL; +} + +CServer *CServerList::FindServer(int nType) +{ + CServer *server = m_lpServers; + + while (server) + { + if (server->m_nType == nType) + return server; + server = server->m_lpNext; + } + + return NULL; } \ No newline at end of file diff --git a/applications/snowcrash/snowflake/ServerList.h b/applications/snowcrash/snowflake/ServerList.h index 318c9480..3515e7e5 100644 --- a/applications/snowcrash/snowflake/ServerList.h +++ b/applications/snowcrash/snowflake/ServerList.h @@ -1,17 +1,17 @@ -#pragma once - -#include ".\Server.h" - -class CServerList -{ -public: - CServerList(void); - ~CServerList(void); - - CServer *m_lpServers; - void FreeServers(void); - bool AddServer(CServer *lpServer); - CServer *FindServer(struct sockaddr_in *address); - CServer *FindServer(int nType); - bool m_bAddedUserServer; -}; +#pragma once + +#include ".\Server.h" + +class CServerList +{ +public: + CServerList(void); + ~CServerList(void); + + CServer *m_lpServers; + void FreeServers(void); + bool AddServer(CServer *lpServer); + CServer *FindServer(struct sockaddr_in *address); + CServer *FindServer(int nType); + bool m_bAddedUserServer; +}; diff --git a/applications/snowcrash/snowflake/Var.cpp b/applications/snowcrash/snowflake/Var.cpp index 93c8feda..e7ed971d 100644 --- a/applications/snowcrash/snowflake/Var.cpp +++ b/applications/snowcrash/snowflake/Var.cpp @@ -1,924 +1,924 @@ -#include "StdAfx.h" -#include ".\Var.h" -#include ".\keywords.h" - -CVar::CVar(void) -{ - m_lpszVar = NULL; - m_nType = 0; - m_nTypeLen = 0; - m_nLen = 0; - m_lpData = NULL; - - m_lpPrev = NULL; - m_lpNext = NULL; -} - -CVar::~CVar(void) -{ - SAFE_FREE(m_lpszVar); - SAFE_FREE(m_lpData); -} - -void CVar::SetVar(char *lpszVar) -{ - if (lpszVar) - { - int nLen = (int)strlen(lpszVar); - - if (nLen > 0) - { - SAFE_FREE(m_lpszVar); - m_lpszVar = (char *)malloc(nLen + 1); - - if (m_lpszVar) - { - strncpy(m_lpszVar, lpszVar, nLen); - m_lpszVar[nLen] = '\0'; - } - } - } -} - -void CVar::SetType(int nType, int nTypeLen) -{ - m_nType = nType; - m_nTypeLen = nTypeLen; -} - -void CVar::GetString(char &lpszStr) -{ - switch (m_nType) - { - case LLTYPE_U8: - { - unsigned char ubData; - memcpy(&ubData, m_lpData, sizeof(ubData)); - sprintf(&lpszStr, "%hu", ubData); - } - break; - - case LLTYPE_U16: - { - WORD wData; - memcpy(&wData, m_lpData, sizeof(wData)); - sprintf(&lpszStr, "%u", wData); - } - break; - - case LLTYPE_U32: - { - DWORD dwData; - memcpy(&dwData, m_lpData, sizeof(dwData)); - sprintf(&lpszStr, "%lu", dwData); - } - break; - - case LLTYPE_U64: - { - ULONGLONG ullData; - memcpy(&ullData, m_lpData, sizeof(ullData)); - sprintf(&lpszStr, "%I64u", ullData); - } - break; - - case LLTYPE_S8: - { - BYTE bData; - memcpy(&bData, m_lpData, sizeof(bData)); - sprintf(&lpszStr, "%hd", bData); - } - break; - - case LLTYPE_S16: - { - SHORT sData; - memcpy(&sData, m_lpData, sizeof(sData)); - sprintf(&lpszStr, "%d", sData); - } - break; - - case LLTYPE_S32: - { - LONG nData; - memcpy(&nData, m_lpData, sizeof(nData)); - sprintf(&lpszStr, "%ld", nData); - } - break; - - case LLTYPE_S64: - break; - - case LLTYPE_F8: - break; - - case LLTYPE_F16: - break; - - case LLTYPE_F32: - { - FLOAT fData; - memcpy(&fData, m_lpData, sizeof(fData)); - sprintf(&lpszStr, "%f", fData); - } - break; - - case LLTYPE_F64: - { - double dData; - memcpy(&dData, m_lpData, sizeof(dData)); - sprintf(&lpszStr, "%f", dData); - } - break; - - case LLTYPE_LLUUID: - { - char szHex[8]; - sprintf(&lpszStr, ""); - - for (int u = 0; u < m_nLen; u++) - { - sprintf(szHex, "%02x", m_lpData[u]); - strcat(&lpszStr, szHex); - - if (u == 3 || u == 5 || u == 7 || u == 9) - strcat(&lpszStr, "-"); - } - } - break; - - case LLTYPE_BOOL: - { - BYTE bData; - memcpy(&bData, m_lpData, sizeof(bData)); - sprintf(&lpszStr, "%s", (bData) ? "True" : "False"); - } - break; - - case LLTYPE_LLVECTOR3: - { - FLOAT fData[3]; - memcpy(&fData, m_lpData, sizeof(fData)); - sprintf(&lpszStr, "%f, %f, %f", fData[0], fData[1], fData[2]); - } - break; - - case LLTYPE_LLVECTOR3D: - { - double dData[3]; - memcpy(&dData, m_lpData, sizeof(dData)); - sprintf(&lpszStr, "%f, %f, %f", dData[0], dData[1], dData[2]); - } - break; - - case LLTYPE_QUATERNION: - { - FLOAT fData[4]; - memcpy(&fData, m_lpData, sizeof(fData)); - sprintf(&lpszStr, "%f, %f, %f, %f", fData[0], fData[1], fData[2], fData[3]); - } - break; - - case LLTYPE_IPADDR: - { - BYTE ipData[4]; - memcpy(&ipData, m_lpData, sizeof(ipData)); - sprintf(&lpszStr, "%hu.%hu.%hu.%hu", ipData[0], ipData[1], ipData[2], ipData[3]); - } - break; - - case LLTYPE_IPPORT: - { - WORD wData; - memcpy(&wData, m_lpData, sizeof(wData)); - sprintf(&lpszStr, "%hu", htons(wData)); - } - break; - - case LLTYPE_FIXED: - case LLTYPE_VARIABLE: - { - sprintf(&lpszStr, ""); - - if (m_lpData) - { - bool bPrintable = true; - - for (int j = 0; j < m_nLen - 1; j++) - { - if (((unsigned char)m_lpData[j] < 0x20 || (unsigned char)m_lpData[j] > 0x7E) && (unsigned char)m_lpData[j] != 0x09 && (unsigned char)m_lpData[j] != 0x0D) - bPrintable = false; - } - - if (bPrintable && m_lpData[m_nLen - 1] == '\0') - { - sprintf(&lpszStr, "%s", m_lpData); - } - else - { - for (int j = 0; j < m_nLen; j++) - { - char szHex[8]; - sprintf(szHex, "%02x", (unsigned char)m_lpData[j]); - strcat(&lpszStr, szHex); - } - } - } - } - break; - - case LLTYPE_SINGLE: - case LLTYPE_MULTIPLE: - case LLTYPE_NULL: - default: - { - sprintf(&lpszStr, ""); - } - break; - } -} - -void CVar::GetBool(bool &lpbBool) -{ - switch (m_nType) - { - case LLTYPE_BOOL: - { - BYTE bData; - memcpy(&bData, m_lpData, sizeof(bData)); - lpbBool = (bData) ? true : false; - } - break; - - case LLTYPE_U8: - case LLTYPE_U16: - case LLTYPE_U32: - case LLTYPE_U64: - case LLTYPE_S8: - case LLTYPE_S16: - case LLTYPE_S32: - case LLTYPE_S64: - case LLTYPE_F8: - case LLTYPE_F16: - case LLTYPE_F32: - case LLTYPE_F64: - case LLTYPE_LLUUID: - case LLTYPE_LLVECTOR3: - case LLTYPE_LLVECTOR3D: - case LLTYPE_QUATERNION: - case LLTYPE_IPADDR: - case LLTYPE_IPPORT: - case LLTYPE_FIXED: - case LLTYPE_VARIABLE: - case LLTYPE_SINGLE: - case LLTYPE_MULTIPLE: - case LLTYPE_NULL: - default: - { - lpbBool = false; - } - break; - } -} - -int CVar::SetData(LPBYTE lpData) -{ - SAFE_FREE(m_lpData); - m_nLen = 0; - - int nRead = 0; - - switch (m_nType) - { - case LLTYPE_U8: - { - m_nLen = sizeof(unsigned char); - - m_lpData = (LPBYTE)malloc(m_nLen); - - if (m_lpData) - { - memcpy(m_lpData, lpData, m_nLen); - nRead += m_nLen; - } - else - m_nLen = 0; - } - break; - - case LLTYPE_U16: - { - m_nLen = sizeof(WORD); - - m_lpData = (LPBYTE)malloc(m_nLen); - - if (m_lpData) - { - memcpy(m_lpData, lpData, m_nLen); - nRead += m_nLen; - } - else - m_nLen = 0; - } - break; - - case LLTYPE_U32: - { - m_nLen = sizeof(DWORD); - - m_lpData = (LPBYTE)malloc(m_nLen); - - if (m_lpData) - { - memcpy(m_lpData, lpData, m_nLen); - nRead += m_nLen; - } - else - m_nLen = 0; - } - break; - - case LLTYPE_U64: - { - m_nLen = sizeof(ULONGLONG); - - m_lpData = (LPBYTE)malloc(m_nLen); - - if (m_lpData) - { - memcpy(m_lpData, lpData, m_nLen); - nRead += m_nLen; - } - else - m_nLen = 0; - } - break; - - case LLTYPE_S8: - { - m_nLen = sizeof(BYTE); - - m_lpData = (LPBYTE)malloc(m_nLen); - - if (m_lpData) - { - memcpy(m_lpData, lpData, m_nLen); - nRead += m_nLen; - } - else - m_nLen = 0; - } - break; - - case LLTYPE_S16: - { - m_nLen = sizeof(SHORT); - - m_lpData = (LPBYTE)malloc(m_nLen); - - if (m_lpData) - { - memcpy(m_lpData, lpData, m_nLen); - nRead += m_nLen; - } - else - m_nLen = 0; - } - break; - - case LLTYPE_S32: - { - m_nLen = sizeof(LONG); - - m_lpData = (LPBYTE)malloc(m_nLen); - - if (m_lpData) - { - memcpy(m_lpData, lpData, m_nLen); - nRead += m_nLen; - } - else - m_nLen = 0; - } - break; - - case LLTYPE_S64: - break; - - case LLTYPE_F8: - break; - - case LLTYPE_F16: - break; - - case LLTYPE_F32: - { - m_nLen = sizeof(FLOAT); - - m_lpData = (LPBYTE)malloc(m_nLen); - - if (m_lpData) - { - memcpy(m_lpData, lpData, m_nLen); - nRead += m_nLen; - } - else - m_nLen = 0; - } - break; - - case LLTYPE_F64: - { - m_nLen = sizeof(double); - - m_lpData = (LPBYTE)malloc(m_nLen); - - if (m_lpData) - { - memcpy(m_lpData, lpData, m_nLen); - nRead += m_nLen; - } - else - m_nLen = 0; - } - break; - - case LLTYPE_LLUUID: - { - m_nLen = sizeof(BYTE) * 16; - - m_lpData = (LPBYTE)malloc(m_nLen); - - if (m_lpData) - { - memcpy(m_lpData, lpData, m_nLen); - nRead += m_nLen; - } - else - m_nLen = 0; - } - break; - - case LLTYPE_BOOL: - { - m_nLen = sizeof(BYTE); - - m_lpData = (LPBYTE)malloc(m_nLen); - - if (m_lpData) - { - memcpy(m_lpData, lpData, m_nLen); - nRead += m_nLen; - } - else - m_nLen = 0; - } - break; - - case LLTYPE_LLVECTOR3: - { - m_nLen = sizeof(FLOAT) * 3; - - m_lpData = (LPBYTE)malloc(m_nLen); - - if (m_lpData) - { - memcpy(m_lpData, lpData, m_nLen); - nRead += m_nLen; - } - else - m_nLen = 0; - } - break; - - case LLTYPE_LLVECTOR3D: - { - m_nLen = sizeof(double) * 3; - - m_lpData = (LPBYTE)malloc(m_nLen); - - if (m_lpData) - { - memcpy(m_lpData, lpData, m_nLen); - nRead += m_nLen; - } - else - m_nLen = 0; - } - break; - - case LLTYPE_QUATERNION: - { - m_nLen = sizeof(FLOAT) * 4; - - m_lpData = (LPBYTE)malloc(m_nLen); - - if (m_lpData) - { - memcpy(m_lpData, lpData, m_nLen); - nRead += m_nLen; - } - else - m_nLen = 0; - } - break; - - case LLTYPE_IPADDR: - { - m_nLen = sizeof(BYTE) * 4; - - m_lpData = (LPBYTE)malloc(m_nLen); - - if (m_lpData) - { - memcpy(m_lpData, lpData, m_nLen); - nRead += m_nLen; - } - else - m_nLen = 0; - } - break; - - case LLTYPE_IPPORT: - { - m_nLen = sizeof(WORD); - - m_lpData = (LPBYTE)malloc(m_nLen); - - if (m_lpData) - { - memcpy(m_lpData, lpData, m_nLen); - nRead += m_nLen; - } - else - m_nLen = 0; - } - break; - - case LLTYPE_VARIABLE: - { - if (m_nTypeLen == 1) - { - BYTE cDataLen; - - memcpy(&cDataLen, lpData, sizeof(cDataLen)); - nRead += sizeof(cDataLen); - lpData += sizeof(cDataLen); - - m_nLen = cDataLen; - - if (m_nLen > 0) - { - m_lpData = (LPBYTE)malloc(m_nLen); - - if (m_lpData) - { - memcpy(m_lpData, lpData, m_nLen); - nRead += m_nLen; - } - else - m_nLen = 0; - } - else - m_nLen = 0; - } - else if (m_nTypeLen == 2) - { - WORD cDataLen; - - memcpy(&cDataLen, lpData, sizeof(cDataLen)); - nRead += sizeof(cDataLen); - lpData += sizeof(cDataLen); - - m_nLen = cDataLen; - - if (m_nLen > 0) - { - m_lpData = (LPBYTE)malloc(m_nLen); - - if (m_lpData) - { - memcpy(m_lpData, lpData, m_nLen); - nRead += m_nLen; - } - else - m_nLen = 0; - } - else - m_nLen = 0; - } - } - break; - - case LLTYPE_FIXED: - { - m_nLen = m_nTypeLen; - - if (m_nLen > 0) - { - m_lpData = (LPBYTE)malloc(m_nLen); - - if (m_lpData) - { - memcpy(m_lpData, lpData, m_nLen); - nRead += m_nLen; - } - else - m_nLen = 0; - } - else - m_nLen = 0; - } - break; - - case LLTYPE_SINGLE: - case LLTYPE_MULTIPLE: - case LLTYPE_NULL: - default: - { - m_nLen = 0; - } - break; - } - - return nRead; -} - -void CVar::Dump(void) -{ - switch (m_nType) - { - case LLTYPE_U8: - { - unsigned char ubData; - memcpy(&ubData, m_lpData, sizeof(ubData)); - dprintf("%s: %hu\n", m_lpszVar, ubData); - } - break; - - case LLTYPE_U16: - { - WORD wData; - memcpy(&wData, m_lpData, sizeof(wData)); - dprintf("%s: %u\n", m_lpszVar, wData); - } - break; - - case LLTYPE_U32: - { - DWORD dwData; - memcpy(&dwData, m_lpData, sizeof(dwData)); - dprintf("%s: %lu\n", m_lpszVar, dwData); - } - break; - - case LLTYPE_U64: - { - ULONGLONG ullData; - memcpy(&ullData, m_lpData, sizeof(ullData)); - dprintf("%s: %I64u\n", m_lpszVar, ullData); - } - break; - - case LLTYPE_S8: - { - BYTE bData; - memcpy(&bData, m_lpData, sizeof(bData)); - dprintf("%s: %hd\n", m_lpszVar, bData); - } - break; - - case LLTYPE_S16: - { - SHORT sData; - memcpy(&sData, m_lpData, sizeof(sData)); - dprintf("%s: %d\n", m_lpszVar, sData); - } - break; - - case LLTYPE_S32: - { - LONG nData; - memcpy(&nData, m_lpData, sizeof(nData)); - dprintf("%s: %ld\n", m_lpszVar, nData); - } - break; - - case LLTYPE_S64: - break; - - case LLTYPE_F8: - break; - - case LLTYPE_F16: - break; - - case LLTYPE_F32: - { - FLOAT fData; - memcpy(&fData, m_lpData, sizeof(fData)); - dprintf("%s: %f\n", m_lpszVar, fData); - } - break; - - case LLTYPE_F64: - { - double dData; - memcpy(&dData, m_lpData, sizeof(dData)); - dprintf("%s: %f\n", m_lpszVar, dData); - } - break; - - case LLTYPE_LLUUID: - { - dprintf("%s: ", m_lpszVar); - for (int u = 0; u < m_nLen; u++) - dprintf("%02x", m_lpData[u]); - dprintf("\n"); - } - break; - - case LLTYPE_BOOL: - { - BYTE bData; - memcpy(&bData, m_lpData, sizeof(bData)); - dprintf("%s: %s\n", m_lpszVar, (bData) ? "True" : "False"); - } - break; - - case LLTYPE_LLVECTOR3: - { - FLOAT fData[3]; - memcpy(&fData, m_lpData, sizeof(fData)); - dprintf("%s: %f, %f, %f\n", m_lpszVar, fData[0], fData[1], fData[2]); - } - break; - - case LLTYPE_LLVECTOR3D: - { - double dData[3]; - memcpy(&dData, m_lpData, sizeof(dData)); - dprintf("%s: %f, %f, %f\n", m_lpszVar, dData[0], dData[1], dData[2]); - } - break; - - case LLTYPE_QUATERNION: - { - FLOAT fData[4]; - memcpy(&fData, m_lpData, sizeof(fData)); - dprintf("%s: %f, %f, %f, %f\n", m_lpszVar, fData[0], fData[1], fData[2], fData[3]); - } - break; - - case LLTYPE_IPADDR: - { - BYTE ipData[4]; - memcpy(&ipData, m_lpData, sizeof(ipData)); - dprintf("%s: %hu.%hu.%hu.%hu\n", m_lpszVar, ipData[0], ipData[1], ipData[2], ipData[3]); - } - break; - - case LLTYPE_IPPORT: - { - WORD wData; - memcpy(&wData, m_lpData, sizeof(wData)); - dprintf("%s: %hu\n", m_lpszVar, htons(wData)); - } - break; - - case LLTYPE_VARIABLE: - case LLTYPE_FIXED: - { - if (m_lpData) - { - bool bPrintable = true; - - for (int j = 0; j < m_nLen - 1; j++) - { - if (((unsigned char)m_lpData[j] < 0x20 || (unsigned char)m_lpData[j] > 0x7E) && (unsigned char)m_lpData[j] != 0x09 && (unsigned char)m_lpData[j] != 0x0D) - bPrintable = false; - } - - if (bPrintable && m_lpData[m_nLen - 1] == '\0') - { - dprintf("%s: %s\n", m_lpszVar, m_lpData); - } - else - { - for (int j = 0; j < m_nLen; j += 16) - { - dprintf("%s: ", m_lpszVar); - - for (int k = 0; k < 16; k++) - { - if ((j + k) < m_nLen) - { - dprintf("%02x ", (unsigned char)m_lpData[j+k]); - } - else - { - dprintf(" "); - } - } - - for (int k = 0; k < 16 && (j + k) < m_nLen; k++) - { - dprintf("%c", ((unsigned char)m_lpData[j+k] >= 0x20 && (unsigned char)m_lpData[j+k] <= 0x7E) ? (unsigned char)m_lpData[j+k] : '.'); - } - - dprintf("\n"); - } - } - } - } - break; - - case LLTYPE_SINGLE: - case LLTYPE_MULTIPLE: - case LLTYPE_NULL: - default: - { - dprintf("%s (%s / %d / %d)\n", m_lpszVar, LLTYPES[m_nType], m_nLen, m_nTypeLen); - } - break; - } -} - -int CVar::Pack(LPBYTE lpData) -{ - LPBYTE lpPtr = lpData; - int nTotalWrote = 0; - - switch (m_nType) - { - case LLTYPE_U8: - case LLTYPE_U16: - case LLTYPE_U32: - case LLTYPE_U64: - case LLTYPE_S8: - case LLTYPE_S16: - case LLTYPE_S32: - case LLTYPE_S64: - case LLTYPE_F8: - case LLTYPE_F16: - case LLTYPE_F32: - case LLTYPE_F64: - case LLTYPE_LLUUID: - case LLTYPE_BOOL: - case LLTYPE_LLVECTOR3: - case LLTYPE_LLVECTOR3D: - case LLTYPE_QUATERNION: - case LLTYPE_IPADDR: - case LLTYPE_IPPORT: - case LLTYPE_FIXED: - { - memcpy(lpPtr, m_lpData, m_nLen); - nTotalWrote = m_nLen; - } - break; - - case LLTYPE_VARIABLE: - { - if (m_nTypeLen == 1) - { - BYTE cDataLen; - - cDataLen = m_nLen; - - memcpy(lpPtr, &cDataLen, sizeof(cDataLen)); - nTotalWrote = sizeof(cDataLen); - - lpPtr += sizeof(cDataLen); - - memcpy(lpPtr, m_lpData, m_nLen); - nTotalWrote += m_nLen; - } - else if (m_nTypeLen == 2) - { - WORD cDataLen; - - cDataLen = m_nLen; - - memcpy(lpPtr, &cDataLen, sizeof(cDataLen)); - nTotalWrote = sizeof(cDataLen); - - lpPtr += sizeof(cDataLen); - - memcpy(lpPtr, m_lpData, m_nLen); - nTotalWrote += m_nLen; - } - } - break; - - case LLTYPE_SINGLE: - case LLTYPE_MULTIPLE: - case LLTYPE_NULL: - default: - { - nTotalWrote = 0; - } - break; - } - - return nTotalWrote; +#include "StdAfx.h" +#include ".\Var.h" +#include ".\keywords.h" + +CVar::CVar(void) +{ + m_lpszVar = NULL; + m_nType = 0; + m_nTypeLen = 0; + m_nLen = 0; + m_lpData = NULL; + + m_lpPrev = NULL; + m_lpNext = NULL; +} + +CVar::~CVar(void) +{ + SAFE_FREE(m_lpszVar); + SAFE_FREE(m_lpData); +} + +void CVar::SetVar(char *lpszVar) +{ + if (lpszVar) + { + int nLen = (int)strlen(lpszVar); + + if (nLen > 0) + { + SAFE_FREE(m_lpszVar); + m_lpszVar = (char *)malloc(nLen + 1); + + if (m_lpszVar) + { + strncpy(m_lpszVar, lpszVar, nLen); + m_lpszVar[nLen] = '\0'; + } + } + } +} + +void CVar::SetType(int nType, int nTypeLen) +{ + m_nType = nType; + m_nTypeLen = nTypeLen; +} + +void CVar::GetString(char &lpszStr) +{ + switch (m_nType) + { + case LLTYPE_U8: + { + unsigned char ubData; + memcpy(&ubData, m_lpData, sizeof(ubData)); + sprintf(&lpszStr, "%hu", ubData); + } + break; + + case LLTYPE_U16: + { + WORD wData; + memcpy(&wData, m_lpData, sizeof(wData)); + sprintf(&lpszStr, "%u", wData); + } + break; + + case LLTYPE_U32: + { + DWORD dwData; + memcpy(&dwData, m_lpData, sizeof(dwData)); + sprintf(&lpszStr, "%lu", dwData); + } + break; + + case LLTYPE_U64: + { + ULONGLONG ullData; + memcpy(&ullData, m_lpData, sizeof(ullData)); + sprintf(&lpszStr, "%I64u", ullData); + } + break; + + case LLTYPE_S8: + { + BYTE bData; + memcpy(&bData, m_lpData, sizeof(bData)); + sprintf(&lpszStr, "%hd", bData); + } + break; + + case LLTYPE_S16: + { + SHORT sData; + memcpy(&sData, m_lpData, sizeof(sData)); + sprintf(&lpszStr, "%d", sData); + } + break; + + case LLTYPE_S32: + { + LONG nData; + memcpy(&nData, m_lpData, sizeof(nData)); + sprintf(&lpszStr, "%ld", nData); + } + break; + + case LLTYPE_S64: + break; + + case LLTYPE_F8: + break; + + case LLTYPE_F16: + break; + + case LLTYPE_F32: + { + FLOAT fData; + memcpy(&fData, m_lpData, sizeof(fData)); + sprintf(&lpszStr, "%f", fData); + } + break; + + case LLTYPE_F64: + { + double dData; + memcpy(&dData, m_lpData, sizeof(dData)); + sprintf(&lpszStr, "%f", dData); + } + break; + + case LLTYPE_LLUUID: + { + char szHex[8]; + sprintf(&lpszStr, ""); + + for (int u = 0; u < m_nLen; u++) + { + sprintf(szHex, "%02x", m_lpData[u]); + strcat(&lpszStr, szHex); + + if (u == 3 || u == 5 || u == 7 || u == 9) + strcat(&lpszStr, "-"); + } + } + break; + + case LLTYPE_BOOL: + { + BYTE bData; + memcpy(&bData, m_lpData, sizeof(bData)); + sprintf(&lpszStr, "%s", (bData) ? "True" : "False"); + } + break; + + case LLTYPE_LLVECTOR3: + { + FLOAT fData[3]; + memcpy(&fData, m_lpData, sizeof(fData)); + sprintf(&lpszStr, "%f, %f, %f", fData[0], fData[1], fData[2]); + } + break; + + case LLTYPE_LLVECTOR3D: + { + double dData[3]; + memcpy(&dData, m_lpData, sizeof(dData)); + sprintf(&lpszStr, "%f, %f, %f", dData[0], dData[1], dData[2]); + } + break; + + case LLTYPE_QUATERNION: + { + FLOAT fData[4]; + memcpy(&fData, m_lpData, sizeof(fData)); + sprintf(&lpszStr, "%f, %f, %f, %f", fData[0], fData[1], fData[2], fData[3]); + } + break; + + case LLTYPE_IPADDR: + { + BYTE ipData[4]; + memcpy(&ipData, m_lpData, sizeof(ipData)); + sprintf(&lpszStr, "%hu.%hu.%hu.%hu", ipData[0], ipData[1], ipData[2], ipData[3]); + } + break; + + case LLTYPE_IPPORT: + { + WORD wData; + memcpy(&wData, m_lpData, sizeof(wData)); + sprintf(&lpszStr, "%hu", htons(wData)); + } + break; + + case LLTYPE_FIXED: + case LLTYPE_VARIABLE: + { + sprintf(&lpszStr, ""); + + if (m_lpData) + { + bool bPrintable = true; + + for (int j = 0; j < m_nLen - 1; j++) + { + if (((unsigned char)m_lpData[j] < 0x20 || (unsigned char)m_lpData[j] > 0x7E) && (unsigned char)m_lpData[j] != 0x09 && (unsigned char)m_lpData[j] != 0x0D) + bPrintable = false; + } + + if (bPrintable && m_lpData[m_nLen - 1] == '\0') + { + sprintf(&lpszStr, "%s", m_lpData); + } + else + { + for (int j = 0; j < m_nLen; j++) + { + char szHex[8]; + sprintf(szHex, "%02x", (unsigned char)m_lpData[j]); + strcat(&lpszStr, szHex); + } + } + } + } + break; + + case LLTYPE_SINGLE: + case LLTYPE_MULTIPLE: + case LLTYPE_NULL: + default: + { + sprintf(&lpszStr, ""); + } + break; + } +} + +void CVar::GetBool(bool &lpbBool) +{ + switch (m_nType) + { + case LLTYPE_BOOL: + { + BYTE bData; + memcpy(&bData, m_lpData, sizeof(bData)); + lpbBool = (bData) ? true : false; + } + break; + + case LLTYPE_U8: + case LLTYPE_U16: + case LLTYPE_U32: + case LLTYPE_U64: + case LLTYPE_S8: + case LLTYPE_S16: + case LLTYPE_S32: + case LLTYPE_S64: + case LLTYPE_F8: + case LLTYPE_F16: + case LLTYPE_F32: + case LLTYPE_F64: + case LLTYPE_LLUUID: + case LLTYPE_LLVECTOR3: + case LLTYPE_LLVECTOR3D: + case LLTYPE_QUATERNION: + case LLTYPE_IPADDR: + case LLTYPE_IPPORT: + case LLTYPE_FIXED: + case LLTYPE_VARIABLE: + case LLTYPE_SINGLE: + case LLTYPE_MULTIPLE: + case LLTYPE_NULL: + default: + { + lpbBool = false; + } + break; + } +} + +int CVar::SetData(LPBYTE lpData) +{ + SAFE_FREE(m_lpData); + m_nLen = 0; + + int nRead = 0; + + switch (m_nType) + { + case LLTYPE_U8: + { + m_nLen = sizeof(unsigned char); + + m_lpData = (LPBYTE)malloc(m_nLen); + + if (m_lpData) + { + memcpy(m_lpData, lpData, m_nLen); + nRead += m_nLen; + } + else + m_nLen = 0; + } + break; + + case LLTYPE_U16: + { + m_nLen = sizeof(WORD); + + m_lpData = (LPBYTE)malloc(m_nLen); + + if (m_lpData) + { + memcpy(m_lpData, lpData, m_nLen); + nRead += m_nLen; + } + else + m_nLen = 0; + } + break; + + case LLTYPE_U32: + { + m_nLen = sizeof(DWORD); + + m_lpData = (LPBYTE)malloc(m_nLen); + + if (m_lpData) + { + memcpy(m_lpData, lpData, m_nLen); + nRead += m_nLen; + } + else + m_nLen = 0; + } + break; + + case LLTYPE_U64: + { + m_nLen = sizeof(ULONGLONG); + + m_lpData = (LPBYTE)malloc(m_nLen); + + if (m_lpData) + { + memcpy(m_lpData, lpData, m_nLen); + nRead += m_nLen; + } + else + m_nLen = 0; + } + break; + + case LLTYPE_S8: + { + m_nLen = sizeof(BYTE); + + m_lpData = (LPBYTE)malloc(m_nLen); + + if (m_lpData) + { + memcpy(m_lpData, lpData, m_nLen); + nRead += m_nLen; + } + else + m_nLen = 0; + } + break; + + case LLTYPE_S16: + { + m_nLen = sizeof(SHORT); + + m_lpData = (LPBYTE)malloc(m_nLen); + + if (m_lpData) + { + memcpy(m_lpData, lpData, m_nLen); + nRead += m_nLen; + } + else + m_nLen = 0; + } + break; + + case LLTYPE_S32: + { + m_nLen = sizeof(LONG); + + m_lpData = (LPBYTE)malloc(m_nLen); + + if (m_lpData) + { + memcpy(m_lpData, lpData, m_nLen); + nRead += m_nLen; + } + else + m_nLen = 0; + } + break; + + case LLTYPE_S64: + break; + + case LLTYPE_F8: + break; + + case LLTYPE_F16: + break; + + case LLTYPE_F32: + { + m_nLen = sizeof(FLOAT); + + m_lpData = (LPBYTE)malloc(m_nLen); + + if (m_lpData) + { + memcpy(m_lpData, lpData, m_nLen); + nRead += m_nLen; + } + else + m_nLen = 0; + } + break; + + case LLTYPE_F64: + { + m_nLen = sizeof(double); + + m_lpData = (LPBYTE)malloc(m_nLen); + + if (m_lpData) + { + memcpy(m_lpData, lpData, m_nLen); + nRead += m_nLen; + } + else + m_nLen = 0; + } + break; + + case LLTYPE_LLUUID: + { + m_nLen = sizeof(BYTE) * 16; + + m_lpData = (LPBYTE)malloc(m_nLen); + + if (m_lpData) + { + memcpy(m_lpData, lpData, m_nLen); + nRead += m_nLen; + } + else + m_nLen = 0; + } + break; + + case LLTYPE_BOOL: + { + m_nLen = sizeof(BYTE); + + m_lpData = (LPBYTE)malloc(m_nLen); + + if (m_lpData) + { + memcpy(m_lpData, lpData, m_nLen); + nRead += m_nLen; + } + else + m_nLen = 0; + } + break; + + case LLTYPE_LLVECTOR3: + { + m_nLen = sizeof(FLOAT) * 3; + + m_lpData = (LPBYTE)malloc(m_nLen); + + if (m_lpData) + { + memcpy(m_lpData, lpData, m_nLen); + nRead += m_nLen; + } + else + m_nLen = 0; + } + break; + + case LLTYPE_LLVECTOR3D: + { + m_nLen = sizeof(double) * 3; + + m_lpData = (LPBYTE)malloc(m_nLen); + + if (m_lpData) + { + memcpy(m_lpData, lpData, m_nLen); + nRead += m_nLen; + } + else + m_nLen = 0; + } + break; + + case LLTYPE_QUATERNION: + { + m_nLen = sizeof(FLOAT) * 4; + + m_lpData = (LPBYTE)malloc(m_nLen); + + if (m_lpData) + { + memcpy(m_lpData, lpData, m_nLen); + nRead += m_nLen; + } + else + m_nLen = 0; + } + break; + + case LLTYPE_IPADDR: + { + m_nLen = sizeof(BYTE) * 4; + + m_lpData = (LPBYTE)malloc(m_nLen); + + if (m_lpData) + { + memcpy(m_lpData, lpData, m_nLen); + nRead += m_nLen; + } + else + m_nLen = 0; + } + break; + + case LLTYPE_IPPORT: + { + m_nLen = sizeof(WORD); + + m_lpData = (LPBYTE)malloc(m_nLen); + + if (m_lpData) + { + memcpy(m_lpData, lpData, m_nLen); + nRead += m_nLen; + } + else + m_nLen = 0; + } + break; + + case LLTYPE_VARIABLE: + { + if (m_nTypeLen == 1) + { + BYTE cDataLen; + + memcpy(&cDataLen, lpData, sizeof(cDataLen)); + nRead += sizeof(cDataLen); + lpData += sizeof(cDataLen); + + m_nLen = cDataLen; + + if (m_nLen > 0) + { + m_lpData = (LPBYTE)malloc(m_nLen); + + if (m_lpData) + { + memcpy(m_lpData, lpData, m_nLen); + nRead += m_nLen; + } + else + m_nLen = 0; + } + else + m_nLen = 0; + } + else if (m_nTypeLen == 2) + { + WORD cDataLen; + + memcpy(&cDataLen, lpData, sizeof(cDataLen)); + nRead += sizeof(cDataLen); + lpData += sizeof(cDataLen); + + m_nLen = cDataLen; + + if (m_nLen > 0) + { + m_lpData = (LPBYTE)malloc(m_nLen); + + if (m_lpData) + { + memcpy(m_lpData, lpData, m_nLen); + nRead += m_nLen; + } + else + m_nLen = 0; + } + else + m_nLen = 0; + } + } + break; + + case LLTYPE_FIXED: + { + m_nLen = m_nTypeLen; + + if (m_nLen > 0) + { + m_lpData = (LPBYTE)malloc(m_nLen); + + if (m_lpData) + { + memcpy(m_lpData, lpData, m_nLen); + nRead += m_nLen; + } + else + m_nLen = 0; + } + else + m_nLen = 0; + } + break; + + case LLTYPE_SINGLE: + case LLTYPE_MULTIPLE: + case LLTYPE_NULL: + default: + { + m_nLen = 0; + } + break; + } + + return nRead; +} + +void CVar::Dump(void) +{ + switch (m_nType) + { + case LLTYPE_U8: + { + unsigned char ubData; + memcpy(&ubData, m_lpData, sizeof(ubData)); + dprintf("%s: %hu\n", m_lpszVar, ubData); + } + break; + + case LLTYPE_U16: + { + WORD wData; + memcpy(&wData, m_lpData, sizeof(wData)); + dprintf("%s: %u\n", m_lpszVar, wData); + } + break; + + case LLTYPE_U32: + { + DWORD dwData; + memcpy(&dwData, m_lpData, sizeof(dwData)); + dprintf("%s: %lu\n", m_lpszVar, dwData); + } + break; + + case LLTYPE_U64: + { + ULONGLONG ullData; + memcpy(&ullData, m_lpData, sizeof(ullData)); + dprintf("%s: %I64u\n", m_lpszVar, ullData); + } + break; + + case LLTYPE_S8: + { + BYTE bData; + memcpy(&bData, m_lpData, sizeof(bData)); + dprintf("%s: %hd\n", m_lpszVar, bData); + } + break; + + case LLTYPE_S16: + { + SHORT sData; + memcpy(&sData, m_lpData, sizeof(sData)); + dprintf("%s: %d\n", m_lpszVar, sData); + } + break; + + case LLTYPE_S32: + { + LONG nData; + memcpy(&nData, m_lpData, sizeof(nData)); + dprintf("%s: %ld\n", m_lpszVar, nData); + } + break; + + case LLTYPE_S64: + break; + + case LLTYPE_F8: + break; + + case LLTYPE_F16: + break; + + case LLTYPE_F32: + { + FLOAT fData; + memcpy(&fData, m_lpData, sizeof(fData)); + dprintf("%s: %f\n", m_lpszVar, fData); + } + break; + + case LLTYPE_F64: + { + double dData; + memcpy(&dData, m_lpData, sizeof(dData)); + dprintf("%s: %f\n", m_lpszVar, dData); + } + break; + + case LLTYPE_LLUUID: + { + dprintf("%s: ", m_lpszVar); + for (int u = 0; u < m_nLen; u++) + dprintf("%02x", m_lpData[u]); + dprintf("\n"); + } + break; + + case LLTYPE_BOOL: + { + BYTE bData; + memcpy(&bData, m_lpData, sizeof(bData)); + dprintf("%s: %s\n", m_lpszVar, (bData) ? "True" : "False"); + } + break; + + case LLTYPE_LLVECTOR3: + { + FLOAT fData[3]; + memcpy(&fData, m_lpData, sizeof(fData)); + dprintf("%s: %f, %f, %f\n", m_lpszVar, fData[0], fData[1], fData[2]); + } + break; + + case LLTYPE_LLVECTOR3D: + { + double dData[3]; + memcpy(&dData, m_lpData, sizeof(dData)); + dprintf("%s: %f, %f, %f\n", m_lpszVar, dData[0], dData[1], dData[2]); + } + break; + + case LLTYPE_QUATERNION: + { + FLOAT fData[4]; + memcpy(&fData, m_lpData, sizeof(fData)); + dprintf("%s: %f, %f, %f, %f\n", m_lpszVar, fData[0], fData[1], fData[2], fData[3]); + } + break; + + case LLTYPE_IPADDR: + { + BYTE ipData[4]; + memcpy(&ipData, m_lpData, sizeof(ipData)); + dprintf("%s: %hu.%hu.%hu.%hu\n", m_lpszVar, ipData[0], ipData[1], ipData[2], ipData[3]); + } + break; + + case LLTYPE_IPPORT: + { + WORD wData; + memcpy(&wData, m_lpData, sizeof(wData)); + dprintf("%s: %hu\n", m_lpszVar, htons(wData)); + } + break; + + case LLTYPE_VARIABLE: + case LLTYPE_FIXED: + { + if (m_lpData) + { + bool bPrintable = true; + + for (int j = 0; j < m_nLen - 1; j++) + { + if (((unsigned char)m_lpData[j] < 0x20 || (unsigned char)m_lpData[j] > 0x7E) && (unsigned char)m_lpData[j] != 0x09 && (unsigned char)m_lpData[j] != 0x0D) + bPrintable = false; + } + + if (bPrintable && m_lpData[m_nLen - 1] == '\0') + { + dprintf("%s: %s\n", m_lpszVar, m_lpData); + } + else + { + for (int j = 0; j < m_nLen; j += 16) + { + dprintf("%s: ", m_lpszVar); + + for (int k = 0; k < 16; k++) + { + if ((j + k) < m_nLen) + { + dprintf("%02x ", (unsigned char)m_lpData[j+k]); + } + else + { + dprintf(" "); + } + } + + for (int k = 0; k < 16 && (j + k) < m_nLen; k++) + { + dprintf("%c", ((unsigned char)m_lpData[j+k] >= 0x20 && (unsigned char)m_lpData[j+k] <= 0x7E) ? (unsigned char)m_lpData[j+k] : '.'); + } + + dprintf("\n"); + } + } + } + } + break; + + case LLTYPE_SINGLE: + case LLTYPE_MULTIPLE: + case LLTYPE_NULL: + default: + { + dprintf("%s (%s / %d / %d)\n", m_lpszVar, LLTYPES[m_nType], m_nLen, m_nTypeLen); + } + break; + } +} + +int CVar::Pack(LPBYTE lpData) +{ + LPBYTE lpPtr = lpData; + int nTotalWrote = 0; + + switch (m_nType) + { + case LLTYPE_U8: + case LLTYPE_U16: + case LLTYPE_U32: + case LLTYPE_U64: + case LLTYPE_S8: + case LLTYPE_S16: + case LLTYPE_S32: + case LLTYPE_S64: + case LLTYPE_F8: + case LLTYPE_F16: + case LLTYPE_F32: + case LLTYPE_F64: + case LLTYPE_LLUUID: + case LLTYPE_BOOL: + case LLTYPE_LLVECTOR3: + case LLTYPE_LLVECTOR3D: + case LLTYPE_QUATERNION: + case LLTYPE_IPADDR: + case LLTYPE_IPPORT: + case LLTYPE_FIXED: + { + memcpy(lpPtr, m_lpData, m_nLen); + nTotalWrote = m_nLen; + } + break; + + case LLTYPE_VARIABLE: + { + if (m_nTypeLen == 1) + { + BYTE cDataLen; + + cDataLen = m_nLen; + + memcpy(lpPtr, &cDataLen, sizeof(cDataLen)); + nTotalWrote = sizeof(cDataLen); + + lpPtr += sizeof(cDataLen); + + memcpy(lpPtr, m_lpData, m_nLen); + nTotalWrote += m_nLen; + } + else if (m_nTypeLen == 2) + { + WORD cDataLen; + + cDataLen = m_nLen; + + memcpy(lpPtr, &cDataLen, sizeof(cDataLen)); + nTotalWrote = sizeof(cDataLen); + + lpPtr += sizeof(cDataLen); + + memcpy(lpPtr, m_lpData, m_nLen); + nTotalWrote += m_nLen; + } + } + break; + + case LLTYPE_SINGLE: + case LLTYPE_MULTIPLE: + case LLTYPE_NULL: + default: + { + nTotalWrote = 0; + } + break; + } + + return nTotalWrote; } \ No newline at end of file diff --git a/applications/snowcrash/snowflake/Var.h b/applications/snowcrash/snowflake/Var.h index b24d73aa..2a609338 100644 --- a/applications/snowcrash/snowflake/Var.h +++ b/applications/snowcrash/snowflake/Var.h @@ -1,24 +1,24 @@ -#pragma once - -class CVar -{ -public: - CVar(void); - ~CVar(void); - - char *m_lpszVar; - int m_nType; - int m_nTypeLen; - int m_nLen; - LPBYTE m_lpData; - - CVar *m_lpNext; - CVar *m_lpPrev; - void SetVar(char *lpszVar); - void SetType(int nType, int nTypeLen = 0); - int SetData(LPBYTE lpData); - void GetString(char &lpszStr); - void GetBool(bool &lpbBool); - void Dump(void); - int Pack(LPBYTE lpData); -}; +#pragma once + +class CVar +{ +public: + CVar(void); + ~CVar(void); + + char *m_lpszVar; + int m_nType; + int m_nTypeLen; + int m_nLen; + LPBYTE m_lpData; + + CVar *m_lpNext; + CVar *m_lpPrev; + void SetVar(char *lpszVar); + void SetType(int nType, int nTypeLen = 0); + int SetData(LPBYTE lpData); + void GetString(char &lpszStr); + void GetBool(bool &lpbBool); + void Dump(void); + int Pack(LPBYTE lpData); +}; diff --git a/applications/snowcrash/snowflake/keywords.cpp b/applications/snowcrash/snowflake/keywords.cpp index 7baecca0..92440bc2 100644 --- a/applications/snowcrash/snowflake/keywords.cpp +++ b/applications/snowcrash/snowflake/keywords.cpp @@ -1,1545 +1,1545 @@ -#include "StdAfx.h" -#include ".\keywords.h" - -TCHAR *LLTYPES[] = { - _T("U8"), - _T("U16"), - _T("U32"), - _T("U64"), - _T("S8"), - _T("S16"), - _T("S32"), - _T("S64"), - _T("F8"), - _T("F16"), - _T("F32"), - _T("F64"), - _T("LLUUID"), - _T("BOOL"), - _T("LLVector3"), - _T("LLVector3d"), - _T("LLQuaternion"), - _T("IPADDR"), - _T("IPPORT"), - _T("Variable"), - _T("Fixed"), - _T("Single"), - _T("Multiple"), - NULL -}; - -TCHAR *LLKEYWORDS[] = { - _T("SeedCapability"), - _T("X"), - _T("Y"), - _T("Z"), - _T("VotedForCandidate"), - _T("AddFlags"), - _T("Everyone"), - _T("ReservedNewbie"), - _T("MapData"), - _T("AddItem"), - _T("MeanCollision"), - _T("RezScript"), - _T("AvatarSitResponse"), - _T("InventoryAssetResponse"), - _T("KillObject"), - _T("ProposalID"), - _T("SerialNum"), - _T("Duration"), - _T("ScriptQuestion"), - _T("AddCircuitCode"), - _T("UseCircuitCode"), - _T("ViewerCircuitCode"), - _T("ScriptAnswerYes"), - _T("PartnerID"), - _T("DirLandQuery"), - _T("TeleportStart"), - _T("EmpoweredBlock"), - _T("LogMessages"), - _T("DropGroupIM"), - _T("AboutText"), - _T("VisualParam"), - _T("GroupPrims"), - _T("SelectedPrims"), - _T("ID"), - _T("UUIDNameRequest"), - _T("UUIDGroupNameRequest"), - _T("MoneyTransactionsRequest"), - _T("GroupAccountTransactionsRequest"), - _T("MapNameRequest"), - _T("MailTaskSimRequest"), - _T("LandScriptsRequest"), - _T("UpdateSimulator"), - _T("BillableFactor"), - _T("ObjectBonusFactor"), - _T("EnableSimulator"), - _T("DisableSimulator"), - _T("ConfirmEnableSimulator"), - _T("LayerType"), - _T("ParcelOverlay"), - _T("AdjustBalance"), - _T("GroupOwned"), - _T("IP"), - _T("ChatFromViewer"), - _T("FirstLogin"), - _T("GroupTitle"), - _T("MapLayerReply"), - _T("CompoundMsgID"), - _T("CameraConstraint"), - _T("DownloadTotals"), - _T("ErrorValue"), - _T("GenCounter"), - _T("FrozenData"), - _T("URLBlock"), - _T("ChildAgentDying"), - _T("To"), - _T("ParcelDirFeeCurrent"), - _T("ObjectDuplicate"), - _T("InventoryData"), - _T("ReplyData"), - _T("ResetList"), - _T("SimulatorPauseState"), - _T("MediaID"), - _T("RedirectGridX"), - _T("RedirectGridY"), - _T("TransferID"), - _T("Transacted"), - _T("TexturesChanged"), - _T("UserLookAt"), - _T("TestBlock1"), - _T("SensedData"), - _T("UpdateBlock"), - _T("EmpoweredID"), - _T("ClassifiedGodDelete"), - _T("LocationPos"), - _T("ObjectGrabUpdate"), - _T("TaxDate"), - _T("StartDateTime"), - _T("ObjectUpdateCached"), - _T("Packets"), - _T("FailureType"), - _T("UpdateGroupInfo"), - _T("InventoryFile"), - _T("ObjectPermissions"), - _T("RevokePermissions"), - _T("UpdateFlags"), - _T("ObjectExportSelected"), - _T("RezSelected"), - _T("AutoPilot"), - _T("UpdateMuteListEntry"), - _T("RemoveMuteListEntry"), - _T("SetSimStatusInDatabase"), - _T("SetSimPresenceInDatabase"), - _T("CameraProperty"), - _T("GroupRecallBallot"), - _T("BrushSize"), - _T("StartExpungeProcess"), - _T("SimulatorSetMap"), - _T("RegionPresenceRequestByRegionID"), - _T("TransferEnergy"), - _T("ParcelObjectOwnersReply"), - _T("GroupMembersReply"), - _T("GroupOfficersAndMembersReply"), - _T("RequestRegionInfo"), - _T("AABBMax"), - _T("RequestPayPrice"), - _T("SimulatorPresentAtLocation"), - _T("AgentRequestSit"), - _T("AABBMin"), - _T("ClassifiedFlags"), - _T("ControlFlags"), - _T("TeleportRequest"), - _T("SpaceLocationTeleportRequest"), - _T("LeaderBoardRequest"), - _T("ScriptTeleportRequest"), - _T("DateUTC"), - _T("TaskIDs"), - _T("RequestResult"), - _T("ReputationAgentAssign"), - _T("CanAcceptAgents"), - _T("ObjectSaleInfo"), - _T("KillChildAgents"), - _T("Balance"), - _T("DerezContainer"), - _T("ObjectData"), - _T("CameraAtAxis"), - _T("InfoBlock"), - _T("OwnershipCost"), - _T("AvatarNotesUpdate"), - _T("PID"), - _T("TimeString"), - _T("DirPopularReply"), - _T("TerrainHeightRange00"), - _T("SimData"), - _T("TerrainHeightRange01"), - _T("TerrainHeightRange10"), - _T("TerrainHeightRange11"), - _T("UpdateInventoryItem"), - _T("MoveInventoryItem"), - _T("CopyInventoryItem"), - _T("RemoveInventoryItem"), - _T("CreateInventoryItem"), - _T("PathTwistBegin"), - _T("CRC"), - _T("AttachmentPoint"), - _T("TelehubBlock"), - _T("FOVBlock"), - _T("StartLocationData"), - _T("PositionData"), - _T("TimeSinceLast"), - _T("MapImage"), - _T("Objects"), - _T("URL"), - _T("CreationDate"), - _T("JointPivot"), - _T("RateeID"), - _T("FPS"), - _T("HasTelehub"), - _T("PathEnd"), - _T("ScriptDataReply"), - _T("MapBlockReply"), - _T("PropertiesData"), - _T("ViewerEffect"), - _T("FreezeUser"), - _T("OwnerPrims"), - _T("ScriptTime"), - _T("ObjectGrab"), - _T("ToAgentID"), - _T("ProxyBlock"), - _T("SimulatorMapUpdate"), - _T("TransferPacket"), - _T("ObjectName"), - _T("OriginalName"), - _T("CompletePingCheck"), - _T("OnlineStatus"), - _T("TrackOnlineStatus"), - _T("IgnoreOnlineStatus"), - _T("ObjectDrop"), - _T("UseBigPackets"), - _T("ParcelAccessListReply"), - _T("RpcChannelReply"), - _T("RegionPresenceResponse"), - _T("AgentPresenceResponse"), - _T("CharterMember"), - _T("EdgeData"), - _T("NameData"), - _T("RegionPushOverride"), - _T("SimName"), - _T("UserReport"), - _T("DownloadPriority"), - _T("ToAgentId"), - _T("Mag"), - _T("DirPopularQuery"), - _T("ParcelPropertiesRequestByID"), - _T("ObjectLink"), - _T("RpcScriptReplyInbound"), - _T("BoardData"), - _T("RezData"), - _T("RemoveInventoryObjects"), - _T("Officer"), - _T("GroupProposalBallot"), - _T("RPCServerIP"), - _T("Far"), - _T("GodSessionID"), - _T("ViewerDigest"), - _T("FLAboutText"), - _T("RegionHandshakeReply"), - _T("GroupActiveProposalItemReply"), - _T("MapItemReply"), - _T("Seconds"), - _T("UpdateUserInfo"), - _T("AggregatePermTexturesOwner"), - _T("Set"), - _T("Key"), - _T("NewName"), - _T("AgentID"), - _T("OnlineStatusRequest"), - _T("DataAgentAccessRequest"), - _T("EventNotificationRemoveRequest"), - _T("Arc"), - _T("NewFolderID"), - _T("RegionX"), - _T("RegionY"), - _T("RequestData"), - _T("Msg"), - _T("Top"), - _T("MiscStats"), - _T("Pos"), - _T("ImageID"), - _T("DataPacket"), - _T("ObjectDehinge"), - _T("You"), - _T("ScriptControlChange"), - _T("LoadURL"), - _T("SetCPURatio"), - _T("NameValueData"), - _T("AtomicPassObject"), - _T("ViewerFrozenMessage"), - _T("HealthMessage"), - _T("LogTextMessage"), - _T("TimeDilation"), - _T("Contribution"), - _T("SetGroupContribution"), - _T("Offline"), - _T("SecPerDay"), - _T("Members"), - _T("FailedResends"), - _T("CameraCenter"), - _T("CameraLeftAxis"), - _T("ExBlock"), - _T("Channel"), - _T("NetTest"), - _T("DiscardLevel"), - _T("LayerID"), - _T("RatorID"), - _T("GrabOffset"), - _T("SimPort"), - _T("PricePerMeter"), - _T("RegionFlags"), - _T("VoteResult"), - _T("ParcelDirFeeEstimate"), - _T("ModifyBlock"), - _T("InventoryBlock"), - _T("ReplyBlock"), - _T("RequireMask"), - _T("ValidUntil"), - _T("VelocityInterpolateOn"), - _T("ClassifiedDelete"), - _T("FLImageID"), - _T("AllowPublish"), - _T("SitName"), - _T("OfficerTitle"), - _T("RegionsVisited"), - _T("RecallID"), - _T("DirClassifiedReply"), - _T("AvatarClassifiedReply"), - _T("ReputationIndividualReply"), - _T("MediaURL"), - _T("CompleteAgentMovement"), - _T("SpaceIP"), - _T("ClassifiedID"), - _T("LocalID"), - _T("RemoveItem"), - _T("LogFailedMoneyTransaction"), - _T("ViewerStartAuction"), - _T("StartAuction"), - _T("NameValueName"), - _T("AngVelX"), - _T("DuplicateFlags"), - _T("AngVelY"), - _T("AngVelZ"), - _T("TextColor"), - _T("SlaveID"), - _T("Charter"), - _T("TargetBlock"), - _T("AlertData"), - _T("CheckParcelAuctions"), - _T("ParcelAuctions"), - _T("NameValuePair"), - _T("RemoveNameValuePair"), - _T("GetNameValuePair"), - _T("BulkUpdateInventory"), - _T("UpdateTaskInventory"), - _T("RemoveTaskInventory"), - _T("MoveTaskInventory"), - _T("RequestTaskInventory"), - _T("ReplyTaskInventory"), - _T("DeclineInventory"), - _T("AggregatePermInventory"), - _T("SimulatorInfo"), - _T("MoneyTransactionsReply"), - _T("GroupAccountTransactionsReply"), - _T("MailTaskSimReply"), - _T("WearableData"), - _T("StatisticsData"), - _T("AccessOK"), - _T("Enabled"), - _T("Savings"), - _T("SimulatorLoad"), - _T("InternalRegionIP"), - _T("ExternalRegionIP"), - _T("CreateGroupRequest"), - _T("JoinGroupRequest"), - _T("LeaveGroupRequest"), - _T("InviteGroupRequest"), - _T("LiveHelpGroupRequest"), - _T("ServerVersion"), - _T("PriceParcelClaimFactor"), - _T("BillableArea"), - _T("ScriptCount"), - _T("ObjectID"), - _T("ObjectFlagUpdate"), - _T("ActiveOnly"), - _T("RequestInventoryAsset"), - _T("RedoLand"), - _T("TravelAccess"), - _T("ChangedGrid"), - _T("Details"), - _T("LocationX"), - _T("SaleType"), - _T("ObjectExportReply"), - _T("LocationY"), - _T("LocationZ"), - _T("EconomyData"), - _T("HeadRotation"), - _T("DeleteOnCompletion"), - _T("PublicPort"), - _T("CurrentTaxes"), - _T("DirClassifiedQuery"), - _T("RequestParcelTransfer"), - _T("ObjectCapacity"), - _T("RequestID"), - _T("GranterName"), - _T("RequestXfer"), - _T("ObjectTaxCurrent"), - _T("LightTaxCurrent"), - _T("LandTaxCurrent"), - _T("GroupTaxCurrent"), - _T("FetchInventoryDescendents"), - _T("InventoryDescendents"), - _T("Descendents"), - _T("PurgeInventoryDescendents"), - _T("ShowDir"), - _T("Timestamp"), - _T("GlobalPos"), - _T("LimitedToEstate"), - _T("GrabOffsetInitial"), - _T("IsTrial"), - _T("FinalizeLogout"), - _T("ObjectDuplicateOnRay"), - _T("GroupMembershipCount"), - _T("MethodData"), - _T("ActivateGestures"), - _T("DeactivateGestures"), - _T("ProposalData"), - _T("PosGlobal"), - _T("SearchID"), - _T("RezMultipleAttachmentsFromInv"), - _T("SearchName"), - _T("VersionString"), - _T("CreateGroupReply"), - _T("ActualArea"), - _T("RevokedID"), - _T("Message"), - _T("ClickAction"), - _T("AssetUploadComplete"), - _T("EstimatedTaxes"), - _T("RequestType"), - _T("UUID"), - _T("BaseMask"), - _T("NetBlock"), - _T("GlobalX"), - _T("GlobalY"), - _T("CopyRotates"), - _T("KickUserAck"), - _T("TopPick"), - _T("SessionID"), - _T("GlobalZ"), - _T("CallVote"), - _T("DeclineFriendship"), - _T("FormFriendship"), - _T("TerminateFriendship"), - _T("TaskData"), - _T("SimWideMaxPrims"), - _T("TotalPrims"), - _T("SourceFilename"), - _T("ProfileBegin"), - _T("MoneyDetailsRequest"), - _T("Request"), - _T("GroupAccountDetailsRequest"), - _T("GroupActiveProposalsRequest"), - _T("VoteQuorum"), - _T("StringValue"), - _T("ClosestSimulator"), - _T("Version"), - _T("OtherCount"), - _T("ChatData"), - _T("IsGroupOwned"), - _T("EnergyEfficiency"), - _T("MaxPlace"), - _T("PickInfoUpdate"), - _T("PickDelete"), - _T("ScriptReset"), - _T("Requester"), - _T("RevokerID"), - _T("ElectionID"), - _T("ForSale"), - _T("NearestLandingRegionReply"), - _T("RecordAgentPresence"), - _T("EraseAgentPresence"), - _T("ParcelID"), - _T("Godlike"), - _T("TotalDebits"), - _T("Direction"), - _T("Appearance"), - _T("HealthData"), - _T("LeftAxis"), - _T("PositionBlock"), - _T("LocationBlock"), - _T("ObjectImage"), - _T("TerrainStartHeight00"), - _T("TerrainStartHeight01"), - _T("TerrainStartHeight10"), - _T("ObjectHinge"), - _T("TerrainStartHeight11"), - _T("MetersPerGrid"), - _T("WaterHeight"), - _T("FetchInventoryReply"), - _T("MoneySummaryReply"), - _T("GroupAccountSummaryReply"), - _T("AttachedSound"), - _T("ParamInUse"), - _T("GodKickUser"), - _T("PickName"), - _T("TaskName"), - _T("SkillFlags"), - _T("ParcelGodReserveForNewbie"), - _T("SubType"), - _T("ObjectCount"), - _T("RegionPresenceRequestByHandle"), - _T("RezSingleAttachmentFromInv"), - _T("ChildAgentUpdate"), - _T("ToID"), - _T("ViewerPort"), - _T("IsOwnerGroup"), - _T("AgentHeightWidth"), - _T("VerticalAngle"), - _T("WearableType"), - _T("AggregatePermNextOwner"), - _T("ShowInList"), - _T("PositionSuggestion"), - _T("UpdateParcel"), - _T("ClearAgentSessions"), - _T("SetAlwaysRun"), - _T("NVPair"), - _T("ObjectSpinStart"), - _T("UseEstateSun"), - _T("LogoutBlock"), - _T("RelayLogControl"), - _T("RegionID"), - _T("Creator"), - _T("ViewerRegion"), - _T("ProposalText"), - _T("DirEventsReply"), - _T("EventInfoReply"), - _T("GroupElectionInfoReply"), - _T("UserInfoReply"), - _T("PathRadiusOffset"), - _T("SessionInfo"), - _T("TextureData"), - _T("ChatPass"), - _T("TargetID"), - _T("DefaultPayPrice"), - _T("UserLocation"), - _T("MaxPrims"), - _T("RegionIP"), - _T("LandmarkID"), - _T("InitiateDownload"), - _T("Name"), - _T("OtherCleanTime"), - _T("TeleportPriceExponent"), - _T("Gain"), - _T("VelX"), - _T("PacketAck"), - _T("PathSkew"), - _T("Negative"), - _T("VelY"), - _T("SimulatorShutdownRequest"), - _T("NearestLandingRegionRequest"), - _T("VelZ"), - _T("OtherID"), - _T("MapLayerRequest"), - _T("PatchVersion"), - _T("ObjectScale"), - _T("TargetIP"), - _T("Redo"), - _T("MoneyBalance"), - _T("TrackAgent"), - _T("MaxX"), - _T("Data"), - _T("MaxY"), - _T("TextureAnim"), - _T("ReturnIDs"), - _T("Date"), - _T("GestureUpdate"), - _T("AgentWearablesUpdate"), - _T("AgentDataUpdate"), - _T("Hash"), - _T("Left"), - _T("Mask"), - _T("ForceMouselook"), - _T("RequestLocationGetAccess"), - _T("Success"), - _T("ObjectGroup"), - _T("SunHour"), - _T("MinX"), - _T("ScriptSensorReply"), - _T("MinY"), - _T("Command"), - _T("Desc"), - _T("AttachmentNeedsSave"), - _T("HistoryItemData"), - _T("AgentCachedTexture"), - _T("East"), - _T("Subject"), - _T("GodExpungeUser"), - _T("QueryReplies"), - _T("ObjectCategory"), - _T("Time"), - _T("CreateLandmarkForEvent"), - _T("ParentID"), - _T("Ping"), - _T("Perp"), - _T("Code"), - _T("InvType"), - _T("AgentFOV"), - _T("BulkMoneyTransfer"), - _T("Audible"), - _T("AuctionData"), - _T("IDBlock"), - _T("ReputationData"), - _T("West"), - _T("ElectionData"), - _T("Undo"), - _T("Info"), - _T("Area"), - _T("Behavior"), - _T("SimCrashed"), - _T("Text"), - _T("AgentToNewRegion"), - _T("PriceGroupCreate"), - _T("ObjectShape"), - _T("PosX"), - _T("PosY"), - _T("MuteCRC"), - _T("PosZ"), - _T("Size"), - _T("FromAddress"), - _T("Body"), - _T("FileData"), - _T("List"), - _T("KickUser"), - _T("OtherPrims"), - _T("RunTime"), - _T("RpcScriptRequestInboundForward"), - _T("More"), - _T("Majority"), - _T("SenderID"), - _T("MetersTraveled"), - _T("Stat"), - _T("FromAgentID"), - _T("Item"), - _T("SoundID"), - _T("User"), - _T("RemoteInfos"), - _T("Vote"), - _T("Prey"), - _T("UsecSinceStart"), - _T("RayStart"), - _T("ParcelData"), - _T("CameraUpAxis"), - _T("ScriptDialog"), - _T("MasterParcelData"), - _T("Invalid"), - _T("MinPlace"), - _T("ProfileCurve"), - _T("ParcelAccessListUpdate"), - _T("MuteListUpdate"), - _T("SendPacket"), - _T("SendXferPacket"), - _T("LastName"), - _T("From"), - _T("Port"), - _T("MemberTitle"), - _T("LogParcelChanges"), - _T("DeRezObject"), - _T("IsTemporary"), - _T("IsComplete"), - _T("InsigniaID"), - _T("CheckFlags"), - _T("TransferPriority"), - _T("EventID"), - _T("FromAgentId"), - _T("Type"), - _T("ChatType"), - _T("ReportData"), - _T("LeaderBoardData"), - _T("RequestBlock"), - _T("GrantData"), - _T("DetachAttachmentIntoInv"), - _T("ParcelDisableObjects"), - _T("Sections"), - _T("GodLevel"), - _T("StartGroupIM"), - _T("PayPriceReply"), - _T("QueryID"), - _T("CameraEyeOffset"), - _T("AgentPosition"), - _T("GrabPosition"), - _T("GrantModification"), - _T("RevokeModification"), - _T("OnlineNotification"), - _T("OfflineNotification"), - _T("SendPostcard"), - _T("RequestFlags"), - _T("MoneyHistoryRequest"), - _T("MoneySummaryRequest"), - _T("GroupMoneyHistoryRequest"), - _T("GroupAccountSummaryRequest"), - _T("ParamValue"), - _T("GroupVoteHistoryRequest"), - _T("Checksum"), - _T("MaxAgents"), - _T("CreateNewOutfitAttachments"), - _T("RegionHandle"), - _T("TeleportProgress"), - _T("AgentQuitCopy"), - _T("LocationValid"), - _T("ToViewer"), - _T("ParcelName"), - _T("InviteOfficers"), - _T("PriceObjectRent"), - _T("ConnectAgentToUserserver"), - _T("ConnectToUserserver"), - _T("OfferCallingCard"), - _T("AgentAccess"), - _T("AcceptCallingCard"), - _T("DeclineCallingCard"), - _T("DataHomeLocationReply"), - _T("EventLocationReply"), - _T("UserLoginLocationReply"), - _T("UserSimLocationReply"), - _T("SpaceLoginLocationReply"), - _T("TerseDateID"), - _T("ObjectOwner"), - _T("AssetID"), - _T("AlertMessage"), - _T("AgentAlertMessage"), - _T("EstateOwnerMessage"), - _T("ParcelMediaCommandMessage"), - _T("Auction"), - _T("Category"), - _T("FilePath"), - _T("ItemFlags"), - _T("Invoice"), - _T("IntervalDays"), - _T("PathScaleX"), - _T("FromTaskID"), - _T("TimeInfo"), - _T("PathScaleY"), - _T("PublicCount"), - _T("ParcelJoin"), - _T("SimulatorBlock"), - _T("UserBlock"), - _T("GroupID"), - _T("AgentVel"), - _T("RequestImage"), - _T("NetStats"), - _T("AgentPos"), - _T("AgentSit"), - _T("Material"), - _T("ObjectDeGrab"), - _T("VelocityInterpolateOff"), - _T("AuthorizedBuyerID"), - _T("RemoveMemberFromGroup"), - _T("GroupIM"), - _T("AvatarPropertiesReply"), - _T("GroupPropertiesReply"), - _T("GroupProfileReply"), - _T("Participants"), - _T("SimOwner"), - _T("SalePrice"), - _T("Animation"), - _T("CurrentDividend"), - _T("OwnerID"), - _T("NearestLandingRegionUpdated"), - _T("PassToAgent"), - _T("PreyAgent"), - _T("SimStats"), - _T("Options"), - _T("LogoutReply"), - _T("ObjectLocalID"), - _T("Dropped"), - _T("Destination"), - _T("MasterID"), - _T("TransferData"), - _T("WantToMask"), - _T("AvatarData"), - _T("ParcelSelectObjects"), - _T("ExtraParams"), - _T("LogLogin"), - _T("CreatorID"), - _T("Summary"), - _T("BuyObjectInventory"), - _T("FetchInventory"), - _T("InventoryID"), - _T("PacketNumber"), - _T("SetFollowCamProperties"), - _T("ClearFollowCamProperties"), - _T("SimulatorThrottleSettings"), - _T("SequenceID"), - _T("DataServerLogout"), - _T("NameValue"), - _T("PathShearX"), - _T("PathShearY"), - _T("ElectionType"), - _T("Velocity"), - _T("SecPerYear"), - _T("FirstName"), - _T("AttachedSoundGainChange"), - _T("LocationID"), - _T("Running"), - _T("ObjectImportReply"), - _T("AgentThrottle"), - _T("NeighborList"), - _T("PathTaperX"), - _T("PathTaperY"), - _T("GranterBlock"), - _T("UseCachedMuteList"), - _T("FailStats"), - _T("StartGroupRecall"), - _T("Tempfile"), - _T("FounderName"), - _T("BuyerID"), - _T("DirPeopleReply"), - _T("TransferInfo"), - _T("AvatarPickerRequestBackend"), - _T("AvatarPropertiesRequestBackend"), - _T("UpdateData"), - _T("ReporterID"), - _T("GranterID"), - _T("ButtonLabel"), - _T("WantToText"), - _T("ReportType"), - _T("DataBlock"), - _T("SimulatorReady"), - _T("AnimationSourceList"), - _T("RefreshViewer"), - _T("SubscribeLoad"), - _T("UnsubscribeLoad"), - _T("Packet"), - _T("UndoLand"), - _T("SimAccess"), - _T("MembershipFee"), - _T("CreateInventoryFolder"), - _T("UpdateInventoryFolder"), - _T("MoveInventoryFolder"), - _T("RemoveInventoryFolder"), - _T("MoneyData"), - _T("ObjectDeselect"), - _T("NewAssetID"), - _T("ObjectAdd"), - _T("RayEndIsIntersection"), - _T("CompleteAuction"), - _T("CircuitCode"), - _T("AgentMovementComplete"), - _T("ViewerIP"), - _T("Header"), - _T("GestureFlags"), - _T("XferID"), - _T("StatValue"), - _T("PickID"), - _T("TaskID"), - _T("GridsPerEdge"), - _T("RayEnd"), - _T("Throttles"), - _T("UpAxis"), - _T("AgentTextures"), - _T("Radius"), - _T("OffCircuit"), - _T("Access"), - _T("SquareMetersCredit"), - _T("Filename"), - _T("SecuredTemplateChecksumRequest"), - _T("TemplateChecksumRequest"), - _T("AgentPresenceRequest"), - _T("ClassifiedInfoRequest"), - _T("ParcelInfoRequest"), - _T("ParcelObjectOwnersRequest"), - _T("TeleportLandmarkRequest"), - _T("EventInfoRequest"), - _T("MovedIntoSimulator"), - _T("ChatFromSimulator"), - _T("PickInfoRequest"), - _T("MoneyBalanceRequest"), - _T("DirPeopleQuery"), - _T("GroupElectionInfoRequest"), - _T("GroupMembersRequest"), - _T("GroupOfficersAndMembersRequest"), - _T("TextureID"), - _T("OldFolderID"), - _T("UserInfoRequest"), - _T("LandCollidersRequest"), - _T("Handle"), - _T("StartParcelRenameAck"), - _T("StateLoad"), - _T("ButtonIndex"), - _T("CurrentElectionID"), - _T("GetScriptRunning"), - _T("SetScriptRunning"), - _T("Health"), - _T("FileID"), - _T("CircuitInfo"), - _T("ObjectBuy"), - _T("ProfileEnd"), - _T("Effect"), - _T("TestMessage"), - _T("ScriptMailRegistration"), - _T("AgentSetAppearance"), - _T("AvatarAppearance"), - _T("RegionData"), - _T("RequestingRegionData"), - _T("LandingRegionData"), - _T("SitTransform"), - _T("TerrainBase0"), - _T("SkillsMask"), - _T("AtAxis"), - _T("TerrainBase1"), - _T("Reason"), - _T("TerrainBase2"), - _T("TerrainBase3"), - _T("Params"), - _T("PingID"), - _T("Height"), - _T("Region"), - _T("MoneyHistoryReply"), - _T("GroupMoneyHistoryReply"), - _T("TelehubInfo"), - _T("StateSave"), - _T("AgentAnimation"), - _T("AvatarAnimation"), - _T("LogDwellTime"), - _T("ParcelGodMarkAsContent"), - _T("UsePhysics"), - _T("JointType"), - _T("TaxEstimate"), - _T("ObjectTaxEstimate"), - _T("LightTaxEstimate"), - _T("TeleportLandingStatusChanged"), - _T("LandTaxEstimate"), - _T("GroupTaxEstimate"), - _T("Buttons"), - _T("Sender"), - _T("Dialog"), - _T("DestID"), - _T("PricePublicObjectDelete"), - _T("ObjectDelete"), - _T("Delete"), - _T("EventGodDelete"), - _T("LastTaxDate"), - _T("MapImageID"), - _T("EndDateTime"), - _T("TerrainDetail0"), - _T("TerrainDetail1"), - _T("TerrainDetail2"), - _T("TerrainDetail3"), - _T("Offset"), - _T("ObjectDelink"), - _T("TargetObject"), - _T("IsEstateManager"), - _T("CancelAuction"), - _T("ObjectDetach"), - _T("Compressed"), - _T("PathBegin"), - _T("BypassRaycast"), - _T("WinnerID"), - _T("ChannelType"), - _T("NumberNonExemptMembers"), - _T("NonExemptMembers"), - _T("Agents"), - _T("SimulatorStart"), - _T("Enable"), - _T("RevokedBlock"), - _T("MemberData"), - _T("ImageNotInDatabase"), - _T("StartDate"), - _T("AnimID"), - _T("Serial"), - _T("GroupElectionBallot"), - _T("ControlPort"), - _T("ModifyLand"), - _T("Digest"), - _T("Victim"), - _T("Script"), - _T("TemplateChecksumReply"), - _T("PickInfoReply"), - _T("MoneyBalanceReply"), - _T("RoutedMoneyBalanceReply"), - _T("RegionInfo"), - _T("Sequence"), - _T("GodUpdateRegionInfo"), - _T("LocalX"), - _T("LocalY"), - _T("StartAnim"), - _T("Location"), - _T("Action"), - _T("SearchDir"), - _T("Active"), - _T("TransferRequest"), - _T("ScriptSensorRequest"), - _T("MoneyTransferRequest"), - _T("EjectGroupMemberRequest"), - _T("SkillsText"), - _T("Resent"), - _T("Center"), - _T("SharedData"), - _T("PSBlock"), - _T("UUIDNameBlock"), - _T("Viewer"), - _T("Method"), - _T("TouchName"), - _T("CandidateID"), - _T("ParamData"), - _T("GodlikeMessage"), - _T("SystemMessage"), - _T("BodyRotation"), - _T("StartGroupElection"), - _T("SearchRegions"), - _T("Ignore"), - _T("AnimationData"), - _T("StatID"), - _T("ItemID"), - _T("AvatarStatisticsReply"), - _T("ScriptDialogReply"), - _T("RegionIDAndHandleReply"), - _T("CameraAtOffset"), - _T("VoteID"), - _T("ParcelGodForceOwner"), - _T("InviteData"), - _T("CandidateData"), - _T("PCode"), - _T("SearchPos"), - _T("PreyID"), - _T("TerrainLowerLimit"), - _T("EventFlags"), - _T("TallyVotes"), - _T("GroupInfoUpdated"), - _T("Result"), - _T("LookAt"), - _T("PayButton"), - _T("SelfCount"), - _T("PacketCount"), - _T("ParcelBuyPass"), - _T("SimHandle"), - _T("Identified"), - _T("OldItemID"), - _T("RegionPort"), - _T("PriceEnergyUnit"), - _T("Bitmap"), - _T("TrackAgentSession"), - _T("CacheMissType"), - _T("VFileID"), - _T("Response"), - _T("GroupInsigniaID"), - _T("FromID"), - _T("Online"), - _T("KickFlags"), - _T("SysCPU"), - _T("EMail"), - _T("InviteMembers"), - _T("IncludeMembers"), - _T("AggregatePermTextures"), - _T("ChatChannel"), - _T("ReturnID"), - _T("ObjectAttach"), - _T("TargetPort"), - _T("ObjectSpinStop"), - _T("FullID"), - _T("ActivateGroup"), - _T("SysGPU"), - _T("StartLure"), - _T("SysRAM"), - _T("ObjectPosition"), - _T("SitPosition"), - _T("StartTime"), - _T("BornOn"), - _T("CameraCollidePlane"), - _T("EconomyDataRequest"), - _T("TeleportLureRequest"), - _T("FolderID"), - _T("RegionHandleRequest"), - _T("GestureRequest"), - _T("ScriptDataRequest"), - _T("AgentWearablesRequest"), - _T("MapBlockRequest"), - _T("LureID"), - _T("CopyCenters"), - _T("RegisterNewAgent"), - _T("TotalColliderCount"), - _T("ParamList"), - _T("InventorySerial"), - _T("EdgeDataPacket"), - _T("AvatarPickerReply"), - _T("ParcelDwellReply"), - _T("IsForSale"), - _T("MuteID"), - _T("MeanCollisionAlert"), - _T("CanAcceptTasks"), - _T("ItemData"), - _T("AnimationList"), - _T("PassObject"), - _T("Reputation"), - _T("IntValue"), - _T("TargetType"), - _T("Amount"), - _T("UpdateAttachment"), - _T("RemoveAttachment"), - _T("HeightWidthBlock"), - _T("RequestObjectPropertiesFamily"), - _T("ObjectPropertiesFamily"), - _T("UserData"), - _T("SessionBlock"), - _T("IsReadable"), - _T("ReputationMax"), - _T("PathCurve"), - _T("ReputationMin"), - _T("Status"), - _T("AlreadyVoted"), - _T("ElectionInitiator"), - _T("PlacesReply"), - _T("DirPlacesReply"), - _T("ParcelBuy"), - _T("DirFindQueryBackend"), - _T("DirPlacesQueryBackend"), - _T("DirPeopleQueryBackend"), - _T("DirGroupsQueryBackend"), - _T("DirClassifiedQueryBackend"), - _T("DirPicksQueryBackend"), - _T("DirLandQueryBackend"), - _T("DirPopularQueryBackend"), - _T("SnapshotID"), - _T("Aspect"), - _T("LogoutDemand"), - _T("HistoryData"), - _T("VoteData"), - _T("EstimatedDividend"), - _T("ParamSize"), - _T("VoteCast"), - _T("EveryoneMask"), - _T("CastsShadows"), - _T("SetSunPhase"), - _T("ObjectSpinUpdate"), - _T("MaturePublish"), - _T("UseExistingAsset"), - _T("ParcelLocalID"), - _T("TeleportCancel"), - _T("UnixTime"), - _T("QueryFlags"), - _T("LastExecFroze"), - _T("AlwaysRun"), - _T("Bottom"), - _T("ButtonData"), - _T("SoundData"), - _T("ViewerStats"), - _T("RegionHandshake"), - _T("Description"), - _T("ObjectDescription"), - _T("ParamType"), - _T("UUIDNameReply"), - _T("UUIDGroupNameReply"), - _T("SaveAssetIntoInventory"), - _T("UserInfo"), - _T("AnimSequenceID"), - _T("NVPairs"), - _T("ParcelAccessListRequest"), - _T("UserListRequest"), - _T("MuteListRequest"), - _T("StartPeriod"), - _T("RpcChannelRequest"), - _T("PlacesQuery"), - _T("DirPlacesQuery"), - _T("Distance"), - _T("SortOrder"), - _T("Hunter"), - _T("TotalScriptCount"), - _T("SunAngVelocity"), - _T("InventoryUpdate"), - _T("ImagePacket"), - _T("BinaryBucket"), - _T("StartGroupProposal"), - _T("EnergyLevel"), - _T("PriceForListing"), - _T("Scale"), - _T("ParentEstateID"), - _T("Extra2"), - _T("Throttle"), - _T("SimIP"), - _T("GodID"), - _T("TeleportMinPrice"), - _T("VoteItem"), - _T("ObjectRotation"), - _T("SitRotation"), - _T("SnapSelection"), - _T("SoundTrigger"), - _T("TerrainRaiseLimit"), - _T("Quorum"), - _T("TokenBlock"), - _T("AgentBlock"), - _T("CommandBlock"), - _T("PricePublicObjectDecay"), - _T("SpawnPointPos"), - _T("AttachedSoundCutoffRadius"), - _T("VolumeDetail"), - _T("TasksPaused"), - _T("Range"), - _T("FromAgentName"), - _T("AddModifyAbility"), - _T("RemoveModifyAbility"), - _T("PublicIP"), - _T("TeleportFailed"), - _T("OnlineStatusReply"), - _T("DataAgentAccessReply"), - _T("RequestLocationGetAccessReply"), - _T("RequestAvatarInfo"), - _T("PreloadSound"), - _T("ScreenshotID"), - _T("OldestUnacked"), - _T("SimulatorIP"), - _T("ObjectImport"), - _T("MoneyMax"), - _T("Value"), - _T("JointAxisOrAnchor"), - _T("Test0"), - _T("MoneyMin"), - _T("Test1"), - _T("Test2"), - _T("SunPhase"), - _T("Place"), - _T("Phase"), - _T("ParcelDivide"), - _T("PriceObjectClaim"), - _T("VoteTime"), - _T("Field"), - _T("Ratio"), - _T("JoinGroupReply"), - _T("LiveHelpGroupReply"), - _T("Agent"), - _T("Score"), - _T("ExpungeData"), - _T("Image"), - _T("ObjectClickAction"), - _T("Delta"), - _T("InitiateUpload"), - _T("Parameter"), - _T("Flags"), - _T("Plane"), - _T("Width"), - _T("VoteText"), - _T("Right"), - _T("DirFindQuery"), - _T("Textures"), - _T("EventData"), - _T("Final"), - _T("TelehubPos"), - _T("ReportAutosaveCrash"), - _T("Reset"), - _T("CreateTrustedCircuit"), - _T("DenyTrustedCircuit"), - _T("Codec"), - _T("Level"), - _T("Modal"), - _T("ChildAgentUnknown"), - _T("LandingType"), - _T("ScriptRunningReply"), - _T("MoneyDetailsReply"), - _T("Reply"), - _T("TelehubRot"), - _T("RequestFriendship"), - _T("AcceptFriendship"), - _T("GroupAccountDetailsReply"), - _T("DwellInfo"), - _T("AgentResume"), - _T("ItemType"), - _T("MailFilter"), - _T("Disconnect"), - _T("SimPosition"), - _T("SimWideTotalPrims"), - _T("Index"), - _T("BaseFilename"), - _T("SimFilename"), - _T("LastOwnerID"), - _T("EmailMessageRequest"), - _T("MapItemRequest"), - _T("AgentCount"), - _T("InitializeLure"), - _T("HelloBlock"), - _T("FuseBlock"), - _T("MessageBlock"), - _T("ClassifiedInfoUpdate"), - _T("RegionPos"), - _T("ParcelMediaUpdate"), - _T("GridX"), - _T("GridY"), - _T("AuctionID"), - _T("VoteType"), - _T("CategoryID"), - _T("Token"), - _T("AggregatePerms"), - _T("StartParcelRemoveAck"), - _T("ObjectSelect"), - _T("ForceObjectSelect"), - _T("Price"), - _T("SunDirection"), - _T("FromName"), - _T("ChangeInventoryItemFlags"), - _T("Force"), - _T("TransactionBlock"), - _T("PowersMask"), - _T("Stamp"), - _T("RelatedID"), - _T("TotalCredits"), - _T("State"), - _T("TextureIndex"), - _T("SimPaused"), - _T("InviteeID"), - _T("ParcelReclaim"), - _T("Money"), - _T("PathTwist"), - _T("AuthBuyerID"), - _T("Color"), - _T("SourceType"), - _T("World"), - _T("QueryData"), - _T("Users"), - _T("SysOS"), - _T("Notes"), - _T("AvatarID"), - _T("FounderID"), - _T("EndPointID"), - _T("StipendEstimate"), - _T("LocationLookAt"), - _T("Sound"), - _T("Cover"), - _T("TextureEntry"), - _T("SquareMetersCommitted"), - _T("ChannelID"), - _T("Dwell"), - _T("North"), - _T("AgentUpdate"), - _T("PickGodDelete"), - _T("UpdateInventoryItemAsset"), - _T("HostName"), - _T("PriceParcelClaim"), - _T("ParcelClaim"), - _T("ProfileHollow"), - _T("Count"), - _T("South"), - _T("Entry"), - _T("ObjectUpdateCompressed"), - _T("MuteFlags"), - _T("Group"), - _T("AgentPause"), - _T("InternalScriptMail"), - _T("FindAgent"), - _T("AgentData"), - _T("FolderData"), - _T("AssetBlock"), - _T("CloseCircuit"), - _T("LogControl"), - _T("TeleportFinish"), - _T("PathRevolutions"), - _T("ClassifiedInfoReply"), - _T("ParcelInfoReply"), - _T("LandCollidersReply"), - _T("AutosaveData"), - _T("SetStartLocation"), - _T("PassHours"), - _T("AttachmentPt"), - _T("ParcelFlags"), - _T("NumVotes"), - _T("AvatarPickerRequest"), - _T("TeleportLocationRequest"), - _T("DataHomeLocationRequest"), - _T("EventNotificationAddRequest"), - _T("ParcelDwellRequest"), - _T("ViewerLoginLocationRequest"), - _T("ViewerSimLocationRequest"), - _T("EventLocationRequest"), - _T("EndPeriod"), - _T("SetStartLocationRequest"), - _T("UserLoginLocationRequest"), - _T("QueryStart"), - _T("AvatarTextureUpdate"), - _T("RequestGrantedProxies"), - _T("GrantedProxies"), - _T("RPCServerPort"), - _T("Bytes"), - _T("Extra"), - _T("ForceScriptControlRelease"), - _T("ParcelRelease"), - _T("VFileType"), - _T("ImageData"), - _T("SpaceServerSimulatorTimeMessage"), - _T("SimulatorViewerTimeMessage"), - _T("Rotation"), - _T("Selection"), - _T("TransactionData"), - _T("OperationData"), - _T("ExpirationDate"), - _T("AgentName"), - _T("ParcelDeedToGroup"), - _T("DirPicksReply"), - _T("AvatarPicksReply"), - _T("AgentInfo"), - _T("MoneyTransferBackend"), - _T("NextOwnerMask"), - _T("MuteData"), - _T("PassPrice"), - _T("SourceID"), - _T("TotalScriptTime"), - _T("ShowMembersInGroupDir"), - _T("TeleportFlags"), - _T("AssetData"), - _T("SlaveParcelData"), - _T("MultipleObjectUpdate"), - _T("ObjectUpdate"), - _T("ImprovedTerseObjectUpdate"), - _T("ConfirmXferPacket"), - _T("StartPingCheck"), - _T("SimWideDeletes"), - _T("UserListReply"), - _T("IsPhantom"), - _T("AgentList"), - _T("RezObject"), - _T("TaskLocalID"), - _T("ClaimDate"), - _T("MergeParcel"), - _T("Priority"), - _T("Building"), - _T("QueryText"), - _T("ReturnType"), - _T("FetchFolders"), - _T("SimulatorPublicHostBlock"), - _T("HeaderData"), - _T("GroupBlock"), - _T("RequestMultipleObjects"), - _T("RetrieveInstantMessages"), - _T("DequeueInstantMessages"), - _T("OpenCircuit"), - _T("SecureSessionID"), - _T("CrossedRegion"), - _T("DirGroupsReply"), - _T("AvatarGroupsReply"), - _T("EmailMessageReply"), - _T("GroupVoteHistoryItemReply"), - _T("ViewerPosition"), - _T("Position"), - _T("ParentEstate"), - _T("MuteName"), - _T("StartParcelRename"), - _T("BulkParcelRename"), - _T("ParcelRename"), - _T("ViewerFilename"), - _T("Positive"), - _T("UserReportInternal"), - _T("AvatarPropertiesRequest"), - _T("ParcelPropertiesRequest"), - _T("GroupPropertiesRequest"), - _T("GroupProfileRequest"), - _T("AgentDataUpdateRequest"), - _T("PriceObjectScaleFactor"), - _T("DirPicksQuery"), - _T("OpenEnrollment"), - _T("GroupData"), - _T("PauseBlock"), - _T("RequestGodlikePowers"), - _T("GrantGodlikePowers"), - _T("TransactionID"), - _T("DestinationID"), - _T("Controls"), - _T("FirstDetachAll"), - _T("EstateID"), - _T("ImprovedInstantMessage"), - _T("AgentQuit"), - _T("WantToFlags"), - _T("CheckParcelSales"), - _T("ParcelSales"), - _T("CurrentInterval"), - _T("PriceRentLight"), - _T("MediaAutoScale"), - _T("NeighborBlock"), - _T("LayerData"), - _T("NVPairData"), - _T("TeleportLocal"), - _T("LayersPaused"), - _T("VoteInitiator"), - _T("MailPingBounce"), - _T("TypeData"), - _T("OwnerIDs"), - _T("SystemKickUser"), - _T("ErrorCode"), - _T("SLXML_ID"), - _T("TransactionTime"), - _T("TimeToLive"), - _T("StartParcelRemove"), - _T("BulkParcelRemove"), - _T("DirGroupsQuery"), - _T("BonusEstimate"), - _T("MusicURL"), - _T("CompleteLure"), - _T("ParcelPrimBonus"), - _T("EjectUser"), - _T("CoarseLocationUpdate"), - _T("ChildAgentPositionUpdate"), - _T("GroupIndex"), - _T("GroupName"), - _T("PriceParcelRent"), - _T("SimStatus"), - _T("TransactionSuccess"), - _T("LureType"), - _T("GroupMask"), - _T("SitObject"), - _T("AssetNum"), - _T("Override"), - _T("LocomotionState"), - _T("PriceUpload"), - _T("RemoveParcel"), - _T("ConfirmAuctionStart"), - _T("RpcScriptRequestInbound"), - _T("ParcelReturnObjects"), - _T("TotalObjects"), - _T("ObjectExtraParams"), - _T("Questions"), - _T("TransferAbort"), - _T("TransferInventory"), - _T("LandScriptsReply"), - _T("Collada_ID"), - _T("RayTargetID"), - _T("ClaimPrice"), - _T("ObjectProperties"), - _T("ParcelProperties"), - _T("LogoutRequest"), - _T("AssetUploadRequest"), - _T("ReputationIndividualRequest"), - _T("MajorVersion"), - _T("MinorVersion"), - _T("SimulatorAssign"), - _T("TransactionType"), - _T("AvatarPropertiesUpdate"), - _T("ParcelPropertiesUpdate"), - _T("FetchItems"), - _T("AbortXfer"), - _T("DeRezAck"), - _T("TakeControls"), - _T("DirLandReply"), - _T("SpaceLocationTeleportReply"), - _T("MuteType"), - _T("IMViaEMail"), - _T("StartExpungeProcessAck"), - _T("RentPrice"), - _T("GenericMessage"), - _T("ChildAgentAlive"), - _T("SpawnPointBlock"), - _T("AttachmentBlock"), - _T("RecallData"), - _T("OfficerData"), - _T("GroupOfficer"), - _T("ObjectMaterial"), - _T("OwnerName"), - _T("AvatarNotesReply"), - _T("CacheID"), - _T("OwnerMask"), - _T("TransferInventoryAck"), - NULL -}; +#include "StdAfx.h" +#include ".\keywords.h" + +TCHAR *LLTYPES[] = { + _T("U8"), + _T("U16"), + _T("U32"), + _T("U64"), + _T("S8"), + _T("S16"), + _T("S32"), + _T("S64"), + _T("F8"), + _T("F16"), + _T("F32"), + _T("F64"), + _T("LLUUID"), + _T("BOOL"), + _T("LLVector3"), + _T("LLVector3d"), + _T("LLQuaternion"), + _T("IPADDR"), + _T("IPPORT"), + _T("Variable"), + _T("Fixed"), + _T("Single"), + _T("Multiple"), + NULL +}; + +TCHAR *LLKEYWORDS[] = { + _T("SeedCapability"), + _T("X"), + _T("Y"), + _T("Z"), + _T("VotedForCandidate"), + _T("AddFlags"), + _T("Everyone"), + _T("ReservedNewbie"), + _T("MapData"), + _T("AddItem"), + _T("MeanCollision"), + _T("RezScript"), + _T("AvatarSitResponse"), + _T("InventoryAssetResponse"), + _T("KillObject"), + _T("ProposalID"), + _T("SerialNum"), + _T("Duration"), + _T("ScriptQuestion"), + _T("AddCircuitCode"), + _T("UseCircuitCode"), + _T("ViewerCircuitCode"), + _T("ScriptAnswerYes"), + _T("PartnerID"), + _T("DirLandQuery"), + _T("TeleportStart"), + _T("EmpoweredBlock"), + _T("LogMessages"), + _T("DropGroupIM"), + _T("AboutText"), + _T("VisualParam"), + _T("GroupPrims"), + _T("SelectedPrims"), + _T("ID"), + _T("UUIDNameRequest"), + _T("UUIDGroupNameRequest"), + _T("MoneyTransactionsRequest"), + _T("GroupAccountTransactionsRequest"), + _T("MapNameRequest"), + _T("MailTaskSimRequest"), + _T("LandScriptsRequest"), + _T("UpdateSimulator"), + _T("BillableFactor"), + _T("ObjectBonusFactor"), + _T("EnableSimulator"), + _T("DisableSimulator"), + _T("ConfirmEnableSimulator"), + _T("LayerType"), + _T("ParcelOverlay"), + _T("AdjustBalance"), + _T("GroupOwned"), + _T("IP"), + _T("ChatFromViewer"), + _T("FirstLogin"), + _T("GroupTitle"), + _T("MapLayerReply"), + _T("CompoundMsgID"), + _T("CameraConstraint"), + _T("DownloadTotals"), + _T("ErrorValue"), + _T("GenCounter"), + _T("FrozenData"), + _T("URLBlock"), + _T("ChildAgentDying"), + _T("To"), + _T("ParcelDirFeeCurrent"), + _T("ObjectDuplicate"), + _T("InventoryData"), + _T("ReplyData"), + _T("ResetList"), + _T("SimulatorPauseState"), + _T("MediaID"), + _T("RedirectGridX"), + _T("RedirectGridY"), + _T("TransferID"), + _T("Transacted"), + _T("TexturesChanged"), + _T("UserLookAt"), + _T("TestBlock1"), + _T("SensedData"), + _T("UpdateBlock"), + _T("EmpoweredID"), + _T("ClassifiedGodDelete"), + _T("LocationPos"), + _T("ObjectGrabUpdate"), + _T("TaxDate"), + _T("StartDateTime"), + _T("ObjectUpdateCached"), + _T("Packets"), + _T("FailureType"), + _T("UpdateGroupInfo"), + _T("InventoryFile"), + _T("ObjectPermissions"), + _T("RevokePermissions"), + _T("UpdateFlags"), + _T("ObjectExportSelected"), + _T("RezSelected"), + _T("AutoPilot"), + _T("UpdateMuteListEntry"), + _T("RemoveMuteListEntry"), + _T("SetSimStatusInDatabase"), + _T("SetSimPresenceInDatabase"), + _T("CameraProperty"), + _T("GroupRecallBallot"), + _T("BrushSize"), + _T("StartExpungeProcess"), + _T("SimulatorSetMap"), + _T("RegionPresenceRequestByRegionID"), + _T("TransferEnergy"), + _T("ParcelObjectOwnersReply"), + _T("GroupMembersReply"), + _T("GroupOfficersAndMembersReply"), + _T("RequestRegionInfo"), + _T("AABBMax"), + _T("RequestPayPrice"), + _T("SimulatorPresentAtLocation"), + _T("AgentRequestSit"), + _T("AABBMin"), + _T("ClassifiedFlags"), + _T("ControlFlags"), + _T("TeleportRequest"), + _T("SpaceLocationTeleportRequest"), + _T("LeaderBoardRequest"), + _T("ScriptTeleportRequest"), + _T("DateUTC"), + _T("TaskIDs"), + _T("RequestResult"), + _T("ReputationAgentAssign"), + _T("CanAcceptAgents"), + _T("ObjectSaleInfo"), + _T("KillChildAgents"), + _T("Balance"), + _T("DerezContainer"), + _T("ObjectData"), + _T("CameraAtAxis"), + _T("InfoBlock"), + _T("OwnershipCost"), + _T("AvatarNotesUpdate"), + _T("PID"), + _T("TimeString"), + _T("DirPopularReply"), + _T("TerrainHeightRange00"), + _T("SimData"), + _T("TerrainHeightRange01"), + _T("TerrainHeightRange10"), + _T("TerrainHeightRange11"), + _T("UpdateInventoryItem"), + _T("MoveInventoryItem"), + _T("CopyInventoryItem"), + _T("RemoveInventoryItem"), + _T("CreateInventoryItem"), + _T("PathTwistBegin"), + _T("CRC"), + _T("AttachmentPoint"), + _T("TelehubBlock"), + _T("FOVBlock"), + _T("StartLocationData"), + _T("PositionData"), + _T("TimeSinceLast"), + _T("MapImage"), + _T("Objects"), + _T("URL"), + _T("CreationDate"), + _T("JointPivot"), + _T("RateeID"), + _T("FPS"), + _T("HasTelehub"), + _T("PathEnd"), + _T("ScriptDataReply"), + _T("MapBlockReply"), + _T("PropertiesData"), + _T("ViewerEffect"), + _T("FreezeUser"), + _T("OwnerPrims"), + _T("ScriptTime"), + _T("ObjectGrab"), + _T("ToAgentID"), + _T("ProxyBlock"), + _T("SimulatorMapUpdate"), + _T("TransferPacket"), + _T("ObjectName"), + _T("OriginalName"), + _T("CompletePingCheck"), + _T("OnlineStatus"), + _T("TrackOnlineStatus"), + _T("IgnoreOnlineStatus"), + _T("ObjectDrop"), + _T("UseBigPackets"), + _T("ParcelAccessListReply"), + _T("RpcChannelReply"), + _T("RegionPresenceResponse"), + _T("AgentPresenceResponse"), + _T("CharterMember"), + _T("EdgeData"), + _T("NameData"), + _T("RegionPushOverride"), + _T("SimName"), + _T("UserReport"), + _T("DownloadPriority"), + _T("ToAgentId"), + _T("Mag"), + _T("DirPopularQuery"), + _T("ParcelPropertiesRequestByID"), + _T("ObjectLink"), + _T("RpcScriptReplyInbound"), + _T("BoardData"), + _T("RezData"), + _T("RemoveInventoryObjects"), + _T("Officer"), + _T("GroupProposalBallot"), + _T("RPCServerIP"), + _T("Far"), + _T("GodSessionID"), + _T("ViewerDigest"), + _T("FLAboutText"), + _T("RegionHandshakeReply"), + _T("GroupActiveProposalItemReply"), + _T("MapItemReply"), + _T("Seconds"), + _T("UpdateUserInfo"), + _T("AggregatePermTexturesOwner"), + _T("Set"), + _T("Key"), + _T("NewName"), + _T("AgentID"), + _T("OnlineStatusRequest"), + _T("DataAgentAccessRequest"), + _T("EventNotificationRemoveRequest"), + _T("Arc"), + _T("NewFolderID"), + _T("RegionX"), + _T("RegionY"), + _T("RequestData"), + _T("Msg"), + _T("Top"), + _T("MiscStats"), + _T("Pos"), + _T("ImageID"), + _T("DataPacket"), + _T("ObjectDehinge"), + _T("You"), + _T("ScriptControlChange"), + _T("LoadURL"), + _T("SetCPURatio"), + _T("NameValueData"), + _T("AtomicPassObject"), + _T("ViewerFrozenMessage"), + _T("HealthMessage"), + _T("LogTextMessage"), + _T("TimeDilation"), + _T("Contribution"), + _T("SetGroupContribution"), + _T("Offline"), + _T("SecPerDay"), + _T("Members"), + _T("FailedResends"), + _T("CameraCenter"), + _T("CameraLeftAxis"), + _T("ExBlock"), + _T("Channel"), + _T("NetTest"), + _T("DiscardLevel"), + _T("LayerID"), + _T("RatorID"), + _T("GrabOffset"), + _T("SimPort"), + _T("PricePerMeter"), + _T("RegionFlags"), + _T("VoteResult"), + _T("ParcelDirFeeEstimate"), + _T("ModifyBlock"), + _T("InventoryBlock"), + _T("ReplyBlock"), + _T("RequireMask"), + _T("ValidUntil"), + _T("VelocityInterpolateOn"), + _T("ClassifiedDelete"), + _T("FLImageID"), + _T("AllowPublish"), + _T("SitName"), + _T("OfficerTitle"), + _T("RegionsVisited"), + _T("RecallID"), + _T("DirClassifiedReply"), + _T("AvatarClassifiedReply"), + _T("ReputationIndividualReply"), + _T("MediaURL"), + _T("CompleteAgentMovement"), + _T("SpaceIP"), + _T("ClassifiedID"), + _T("LocalID"), + _T("RemoveItem"), + _T("LogFailedMoneyTransaction"), + _T("ViewerStartAuction"), + _T("StartAuction"), + _T("NameValueName"), + _T("AngVelX"), + _T("DuplicateFlags"), + _T("AngVelY"), + _T("AngVelZ"), + _T("TextColor"), + _T("SlaveID"), + _T("Charter"), + _T("TargetBlock"), + _T("AlertData"), + _T("CheckParcelAuctions"), + _T("ParcelAuctions"), + _T("NameValuePair"), + _T("RemoveNameValuePair"), + _T("GetNameValuePair"), + _T("BulkUpdateInventory"), + _T("UpdateTaskInventory"), + _T("RemoveTaskInventory"), + _T("MoveTaskInventory"), + _T("RequestTaskInventory"), + _T("ReplyTaskInventory"), + _T("DeclineInventory"), + _T("AggregatePermInventory"), + _T("SimulatorInfo"), + _T("MoneyTransactionsReply"), + _T("GroupAccountTransactionsReply"), + _T("MailTaskSimReply"), + _T("WearableData"), + _T("StatisticsData"), + _T("AccessOK"), + _T("Enabled"), + _T("Savings"), + _T("SimulatorLoad"), + _T("InternalRegionIP"), + _T("ExternalRegionIP"), + _T("CreateGroupRequest"), + _T("JoinGroupRequest"), + _T("LeaveGroupRequest"), + _T("InviteGroupRequest"), + _T("LiveHelpGroupRequest"), + _T("ServerVersion"), + _T("PriceParcelClaimFactor"), + _T("BillableArea"), + _T("ScriptCount"), + _T("ObjectID"), + _T("ObjectFlagUpdate"), + _T("ActiveOnly"), + _T("RequestInventoryAsset"), + _T("RedoLand"), + _T("TravelAccess"), + _T("ChangedGrid"), + _T("Details"), + _T("LocationX"), + _T("SaleType"), + _T("ObjectExportReply"), + _T("LocationY"), + _T("LocationZ"), + _T("EconomyData"), + _T("HeadRotation"), + _T("DeleteOnCompletion"), + _T("PublicPort"), + _T("CurrentTaxes"), + _T("DirClassifiedQuery"), + _T("RequestParcelTransfer"), + _T("ObjectCapacity"), + _T("RequestID"), + _T("GranterName"), + _T("RequestXfer"), + _T("ObjectTaxCurrent"), + _T("LightTaxCurrent"), + _T("LandTaxCurrent"), + _T("GroupTaxCurrent"), + _T("FetchInventoryDescendents"), + _T("InventoryDescendents"), + _T("Descendents"), + _T("PurgeInventoryDescendents"), + _T("ShowDir"), + _T("Timestamp"), + _T("GlobalPos"), + _T("LimitedToEstate"), + _T("GrabOffsetInitial"), + _T("IsTrial"), + _T("FinalizeLogout"), + _T("ObjectDuplicateOnRay"), + _T("GroupMembershipCount"), + _T("MethodData"), + _T("ActivateGestures"), + _T("DeactivateGestures"), + _T("ProposalData"), + _T("PosGlobal"), + _T("SearchID"), + _T("RezMultipleAttachmentsFromInv"), + _T("SearchName"), + _T("VersionString"), + _T("CreateGroupReply"), + _T("ActualArea"), + _T("RevokedID"), + _T("Message"), + _T("ClickAction"), + _T("AssetUploadComplete"), + _T("EstimatedTaxes"), + _T("RequestType"), + _T("UUID"), + _T("BaseMask"), + _T("NetBlock"), + _T("GlobalX"), + _T("GlobalY"), + _T("CopyRotates"), + _T("KickUserAck"), + _T("TopPick"), + _T("SessionID"), + _T("GlobalZ"), + _T("CallVote"), + _T("DeclineFriendship"), + _T("FormFriendship"), + _T("TerminateFriendship"), + _T("TaskData"), + _T("SimWideMaxPrims"), + _T("TotalPrims"), + _T("SourceFilename"), + _T("ProfileBegin"), + _T("MoneyDetailsRequest"), + _T("Request"), + _T("GroupAccountDetailsRequest"), + _T("GroupActiveProposalsRequest"), + _T("VoteQuorum"), + _T("StringValue"), + _T("ClosestSimulator"), + _T("Version"), + _T("OtherCount"), + _T("ChatData"), + _T("IsGroupOwned"), + _T("EnergyEfficiency"), + _T("MaxPlace"), + _T("PickInfoUpdate"), + _T("PickDelete"), + _T("ScriptReset"), + _T("Requester"), + _T("RevokerID"), + _T("ElectionID"), + _T("ForSale"), + _T("NearestLandingRegionReply"), + _T("RecordAgentPresence"), + _T("EraseAgentPresence"), + _T("ParcelID"), + _T("Godlike"), + _T("TotalDebits"), + _T("Direction"), + _T("Appearance"), + _T("HealthData"), + _T("LeftAxis"), + _T("PositionBlock"), + _T("LocationBlock"), + _T("ObjectImage"), + _T("TerrainStartHeight00"), + _T("TerrainStartHeight01"), + _T("TerrainStartHeight10"), + _T("ObjectHinge"), + _T("TerrainStartHeight11"), + _T("MetersPerGrid"), + _T("WaterHeight"), + _T("FetchInventoryReply"), + _T("MoneySummaryReply"), + _T("GroupAccountSummaryReply"), + _T("AttachedSound"), + _T("ParamInUse"), + _T("GodKickUser"), + _T("PickName"), + _T("TaskName"), + _T("SkillFlags"), + _T("ParcelGodReserveForNewbie"), + _T("SubType"), + _T("ObjectCount"), + _T("RegionPresenceRequestByHandle"), + _T("RezSingleAttachmentFromInv"), + _T("ChildAgentUpdate"), + _T("ToID"), + _T("ViewerPort"), + _T("IsOwnerGroup"), + _T("AgentHeightWidth"), + _T("VerticalAngle"), + _T("WearableType"), + _T("AggregatePermNextOwner"), + _T("ShowInList"), + _T("PositionSuggestion"), + _T("UpdateParcel"), + _T("ClearAgentSessions"), + _T("SetAlwaysRun"), + _T("NVPair"), + _T("ObjectSpinStart"), + _T("UseEstateSun"), + _T("LogoutBlock"), + _T("RelayLogControl"), + _T("RegionID"), + _T("Creator"), + _T("ViewerRegion"), + _T("ProposalText"), + _T("DirEventsReply"), + _T("EventInfoReply"), + _T("GroupElectionInfoReply"), + _T("UserInfoReply"), + _T("PathRadiusOffset"), + _T("SessionInfo"), + _T("TextureData"), + _T("ChatPass"), + _T("TargetID"), + _T("DefaultPayPrice"), + _T("UserLocation"), + _T("MaxPrims"), + _T("RegionIP"), + _T("LandmarkID"), + _T("InitiateDownload"), + _T("Name"), + _T("OtherCleanTime"), + _T("TeleportPriceExponent"), + _T("Gain"), + _T("VelX"), + _T("PacketAck"), + _T("PathSkew"), + _T("Negative"), + _T("VelY"), + _T("SimulatorShutdownRequest"), + _T("NearestLandingRegionRequest"), + _T("VelZ"), + _T("OtherID"), + _T("MapLayerRequest"), + _T("PatchVersion"), + _T("ObjectScale"), + _T("TargetIP"), + _T("Redo"), + _T("MoneyBalance"), + _T("TrackAgent"), + _T("MaxX"), + _T("Data"), + _T("MaxY"), + _T("TextureAnim"), + _T("ReturnIDs"), + _T("Date"), + _T("GestureUpdate"), + _T("AgentWearablesUpdate"), + _T("AgentDataUpdate"), + _T("Hash"), + _T("Left"), + _T("Mask"), + _T("ForceMouselook"), + _T("RequestLocationGetAccess"), + _T("Success"), + _T("ObjectGroup"), + _T("SunHour"), + _T("MinX"), + _T("ScriptSensorReply"), + _T("MinY"), + _T("Command"), + _T("Desc"), + _T("AttachmentNeedsSave"), + _T("HistoryItemData"), + _T("AgentCachedTexture"), + _T("East"), + _T("Subject"), + _T("GodExpungeUser"), + _T("QueryReplies"), + _T("ObjectCategory"), + _T("Time"), + _T("CreateLandmarkForEvent"), + _T("ParentID"), + _T("Ping"), + _T("Perp"), + _T("Code"), + _T("InvType"), + _T("AgentFOV"), + _T("BulkMoneyTransfer"), + _T("Audible"), + _T("AuctionData"), + _T("IDBlock"), + _T("ReputationData"), + _T("West"), + _T("ElectionData"), + _T("Undo"), + _T("Info"), + _T("Area"), + _T("Behavior"), + _T("SimCrashed"), + _T("Text"), + _T("AgentToNewRegion"), + _T("PriceGroupCreate"), + _T("ObjectShape"), + _T("PosX"), + _T("PosY"), + _T("MuteCRC"), + _T("PosZ"), + _T("Size"), + _T("FromAddress"), + _T("Body"), + _T("FileData"), + _T("List"), + _T("KickUser"), + _T("OtherPrims"), + _T("RunTime"), + _T("RpcScriptRequestInboundForward"), + _T("More"), + _T("Majority"), + _T("SenderID"), + _T("MetersTraveled"), + _T("Stat"), + _T("FromAgentID"), + _T("Item"), + _T("SoundID"), + _T("User"), + _T("RemoteInfos"), + _T("Vote"), + _T("Prey"), + _T("UsecSinceStart"), + _T("RayStart"), + _T("ParcelData"), + _T("CameraUpAxis"), + _T("ScriptDialog"), + _T("MasterParcelData"), + _T("Invalid"), + _T("MinPlace"), + _T("ProfileCurve"), + _T("ParcelAccessListUpdate"), + _T("MuteListUpdate"), + _T("SendPacket"), + _T("SendXferPacket"), + _T("LastName"), + _T("From"), + _T("Port"), + _T("MemberTitle"), + _T("LogParcelChanges"), + _T("DeRezObject"), + _T("IsTemporary"), + _T("IsComplete"), + _T("InsigniaID"), + _T("CheckFlags"), + _T("TransferPriority"), + _T("EventID"), + _T("FromAgentId"), + _T("Type"), + _T("ChatType"), + _T("ReportData"), + _T("LeaderBoardData"), + _T("RequestBlock"), + _T("GrantData"), + _T("DetachAttachmentIntoInv"), + _T("ParcelDisableObjects"), + _T("Sections"), + _T("GodLevel"), + _T("StartGroupIM"), + _T("PayPriceReply"), + _T("QueryID"), + _T("CameraEyeOffset"), + _T("AgentPosition"), + _T("GrabPosition"), + _T("GrantModification"), + _T("RevokeModification"), + _T("OnlineNotification"), + _T("OfflineNotification"), + _T("SendPostcard"), + _T("RequestFlags"), + _T("MoneyHistoryRequest"), + _T("MoneySummaryRequest"), + _T("GroupMoneyHistoryRequest"), + _T("GroupAccountSummaryRequest"), + _T("ParamValue"), + _T("GroupVoteHistoryRequest"), + _T("Checksum"), + _T("MaxAgents"), + _T("CreateNewOutfitAttachments"), + _T("RegionHandle"), + _T("TeleportProgress"), + _T("AgentQuitCopy"), + _T("LocationValid"), + _T("ToViewer"), + _T("ParcelName"), + _T("InviteOfficers"), + _T("PriceObjectRent"), + _T("ConnectAgentToUserserver"), + _T("ConnectToUserserver"), + _T("OfferCallingCard"), + _T("AgentAccess"), + _T("AcceptCallingCard"), + _T("DeclineCallingCard"), + _T("DataHomeLocationReply"), + _T("EventLocationReply"), + _T("UserLoginLocationReply"), + _T("UserSimLocationReply"), + _T("SpaceLoginLocationReply"), + _T("TerseDateID"), + _T("ObjectOwner"), + _T("AssetID"), + _T("AlertMessage"), + _T("AgentAlertMessage"), + _T("EstateOwnerMessage"), + _T("ParcelMediaCommandMessage"), + _T("Auction"), + _T("Category"), + _T("FilePath"), + _T("ItemFlags"), + _T("Invoice"), + _T("IntervalDays"), + _T("PathScaleX"), + _T("FromTaskID"), + _T("TimeInfo"), + _T("PathScaleY"), + _T("PublicCount"), + _T("ParcelJoin"), + _T("SimulatorBlock"), + _T("UserBlock"), + _T("GroupID"), + _T("AgentVel"), + _T("RequestImage"), + _T("NetStats"), + _T("AgentPos"), + _T("AgentSit"), + _T("Material"), + _T("ObjectDeGrab"), + _T("VelocityInterpolateOff"), + _T("AuthorizedBuyerID"), + _T("RemoveMemberFromGroup"), + _T("GroupIM"), + _T("AvatarPropertiesReply"), + _T("GroupPropertiesReply"), + _T("GroupProfileReply"), + _T("Participants"), + _T("SimOwner"), + _T("SalePrice"), + _T("Animation"), + _T("CurrentDividend"), + _T("OwnerID"), + _T("NearestLandingRegionUpdated"), + _T("PassToAgent"), + _T("PreyAgent"), + _T("SimStats"), + _T("Options"), + _T("LogoutReply"), + _T("ObjectLocalID"), + _T("Dropped"), + _T("Destination"), + _T("MasterID"), + _T("TransferData"), + _T("WantToMask"), + _T("AvatarData"), + _T("ParcelSelectObjects"), + _T("ExtraParams"), + _T("LogLogin"), + _T("CreatorID"), + _T("Summary"), + _T("BuyObjectInventory"), + _T("FetchInventory"), + _T("InventoryID"), + _T("PacketNumber"), + _T("SetFollowCamProperties"), + _T("ClearFollowCamProperties"), + _T("SimulatorThrottleSettings"), + _T("SequenceID"), + _T("DataServerLogout"), + _T("NameValue"), + _T("PathShearX"), + _T("PathShearY"), + _T("ElectionType"), + _T("Velocity"), + _T("SecPerYear"), + _T("FirstName"), + _T("AttachedSoundGainChange"), + _T("LocationID"), + _T("Running"), + _T("ObjectImportReply"), + _T("AgentThrottle"), + _T("NeighborList"), + _T("PathTaperX"), + _T("PathTaperY"), + _T("GranterBlock"), + _T("UseCachedMuteList"), + _T("FailStats"), + _T("StartGroupRecall"), + _T("Tempfile"), + _T("FounderName"), + _T("BuyerID"), + _T("DirPeopleReply"), + _T("TransferInfo"), + _T("AvatarPickerRequestBackend"), + _T("AvatarPropertiesRequestBackend"), + _T("UpdateData"), + _T("ReporterID"), + _T("GranterID"), + _T("ButtonLabel"), + _T("WantToText"), + _T("ReportType"), + _T("DataBlock"), + _T("SimulatorReady"), + _T("AnimationSourceList"), + _T("RefreshViewer"), + _T("SubscribeLoad"), + _T("UnsubscribeLoad"), + _T("Packet"), + _T("UndoLand"), + _T("SimAccess"), + _T("MembershipFee"), + _T("CreateInventoryFolder"), + _T("UpdateInventoryFolder"), + _T("MoveInventoryFolder"), + _T("RemoveInventoryFolder"), + _T("MoneyData"), + _T("ObjectDeselect"), + _T("NewAssetID"), + _T("ObjectAdd"), + _T("RayEndIsIntersection"), + _T("CompleteAuction"), + _T("CircuitCode"), + _T("AgentMovementComplete"), + _T("ViewerIP"), + _T("Header"), + _T("GestureFlags"), + _T("XferID"), + _T("StatValue"), + _T("PickID"), + _T("TaskID"), + _T("GridsPerEdge"), + _T("RayEnd"), + _T("Throttles"), + _T("UpAxis"), + _T("AgentTextures"), + _T("Radius"), + _T("OffCircuit"), + _T("Access"), + _T("SquareMetersCredit"), + _T("Filename"), + _T("SecuredTemplateChecksumRequest"), + _T("TemplateChecksumRequest"), + _T("AgentPresenceRequest"), + _T("ClassifiedInfoRequest"), + _T("ParcelInfoRequest"), + _T("ParcelObjectOwnersRequest"), + _T("TeleportLandmarkRequest"), + _T("EventInfoRequest"), + _T("MovedIntoSimulator"), + _T("ChatFromSimulator"), + _T("PickInfoRequest"), + _T("MoneyBalanceRequest"), + _T("DirPeopleQuery"), + _T("GroupElectionInfoRequest"), + _T("GroupMembersRequest"), + _T("GroupOfficersAndMembersRequest"), + _T("TextureID"), + _T("OldFolderID"), + _T("UserInfoRequest"), + _T("LandCollidersRequest"), + _T("Handle"), + _T("StartParcelRenameAck"), + _T("StateLoad"), + _T("ButtonIndex"), + _T("CurrentElectionID"), + _T("GetScriptRunning"), + _T("SetScriptRunning"), + _T("Health"), + _T("FileID"), + _T("CircuitInfo"), + _T("ObjectBuy"), + _T("ProfileEnd"), + _T("Effect"), + _T("TestMessage"), + _T("ScriptMailRegistration"), + _T("AgentSetAppearance"), + _T("AvatarAppearance"), + _T("RegionData"), + _T("RequestingRegionData"), + _T("LandingRegionData"), + _T("SitTransform"), + _T("TerrainBase0"), + _T("SkillsMask"), + _T("AtAxis"), + _T("TerrainBase1"), + _T("Reason"), + _T("TerrainBase2"), + _T("TerrainBase3"), + _T("Params"), + _T("PingID"), + _T("Height"), + _T("Region"), + _T("MoneyHistoryReply"), + _T("GroupMoneyHistoryReply"), + _T("TelehubInfo"), + _T("StateSave"), + _T("AgentAnimation"), + _T("AvatarAnimation"), + _T("LogDwellTime"), + _T("ParcelGodMarkAsContent"), + _T("UsePhysics"), + _T("JointType"), + _T("TaxEstimate"), + _T("ObjectTaxEstimate"), + _T("LightTaxEstimate"), + _T("TeleportLandingStatusChanged"), + _T("LandTaxEstimate"), + _T("GroupTaxEstimate"), + _T("Buttons"), + _T("Sender"), + _T("Dialog"), + _T("DestID"), + _T("PricePublicObjectDelete"), + _T("ObjectDelete"), + _T("Delete"), + _T("EventGodDelete"), + _T("LastTaxDate"), + _T("MapImageID"), + _T("EndDateTime"), + _T("TerrainDetail0"), + _T("TerrainDetail1"), + _T("TerrainDetail2"), + _T("TerrainDetail3"), + _T("Offset"), + _T("ObjectDelink"), + _T("TargetObject"), + _T("IsEstateManager"), + _T("CancelAuction"), + _T("ObjectDetach"), + _T("Compressed"), + _T("PathBegin"), + _T("BypassRaycast"), + _T("WinnerID"), + _T("ChannelType"), + _T("NumberNonExemptMembers"), + _T("NonExemptMembers"), + _T("Agents"), + _T("SimulatorStart"), + _T("Enable"), + _T("RevokedBlock"), + _T("MemberData"), + _T("ImageNotInDatabase"), + _T("StartDate"), + _T("AnimID"), + _T("Serial"), + _T("GroupElectionBallot"), + _T("ControlPort"), + _T("ModifyLand"), + _T("Digest"), + _T("Victim"), + _T("Script"), + _T("TemplateChecksumReply"), + _T("PickInfoReply"), + _T("MoneyBalanceReply"), + _T("RoutedMoneyBalanceReply"), + _T("RegionInfo"), + _T("Sequence"), + _T("GodUpdateRegionInfo"), + _T("LocalX"), + _T("LocalY"), + _T("StartAnim"), + _T("Location"), + _T("Action"), + _T("SearchDir"), + _T("Active"), + _T("TransferRequest"), + _T("ScriptSensorRequest"), + _T("MoneyTransferRequest"), + _T("EjectGroupMemberRequest"), + _T("SkillsText"), + _T("Resent"), + _T("Center"), + _T("SharedData"), + _T("PSBlock"), + _T("UUIDNameBlock"), + _T("Viewer"), + _T("Method"), + _T("TouchName"), + _T("CandidateID"), + _T("ParamData"), + _T("GodlikeMessage"), + _T("SystemMessage"), + _T("BodyRotation"), + _T("StartGroupElection"), + _T("SearchRegions"), + _T("Ignore"), + _T("AnimationData"), + _T("StatID"), + _T("ItemID"), + _T("AvatarStatisticsReply"), + _T("ScriptDialogReply"), + _T("RegionIDAndHandleReply"), + _T("CameraAtOffset"), + _T("VoteID"), + _T("ParcelGodForceOwner"), + _T("InviteData"), + _T("CandidateData"), + _T("PCode"), + _T("SearchPos"), + _T("PreyID"), + _T("TerrainLowerLimit"), + _T("EventFlags"), + _T("TallyVotes"), + _T("GroupInfoUpdated"), + _T("Result"), + _T("LookAt"), + _T("PayButton"), + _T("SelfCount"), + _T("PacketCount"), + _T("ParcelBuyPass"), + _T("SimHandle"), + _T("Identified"), + _T("OldItemID"), + _T("RegionPort"), + _T("PriceEnergyUnit"), + _T("Bitmap"), + _T("TrackAgentSession"), + _T("CacheMissType"), + _T("VFileID"), + _T("Response"), + _T("GroupInsigniaID"), + _T("FromID"), + _T("Online"), + _T("KickFlags"), + _T("SysCPU"), + _T("EMail"), + _T("InviteMembers"), + _T("IncludeMembers"), + _T("AggregatePermTextures"), + _T("ChatChannel"), + _T("ReturnID"), + _T("ObjectAttach"), + _T("TargetPort"), + _T("ObjectSpinStop"), + _T("FullID"), + _T("ActivateGroup"), + _T("SysGPU"), + _T("StartLure"), + _T("SysRAM"), + _T("ObjectPosition"), + _T("SitPosition"), + _T("StartTime"), + _T("BornOn"), + _T("CameraCollidePlane"), + _T("EconomyDataRequest"), + _T("TeleportLureRequest"), + _T("FolderID"), + _T("RegionHandleRequest"), + _T("GestureRequest"), + _T("ScriptDataRequest"), + _T("AgentWearablesRequest"), + _T("MapBlockRequest"), + _T("LureID"), + _T("CopyCenters"), + _T("RegisterNewAgent"), + _T("TotalColliderCount"), + _T("ParamList"), + _T("InventorySerial"), + _T("EdgeDataPacket"), + _T("AvatarPickerReply"), + _T("ParcelDwellReply"), + _T("IsForSale"), + _T("MuteID"), + _T("MeanCollisionAlert"), + _T("CanAcceptTasks"), + _T("ItemData"), + _T("AnimationList"), + _T("PassObject"), + _T("Reputation"), + _T("IntValue"), + _T("TargetType"), + _T("Amount"), + _T("UpdateAttachment"), + _T("RemoveAttachment"), + _T("HeightWidthBlock"), + _T("RequestObjectPropertiesFamily"), + _T("ObjectPropertiesFamily"), + _T("UserData"), + _T("SessionBlock"), + _T("IsReadable"), + _T("ReputationMax"), + _T("PathCurve"), + _T("ReputationMin"), + _T("Status"), + _T("AlreadyVoted"), + _T("ElectionInitiator"), + _T("PlacesReply"), + _T("DirPlacesReply"), + _T("ParcelBuy"), + _T("DirFindQueryBackend"), + _T("DirPlacesQueryBackend"), + _T("DirPeopleQueryBackend"), + _T("DirGroupsQueryBackend"), + _T("DirClassifiedQueryBackend"), + _T("DirPicksQueryBackend"), + _T("DirLandQueryBackend"), + _T("DirPopularQueryBackend"), + _T("SnapshotID"), + _T("Aspect"), + _T("LogoutDemand"), + _T("HistoryData"), + _T("VoteData"), + _T("EstimatedDividend"), + _T("ParamSize"), + _T("VoteCast"), + _T("EveryoneMask"), + _T("CastsShadows"), + _T("SetSunPhase"), + _T("ObjectSpinUpdate"), + _T("MaturePublish"), + _T("UseExistingAsset"), + _T("ParcelLocalID"), + _T("TeleportCancel"), + _T("UnixTime"), + _T("QueryFlags"), + _T("LastExecFroze"), + _T("AlwaysRun"), + _T("Bottom"), + _T("ButtonData"), + _T("SoundData"), + _T("ViewerStats"), + _T("RegionHandshake"), + _T("Description"), + _T("ObjectDescription"), + _T("ParamType"), + _T("UUIDNameReply"), + _T("UUIDGroupNameReply"), + _T("SaveAssetIntoInventory"), + _T("UserInfo"), + _T("AnimSequenceID"), + _T("NVPairs"), + _T("ParcelAccessListRequest"), + _T("UserListRequest"), + _T("MuteListRequest"), + _T("StartPeriod"), + _T("RpcChannelRequest"), + _T("PlacesQuery"), + _T("DirPlacesQuery"), + _T("Distance"), + _T("SortOrder"), + _T("Hunter"), + _T("TotalScriptCount"), + _T("SunAngVelocity"), + _T("InventoryUpdate"), + _T("ImagePacket"), + _T("BinaryBucket"), + _T("StartGroupProposal"), + _T("EnergyLevel"), + _T("PriceForListing"), + _T("Scale"), + _T("ParentEstateID"), + _T("Extra2"), + _T("Throttle"), + _T("SimIP"), + _T("GodID"), + _T("TeleportMinPrice"), + _T("VoteItem"), + _T("ObjectRotation"), + _T("SitRotation"), + _T("SnapSelection"), + _T("SoundTrigger"), + _T("TerrainRaiseLimit"), + _T("Quorum"), + _T("TokenBlock"), + _T("AgentBlock"), + _T("CommandBlock"), + _T("PricePublicObjectDecay"), + _T("SpawnPointPos"), + _T("AttachedSoundCutoffRadius"), + _T("VolumeDetail"), + _T("TasksPaused"), + _T("Range"), + _T("FromAgentName"), + _T("AddModifyAbility"), + _T("RemoveModifyAbility"), + _T("PublicIP"), + _T("TeleportFailed"), + _T("OnlineStatusReply"), + _T("DataAgentAccessReply"), + _T("RequestLocationGetAccessReply"), + _T("RequestAvatarInfo"), + _T("PreloadSound"), + _T("ScreenshotID"), + _T("OldestUnacked"), + _T("SimulatorIP"), + _T("ObjectImport"), + _T("MoneyMax"), + _T("Value"), + _T("JointAxisOrAnchor"), + _T("Test0"), + _T("MoneyMin"), + _T("Test1"), + _T("Test2"), + _T("SunPhase"), + _T("Place"), + _T("Phase"), + _T("ParcelDivide"), + _T("PriceObjectClaim"), + _T("VoteTime"), + _T("Field"), + _T("Ratio"), + _T("JoinGroupReply"), + _T("LiveHelpGroupReply"), + _T("Agent"), + _T("Score"), + _T("ExpungeData"), + _T("Image"), + _T("ObjectClickAction"), + _T("Delta"), + _T("InitiateUpload"), + _T("Parameter"), + _T("Flags"), + _T("Plane"), + _T("Width"), + _T("VoteText"), + _T("Right"), + _T("DirFindQuery"), + _T("Textures"), + _T("EventData"), + _T("Final"), + _T("TelehubPos"), + _T("ReportAutosaveCrash"), + _T("Reset"), + _T("CreateTrustedCircuit"), + _T("DenyTrustedCircuit"), + _T("Codec"), + _T("Level"), + _T("Modal"), + _T("ChildAgentUnknown"), + _T("LandingType"), + _T("ScriptRunningReply"), + _T("MoneyDetailsReply"), + _T("Reply"), + _T("TelehubRot"), + _T("RequestFriendship"), + _T("AcceptFriendship"), + _T("GroupAccountDetailsReply"), + _T("DwellInfo"), + _T("AgentResume"), + _T("ItemType"), + _T("MailFilter"), + _T("Disconnect"), + _T("SimPosition"), + _T("SimWideTotalPrims"), + _T("Index"), + _T("BaseFilename"), + _T("SimFilename"), + _T("LastOwnerID"), + _T("EmailMessageRequest"), + _T("MapItemRequest"), + _T("AgentCount"), + _T("InitializeLure"), + _T("HelloBlock"), + _T("FuseBlock"), + _T("MessageBlock"), + _T("ClassifiedInfoUpdate"), + _T("RegionPos"), + _T("ParcelMediaUpdate"), + _T("GridX"), + _T("GridY"), + _T("AuctionID"), + _T("VoteType"), + _T("CategoryID"), + _T("Token"), + _T("AggregatePerms"), + _T("StartParcelRemoveAck"), + _T("ObjectSelect"), + _T("ForceObjectSelect"), + _T("Price"), + _T("SunDirection"), + _T("FromName"), + _T("ChangeInventoryItemFlags"), + _T("Force"), + _T("TransactionBlock"), + _T("PowersMask"), + _T("Stamp"), + _T("RelatedID"), + _T("TotalCredits"), + _T("State"), + _T("TextureIndex"), + _T("SimPaused"), + _T("InviteeID"), + _T("ParcelReclaim"), + _T("Money"), + _T("PathTwist"), + _T("AuthBuyerID"), + _T("Color"), + _T("SourceType"), + _T("World"), + _T("QueryData"), + _T("Users"), + _T("SysOS"), + _T("Notes"), + _T("AvatarID"), + _T("FounderID"), + _T("EndPointID"), + _T("StipendEstimate"), + _T("LocationLookAt"), + _T("Sound"), + _T("Cover"), + _T("TextureEntry"), + _T("SquareMetersCommitted"), + _T("ChannelID"), + _T("Dwell"), + _T("North"), + _T("AgentUpdate"), + _T("PickGodDelete"), + _T("UpdateInventoryItemAsset"), + _T("HostName"), + _T("PriceParcelClaim"), + _T("ParcelClaim"), + _T("ProfileHollow"), + _T("Count"), + _T("South"), + _T("Entry"), + _T("ObjectUpdateCompressed"), + _T("MuteFlags"), + _T("Group"), + _T("AgentPause"), + _T("InternalScriptMail"), + _T("FindAgent"), + _T("AgentData"), + _T("FolderData"), + _T("AssetBlock"), + _T("CloseCircuit"), + _T("LogControl"), + _T("TeleportFinish"), + _T("PathRevolutions"), + _T("ClassifiedInfoReply"), + _T("ParcelInfoReply"), + _T("LandCollidersReply"), + _T("AutosaveData"), + _T("SetStartLocation"), + _T("PassHours"), + _T("AttachmentPt"), + _T("ParcelFlags"), + _T("NumVotes"), + _T("AvatarPickerRequest"), + _T("TeleportLocationRequest"), + _T("DataHomeLocationRequest"), + _T("EventNotificationAddRequest"), + _T("ParcelDwellRequest"), + _T("ViewerLoginLocationRequest"), + _T("ViewerSimLocationRequest"), + _T("EventLocationRequest"), + _T("EndPeriod"), + _T("SetStartLocationRequest"), + _T("UserLoginLocationRequest"), + _T("QueryStart"), + _T("AvatarTextureUpdate"), + _T("RequestGrantedProxies"), + _T("GrantedProxies"), + _T("RPCServerPort"), + _T("Bytes"), + _T("Extra"), + _T("ForceScriptControlRelease"), + _T("ParcelRelease"), + _T("VFileType"), + _T("ImageData"), + _T("SpaceServerSimulatorTimeMessage"), + _T("SimulatorViewerTimeMessage"), + _T("Rotation"), + _T("Selection"), + _T("TransactionData"), + _T("OperationData"), + _T("ExpirationDate"), + _T("AgentName"), + _T("ParcelDeedToGroup"), + _T("DirPicksReply"), + _T("AvatarPicksReply"), + _T("AgentInfo"), + _T("MoneyTransferBackend"), + _T("NextOwnerMask"), + _T("MuteData"), + _T("PassPrice"), + _T("SourceID"), + _T("TotalScriptTime"), + _T("ShowMembersInGroupDir"), + _T("TeleportFlags"), + _T("AssetData"), + _T("SlaveParcelData"), + _T("MultipleObjectUpdate"), + _T("ObjectUpdate"), + _T("ImprovedTerseObjectUpdate"), + _T("ConfirmXferPacket"), + _T("StartPingCheck"), + _T("SimWideDeletes"), + _T("UserListReply"), + _T("IsPhantom"), + _T("AgentList"), + _T("RezObject"), + _T("TaskLocalID"), + _T("ClaimDate"), + _T("MergeParcel"), + _T("Priority"), + _T("Building"), + _T("QueryText"), + _T("ReturnType"), + _T("FetchFolders"), + _T("SimulatorPublicHostBlock"), + _T("HeaderData"), + _T("GroupBlock"), + _T("RequestMultipleObjects"), + _T("RetrieveInstantMessages"), + _T("DequeueInstantMessages"), + _T("OpenCircuit"), + _T("SecureSessionID"), + _T("CrossedRegion"), + _T("DirGroupsReply"), + _T("AvatarGroupsReply"), + _T("EmailMessageReply"), + _T("GroupVoteHistoryItemReply"), + _T("ViewerPosition"), + _T("Position"), + _T("ParentEstate"), + _T("MuteName"), + _T("StartParcelRename"), + _T("BulkParcelRename"), + _T("ParcelRename"), + _T("ViewerFilename"), + _T("Positive"), + _T("UserReportInternal"), + _T("AvatarPropertiesRequest"), + _T("ParcelPropertiesRequest"), + _T("GroupPropertiesRequest"), + _T("GroupProfileRequest"), + _T("AgentDataUpdateRequest"), + _T("PriceObjectScaleFactor"), + _T("DirPicksQuery"), + _T("OpenEnrollment"), + _T("GroupData"), + _T("PauseBlock"), + _T("RequestGodlikePowers"), + _T("GrantGodlikePowers"), + _T("TransactionID"), + _T("DestinationID"), + _T("Controls"), + _T("FirstDetachAll"), + _T("EstateID"), + _T("ImprovedInstantMessage"), + _T("AgentQuit"), + _T("WantToFlags"), + _T("CheckParcelSales"), + _T("ParcelSales"), + _T("CurrentInterval"), + _T("PriceRentLight"), + _T("MediaAutoScale"), + _T("NeighborBlock"), + _T("LayerData"), + _T("NVPairData"), + _T("TeleportLocal"), + _T("LayersPaused"), + _T("VoteInitiator"), + _T("MailPingBounce"), + _T("TypeData"), + _T("OwnerIDs"), + _T("SystemKickUser"), + _T("ErrorCode"), + _T("SLXML_ID"), + _T("TransactionTime"), + _T("TimeToLive"), + _T("StartParcelRemove"), + _T("BulkParcelRemove"), + _T("DirGroupsQuery"), + _T("BonusEstimate"), + _T("MusicURL"), + _T("CompleteLure"), + _T("ParcelPrimBonus"), + _T("EjectUser"), + _T("CoarseLocationUpdate"), + _T("ChildAgentPositionUpdate"), + _T("GroupIndex"), + _T("GroupName"), + _T("PriceParcelRent"), + _T("SimStatus"), + _T("TransactionSuccess"), + _T("LureType"), + _T("GroupMask"), + _T("SitObject"), + _T("AssetNum"), + _T("Override"), + _T("LocomotionState"), + _T("PriceUpload"), + _T("RemoveParcel"), + _T("ConfirmAuctionStart"), + _T("RpcScriptRequestInbound"), + _T("ParcelReturnObjects"), + _T("TotalObjects"), + _T("ObjectExtraParams"), + _T("Questions"), + _T("TransferAbort"), + _T("TransferInventory"), + _T("LandScriptsReply"), + _T("Collada_ID"), + _T("RayTargetID"), + _T("ClaimPrice"), + _T("ObjectProperties"), + _T("ParcelProperties"), + _T("LogoutRequest"), + _T("AssetUploadRequest"), + _T("ReputationIndividualRequest"), + _T("MajorVersion"), + _T("MinorVersion"), + _T("SimulatorAssign"), + _T("TransactionType"), + _T("AvatarPropertiesUpdate"), + _T("ParcelPropertiesUpdate"), + _T("FetchItems"), + _T("AbortXfer"), + _T("DeRezAck"), + _T("TakeControls"), + _T("DirLandReply"), + _T("SpaceLocationTeleportReply"), + _T("MuteType"), + _T("IMViaEMail"), + _T("StartExpungeProcessAck"), + _T("RentPrice"), + _T("GenericMessage"), + _T("ChildAgentAlive"), + _T("SpawnPointBlock"), + _T("AttachmentBlock"), + _T("RecallData"), + _T("OfficerData"), + _T("GroupOfficer"), + _T("ObjectMaterial"), + _T("OwnerName"), + _T("AvatarNotesReply"), + _T("CacheID"), + _T("OwnerMask"), + _T("TransferInventoryAck"), + NULL +}; diff --git a/applications/snowcrash/snowflake/keywords.h b/applications/snowcrash/snowflake/keywords.h index 9e877ee6..78365a45 100644 --- a/applications/snowcrash/snowflake/keywords.h +++ b/applications/snowcrash/snowflake/keywords.h @@ -1,32 +1,32 @@ -#pragma once - -enum LLTYPES -{ - LLTYPE_U8, - LLTYPE_U16, - LLTYPE_U32, - LLTYPE_U64, - LLTYPE_S8, - LLTYPE_S16, - LLTYPE_S32, - LLTYPE_S64, - LLTYPE_F8, - LLTYPE_F16, - LLTYPE_F32, - LLTYPE_F64, - LLTYPE_LLUUID, - LLTYPE_BOOL, - LLTYPE_LLVECTOR3, - LLTYPE_LLVECTOR3D, - LLTYPE_QUATERNION, - LLTYPE_IPADDR, - LLTYPE_IPPORT, - LLTYPE_VARIABLE, - LLTYPE_FIXED, - LLTYPE_SINGLE, - LLTYPE_MULTIPLE, - LLTYPE_NULL -}; - -extern TCHAR *LLTYPES[]; -extern TCHAR *LLKEYWORDS[]; +#pragma once + +enum LLTYPES +{ + LLTYPE_U8, + LLTYPE_U16, + LLTYPE_U32, + LLTYPE_U64, + LLTYPE_S8, + LLTYPE_S16, + LLTYPE_S32, + LLTYPE_S64, + LLTYPE_F8, + LLTYPE_F16, + LLTYPE_F32, + LLTYPE_F64, + LLTYPE_LLUUID, + LLTYPE_BOOL, + LLTYPE_LLVECTOR3, + LLTYPE_LLVECTOR3D, + LLTYPE_QUATERNION, + LLTYPE_IPADDR, + LLTYPE_IPPORT, + LLTYPE_VARIABLE, + LLTYPE_FIXED, + LLTYPE_SINGLE, + LLTYPE_MULTIPLE, + LLTYPE_NULL +}; + +extern TCHAR *LLTYPES[]; +extern TCHAR *LLKEYWORDS[]; diff --git a/applications/snowcrash/snowflake/snowflake.cpp b/applications/snowcrash/snowflake/snowflake.cpp index e65870c2..34f3d930 100644 --- a/applications/snowcrash/snowflake/snowflake.cpp +++ b/applications/snowcrash/snowflake/snowflake.cpp @@ -1,2964 +1,2964 @@ -// snowflake.cpp : Defines the entry point for the DLL application. -// - -#include "stdafx.h" -#include ".\snowflake.h" -#include ".\MainFrame.h" -#include ".\Server.h" -#include ".\ServerList.h" -#include ".\Message.h" -#include ".\Block.h" -#include ".\Var.h" -#include ".\Config.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include ".\keywords.h" - -#pragma pack(1) - -struct COMMANDVAR -{ - char *lpszVar; - int nKeywordPos; - int nType; - int nTypeLen; - struct COMMANDVAR *lpNext; - struct COMMANDVAR *lpPrev; -} typedef COMMANDVARS; - -typedef COMMANDVAR * LPCOMMANDVAR; -typedef COMMANDVARS * LPCOMMANDVARS; - -struct COMMANDSTRUCT -{ - char *lpszStruct; - int nKeywordPos; - int nType; - BYTE cItems; - LPCOMMANDVARS vars; - struct COMMANDSTRUCT *lpNext; - struct COMMANDSTRUCT *lpPrev; -} typedef COMMANDSTRUCTS; - -typedef COMMANDSTRUCT * LPCOMMANDSTRUCT; -typedef COMMANDSTRUCTS * LPCOMMANDSTRUCTS; - -typedef struct -{ - char *lpszCmd; - bool bZerocoded; - bool bTrusted; - LPCOMMANDSTRUCTS structs; -} COMMAND; - -typedef COMMAND * LPCOMMAND; - -#define MAX_COMMANDS_LOW 65536 -#define MAX_COMMANDS_MEDIUM 256 -#define MAX_COMMANDS_HIGH 256 - -COMMAND cmds_low[MAX_COMMANDS_LOW]; -COMMAND cmds_med[MAX_COMMANDS_MEDIUM]; -COMMAND cmds_high[MAX_COMMANDS_HIGH]; - -typedef struct -{ - LPCTSTR szCommand; - PROC pProc; -} CMDHOOK, *LPCMDHOOK; - -CMDHOOK pCMDHooks[]; - -#pragma data_seg(".shared") -HHOOK h_hCBTHook = NULL; -#pragma data_seg() -#pragma comment(linker, "/SECTION:.shared,RWS") - -HINSTANCE g_hinstDLL = NULL; -HMODULE g_hOpenGL = NULL; -CMainFrame* g_pMainFrm = NULL; -CAppModule _Module; -CMessageLoop g_msgLoop; -CConfig* g_pConfig = NULL; -BOOL g_bAllowSub = TRUE; - -CServerList servers; - -typedef struct -{ - LPCTSTR szPatch; - LPCTSTR szModule; - LPCSTR szImport; - BOOL bOrdinal; - PROC pOldProc; - PROC pNewProc; -} APIHOOK, *LPAPIHOOK; - -APIHOOK pAPIHooks[]; - -#define MAKEPTR(cast, ptr, add) (cast)((DWORD)(ptr)+(DWORD)(add)) - -enum APIHOOKS -{ - APIHOOK_GETPROCADDRESS, - APIHOOK_LOADLIBRARYA, - APIHOOK_LOADLIBRARYW, - APIHOOK_LOADLIBRARYEXA, - APIHOOK_LOADLIBRARYEXW, - APIHOOK_FREELIBRARYA, - APIHOOK_DELETEFILEA, - APIHOOK_WRITEFILEA, - APIHOOK_LSTRCMPIA, - APIHOOK_CONNECT, - APIHOOK_RECV, - APIHOOK_RECVFROM, - APIHOOK_SEND, - APIHOOK_SENDTO, - APIHOOK_GETHOSTBYNAME, -// APIHOOK_SETWINDOWLONGA, -// APIHOOK_SETWINDOWLONGW, - APIHOOK_INTERNETREADFILE, - APIHOOK_INTERNETOPENURLA, - APIHOOK_CPENCRYPT, - APIHOOK_PEEKMESSAGEA, - APIHOOK_GLGETERROR, - APIHOOK_GLBEGIN, - APIHOOK_GLENABLE, - APIHOOK_GLISENABLED, - APIHOOK_GLTRANSLATED, - APIHOOK_GLTRANSLATEF, - APIHOOK_GLTEXCOORD2F, - APIHOOK_GLTEXCOORD2FV, - APIHOOK_GLVERTEX2F, - APIHOOK_GLVERTEX3F, - APIHOOK_GLVERTEX3FV, - APIHOOK_GLVERTEX4F, - APIHOOK_GLVERTEX4FV, - APIHOOK_GLVERTEXPOINTER, - APIHOOK_GLTEXCOORDPOINTER, - APIHOOK_GLNORMALPOINTER, - APIHOOK_GLDRAWELEMENTS, - APIHOOK_GLDRAWARRAYS, - APIHOOK_GLDRAWPIXELS, - APIHOOK_GLTEXIMAGE2D, - APIHOOK_GLCOLOR3F, - APIHOOK_GLCOLOR3FV, - APIHOOK_GLCOLOR4F, - APIHOOK_GLCOLOR4FV, - APIHOOK_GLCOLOR4UBV, - APIHOOK_GLCOLORPOINTER, - APIHOOK_GLVIEWPORT, - APIHOOK_GLFLUSH, - APIHOOK_GLUPERSPECTIVE, - APIHOOK_GLUQUADRICDRAWSTYLE, - APIHOOK_GLUTESSVERTEX, - APIHOOK_NULL -}; - -bool InstallSLHooks(HWND hwnd); -bool RemoveSLHooks(); -void InstallImportHooks(); -void RemoveImportHooks(); -void SaveImportHooks(); - -int ZeroDecode(char *src, int srclen, char *dest, int destlen) -{ - int zerolen = 0; - - if (src[0] & MSG_ZEROCODED) - { - memcpy(dest, src, 4); - zerolen += 4; - - for (int i = zerolen; i < srclen; i++) - { - if ((unsigned char)src[i] == 0x00) - { - for (unsigned char j = 0; j < (unsigned char)src[i+1]; j++) - dest[zerolen++] = 0x00; - - i++; - } - else - dest[zerolen++] = src[i]; - } - } - else - { - memcpy(dest, src, srclen); - zerolen = srclen; - } - - return zerolen; -} - -int ZeroEncode(char *src, int srclen, char *dest, int destlen) -{ - int zerolen = 0; - unsigned char zerocount = 0; - - if (src[0] & MSG_ZEROCODED) - { - memcpy(dest, src, 4); - zerolen += 4; - - for (int i = zerolen; i < srclen; i++) - { - if ((unsigned char)src[i] == 0x00) - { - zerocount++; - - if (zerocount == 0) - { - dest[zerolen++] = 0x00; - dest[zerolen++] = 0xff; - zerocount++; - } - } - else - { - if (zerocount) - { - dest[zerolen++] = 0x00; - dest[zerolen++] = zerocount; - zerocount = 0; - } - - dest[zerolen++] = src[i]; - } - } - - if (zerocount) - { - dest[zerolen++] = 0x00; - dest[zerolen++] = zerocount; - } - } - else - { - memcpy(dest, src, srclen); - zerolen = srclen; - } - - return zerolen; -} - -// Convert a "hex string" to an integer by Anders Molin -int httoi(const TCHAR *value) -{ - struct HEXMAP - { - TCHAR c; - int value; - }; - - const int nHexMap = 16; - - HEXMAP hmLookup[nHexMap] = - { - {'0', 0}, {'1', 1}, - {'2', 2}, {'3', 3}, - {'4', 4}, {'5', 5}, - {'6', 6}, {'7', 7}, - {'8', 8}, {'9', 9}, - {'A', 10}, {'B', 11}, - {'C', 12}, {'D', 13}, - {'E', 14}, {'F', 15} - }; - - TCHAR *mstr = _tcsupr(_tcsdup(value)); - TCHAR *s = mstr; - int result = 0; - - if (*s == '0' && *(s + 1) == 'X') - s += 2; - - bool firsttime = true; - - while (*s != '\0') - { - bool found = false; - - for (int i = 0; i < nHexMap; i++) - { - if (*s == hmLookup[i].c) - { - if (!firsttime) - result <<= 4; - - result |= hmLookup[i].value; - found = true; - break; - } - } - - if (!found) - break; - - s++; - firsttime = false; - } - - free(mstr); - - return result; -} - -// Trim beginning, ending, and excess embedded whitespace from a string -char *trim(char *szStr) -{ - char *iBuf, *oBuf; - - if (szStr) - { - for (iBuf = oBuf = szStr; *iBuf;) - { - while (*iBuf && (isspace(*iBuf))) - iBuf++; - - if (*iBuf && (oBuf != szStr)) - *(oBuf++) = ' '; - - while (*iBuf && (!isspace(*iBuf))) - *(oBuf++) = *(iBuf++); - } - - *oBuf = NULL; - } - - return(szStr); -} - -int get_var_type(TCHAR *lptszType) -{ - int i = 0; - - while (LLTYPES[i]) - { - if (!_tcscmp(lptszType, LLTYPES[i])) - { - //printf("Type: %s\n", LLTYPES[i]); - return i; - } - - i++; - } - - return -1; -} - -int get_keyword_pos(TCHAR *lptszKeyword) -{ - int i = 0; - - while (LLKEYWORDS[i]) - { - if (!_tcscmp(lptszKeyword, LLKEYWORDS[i])) - { - //printf("Keyword: %s\n", LLKEYWORDS[i]); - return i; - } - - i++; - } - - dprintf("Unhandled keyword: %s\n", lptszKeyword); - return -1; -} - -// Get message template block deliminator positions -bool get_block_markers(LPBYTE lpBuffer, DWORD &dwStart, DWORD &dwEnd, DWORD &dwChildren) -{ - DWORD dwStartBlock = 0; - DWORD dwEndBlock = 0; - DWORD dwDepth = 0; - - dwChildren = 0; - - for (DWORD dwPos = dwStart; dwPos <= dwEnd; dwPos++) - { - if (lpBuffer[dwPos] == '{') - { - dwDepth++; - - if (dwDepth == 1) - dwStartBlock = dwPos; - else if (dwDepth == 2 && !dwChildren) - dwChildren = dwPos; - } - - else if (lpBuffer[dwPos] == '}') - { - dwDepth--; - - if (dwDepth == 0 && dwStartBlock) - { - dwEndBlock = dwPos; - dwStart = dwStartBlock; - dwEnd = dwEndBlock; - return true; - } - } - } - - return false; -} - -// Parse the variables message template block of a struct -bool get_var_blocks(LPCOMMANDSTRUCT lpStruct, LPBYTE lpBuffer, DWORD dwStart, DWORD dwEnd) -{ - DWORD dwVarStart = dwStart; - DWORD dwVarEnd = dwEnd; - DWORD dwVarChildren = 0; - - while (get_block_markers(lpBuffer, dwVarStart, dwVarEnd, dwVarChildren)) - { - char szVarLine[256]; - DWORD dwVarLen = (dwVarChildren ? dwVarChildren - 1 : dwVarEnd - 1) - dwVarStart; - - memcpy(&szVarLine, &lpBuffer[dwVarStart+1], dwVarLen); - szVarLine[dwVarLen] = '\0'; - trim(szVarLine); - - //printf("\t\t%s\n", szVarLine); - - char *lpszVar = strtok(szVarLine, " "); - char *lpszType = strtok(NULL, " "); - char *lpszTypeLen = NULL; - int nKeywordPos = get_keyword_pos(lpszVar); - int nVarType = get_var_type(lpszType); - - LPCOMMANDVAR lpVar = lpStruct->vars; - - if (lpVar) - { - // Insert after an item - if (nKeywordPos > lpVar->nKeywordPos) - { - while (lpVar->lpNext && nKeywordPos > lpVar->lpNext->nKeywordPos) - lpVar = lpVar->lpNext; - - LPCOMMANDVAR lpBelow = lpVar->lpNext; - - lpVar->lpNext = (LPCOMMANDVAR)malloc(sizeof(COMMANDVAR)); - - if (!lpVar->lpNext) - return false; - - ZeroMemory(lpVar->lpNext, sizeof(COMMANDVAR)); - lpVar->lpNext->lpPrev = lpVar; - lpVar->lpNext->lpNext = lpBelow; - lpVar = lpVar->lpNext; - } - // Insert before all items - else - { - lpVar->lpPrev = (LPCOMMANDVAR)malloc(sizeof(COMMANDVAR)); - - if (!lpVar->lpPrev) - return false; - - ZeroMemory(lpVar->lpPrev, sizeof(COMMANDVAR)); - - lpVar->lpPrev->lpNext = lpVar; - lpVar->lpPrev->lpPrev = NULL; - lpVar = lpVar->lpPrev; - lpStruct->vars = lpVar; - } - } - // No existing list, create a new list with our entry - else - { - lpVar = (LPCOMMANDVAR)malloc(sizeof(COMMANDVAR)); - - if (!lpVar) - return false; - - ZeroMemory(lpVar, sizeof(COMMANDVAR)); - lpStruct->vars = lpVar; - } - - lpVar->lpszVar = strdup(lpszVar); - lpVar->nType = nVarType; - lpVar->nKeywordPos = nKeywordPos; - - if (nVarType == LLTYPE_VARIABLE || nVarType == LLTYPE_FIXED) - { - lpszTypeLen = strtok(NULL, " "); - lpVar->nTypeLen = atoi(lpszTypeLen); - } - - dwVarStart = dwVarEnd + 1; - dwVarEnd = dwEnd; - } - - return true; -} - -// Parse the struct message template block of a command -bool get_struct_blocks(LPCOMMAND lpCmd, LPBYTE lpBuffer, DWORD dwStart, DWORD dwEnd) -{ - DWORD dwStructStart = dwStart; - DWORD dwStructEnd = dwEnd; - DWORD dwStructChildren = 0; - - while (get_block_markers(lpBuffer, dwStructStart, dwStructEnd, dwStructChildren)) - { - char szStructLine[256]; - DWORD dwStructLen = (dwStructChildren ? dwStructChildren - 1 : dwStructEnd - 1) - dwStructStart; - - memcpy(&szStructLine, &lpBuffer[dwStructStart+1], dwStructLen); - szStructLine[dwStructLen] = '\0'; - trim(szStructLine); - - //printf("\t%s\n", szStructLine); - - char *lpszStruct = strtok(szStructLine, " "); - char *lpszType = strtok(NULL, " "); - int nKeywordPos = get_keyword_pos(lpszStruct); - int nVarType = get_var_type(lpszType); - - LPCOMMANDSTRUCT lpStruct = lpCmd->structs; - - if (lpStruct) - { - // Insert after an item - if (nKeywordPos > lpStruct->nKeywordPos) - { - while (lpStruct->lpNext && nKeywordPos > lpStruct->lpNext->nKeywordPos) - lpStruct = lpStruct->lpNext; - - LPCOMMANDSTRUCT lpBelow = lpStruct->lpNext; - - lpStruct->lpNext = (LPCOMMANDSTRUCT)malloc(sizeof(COMMANDSTRUCT)); - - if (!lpStruct->lpNext) - return false; - - ZeroMemory(lpStruct->lpNext, sizeof(COMMANDSTRUCT)); - lpStruct->lpNext->lpPrev = lpStruct; - lpStruct->lpNext->lpNext = lpBelow; - lpStruct = lpStruct->lpNext; - } - // Insert before all items - else - { - lpStruct->lpPrev = (LPCOMMANDSTRUCT)malloc(sizeof(COMMANDSTRUCT)); - - if (!lpStruct->lpPrev) - return false; - - ZeroMemory(lpStruct->lpPrev, sizeof(COMMANDSTRUCT)); - - lpStruct->lpPrev->lpNext = lpStruct; - lpStruct->lpPrev->lpPrev = NULL; - lpStruct = lpStruct->lpPrev; - lpCmd->structs = lpStruct; - } - } - // No existing list, create a new list with our entry - else - { - lpCmd->structs = (LPCOMMANDSTRUCT)malloc(sizeof(COMMANDSTRUCT)); - - if (!lpCmd->structs) - return false; - - ZeroMemory(lpCmd->structs, sizeof(COMMANDSTRUCT)); - lpStruct = lpCmd->structs; - } - - lpStruct->lpszStruct = strdup(lpszStruct); - lpStruct->nKeywordPos = nKeywordPos; - lpStruct->nType = nVarType; - - if (nVarType == LLTYPE_VARIABLE) - { - lpStruct->cItems = 1; - } - else if (nVarType == LLTYPE_MULTIPLE) - { - char *lpszTypeLen = strtok(NULL, " "); - lpStruct->cItems = atoi(lpszTypeLen); - } - - get_var_blocks(lpStruct, lpBuffer, dwStructStart + 1, dwStructEnd - 1); - - dwStructStart = dwStructEnd + 1; - dwStructEnd = dwEnd; - } - - return true; -} - -// Parse the command message template blocks -bool get_command_blocks(LPBYTE lpBuffer, DWORD dwStart, DWORD dwEnd) -{ - DWORD dwCmdStart = dwStart; - DWORD dwCmdEnd = dwEnd; - DWORD dwCmdChildren = 0; - - while (get_block_markers(lpBuffer, dwCmdStart, dwCmdEnd, dwCmdChildren)) - { - char szCmdLine[256]; - DWORD dwCmdLen = (dwCmdChildren ? dwCmdChildren - 1 : dwCmdEnd - 1) - dwCmdStart; - - memcpy(&szCmdLine, &lpBuffer[dwCmdStart+1], dwCmdLen); - szCmdLine[dwCmdLen] = '\0'; - trim(szCmdLine); - - //printf("%s\n", szCmdLine); - - char *lpszCmd = strtok(szCmdLine, " "); - char *lpszFreq = strtok(NULL, " "); - char *lpszFixed = NULL; - char *lpszTrust = NULL; - char *lpszCoding = NULL; - static DWORD dwLow = 1; - static DWORD dwMed = 1; - static DWORD dwHigh = 1; - COMMAND *lpCmd = NULL; - - // Get the commands frequency - if (!strnicmp(lpszFreq, "Fixed", 6)) - { - lpszFixed = strtok(NULL, " "); - DWORD dwFixed = (DWORD)httoi(lpszFixed) ^ 0xffff0000; - lpCmd = &cmds_low[dwFixed]; - } - else if (!strnicmp(lpszFreq, "Low", 4)) - { - lpCmd = &cmds_low[dwLow++]; - } - else if (!strnicmp(lpszFreq, "Medium", 7)) - { - lpCmd = &cmds_med[dwMed++]; - } - else if (!strnicmp(lpszFreq, "High", 5)) - { - lpCmd = &cmds_high[dwHigh++]; - } - - lpszTrust = strtok(NULL, " "); - lpszCoding = strtok(NULL, " "); - - lpCmd->lpszCmd = strdup(lpszCmd); - - // Is the command zero encoded? - if (!strnicmp(lpszCoding, "Zerocoded", 10)) - { - lpCmd->bZerocoded = true; - } - - // Is the command trusted? - if (!strnicmp(lpszTrust, "Trusted", 8)) - { - lpCmd->bTrusted = true; - } - - get_struct_blocks(lpCmd, lpBuffer, dwCmdStart + 1, dwCmdEnd - 1); - - //printf("----------------------\n"); - - dwCmdStart = dwCmdEnd + 1; - dwCmdEnd = dwEnd; - } - - return true; -} - -void dump_structs(LPCOMMANDSTRUCT lpStruct) -{ - while (lpStruct) - { - //dprintf("\t%04d %s (%s / %hu)\n", lpStruct->nKeywordPos, lpStruct->lpszStruct, LLTYPES[lpStruct->nType], lpStruct->cItems); - - LPCOMMANDVAR lpVar = lpStruct->vars; - - while (lpVar) - { - //dprintf("\t\t%04d %s (%s / %d)\n", lpVar->nKeywordPos, lpVar->lpszVar, LLTYPES[lpVar->nType], lpVar->nTypeLen); - lpVar = lpVar->lpNext; - } - -// if (lpStruct->lpNext) -// { - lpStruct = lpStruct->lpNext; -// SAFE_FREE(lpStruct->lpPrev->lpszStruct); -// SAFE_FREE(lpStruct->lpPrev); -// } -// else -// { -// SAFE_FREE(lpStruct->lpszStruct); -// SAFE_FREE(lpStruct); -// } - } -} - -void WINAPI parse_command(LPCOMMAND lpCommand, CServer *server, char *zerobuf, int *len, int pos) -{ - //dprintf("--- %s ---\n", lpCommand->lpszCmd); - - LPCOMMANDSTRUCT lpStruct = lpCommand->structs; - - while (lpStruct) - { - //dprintf("\t%04d %s (%s / %hu)\n", lpStruct->nKeywordPos, lpStruct->lpszStruct, LLTYPES[lpStruct->nType], lpStruct->cItems); - BYTE cItems = 1; - - if (lpStruct->nType == LLTYPE_VARIABLE) - { - memcpy(&cItems, &zerobuf[pos], sizeof(cItems)); - pos += sizeof(cItems); - } - else if (lpStruct->nType == LLTYPE_MULTIPLE) - { - cItems = lpStruct->cItems; - } - - for (BYTE c = 0; c < cItems; c++) - { - //dprintf("--- %s ----\n", lpStruct->lpszStruct); - - LPCOMMANDVAR lpVar = lpStruct->vars; - - while (lpVar) - { - //dprintf("\t\t%04d %s (%s / %d)\n", lpVar->nKeywordPos, lpVar->lpszVar, LLTYPES[lpVar->nType], lpVar->nTypeLen); - - switch (lpVar->nType) - { - case LLTYPE_U8: - { - unsigned char ubData; - memcpy(&ubData, &zerobuf[pos], sizeof(ubData)); - pos += sizeof(ubData); - //dprintf("%s: %hu\n", lpVar->lpszVar, ubData); - } - break; - - case LLTYPE_U16: - { - WORD wData; - memcpy(&wData, &zerobuf[pos], sizeof(wData)); - pos += sizeof(wData); - //dprintf("%s: %u\n", lpVar->lpszVar, wData); - } - break; - - case LLTYPE_U32: - { - DWORD dwData; - memcpy(&dwData, &zerobuf[pos], sizeof(dwData)); - pos += sizeof(dwData); - //dprintf("%s: %lu\n", lpVar->lpszVar, dwData); - } - break; - - case LLTYPE_U64: - { - ULONGLONG ullData; - memcpy(&ullData, &zerobuf[pos], sizeof(ullData)); - pos += sizeof(ullData); - //dprintf("%s: %I64u\n", lpVar->lpszVar, ullData); - } - break; - - case LLTYPE_S8: - { - BYTE bData; - memcpy(&bData, &zerobuf[pos], sizeof(bData)); - pos += sizeof(bData); - //dprintf("%s: %hd\n", lpVar->lpszVar, bData); - } - break; - - case LLTYPE_S16: - { - SHORT sData; - memcpy(&sData, &zerobuf[pos], sizeof(sData)); - pos += sizeof(sData); - //dprintf("%s: %d\n", lpVar->lpszVar, sData); - } - break; - - case LLTYPE_S32: - { - LONG nData; - memcpy(&nData, &zerobuf[pos], sizeof(nData)); - pos += sizeof(nData); - //dprintf("%s: %ld\n", lpVar->lpszVar, nData); - } - break; - - case LLTYPE_S64: - break; - - case LLTYPE_F8: - break; - - case LLTYPE_F16: - break; - - case LLTYPE_F32: - { - FLOAT fData; - memcpy(&fData, &zerobuf[pos], sizeof(fData)); - pos += sizeof(fData); - //dprintf("%s: %f\n", lpVar->lpszVar, fData); - } - break; - - case LLTYPE_F64: - { - double dData; - memcpy(&dData, &zerobuf[pos], sizeof(dData)); - pos += sizeof(dData); - //dprintf("%s: %f\n", lpVar->lpszVar, dData); - } - break; - - case LLTYPE_LLUUID: - { - BYTE bData[16]; - memcpy(&bData, &zerobuf[pos], sizeof(bData)); - pos += sizeof(bData); - //dprintf("%s: ", lpVar->lpszVar); - //for (int u = 0; u < sizeof(bData); u++) - //dprintf("%02x", bData[u]); - //dprintf("\n"); - } - break; - - case LLTYPE_BOOL: - { - BYTE bData; - memcpy(&bData, &zerobuf[pos], sizeof(bData)); - pos += sizeof(bData); - //dprintf("%s: %s\n", lpVar->lpszVar, (bData) ? "True" : "False"); - } - break; - - case LLTYPE_LLVECTOR3: - { - FLOAT fData[3]; - memcpy(&fData, &zerobuf[pos], sizeof(fData)); - pos += sizeof(fData); - //dprintf("%s: %f, %f, %f\n", lpVar->lpszVar, fData[0], fData[1], fData[2]); - } - break; - - case LLTYPE_LLVECTOR3D: - { - double dData[3]; - memcpy(&dData, &zerobuf[pos], sizeof(dData)); - pos += sizeof(dData); - //dprintf("%s: %f, %f, %f\n", lpVar->lpszVar, dData[0], dData[1], dData[2]); - } - break; - - /*case LLTYPE_VECTOR4: - { - FLOAT fData[4]; - memcpy(&fData, &zerobuf[pos], sizeof(fData)); - pos += sizeof(fData); - dprintf("%s: %f, %f, %f, %f\n", lpVar->lpszVar, fData[0], fData[1], fData[2], fData[3]); - } - break;*/ - - case LLTYPE_QUATERNION: - { - FLOAT fData[4]; - memcpy(&fData, &zerobuf[pos], sizeof(fData)); - pos += sizeof(fData); - //dprintf("%s: %f, %f, %f, %f\n", lpVar->lpszVar, fData[0], fData[1], fData[2], fData[3]); - } - break; - - case LLTYPE_IPADDR: - { - BYTE ipData[4]; - memcpy(&ipData, &zerobuf[pos], sizeof(ipData)); - pos += sizeof(ipData); - //dprintf("%s: %hu.%hu.%hu.%hu\n", lpVar->lpszVar, ipData[0], ipData[1], ipData[2], ipData[3]); - } - break; - - case LLTYPE_IPPORT: - { - WORD wData; - memcpy(&wData, &zerobuf[pos], sizeof(wData)); - pos += sizeof(wData); - //dprintf("%s: %hu\n", lpVar->lpszVar, htons(wData)); - } - break; - - case LLTYPE_VARIABLE: - { - if (lpVar->nTypeLen == 1) - { - BYTE cDataLen; - LPBYTE lpData = NULL; - - memcpy(&cDataLen, &zerobuf[pos], sizeof(cDataLen)); - pos += sizeof(cDataLen); - - if (cDataLen > 0) - lpData = (LPBYTE)malloc(cDataLen); - - if (lpData) - memcpy(lpData, &zerobuf[pos], cDataLen); - - pos += cDataLen; - - if (lpData) - { - bool bPrintable = true; - - for (int j = 0; j < cDataLen - 1; j++) - { - if (((unsigned char)lpData[j] < 0x20 || (unsigned char)lpData[j] > 0x7E) && (unsigned char)lpData[j] != 0x09 && (unsigned char)lpData[j] != 0x0D) - bPrintable = false; - } - - if (bPrintable && lpData[cDataLen - 1] == '\0') - { - //dprintf("%s: %s\n", lpVar->lpszVar, lpData); - } - else - { - for (int j = 0; j < cDataLen; j += 16) - { - //dprintf("%s: ", lpVar->lpszVar); - - for (int k = 0; k < 16; k++) - { - if ((j + k) < cDataLen) - { - //dprintf("%02x ", (unsigned char)lpData[j+k]); - } - else - { - //dprintf(" "); - } - } - - for (int k = 0; k < 16 && (j + k) < cDataLen; k++) - { - //dprintf("%c", ((unsigned char)lpData[j+k] >= 0x20 && (unsigned char)lpData[j+k] <= 0x7E) ? (unsigned char)lpData[j+k] : '.'); - } - - //dprintf("\n"); - } - } - } - - SAFE_FREE(lpData); - } - else if (lpVar->nTypeLen == 2) - { - WORD cDataLen; - LPBYTE lpData = NULL; - - memcpy(&cDataLen, &zerobuf[pos], sizeof(cDataLen)); - pos += sizeof(cDataLen); - - if (cDataLen > 0) - lpData = (LPBYTE)malloc(cDataLen); - - if (lpData) - memcpy(lpData, &zerobuf[pos], cDataLen); - - pos += cDataLen; - - if (lpData) - { - bool bPrintable = true; - - for (int j = 0; j < cDataLen - 1; j++) - { - if (((unsigned char)lpData[j] < 0x20 || (unsigned char)lpData[j] > 0x7E) && (unsigned char)lpData[j] != 0x09 && (unsigned char)lpData[j] != 0x0D) - bPrintable = false; - } - - if (bPrintable && lpData[cDataLen - 1] == '\0') - { - //dprintf("%s: %s\n", lpVar->lpszVar, lpData); - } - else - { - for (int j = 0; j < cDataLen; j += 16) - { - //dprintf("%s: ", lpVar->lpszVar); - - for (int k = 0; k < 16; k++) - { - if ((j + k) < cDataLen) - { - //dprintf("%02x ", (unsigned char)lpData[j+k]); - } - else - { - //dprintf(" "); - } - } - - for (int k = 0; k < 16 && (j + k) < cDataLen; k++) - { - //dprintf("%c", ((unsigned char)lpData[j+k] >= 0x20 && (unsigned char)lpData[j+k] <= 0x7E) ? (unsigned char)lpData[j+k] : '.'); - } - - //dprintf("\n"); - } - } - } - - SAFE_FREE(lpData); - } - } - break; - - case LLTYPE_FIXED: - { - LPBYTE lpData = NULL; - - if (lpVar->nTypeLen > 0) - lpData = (LPBYTE)malloc(lpVar->nTypeLen); - - if (lpData) - memcpy(lpData, &zerobuf[pos], lpVar->nTypeLen); - - pos += lpVar->nTypeLen; - - if (lpData) - { - bool bPrintable = true; - - for (int j = 0; j < lpVar->nTypeLen - 1; j++) - { - if (((unsigned char)lpData[j] < 0x20 || (unsigned char)lpData[j] > 0x7E) && (unsigned char)lpData[j] != 0x09 && (unsigned char)lpData[j] != 0x0D) - bPrintable = false; - } - - if (bPrintable && lpData[lpVar->nTypeLen - 1] == '\0') - { - //dprintf("%s: %s\n", lpVar->lpszVar, lpData); - } - else - { - for (int j = 0; j < lpVar->nTypeLen; j += 16) - { - //dprintf("%s: ", lpVar->lpszVar); - - for (int k = 0; k < 16; k++) - { - if ((j + k) < lpVar->nTypeLen) - { - //dprintf("%02x ", (unsigned char)lpData[j+k]); - } - else - { - //dprintf(" "); - } - } - - for (int k = 0; k < 16 && (j + k) < lpVar->nTypeLen; k++) - { - //dprintf("%c", ((unsigned char)lpData[j+k] >= 0x20 && (unsigned char)lpData[j+k] <= 0x7E) ? (unsigned char)lpData[j+k] : '.'); - } - - //dprintf("\n"); - } - } - } - - SAFE_FREE(lpData); - } - break; - - case LLTYPE_SINGLE: - case LLTYPE_MULTIPLE: - case LLTYPE_NULL: - default: - break; - } - - lpVar = lpVar->lpNext; - } - } - - lpStruct = lpStruct->lpNext; - } -} - -CMessage * WINAPI map_command(LPCOMMAND lpCommand, CServer *server, char *zerobuf, int *len, int pos) -{ -// dprintf("--- %s ---\n", lpCommand->lpszCmd); - - int oldPos = pos; - - CMessage *msg = new CMessage; - - if (!msg) - return NULL; - - msg->SetCommand(lpCommand->lpszCmd); - - LPCOMMANDSTRUCT lpStruct = lpCommand->structs; - - while (lpStruct) - { - //dprintf("\t%04d %s (%s / %hu)\n", lpStruct->nKeywordPos, lpStruct->lpszStruct, LLTYPES[lpStruct->nType], lpStruct->cItems); - BYTE cItems = 1; - - if (lpStruct->nType == LLTYPE_VARIABLE) - { - memcpy(&cItems, &zerobuf[pos], sizeof(cItems)); - pos += sizeof(cItems); - } - else if (lpStruct->nType == LLTYPE_MULTIPLE) - { - cItems = lpStruct->cItems; - } - - for (BYTE c = 0; c < cItems; c++) - { - //dprintf("--- %s ----\n", lpStruct->lpszStruct); - CBlock *block = new CBlock; - msg->AddBlock(lpStruct->lpszStruct, lpStruct->nType, block); - - LPCOMMANDVAR lpVar = lpStruct->vars; - - while (lpVar) - { - //dprintf("\t\t%04d %s (%s / %d)\n", lpVar->nKeywordPos, lpVar->lpszVar, LLTYPES[lpVar->nType], lpVar->nTypeLen); - CVar *var = new CVar; - var->SetVar(lpVar->lpszVar); - var->SetType(lpVar->nType, lpVar->nTypeLen); - pos += var->SetData((LPBYTE)&zerobuf[pos]); - block->AddVar(var); - lpVar = lpVar->lpNext; - } - } - - lpStruct = lpStruct->lpNext; - } - - BYTE bPack[4096]; - int nPackedSize = msg->Pack(bPack); - int diff = memcmp(bPack, &zerobuf[oldPos], nPackedSize); - - if (diff) - { - msg->Dump(); - dprintf("PACKED: %d / %d (%d) ===> %d\n", nPackedSize, *len, oldPos, diff); - } - - return msg; -} - -void WINAPI cmd_Silent(LPCOMMAND lpCommand, CServer *server, char *zerobuf, int *len, int pos) -{ -} - -void WINAPI cmd_Default(LPCOMMAND lpCommand, CServer *server, char *zerobuf, int *len, int pos) -{ - //dprintf("Flags: %u\n", zerobuf[0]); - CMessage *msg = map_command(lpCommand, server, zerobuf, len, pos); - msg->Dump(); - SAFE_DELETE(msg); -} - -void WINAPI cmd_LoginReply(LPCOMMAND lpCommand, CServer *server, char *zerobuf, int *len, int pos) -{ - parse_command(lpCommand, server, zerobuf, len, pos); -} - -CMDHOOK pCMDHooks[] = { - { _T("Default"), (PROC)cmd_Default }, - { _T("DirLandReply"), (PROC)cmd_Silent }, // Silence the most common - { _T("AvatarAnimation"), (PROC)cmd_Silent }, // packets - { _T("CoarseLocationUpdate"), (PROC)cmd_Silent }, - { _T("CompletePingCheck"), (PROC)cmd_Silent }, - { _T("LayerData"), (PROC)cmd_Silent }, - { _T("PacketAck"), (PROC)cmd_Silent }, - { _T("StartPingCheck"), (PROC)cmd_Silent }, - { _T("SimulatorViewerTimeMessage"), (PROC)cmd_Silent }, - { _T("ImagePacket"), (PROC)cmd_Silent }, - { _T("TransferPacket"), (PROC)cmd_Silent }, - { _T("ObjectUpdate"), (PROC)cmd_Silent }, - { _T("ObjectUpdateCompressed"), (PROC)cmd_Silent }, - { _T("AgentThrottle"), (PROC)cmd_Silent }, - { _T("CoarseLocationUpdate"), (PROC)cmd_Silent }, - { _T("UUIDNameReply"), (PROC)cmd_Silent }, - { _T("RequestImage"), (PROC)cmd_Silent }, - { _T("ImageData"), (PROC)cmd_Silent }, - { _T("SimStats"), (PROC)cmd_Silent }, - { _T("ViewerEffect"), (PROC)cmd_Silent }, - { _T("TransferRequest"), (PROC)cmd_Silent }, - { _T("DirClassifiedReply"), (PROC)cmd_Silent }, - { _T("DirEventsReply"), (PROC)cmd_Silent }, - { _T("DirPopularReply"), (PROC)cmd_Silent }, - { _T("DirLandReply"), (PROC)cmd_Silent }, - { _T("AgentUpdate"), (PROC)cmd_Silent }, - { _T("ObjectUpdateCached"), (PROC)cmd_Silent }, - { _T("ImprovedTerseObjectUpdate"), (PROC)cmd_Silent }, - { _T("RequestMultipleObjects"), (PROC)cmd_Silent }, - { _T("AttachedSound"), (PROC)cmd_Silent }, - { _T("ViewerStats"), (PROC)cmd_Silent }, - { _T("TransferInfo"), (PROC)cmd_Silent }, - { _T("ParcelOverlay"), (PROC)cmd_Silent }, - { _T("SendXferPacket"), (PROC)cmd_Silent }, - { _T("DirPlacesReply"), (PROC)cmd_Silent }, - { NULL, NULL } -}; - -int decomm() -{ - FILE *fpComm; - FILE *fpMsg; - - fpComm = fopen(g_pConfig->m_pCommDatPath, "rb"); - - if (!fpComm) - { - printf("Couldn't open %s for reading, aborting...\n", g_pConfig->m_pCommDatPath); - return -1; - } - - fpMsg = fopen(g_pConfig->m_pMessageTemplatePath, "wb"); - - if (!fpMsg) - { - printf("Couldn't open %s for writing, aborting...\n", g_pConfig->m_pMessageTemplatePath); - return -1; - } - - printf("Decrypting %s to %s\n", g_pConfig->m_pCommDatPath, g_pConfig->m_pMessageTemplatePath); - static unsigned char ucMagicKey = 0; - long lTemplateSize = 0; - - fseek(fpComm, 0, SEEK_END); - lTemplateSize = ftell(fpComm); - fseek(fpComm, 0, SEEK_SET); - - BYTE buffer[2048]; - BYTE stripped[2048]; - LPBYTE lpTemplate = (LPBYTE)malloc(lTemplateSize); - DWORD dwTemplateWrote = 0; - - if (!lpTemplate) - return -1; - - bool bComment = false; - - while (!feof(fpComm)) - { - size_t stRead = fread(&buffer, 1, sizeof(buffer), fpComm); - size_t stStripped = 0; - - for (size_t stCount = 0; stCount < stRead; stCount++) - { - buffer[stCount] ^= ucMagicKey; - - if (!bComment && buffer[stCount] != '/') - stripped[stStripped++] = buffer[stCount]; - - if (bComment && buffer[stCount] == '\n') - bComment = false; - - if (!bComment && buffer[stCount] == '/') - bComment = true; - - ucMagicKey += 43; - } - - memcpy(lpTemplate + dwTemplateWrote, &stripped, stStripped); - dwTemplateWrote += (DWORD)stStripped; - - size_t stWrote = fwrite(&stripped, 1, stStripped, fpMsg); - - printf("."); - fflush(stdout); - } - - printf("\nDone.\n"); - - printf("template size: %ld\n", lTemplateSize); - - ZeroMemory(&cmds_low, sizeof(cmds_low)); - ZeroMemory(&cmds_med, sizeof(cmds_med)); - ZeroMemory(&cmds_high, sizeof(cmds_high)); - - get_command_blocks(lpTemplate, 0, lTemplateSize); - - fclose(fpComm); - fclose(fpMsg); - - for (int i = 1; i < MAX_COMMANDS_LOW; i++) - { - if (cmds_low[i].lpszCmd) - { - //dprintf("LOW %05d - %s - %s - %s\n", i, cmds_low[i].lpszCmd, cmds_low[i].bTrusted ? "Trusted" : "Untrusted", cmds_low[i].bZerocoded ? "Zerocoded" : "Unencoded"); - dump_structs(cmds_low[i].structs); - //SAFE_FREE(cmds_low[i].lpszCmd); - } - } - - for (int i = 1; i < MAX_COMMANDS_MEDIUM; i++) - { - if (cmds_med[i].lpszCmd) - { - //dprintf("Medium %05d - %s\n", i, cmds_med[i].lpszCmd); - dump_structs(cmds_med[i].structs); - //SAFE_FREE(cmds_med[i].lpszCmd); - } - } - - for (int i = 1; i < MAX_COMMANDS_HIGH; i++) - { - if (cmds_high[i].lpszCmd) - { - //dprintf("High %05d - %s\n", i, cmds_high[i].lpszCmd); - dump_structs(cmds_high[i].structs); - //SAFE_FREE(cmds_high[i].lpszCmd); - } - } - - return 0; -} - -HMODULE WINAPI new_LoadLibraryA( - LPCSTR lpLibFileName - ) -{ - if (g_hOpenGL != NULL && !_tcsicmp(lpLibFileName, "OPENGL32")) - return g_hOpenGL; - -// dprintf("[LoadLibraryA] Filename(%s)\n", lpLibFileName); - - HMODULE hModule = NULL; - PROC pOldProc = pAPIHooks[APIHOOK_LOADLIBRARYA].pOldProc; - - if (pOldProc != NULL && !IsBadCodePtr((PROC)pOldProc)) - { - hModule = ((HMODULE (WINAPI *)(LPCSTR))pOldProc)(lpLibFileName); - if (hModule != NULL) - { - SaveImportHooks(); - InstallImportHooks(); - } - } - - if (!_tcsicmp(lpLibFileName, "OPENGL32")) - g_hOpenGL = hModule; - - return hModule; -} - -BOOL WINAPI new_FreeLibraryA( - HMODULE hLibModule - ) -{ - if (hLibModule == g_hOpenGL) - { - return TRUE; - } - - return ((BOOL (WINAPI *)(HMODULE))pAPIHooks[APIHOOK_FREELIBRARYA].pOldProc)(hLibModule); -} - -HMODULE WINAPI new_LoadLibraryW( - LPCWSTR lpLibFileName - ) -{ -// dprintf("[LoadLibraryW] Filename(%S)\n", lpLibFileName); - - HMODULE hModule = NULL; - PROC pOldProc = pAPIHooks[APIHOOK_LOADLIBRARYW].pOldProc; - - if (pOldProc != NULL && !IsBadCodePtr((PROC)pOldProc)) - { - hModule = ((HMODULE (WINAPI *)(LPCWSTR))pOldProc)(lpLibFileName); - if (hModule != NULL) - { - SaveImportHooks(); - InstallImportHooks(); - } - } - - return hModule; -} - -HMODULE WINAPI new_LoadLibraryExA( - LPCSTR lpLibFileName, - HANDLE hFile, - DWORD dwFlags - ) -{ -// dprintf("[LoadLibraryExA] Filename(%s)\n", lpLibFileName); - - HMODULE hModule = NULL; - PROC pOldProc = pAPIHooks[APIHOOK_LOADLIBRARYEXA].pOldProc; - - if (pOldProc != NULL && !IsBadCodePtr((PROC)pOldProc)) - { - hModule = ((HMODULE (WINAPI *)(LPCSTR, HANDLE, DWORD))pOldProc)(lpLibFileName, hFile, dwFlags); - if (hModule != NULL) - { - SaveImportHooks(); - InstallImportHooks(); - } - } - - return hModule; -} - -HMODULE WINAPI new_LoadLibraryExW( - LPCWSTR lpLibFileName, - HANDLE hFile, - DWORD dwFlags) -{ -// dprintf("[LoadLibraryExW] Filename(%S)\n", lpLibFileName); - - HMODULE hModule = NULL; - PROC pOldProc = pAPIHooks[APIHOOK_LOADLIBRARYEXW].pOldProc; - - if (pOldProc != NULL && !IsBadCodePtr((PROC)pOldProc)) - { - hModule = ((HMODULE (WINAPI *)(LPCWSTR, HANDLE, DWORD))pOldProc)(lpLibFileName, hFile, dwFlags); - if (hModule != NULL) - { - SaveImportHooks(); - InstallImportHooks(); - } - } - - return hModule; -} - -FARPROC WINAPI new_GetProcAddress(HMODULE hModule, LPCSTR lpProcName) -{ - TCHAR szMod[MAX_PATH]; - - GetModuleFileName(hModule, szMod, sizeof(szMod)); - - if (HIWORD((DWORD)lpProcName) == 0) - { - WORD wOrdinal = LOWORD((DWORD)lpProcName); -// dprintf(_T("[GetProcAddress] [%s][@%d]\n"), szMod, wOrdinal); - } - else - { - if (lpProcName != NULL && !IsBadCodePtr((PROC)lpProcName)) - { - if (!stricmp(lpProcName, "wglSwapBuffers")) - { - - } - else if (!stricmp(lpProcName, "InternetReadFile")) - { - dprintf(_T("[***GetProcAddress] [%s][%s]\n"), szMod, lpProcName); - return pAPIHooks[(int)APIHOOK_INTERNETREADFILE].pNewProc; - } - else if (!stricmp(lpProcName, "InternetOpenUrlA")) - { - dprintf(_T("[***GetProcAddress] [%s][%s]\n"), szMod, lpProcName); - return pAPIHooks[(int)APIHOOK_INTERNETOPENURLA].pNewProc; - } - else if (!stricmp(lpProcName, "CPEncrypt")) - { - dprintf(_T("[***CPEncrypt] [%s][%s]\n"), szMod, lpProcName); - return pAPIHooks[(int)APIHOOK_CPENCRYPT].pNewProc; - } - //else - //dprintf(_T("[GetProcAddress] [%s][%s]\n"), szMod, lpProcName); - } - //else - //dprintf(_T("[GetProcAddress] [%s][]\n"), szMod); - } - - return ((FARPROC (WINAPI *)(HMODULE, LPCSTR))pAPIHooks[(int)APIHOOK_GETPROCADDRESS].pOldProc)(hModule, lpProcName); -} - -struct hostent FAR * WINAPI new_gethostbyname( - const char FAR *name - ) -{ - dprintf("[new_gethostbyname] name(%s)\n", name); - - struct hostent FAR * hp = ((struct hostent FAR * (WINAPI *)(const char FAR *))pAPIHooks[(int)APIHOOK_GETHOSTBYNAME].pOldProc)(name); - - return hp; -} - -int WINAPI new_connect( - SOCKET s, - const struct sockaddr FAR *name, - int namelen - ) -{ - dprintf("[connect] socket(0x%08X) host(%s) port(%d)\n", s, inet_ntoa(((struct sockaddr_in *)name)->sin_addr), ntohs(((struct sockaddr_in *)name)->sin_port)); - - return ((int (WINAPI *)(SOCKET, const struct sockaddr FAR *, int))pAPIHooks[(int)APIHOOK_CONNECT].pOldProc)(s, name, namelen); -} - -int WINAPI new_recv( - SOCKET s, - char *buf, - int len, - int flags - ) -{ - //dprintf("[recv] socket(0x%08X)\n", s); - - int nRes = 0; - { - nRes = ((int (WINAPI *)(SOCKET, char *, int, int))pAPIHooks[APIHOOK_RECV].pOldProc)(s, buf, len, flags); - } -/* - for (int j = 0; j < nRes; j += 16) - { - for (int k = 0; k < 16; k++) - { - if ((j + k) < nRes) - { - dprintf("%02x ", (unsigned char)buf[j+k]); - } - else - { - dprintf(" "); - } - } - - for (int k = 0; k < 16 && (j + k) < nRes; k++) - { - dprintf("%c", ((unsigned char)buf[j+k] >= 0x20 && (unsigned char)buf[j+k] <= 0x7E) ? (unsigned char)buf[j+k] : '.'); - } - - dprintf("\n"); - } -*/ - return nRes; -} - -int WINAPI new_recvfrom( - SOCKET s, - char *buf, - int len, - int flags, - struct sockaddr *from, - int *fromlen - ) -{ - int nRes = 0; - WORD wSeq = 0; - int zerolen = 0; - static char zerobuf[8192]; - bool bZerocoded = false; - CServer *server = NULL; - CSequence *sequence = NULL; - - nRes = ((int (WINAPI *)(SOCKET, char *, int, int, struct sockaddr *, int *))pAPIHooks[APIHOOK_RECVFROM].pOldProc)(s, buf, len, flags, from, fromlen); - - // !!! - //return nRes; - - if (nRes > 0) - { - //dprintf("Receiving %u bytes\n", nRes); - - // Get packet sequence number - memcpy(&wSeq, &buf[2], sizeof(wSeq)); - wSeq = htons(wSeq); - - // Get current server - server = servers.FindServer((struct sockaddr_in *)from); - - // If server isn't in our list add it as new - if (!server) - { - server = new CServer((struct sockaddr_in *)from); - servers.AddServer(server); - } - - // Handle packet acks - BYTE bAppended[4096]; - int nAppendedLen = 0; - - if (buf[0] & MSG_APPENDED_ACKS) - { - //dprintf("APPENDED ACKS\n"); - - BYTE cPacketsItems = buf[nRes - 1]; - - int nOldRes = nRes; - - nRes = nOldRes - 1 - (cPacketsItems * sizeof(DWORD)); - //dprintf("NEW AND OLD: %d / %d\n", nRes, nOldRes); - nAppendedLen = nOldRes - nRes; - memcpy(bAppended, &buf[nRes], nAppendedLen); - } - zerolen = ZeroDecode(buf, nRes, zerobuf, sizeof(zerobuf)); - - if ((unsigned char)buf[4] != 0xff) - { - // High - //dprintf("parse high: %hu\n", zerobuf[4]); - - bool bCmdFound = false; - - for (int j = 0; pCMDHooks[j].szCommand; j++) - { - if (_tcsicmp(cmds_high[zerobuf[4]].lpszCmd, pCMDHooks[j].szCommand) == 0 && pCMDHooks[j].pProc != NULL && !IsBadCodePtr(pCMDHooks[j].pProc)) - { - bCmdFound = true; - ((void (WINAPI *)(LPCOMMAND, CServer *, char *, int *, int))pCMDHooks[j].pProc)(&cmds_high[zerobuf[4]], server, zerobuf, &zerolen, 5); - break; - } - } - - if (!bCmdFound) - { - ((void (WINAPI *)(LPCOMMAND, CServer *, char *, int *, int))pCMDHooks[0].pProc)(&cmds_high[zerobuf[4]], server, zerobuf, &zerolen, 5); - } - } - - else if ((unsigned char)buf[5] != 0xff) - { - // Medium - //dprintf("parse med: %hu\n", zerobuf[5]); - - bool bCmdFound = false; - - for (int j = 0; pCMDHooks[j].szCommand; j++) - { - if (!_tcsicmp(cmds_med[zerobuf[5]].lpszCmd, pCMDHooks[j].szCommand) && pCMDHooks[j].pProc != NULL && !IsBadCodePtr(pCMDHooks[j].pProc)) - { - bCmdFound = true; - ((void (WINAPI *)(LPCOMMAND, CServer *, char *, int *, int))pCMDHooks[j].pProc)(&cmds_med[zerobuf[5]], server, zerobuf, &zerolen, 6); - break; - } - } - - if (!bCmdFound) - { - ((void (WINAPI *)(LPCOMMAND, CServer *, char *, int *, int))pCMDHooks[0].pProc)(&cmds_med[zerobuf[5]], server, zerobuf, &zerolen, 6); - } - } - - else if ((unsigned char)buf[4] == 0xff && (unsigned char)buf[5] == 0xff) - { - // Fixed - // Low - - //dprintf("parse low: %hu\n", htons(wFreq)); - - bool bCmdFound = false; - WORD wFreq; - memcpy(&wFreq, &zerobuf[6], sizeof(wFreq)); - - for (int j = 0; pCMDHooks[j].szCommand; j++) - { - if (!_tcsicmp(cmds_low[htons(wFreq)].lpszCmd, pCMDHooks[j].szCommand) && pCMDHooks[j].pProc != NULL && !IsBadCodePtr(pCMDHooks[j].pProc)) - { - bCmdFound = true; - ((void (WINAPI *)(LPCOMMAND, CServer *, char *, int *, int))pCMDHooks[j].pProc)(&cmds_low[htons(wFreq)], server, zerobuf, &zerolen, 8); - break; - } - } - - if (!bCmdFound) - { - ((void (WINAPI *)(LPCOMMAND, CServer *, char *, int *, int))pCMDHooks[0].pProc)(&cmds_low[htons(wFreq)], server, zerobuf, &zerolen, 8); - } - } - - nRes = ZeroEncode(zerobuf, zerolen, buf, len); - - if (nAppendedLen > 0) - { - memcpy(&buf[nRes], bAppended, nAppendedLen); - nRes += nAppendedLen; - } - } - else - { - // We can use this area to synthesize incoming packets - } - - return nRes; -} - -int WINAPI new_send( - SOCKET s, - const char *buf, - int len, - int flags - ) -{ -// dprintf("[send] socket(0x%08X)\n", s); - - int nRes = 0; - { - nRes = ((int (WINAPI *)(SOCKET, const char *, int, int))pAPIHooks[APIHOOK_SEND].pOldProc)(s, buf, len, flags); - } - - return nRes; -} - -int WINAPI new_sendto( - SOCKET s, - char *buf, - int len, - int flags, - struct sockaddr *to, - int tolen - ) -{ - int nRes = 0; - WORD wSeq = 0; - int zerolen = 0; - char *zerobuf = NULL; - bool bZerocoded = false; - CServer *server = NULL; - CSequence *sequence = NULL; - - // Get packet sequence number - memcpy(&wSeq, &buf[2], sizeof(wSeq)); - wSeq = htons(wSeq); - - // Get current server - server = servers.FindServer((struct sockaddr_in *)to); - - // If server isn't in our list add it as new - if (!server) - { - server = new CServer((struct sockaddr_in *)to); - servers.AddServer(server); - } - - static int nDropPacket = 0; - - if (buf[0] & MSG_ZEROCODED) - { - bZerocoded = true; - zerolen = 4; - - for (int i = 4; i < len; i++) - { - if ((unsigned char)buf[i] == 0x00) - zerolen += (unsigned char)buf[++i]; - else - zerolen++; - } - - zerobuf = (char *)malloc(zerolen); - - if (!zerobuf) - { - dprintf("Couldn't allocate memory for zerocoded buffer\n"); - return -1; - } - - int j = 4; - memcpy(zerobuf, buf, 4); - - for (int i = 4; i < len; i++) - { - if ((unsigned char)buf[i] == 0x00) - { - for (int z = 0; z < (unsigned char)buf[i+1]; z++) - zerobuf[j++] = 0x00; - - i++; - } - else - zerobuf[j++] = buf[i]; - } - } - else - { - zerolen = len; - zerobuf = buf; - } - - nRes = ((int (WINAPI *)(SOCKET, char *, int, int, struct sockaddr *, int))pAPIHooks[APIHOOK_SENDTO].pOldProc)(s, buf, len, flags, to, tolen); - - // !!! - //return nRes; - - //dprintf("Sending %u bytes\n", nRes); - - if ((unsigned char)buf[4] != 0xff) - { - // High - //dprintf("parse high: %hu\n", zerobuf[4]); - - bool bCmdFound = false; - - for (int j = 0; pCMDHooks[j].szCommand; j++) - { - if (_tcsicmp(cmds_high[zerobuf[4]].lpszCmd, pCMDHooks[j].szCommand) == 0 && pCMDHooks[j].pProc != NULL && !IsBadCodePtr(pCMDHooks[j].pProc)) - { - bCmdFound = true; - ((void (WINAPI *)(LPCOMMAND, CServer *, char *, int *, int))pCMDHooks[j].pProc)(&cmds_high[zerobuf[4]], server, zerobuf, &zerolen, 5); - break; - } - } - - if (!bCmdFound) - { - ((void (WINAPI *)(LPCOMMAND, CServer *, char *, int *, int))pCMDHooks[0].pProc)(&cmds_high[zerobuf[4]], server, zerobuf, &zerolen, 5); - } - } - - else if ((unsigned char)buf[5] != 0xff) - { - // Medium - //dprintf("parse med: %hu\n", zerobuf[5]); - - bool bCmdFound = false; - - for (int j = 0; pCMDHooks[j].szCommand; j++) - { - if (!_tcsicmp(cmds_med[zerobuf[5]].lpszCmd, pCMDHooks[j].szCommand) && pCMDHooks[j].pProc != NULL && !IsBadCodePtr(pCMDHooks[j].pProc)) - { - bCmdFound = true; - ((void (WINAPI *)(LPCOMMAND, CServer *, char *, int *, int))pCMDHooks[j].pProc)(&cmds_med[zerobuf[5]], server, zerobuf, &zerolen, 6); - break; - } - } - - if (!bCmdFound) - { - ((void (WINAPI *)(LPCOMMAND, CServer *, char *, int *, int))pCMDHooks[0].pProc)(&cmds_med[zerobuf[5]], server, zerobuf, &zerolen, 6); - } - } - - else if ((unsigned char)buf[4] == 0xff && (unsigned char)buf[5] == 0xff) - { - // Fixed - // Low - - //dprintf("parse low: %hu\n", htons(wFreq)); - - bool bCmdFound = false; - WORD wFreq; - memcpy(&wFreq, &zerobuf[6], sizeof(wFreq)); - - for (int j = 0; pCMDHooks[j].szCommand; j++) - { - if (!_tcsicmp(cmds_low[htons(wFreq)].lpszCmd, pCMDHooks[j].szCommand) && pCMDHooks[j].pProc != NULL && !IsBadCodePtr(pCMDHooks[j].pProc)) - { - bCmdFound = true; - ((void (WINAPI *)(LPCOMMAND, CServer *, char *, int *, int))pCMDHooks[j].pProc)(&cmds_low[htons(wFreq)], server, zerobuf, &zerolen, 8); - break; - } - } - - if (!bCmdFound) - { - ((void (WINAPI *)(LPCOMMAND, CServer *, char *, int *, int))pCMDHooks[0].pProc)(&cmds_low[htons(wFreq)], server, zerobuf, &zerolen, 8); - } - } - else - { - dprintf("[sendto] *** UNKNOWN FREQUENCY TYPE ***\n", s); - int i, j; - - for (i = 0; i < len + 16; i += 16) - { - for (j = 0; j < 16; j++) - { - if ((i + j) < len) - { - dprintf("%02x ", (unsigned char)buf[i+j]); - } - else - { - dprintf(" "); - } - } - - for (j = 0; j < 16 && (i + j) < len; j++) - { - dprintf("%c", isprint(buf[i+j]) ? (unsigned char)buf[i+j] : '.'); - } - - dprintf("\n"); - } - - dprintf("\n"); - } - - if (bZerocoded && zerobuf) - free(zerobuf); - - return nRes; -} - -/* -LONG WINAPI new_SetWindowLongA( - HWND hWnd, - int nIndex, - LONG dwNewLong -) -{ - LONG nRes = 0; - - if (nIndex == GWL_WNDPROC && g_pMainFrm && hWnd == g_pMainFrm->m_hWnd) - { - dprintf(_T("[SetWindowLongA] %08x [%x] = "), hWnd, dwNewLong); - - nRes = ((LONG (WINAPI *)(HWND, int, LONG))pAPIHooks[APIHOOK_SETWINDOWLONGA].pOldProc)(hWnd, nIndex, dwNewLong); - - dprintf(_T("[%x]\n"), nRes); - } - else - { - if (nIndex == GWL_WNDPROC) - dprintf(_T("[SetWindowLongA] %08x [%x]\n"), hWnd, dwNewLong); - - nRes = ((LONG (WINAPI *)(HWND, int, LONG))pAPIHooks[APIHOOK_SETWINDOWLONGA].pOldProc)(hWnd, nIndex, dwNewLong); - } - - return nRes; -} - -LONG WINAPI new_SetWindowLongW( - HWND hWnd, - int nIndex, - LONG dwNewLong -) -{ - LONG nRes = 0; - - if (nIndex == GWL_WNDPROC) - { - dprintf(_T("[SetWindowLongW] %08x\n"), hWnd); - - nRes = ((LONG (WINAPI *)(HWND, int, LONG))pAPIHooks[APIHOOK_SETWINDOWLONGW].pOldProc)(hWnd, nIndex, dwNewLong); - } - else - { - nRes = ((LONG (WINAPI *)(HWND, int, LONG))pAPIHooks[APIHOOK_SETWINDOWLONGW].pOldProc)(hWnd, nIndex, dwNewLong); - } - - return nRes; -} -*/ -BOOL WINAPI new_InternetReadFile( - IN HINTERNET hFile, - IN LPVOID lpBuffer, - IN DWORD dwNumberOfBytesToRead, - OUT LPDWORD lpNumberOfBytesRead -) -{ - BOOL bRes = FALSE; - - bRes = ((BOOL (WINAPI *)(HINTERNET, LPVOID, DWORD, LPDWORD))pAPIHooks[APIHOOK_INTERNETREADFILE].pOldProc)(hFile, lpBuffer, dwNumberOfBytesToRead, lpNumberOfBytesRead); - - dprintf(_T("[InternetReadFile] [%s] %d\n"), lpBuffer, *lpNumberOfBytesRead); - - return bRes; -} - -HINTERNET WINAPI new_InternetOpenUrlA( - HINTERNET hInternet, - LPCTSTR lpszUrl, - LPCTSTR lpszHeaders, - DWORD dwHeadersLength, - DWORD dwFlags, - DWORD_PTR dwContext -) -{ - HINTERNET hNet = 0; - - dprintf(_T("[InternetOpenUrlA] [%s][%s]\n"), lpszUrl, lpszHeaders); - - hNet = ((HINTERNET (WINAPI *)(HINTERNET, LPCTSTR, LPCTSTR, DWORD, DWORD, DWORD_PTR))pAPIHooks[APIHOOK_INTERNETOPENURLA].pOldProc)(hInternet, lpszUrl, lpszHeaders, dwHeadersLength, dwFlags, dwContext); - - return hNet; -} - -BOOL WINAPI new_CPEncrypt( - HCRYPTPROV hProv, - HCRYPTKEY hKey, - HCRYPTHASH hHash, - BOOL Final, - DWORD dwFlags, - BYTE* pbData, - DWORD* pdwDataLen, - DWORD dwBufLen -) -{ - BOOL bRes = FALSE; - - bRes = ((BOOL (WINAPI *)(HCRYPTPROV, HCRYPTKEY, HCRYPTHASH, BOOL, DWORD, BYTE *, DWORD *, DWORD))pAPIHooks[APIHOOK_CPENCRYPT].pOldProc)(hProv, hKey, hHash, Final, dwFlags, pbData, pdwDataLen, dwBufLen); - - TCHAR szStr[2048]; - ZeroMemory(szStr, sizeof(szStr)); - memcpy(szStr, pbData, sizeof(szStr)); - - dprintf(_T("[CPEncrypt] [%s] %d\n"), szStr, 0); - - return bRes; -} - -BOOL WINAPI new_PeekMessageA( - LPMSG lpMsg, // pointer to structure for message - HWND hWnd, // handle to window - UINT wMsgFilterMin, // first message - UINT wMsgFilterMax, // last message - UINT wRemoveMsg // removal flags -) -{ - //dprintf(_T("[PeekMessageA] [%x]\n"), hWnd); - - BOOL bRes = FALSE; - static UINT uiAntiIdle = 0; - - bRes = ((BOOL (WINAPI *)(LPMSG, HWND, UINT, UINT, UINT))pAPIHooks[APIHOOK_PEEKMESSAGEA].pOldProc)(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg); - - if (!bRes && GetFocus() == NULL) - { - // Wait for any message sent or posted to this queue - DWORD dwResult = MsgWaitForMultipleObjects(0, NULL, FALSE, 1000, QS_ALLINPUT); - - uiAntiIdle++; - - if (uiAntiIdle > 4) - { - //dprintf(_T("idle.. %d\n"), uiAntiIdle); - if (g_pMainFrm) - { - //dprintf(_T("sending anti.. idle...\n")); - PostMessage(g_pMainFrm->m_hWnd, WM_MOUSEMOVE, 0, MAKEWORD(10, 10)); - } - - uiAntiIdle = 0; - } - } - - static UINT uiAutoPilot = 0; - - if (g_pMainFrm) - { - //uiAutoPilot++; - - if (uiAutoPilot > 200) - { - WORD wRepeatCount = 1; - LPARAM lParam = MAKELPARAM(wRepeatCount, 0); - - lParam |= 1 << 24; - lParam |= 0 << 29; - lParam |= 1 << 30; - lParam |= 0 << 31; - - //PostMessage(g_pMainFrm->m_hWnd, WM_KEYDOWN, VK_UP, lParam); - - lParam |= 0 << 24; - //PostMessage(g_pMainFrm->m_hWnd, WM_KEYDOWN, 'E', 0); - - char sc = 0; - sc = MapVirtualKey('E', 0); - - for (int k = 0; k < 90; k++) - PostMessage(g_pMainFrm->m_hWnd, WM_KEYDOWN, 'E', 1 | (1 << 30) | (sc << 16)); - - //PostMessage(g_pMainFrm->m_hWnd, WM_KEYUP, 'E', 1 | (3 << 30) | (sc << 16)); - - uiAutoPilot = 0; - } - } - - return bRes; -} - -VOID WINAPI new_glEnable( - GLenum cap -) -{ - dprintf(_T("[glEnable] [0x%08x]\n"), cap); - -// if (cap != GL_TEXTURE_2D) - ((VOID (WINAPI *)(GLenum))pAPIHooks[APIHOOK_GLENABLE].pOldProc)(cap); -// else -// glDisable(GL_TEXTURE_2D); -} - -GLboolean WINAPI new_glIsEnabled( - GLenum cap -) -{ -// if (cap == GL_TEXTURE_2D) -// return GL_TRUE; - - return ((GLboolean (WINAPI *)(GLenum))pAPIHooks[APIHOOK_GLISENABLED].pOldProc)(cap); -} - -VOID WINAPI new_glTranslatef( - GLfloat x, - GLfloat y, - GLfloat z -) -{ - dprintf(_T("[glTranslatef]\n")); - ((VOID (WINAPI *)(GLfloat, GLfloat, GLfloat))pAPIHooks[APIHOOK_GLTRANSLATEF].pOldProc)(x, y, z); -} - -VOID WINAPI new_glTranslated( - GLdouble x, - GLdouble y, - GLdouble z -) -{ - dprintf(_T("[glTranslated]\n")); - ((VOID (WINAPI *)(GLdouble, GLdouble, GLdouble))pAPIHooks[APIHOOK_GLTRANSLATED].pOldProc)(x, y, z); -} - -VOID WINAPI new_glTexCoord2f( - GLfloat s, - GLfloat t -) -{ - ((VOID (WINAPI *)(GLfloat, GLfloat))pAPIHooks[APIHOOK_GLTEXCOORD2F].pOldProc)(s, t); -} - -VOID WINAPI new_glVertex2f( - GLfloat x, - GLfloat y -) -{ - dprintf("[glVertex2f]\n"); - ((VOID (WINAPI *)(GLfloat, GLfloat))pAPIHooks[APIHOOK_GLVERTEX2F].pOldProc)(x, y); -} - -VOID WINAPI new_glVertex3f( - GLfloat x, - GLfloat y, - GLfloat z -) -{ - dprintf("[glVertex3f]\n"); - ((VOID (WINAPI *)(GLfloat, GLfloat, GLfloat))pAPIHooks[APIHOOK_GLVERTEX3F].pOldProc)(x, y, z); -} - -// Moves floating name tags -VOID WINAPI new_glVertex3fv( - GLfloat *v -) -{ - dprintf("[glVertex3fv]\n"); - ((VOID (WINAPI *)(const GLfloat *v))pAPIHooks[APIHOOK_GLVERTEX3FV].pOldProc)(v); -} - -VOID WINAPI new_glVertex4f( - GLfloat x, - GLfloat y, - GLfloat z, - GLfloat w -) -{ - dprintf("[glVertex4f]\n"); - ((VOID (WINAPI *)(GLfloat, GLfloat, GLfloat, GLfloat))pAPIHooks[APIHOOK_GLVERTEX4F].pOldProc)(x, y, z, w); -} - -VOID WINAPI new_glVertex4fv( - GLfloat *v -) -{ - dprintf("[glVertex4v]\n"); - ((VOID (WINAPI *)(const GLfloat *v))pAPIHooks[APIHOOK_GLVERTEX4FV].pOldProc)(v); -} - -VOID WINAPI new_glTexCoord2fv( - GLfloat *v -) -{ - ((VOID (WINAPI *)(GLfloat *))pAPIHooks[APIHOOK_GLTEXCOORD2FV].pOldProc)(v); -} - -VOID WINAPI new_glColor4f( - GLfloat red, - GLfloat green, - GLfloat blue, - GLfloat alpha -) -{ - ((VOID (WINAPI *)(GLfloat, GLfloat, GLfloat, GLfloat))pAPIHooks[APIHOOK_GLCOLOR4F].pOldProc)(red, green, blue, alpha); -} - -VOID WINAPI new_glColor3f( - GLfloat red, - GLfloat green, - GLfloat blue -) -{ - GLfloat alpha; - alpha = 1.0f; - - ((VOID (WINAPI *)(GLfloat, GLfloat, GLfloat, GLfloat))pAPIHooks[APIHOOK_GLCOLOR4F].pOldProc)(red, green, blue, alpha); -} - -VOID WINAPI new_glColor4fv( - GLfloat *v -) -{ - ((VOID (WINAPI *)(const GLfloat *))pAPIHooks[APIHOOK_GLCOLOR4FV].pOldProc)(v); -} - -VOID WINAPI new_glColor4ubv( - GLubyte *v -) -{ - ((VOID (WINAPI *)(const GLubyte *))pAPIHooks[APIHOOK_GLCOLOR4UBV].pOldProc)(v); -} - -VOID WINAPI new_glColor3fv( - GLfloat *v -) -{ - GLfloat n[4]; - n[0] = v[0]; - n[1] = v[1]; - n[2] = v[2]; - n[3] = 1.0; - - ((VOID (WINAPI *)(const GLfloat *))pAPIHooks[APIHOOK_GLCOLOR4FV].pOldProc)(n); -} - -GLenum WINAPI new_glGetError( - void -) -{ - dprintf("[glGetError] "); - GLenum error = ((GLenum (WINAPI *)(void))pAPIHooks[APIHOOK_GLGETERROR].pOldProc)(); - - dprintf("0x%x\n", error); - if (error == GL_INVALID_OPERATION) - return GL_NO_ERROR; - else return error; -} - -VOID WINAPI new_glColorPointer( - GLint size, - GLenum type, - GLsizei stride, - const GLvoid *pointer -) -{ - dprintf("[glColorPointer]\n"); - ((VOID (WINAPI *)(GLint, GLenum, GLsizei, const GLvoid *))pAPIHooks[APIHOOK_GLCOLORPOINTER].pOldProc)(size, type, stride, pointer); -} - -// Used to render avatars and trees -VOID WINAPI new_glDrawElements( - GLenum mode, - GLsizei count, - GLenum type, - const GLvoid *indices -) -{ - //glColor4f(1.0, 1.0, 1.0, 0.2); - /*glBegin(GL_QUADS); - for (int i = 0; i < 10; i++) - { - GLfloat fPosX; - GLfloat fPosY; - GLfloat fPosZ; - - fPosX = (float)(rand() % 300) - 150.0f; - fPosY = -10;//(float)(rand() % 200) - 10.0f; - fPosZ = (float)(rand() % 300) - 150.0f; - - glTexCoord2f(0.0, 1.0); - glVertex3f(fPosX - 4.0f, fPosY + 1.0f, fPosZ - 4.0f); - - glTexCoord2f(0.0, 0.0); - glVertex3f(fPosX - 4.0f, fPosY + 1.0f, fPosZ + 4.0f); - - glTexCoord2f(1.0, 0.0); - glVertex3f(fPosX + 4.0f, fPosY + 1.0f, fPosZ + 4.0f); - - glTexCoord2f(1.0, 1.0); - glVertex3f(fPosX + 4.0f, fPosY + 1.0f, fPosZ - 4.0f); - - } - glEnd();*/ - - dprintf("[glDrawElements] %d\n", count); - ((VOID (WINAPI *)(GLenum, GLsizei, GLenum, const GLvoid *))pAPIHooks[APIHOOK_GLDRAWELEMENTS].pOldProc)(mode, count, type, indices); -} - -VOID WINAPI new_glDrawArrays( - GLenum mode, - GLint first, - GLsizei count -) -{ - dprintf("[glDrawArrays] %d\n", count); - ((VOID (WINAPI *)(GLenum, GLint, GLsizei))pAPIHooks[APIHOOK_GLDRAWARRAYS].pOldProc)(mode, first, count); -} - -VOID WINAPI new_glDrawPixels( - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - const GLvoid *pixels -) -{ - dprintf("[glDrawPixels]\n"); - ((VOID (WINAPI *)(GLsizei, GLsizei, GLenum, GLenum, const GLvoid))pAPIHooks[APIHOOK_GLDRAWPIXELS].pOldProc)(width, height, format, type, pixels); -} - -VOID WINAPI new_glVertexPointer( - GLint size, - GLenum type, - GLsizei stride, - const GLvoid *pointer -) -{ - ((VOID (WINAPI *)(GLint, GLenum, GLsizei, const GLvoid *))pAPIHooks[APIHOOK_GLVERTEXPOINTER].pOldProc)(size, type, stride, pointer); -} - -VOID WINAPI new_glNormalPointer( - GLenum type, - GLsizei stride, - const GLvoid *pointer -) -{ - dprintf("[glNormalPointer]\n"); - ((VOID (WINAPI *)(GLenum, GLsizei, const GLvoid *))pAPIHooks[APIHOOK_GLNORMALPOINTER].pOldProc)(type, stride, pointer); -} - -VOID WINAPI new_glTexCoordPointer( - GLint size, - GLenum type, - GLsizei stride, - const GLvoid *pointer -) -{ - ((VOID (WINAPI *)(GLint, GLenum, GLsizei, const GLvoid *))pAPIHooks[APIHOOK_GLTEXCOORDPOINTER].pOldProc)(size, type, stride, pointer); -} - -VOID WINAPI new_glViewport( - GLint x, - GLint y, - GLsizei width, - GLsizei height -) -{ - ((VOID (WINAPI *)(GLint, GLint, GLsizei, GLsizei))pAPIHooks[APIHOOK_GLVIEWPORT].pOldProc)(x, y, width, height); -} - -VOID WINAPI new_glTexImage2D( - GLenum target, - GLint level, - GLint components, - GLsizei width, - GLsizei height, - GLint border, - GLenum format, - GLenum type, - const GLvoid *pixels -) -{ - ((VOID (WINAPI *)(GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *))pAPIHooks[APIHOOK_GLTEXIMAGE2D].pOldProc)(target, level, components, width, height, border, format, type, pixels); -} - -VOID WINAPI new_gluPerspective( - GLdouble fovy, - GLdouble aspect, - GLdouble zNear, - GLdouble zFar -) -{ - ((VOID (WINAPI *)(GLdouble, GLdouble, GLdouble, GLdouble))pAPIHooks[APIHOOK_GLUPERSPECTIVE].pOldProc)(fovy, aspect, zNear, zFar); -} - -VOID WINAPI new_glBegin( - GLenum mode -) -{ - ((VOID (WINAPI *)(GLenum))pAPIHooks[APIHOOK_GLBEGIN].pOldProc)(mode); -} - -VOID WINAPI new_glFlush( - void -) -{ - ((VOID (WINAPI *)(void))pAPIHooks[APIHOOK_GLFLUSH].pOldProc)(); -} - -VOID WINAPI new_gluQuadricDrawStyle( - GLUquadricObj * qobj, - GLenum drawStyle - ) -{ - ((VOID (WINAPI *)(GLUquadricObj *, GLenum))pAPIHooks[APIHOOK_GLUQUADRICDRAWSTYLE].pOldProc)(qobj, drawStyle); -} - -VOID WINAPI new_gluTessVertex( - GLUtesselator * tess, - GLdouble coords[3], - void * data -) -{ - dprintf("[gluTessVertex]\n"); - ((VOID (WINAPI *)(GLUtesselator *, GLdouble[3], void *))pAPIHooks[APIHOOK_GLUTESSVERTEX].pOldProc)(tess, coords, data); -} - -BOOL WINAPI new_WriteFileA( - HANDLE hFile, // handle to file to write to - LPCVOID lpBuffer, // pointer to data to write to file - DWORD nNumberOfBytesToWrite, // number of bytes to write - LPDWORD lpNumberOfBytesWritten, // pointer to number of bytes written - LPOVERLAPPED lpOverlapped // pointer to structure for overlapped I/O -) -{ - return ((BOOL (WINAPI *)(HANDLE, LPCVOID, DWORD, LPDWORD, LPOVERLAPPED))pAPIHooks[APIHOOK_WRITEFILEA].pOldProc)(hFile, lpBuffer, nNumberOfBytesToWrite, lpNumberOfBytesWritten, lpOverlapped); -} - -BOOL WINAPI new_DeleteFileA( - LPCTSTR lpFileName // pointer to name of file to delete -) -{ - dprintf("[DeleteFileA] %s\n", lpFileName); - - //return TRUE; - return ((BOOL (WINAPI *)(LPCTSTR))pAPIHooks[APIHOOK_DELETEFILEA].pOldProc)(lpFileName); -} - -int WINAPI new_lstrcmpiA( - LPCTSTR lpString1, // pointer to first string - LPCTSTR lpString2 // pointer to second string -) -{ - //dprintf("[lstrcmpiA] %s <> %s\n", lpString1, lpString2); - return ((int (WINAPI *)(LPCTSTR, LPCTSTR))pAPIHooks[APIHOOK_LSTRCMPIA].pOldProc)(lpString1, lpString2); -} - -APIHOOK pAPIHooks[] = { - { NULL, _T("KERNEL32.DLL"), "GetProcAddress", FALSE, NULL, (PROC)new_GetProcAddress }, - { NULL, _T("KERNEL32.DLL"), "LoadLibraryA", FALSE, NULL, (PROC)new_LoadLibraryA }, - { NULL, _T("KERNEL32.DLL"), "LoadLibraryW", FALSE, NULL, (PROC)new_LoadLibraryW }, - { NULL, _T("KERNEL32.DLL"), "LoadLibraryExA", FALSE, NULL, (PROC)new_LoadLibraryExA }, - { NULL, _T("KERNEL32.DLL"), "LoadLibraryExW", FALSE, NULL, (PROC)new_LoadLibraryExW }, - { NULL, _T("KERNEL32.DLL"), "FreeLibraryA", FALSE, NULL, (PROC)new_FreeLibraryA }, - { NULL, _T("KERNEL32.DLL"), "DeleteFileA", FALSE, NULL, (PROC)new_DeleteFileA }, - { NULL, _T("XKERNEL32.DLL"), "WriteFileA", FALSE, NULL, (PROC)new_WriteFileA }, - { NULL, _T("XKERNEL32.DLL"), "lstrcmpiA", FALSE, NULL, (PROC)new_lstrcmpiA }, - { NULL, _T("WS2_32.DLL"), (LPCSTR)4, TRUE, NULL, (PROC)new_connect }, - { NULL, _T("WS2_32.DLL"), (LPCSTR)16, TRUE, NULL, (PROC)new_recv }, - { NULL, _T("WS2_32.DLL"), (LPCSTR)17, TRUE, NULL, (PROC)new_recvfrom }, - { NULL, _T("WS2_32.DLL"), (LPCSTR)19, TRUE, NULL, (PROC)new_send }, - { NULL, _T("WS2_32.DLL"), (LPCSTR)20, TRUE, NULL, (PROC)new_sendto }, - { NULL, _T("WS2_32.DLL"), (LPCSTR)52, TRUE, NULL, (PROC)new_gethostbyname }, -// { NULL, _T("USER32.DLL"), "SetWindowLongA", FALSE, NULL, (PROC)new_SetWindowLongA }, -// { NULL, _T("USER32.DLL"), "SetWindowLongW", FALSE, NULL, (PROC)new_SetWindowLongW }, - { NULL, _T("WININET.DLL"), "InternetReadFile", FALSE, NULL, (PROC)new_InternetReadFile }, - { NULL, _T("WININET.DLL"), "InternetOpenUrlA", FALSE, NULL, (PROC)new_InternetOpenUrlA }, - { NULL, _T("RSAENH.DLL"), "CPEncrypt", FALSE, NULL, (PROC)new_CPEncrypt }, - { NULL, _T("USER32.DLL"), "PeekMessageA", FALSE, NULL, (PROC)new_PeekMessageA }, -// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glGetError", FALSE, NULL, (PROC)new_glGetError }, -// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glBegin", FALSE, NULL, (PROC)new_glBegin }, -// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glEnable", FALSE, NULL, (PROC)new_glEnable }, -// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glIsEnabled", FALSE, NULL, (PROC)new_glIsEnabled }, -// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glTranslated", FALSE, NULL, (PROC)new_glTranslated }, -// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glTranslatef", FALSE, NULL, (PROC)new_glTranslatef }, -// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glTexCoord2f", FALSE, NULL, (PROC)new_glTexCoord2f }, -// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glTexCoord2fv", FALSE, NULL, (PROC)new_glTexCoord2fv }, -// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glVertex2f", FALSE, NULL, (PROC)new_glVertex2f }, -// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glVertex3f", FALSE, NULL, (PROC)new_glVertex3f }, -// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glVertex3fv", FALSE, NULL, (PROC)new_glVertex3fv }, -// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glVertex4f", FALSE, NULL, (PROC)new_glVertex4f }, -// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glVertex4fv", FALSE, NULL, (PROC)new_glVertex4fv }, -// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glVertexPointer", FALSE, NULL, (PROC)new_glVertexPointer }, -// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glTexCoordPointer", FALSE, NULL, (PROC)new_glTexCoordPointer }, -// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glNormalPointer", FALSE, NULL, (PROC)new_glNormalPointer }, -// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glDrawElements", FALSE, NULL, (PROC)new_glDrawElements }, -// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glDrawArrays", FALSE, NULL, (PROC)new_glDrawArrays }, -// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glDrawPixels", FALSE, NULL, (PROC)new_glDrawPixels }, -// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glTexImage2D", FALSE, NULL, (PROC)new_glTexImage2D }, -// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glColor3f", FALSE, NULL, (PROC)new_glColor3f }, -// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glColor3fv", FALSE, NULL, (PROC)new_glColor3fv }, -// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glColor4f", FALSE, NULL, (PROC)new_glColor4f }, -// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glColor4fv", FALSE, NULL, (PROC)new_glColor4fv }, -// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glColor4ubv", FALSE, NULL, (PROC)new_glColor4ubv }, -// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glColorPointer", FALSE, NULL, (PROC)new_glColorPointer }, -// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glViewport", FALSE, NULL, (PROC)new_glViewport }, -// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glFlush", FALSE, NULL, (PROC)new_glFlush }, -// { NULL, _T("UNCOMMENT"/*"GLU32.DLL"*/), "gluPerspective", FALSE, NULL, (PROC)new_gluPerspective }, -// { NULL, _T("UNCOMMENT"/*"GLU32.DLL"*/), "gluQuadricDrawStyle", FALSE, NULL, (PROC)new_gluQuadricDrawStyle }, -// { NULL, _T("UNCOMMENT"/*"GLU32.DLL"*/), "gluTessVertex", FALSE, NULL, (PROC)new_gluTessVertex }, - { NULL, NULL, NULL, FALSE, NULL, NULL } -}; - -PROC HookModuleImport(HMODULE hModule, LPCTSTR szModule, LPCSTR szImport, PROC pNewProc, BOOL bOrdinal) -{ - PIMAGE_DOS_HEADER pDOSHeader = (PIMAGE_DOS_HEADER)hModule; - - if (IsBadReadPtr(pDOSHeader, sizeof(IMAGE_DOS_HEADER)) || pDOSHeader->e_magic != IMAGE_DOS_SIGNATURE) - { - SetLastErrorEx(ERROR_INVALID_PARAMETER, SLE_ERROR); - return NULL; - } - - PIMAGE_NT_HEADERS pNTHeader = MAKEPTR (PIMAGE_NT_HEADERS, pDOSHeader, pDOSHeader->e_lfanew); - if (IsBadReadPtr(pNTHeader, sizeof(IMAGE_NT_HEADERS)) || pNTHeader->Signature != IMAGE_NT_SIGNATURE) - { - SetLastErrorEx(ERROR_INVALID_PARAMETER, SLE_ERROR); - return NULL; - } - - if (pNTHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].Size != 0) - { - PIMAGE_IMPORT_DESCRIPTOR pImportDesc = MAKEPTR(PIMAGE_IMPORT_DESCRIPTOR, pDOSHeader, pNTHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress); - while (pImportDesc && pImportDesc->Name != NULL) - { - PTSTR szImportModule = MAKEPTR(PTSTR, pDOSHeader, pImportDesc->Name); - if (szImportModule != NULL && _tcsicmp(szImportModule, szModule) == 0) - { - PIMAGE_THUNK_DATA pOrigThunk = MAKEPTR(PIMAGE_THUNK_DATA, hModule, pImportDesc->OriginalFirstThunk); - PIMAGE_THUNK_DATA pRealThunk = MAKEPTR(PIMAGE_THUNK_DATA, hModule, pImportDesc->FirstThunk); - while (pOrigThunk != NULL && pRealThunk != NULL && pOrigThunk->u1.Function != NULL && pRealThunk->u1.Function) - { - PIMAGE_IMPORT_BY_NAME pByName = MAKEPTR(PIMAGE_IMPORT_BY_NAME, hModule, pOrigThunk->u1.AddressOfData); - - if ((!bOrdinal && IMAGE_ORDINAL_FLAG != (pOrigThunk->u1.Ordinal & IMAGE_ORDINAL_FLAG) && pByName->Name[0] != 0 && stricmp((char*)pByName->Name, szImport) == 0) || (bOrdinal && IMAGE_ORDINAL(pOrigThunk->u1.Ordinal) == (DWORD)szImport)) - { - PROC pOldProc; - - /* - Retrieve memory information - */ - MEMORY_BASIC_INFORMATION mbi; - if (VirtualQuery(pRealThunk, &mbi, sizeof(MEMORY_BASIC_INFORMATION))) - { - /* - Give ourselves write access - */ - if (VirtualProtect(mbi.BaseAddress, mbi.RegionSize, PAGE_READWRITE, &mbi.Protect)) - { - /* - Store old function pointer for return value - */ - pOldProc = (PROC)pRealThunk->u1.Function; - /* - Only patch import table if the new function is different than the old one - */ - if (pNewProc != NULL && pOldProc != pNewProc) pRealThunk->u1.Function = (DWORD)pNewProc; - - /* - Restore old protection value - */ - DWORD dwOldProtect; - VirtualProtect(mbi.BaseAddress, mbi.RegionSize, mbi.Protect, &dwOldProtect); - } - -// TCHAR szModuleFileName[MAX_PATH]; -// GetModuleFileName(hModule, szModuleFileName, sizeof(szModuleFileName)); -// dprintf(_T("HOOKED [%s => %s]\n"), szImport, szModuleFileName); -// return pOldProc; - } - } - pOrigThunk++; - pRealThunk++; - } - } - pImportDesc++; - } - } - - return NULL; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -// -// Retrieve the loaded modules for the specified process -// -// dwProccessID Process ID of the process whose loaded module list you wish to retrive. -// Specify 0 for the current process. -// -// pModules Pointer to an array of MODULEINFO structures to store the module list. -// Can be NULL. -// -// puiCount Specify 0 to retrieve the module count otherwise the maximum number of -// entries in the pModule array to return. -// -// Return Value -// -// Returns FALSE if failed -// -/////////////////////////////////////////////////////////////////////////////////////////// -BOOL GetModuleList(DWORD dwProcessID, PMODULEENTRY32 pModules, LPUINT puiCount) -{ -// dprintf(_T("[GetModuleList]\n")); - - HANDLE hSnapshot; - MODULEENTRY32 cME32; - UINT uiCount = 0; - - if (puiCount == NULL) - { - SetLastErrorEx(ERROR_INVALID_PARAMETER, SLE_ERROR); - return FALSE; - } - - hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, dwProcessID); - if (hSnapshot == INVALID_HANDLE_VALUE) - { - return FALSE; - } - - ZeroMemory(&cME32, sizeof(cME32)); - cME32.dwSize = sizeof(MODULEENTRY32); - if (Module32First(hSnapshot, &cME32) == TRUE) - { - do - { - if (pModules != NULL && *puiCount) - { - _tcsncpy(pModules[uiCount].szModule, cME32.szModule, MAX_PATH); - pModules[uiCount].hModule = cME32.hModule; - } - uiCount++; - } while (Module32Next(hSnapshot, &cME32) == TRUE && (*puiCount == 0 || uiCount < *puiCount)); - } - - CloseHandle(hSnapshot); - - *puiCount = uiCount; - - return TRUE; -} - -/////////////////////////////////////////////////////////////////////////////////////////// -// -// Save pointers to old functions -// -/////////////////////////////////////////////////////////////////////////////////////////// -void SaveImportHooks() -{ -// dprintf(_T("[SaveImportHooks]\n")); - - INT i; - - for (i = 0; pAPIHooks[i].szModule; i++) - { - /* - Only store pointers for any functions we haven't taken care of yet so this may be called multiple times - */ - if (pAPIHooks[i].pOldProc == NULL) - { - pAPIHooks[i].pOldProc = GetProcAddress(GetModuleHandle(pAPIHooks[i].szModule), (LPCSTR)pAPIHooks[i].szImport); -// dprintf(_T("Saved import for %s(%s) at 0x%08X\n"), pAPIHooks[i].szModule, pAPIHooks[i].szImport, pAPIHooks[i].pOldProc); - } - } -} - -/////////////////////////////////////////////////////////////////////////////////////////// -// -// Patch import table of all loaded modules -// -/////////////////////////////////////////////////////////////////////////////////////////// -void InstallImportHooks() -{ -// dprintf(_T("[InstallImportHooks]\n")); - - /* - Retrieve number of loaded modules - */ - UINT uiCount = 0; - INT i, j; - if (GetModuleList(0, NULL, &uiCount)) - { - /* - Allocate temporary table of loaded modules - */ - PMODULEENTRY32 pModules = (PMODULEENTRY32)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, uiCount*sizeof(MODULEENTRY32)); - if (pModules != NULL) - { - /* - Retrieve table of loaded modules - */ - if (GetModuleList(0, pModules, &uiCount)) - { - /* - Loop through each module and patch its import table - */ - for (i = 0; i < (INT)uiCount; i++) - { - /* - Loop through each API hook and patch import table for this module - HookModuleImport() takes care of dupe checking - */ - for (j = 0; pAPIHooks[j].szModule; j++) - { - if (_tcsicmp(pModules[i].szModule, _T("SNOWFLAKE.DLL")) && _tcsicmp(pModules[i].szModule, _T("FMOD.DLL")) && /*_tcsicmp(pModules[i].szModule, _T("NEWVIEW.EXE")) &&*/ _tcsicmp(pModules[i].szModule, pAPIHooks[j].szModule) && pAPIHooks[j].pNewProc != NULL && !IsBadCodePtr(pAPIHooks[j].pNewProc)) - { - HookModuleImport(pModules[i].hModule, pAPIHooks[j].szModule, pAPIHooks[j].szImport, pAPIHooks[j].pNewProc, pAPIHooks[j].bOrdinal); - } - } - } - } - GlobalFree(pModules); - } - } -} - -/////////////////////////////////////////////////////////////////////////////////////////// -// -// Removes the import table for all loaded modules back to the original saved functions -// -/////////////////////////////////////////////////////////////////////////////////////////// -void RemoveImportHooks() -{ - dprintf(_T("[RemoveImportHooks]\n")); - - /* - Retrieve number of loaded modules - */ - UINT uiCount = 0; - INT i, j; - if (GetModuleList(0, NULL, &uiCount)) - { - /* - Allocate temporary table of loaded modules - */ - PMODULEENTRY32 pModules = (PMODULEENTRY32)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, uiCount*sizeof(MODULEENTRY32)); - if (pModules != NULL) - { - /* - Retrieve table of loaded modules - */ - if (GetModuleList(0, pModules, &uiCount)) - { - /* - Loop through each module and patch its import table - */ - for (i = 0; i < (INT)uiCount; i++) - { - /* - Loop through each API hook and restore import table for this module - */ -// dprintf("RESTORE [%s]\n", pModules[i].szModule); - for (j = 0; pAPIHooks[j].szModule; j++) - { - if (_tcsicmp(pModules[i].szModule, _T("SNOWFLAKE.DLL")) && /*_tcsicmp(pModules[i].szModule, _T("NEWVIEW.EXE")) &&*/ _tcsicmp(pModules[i].szModule, pAPIHooks[j].szModule) && pAPIHooks[j].pOldProc != NULL && !IsBadCodePtr(pAPIHooks[j].pOldProc)) - { -// dprintf(_T("REMOVE [%s => %s]\n"), pAPIHooks[j].szImport, pModules[i].szModule); - HookModuleImport(pModules[i].hModule, pAPIHooks[j].szModule, pAPIHooks[j].szImport, pAPIHooks[j].pOldProc, pAPIHooks[j].bOrdinal); - } - } - } - - for (j = 0; pAPIHooks[j].szModule; j++) - { - pAPIHooks[j].pOldProc = NULL; - } - } - GlobalFree(pModules); - } - } -} - -BOOL APIENTRY DllMain( HANDLE hModule, - DWORD ul_reason_for_call, - LPVOID lpReserved - ) -{ - if (ul_reason_for_call == DLL_PROCESS_ATTACH) - { - TCHAR szPath[MAX_PATH]; - - g_hinstDLL = (HINSTANCE)hModule; - _Module.Init(NULL, g_hinstDLL); - DisableThreadLibraryCalls(g_hinstDLL); - - if (GetModuleFileName(GetModuleHandle(0), szPath, MAX_PATH)) - { - _tcsupr(szPath); - - if (_tcsstr(szPath, _T("\\SECONDLIFE.EXE"))) - { - if (!g_pConfig) - g_pConfig = new CConfig(); - -#ifdef ECHO - AllocConsole(); - - if (!fpLog) - fpLog = fopen(g_pConfig->m_pSnowcrashTxtPath, "w"); -#endif - dprintf(_T("[snowflake] %s\n"), szPath); - - decomm(); - - SaveImportHooks(); - InstallImportHooks(); - } - } - } else if (ul_reason_for_call == DLL_PROCESS_DETACH) - { - RemoveSLHooks(); - RemoveImportHooks(); -#ifdef ECHO - FreeConsole(); - - if (fpLog) - { - fclose(fpLog); - fpLog = NULL; - } -#endif - _Module.Term(); - } - - return TRUE; -} - -LRESULT CALLBACK CBTHookProc(int nCode, WPARAM wParam, LPARAM lParam) -{ - switch(nCode) - { - case HCBT_ACTIVATE: - { - if (!g_pMainFrm) - { - TCHAR szClass[128]; - HWND hwnd = (HWND)wParam; - - if (GetClassName(hwnd, szClass, sizeof(szClass))) - { - if (_tcsicmp(szClass, _T("Second Life")) == 0) - { - TCHAR szTitle[256]; - GetWindowText(hwnd, szTitle, sizeof(szTitle)); - - if (_tcsstr(szTitle, "Second Life")) - { - dprintf(_T(">>> [%s][%s]\n"), szClass, szTitle); - InstallSLHooks(hwnd); - } - } - else - dprintf(_T(">>> [%s]\n"), szClass); - } - } - } - break; - - case HCBT_CREATEWND: - { - TCHAR szClass[128]; - HWND hwnd = (HWND)wParam; - LPCBT_CREATEWND lpcbt = (LPCBT_CREATEWND)lParam; - - if (GetClassName(hwnd, szClass, sizeof(szClass))) - { - //dprintf(_T(">>> [%s]\n"), szClass); - //if (_tcsicmp(szClass, _T("OpenGL")) == 0) - //{ - //dprintf(_T("[snowflake] SL window created\n")); - //InstallSLHooks(hwnd); - //} - } - } - break; - - case HCBT_DESTROYWND: - { - TCHAR szClass[128]; - HWND hwnd = (HWND)wParam; - - if (GetClassName(hwnd, szClass, sizeof(szClass))) - { - if (g_pMainFrm && g_pMainFrm->m_hWnd == hwnd) - { - dprintf(_T("[snowflake] SL window destroyed\n")); - RemoveSLHooks(); - } - } - } - break; - } - return ::CallNextHookEx(h_hCBTHook, nCode, wParam, lParam); -} - -SNOWFLAKE_API bool InstallSystemHook(void) -{ -// dprintf(_T("[InstallSystemHook]\n")); - - if (h_hCBTHook == NULL) - { - h_hCBTHook = ::SetWindowsHookEx(WH_CBT, CBTHookProc, g_hinstDLL, 0); - } - - return (h_hCBTHook != NULL); -} - -SNOWFLAKE_API BOOL RemoveSystemHook() -{ - dprintf(_T("[RemoveSystemHook]\n")); - - if (h_hCBTHook != NULL) - { - if (UnhookWindowsHookEx(h_hCBTHook)) - { - h_hCBTHook = NULL; - - return TRUE; - } - } - - return FALSE; -} - -bool InstallSLHooks(HWND hwnd) -{ - _Module.AddMessageLoop(&g_msgLoop); - - if (g_pMainFrm == NULL) - { - g_pMainFrm = new CMainFrame(); - - if (g_pMainFrm->SubclassWindow(hwnd)) - { - return true; - } - } - - return false; -} - -bool RemoveSLHooks() -{ - if (g_pMainFrm != NULL) - { - dprintf(_T("RemoveSLHooks MainFrm\n")); - if (g_pMainFrm->m_hWnd != NULL && ::IsWindow(*g_pMainFrm)) - { - dprintf(_T("RemoveSLHooks MainFrm Unsub\n")); - g_pMainFrm->UnsubclassWindow(TRUE); - g_pMainFrm->m_hWnd = NULL; - } else - g_pMainFrm->m_hWnd = NULL; - delete(g_pMainFrm); - g_pMainFrm = NULL; - - return true; - } - - return false; -} +// snowflake.cpp : Defines the entry point for the DLL application. +// + +#include "stdafx.h" +#include ".\snowflake.h" +#include ".\MainFrame.h" +#include ".\Server.h" +#include ".\ServerList.h" +#include ".\Message.h" +#include ".\Block.h" +#include ".\Var.h" +#include ".\Config.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include ".\keywords.h" + +#pragma pack(1) + +struct COMMANDVAR +{ + char *lpszVar; + int nKeywordPos; + int nType; + int nTypeLen; + struct COMMANDVAR *lpNext; + struct COMMANDVAR *lpPrev; +} typedef COMMANDVARS; + +typedef COMMANDVAR * LPCOMMANDVAR; +typedef COMMANDVARS * LPCOMMANDVARS; + +struct COMMANDSTRUCT +{ + char *lpszStruct; + int nKeywordPos; + int nType; + BYTE cItems; + LPCOMMANDVARS vars; + struct COMMANDSTRUCT *lpNext; + struct COMMANDSTRUCT *lpPrev; +} typedef COMMANDSTRUCTS; + +typedef COMMANDSTRUCT * LPCOMMANDSTRUCT; +typedef COMMANDSTRUCTS * LPCOMMANDSTRUCTS; + +typedef struct +{ + char *lpszCmd; + bool bZerocoded; + bool bTrusted; + LPCOMMANDSTRUCTS structs; +} COMMAND; + +typedef COMMAND * LPCOMMAND; + +#define MAX_COMMANDS_LOW 65536 +#define MAX_COMMANDS_MEDIUM 256 +#define MAX_COMMANDS_HIGH 256 + +COMMAND cmds_low[MAX_COMMANDS_LOW]; +COMMAND cmds_med[MAX_COMMANDS_MEDIUM]; +COMMAND cmds_high[MAX_COMMANDS_HIGH]; + +typedef struct +{ + LPCTSTR szCommand; + PROC pProc; +} CMDHOOK, *LPCMDHOOK; + +CMDHOOK pCMDHooks[]; + +#pragma data_seg(".shared") +HHOOK h_hCBTHook = NULL; +#pragma data_seg() +#pragma comment(linker, "/SECTION:.shared,RWS") + +HINSTANCE g_hinstDLL = NULL; +HMODULE g_hOpenGL = NULL; +CMainFrame* g_pMainFrm = NULL; +CAppModule _Module; +CMessageLoop g_msgLoop; +CConfig* g_pConfig = NULL; +BOOL g_bAllowSub = TRUE; + +CServerList servers; + +typedef struct +{ + LPCTSTR szPatch; + LPCTSTR szModule; + LPCSTR szImport; + BOOL bOrdinal; + PROC pOldProc; + PROC pNewProc; +} APIHOOK, *LPAPIHOOK; + +APIHOOK pAPIHooks[]; + +#define MAKEPTR(cast, ptr, add) (cast)((DWORD)(ptr)+(DWORD)(add)) + +enum APIHOOKS +{ + APIHOOK_GETPROCADDRESS, + APIHOOK_LOADLIBRARYA, + APIHOOK_LOADLIBRARYW, + APIHOOK_LOADLIBRARYEXA, + APIHOOK_LOADLIBRARYEXW, + APIHOOK_FREELIBRARYA, + APIHOOK_DELETEFILEA, + APIHOOK_WRITEFILEA, + APIHOOK_LSTRCMPIA, + APIHOOK_CONNECT, + APIHOOK_RECV, + APIHOOK_RECVFROM, + APIHOOK_SEND, + APIHOOK_SENDTO, + APIHOOK_GETHOSTBYNAME, +// APIHOOK_SETWINDOWLONGA, +// APIHOOK_SETWINDOWLONGW, + APIHOOK_INTERNETREADFILE, + APIHOOK_INTERNETOPENURLA, + APIHOOK_CPENCRYPT, + APIHOOK_PEEKMESSAGEA, + APIHOOK_GLGETERROR, + APIHOOK_GLBEGIN, + APIHOOK_GLENABLE, + APIHOOK_GLISENABLED, + APIHOOK_GLTRANSLATED, + APIHOOK_GLTRANSLATEF, + APIHOOK_GLTEXCOORD2F, + APIHOOK_GLTEXCOORD2FV, + APIHOOK_GLVERTEX2F, + APIHOOK_GLVERTEX3F, + APIHOOK_GLVERTEX3FV, + APIHOOK_GLVERTEX4F, + APIHOOK_GLVERTEX4FV, + APIHOOK_GLVERTEXPOINTER, + APIHOOK_GLTEXCOORDPOINTER, + APIHOOK_GLNORMALPOINTER, + APIHOOK_GLDRAWELEMENTS, + APIHOOK_GLDRAWARRAYS, + APIHOOK_GLDRAWPIXELS, + APIHOOK_GLTEXIMAGE2D, + APIHOOK_GLCOLOR3F, + APIHOOK_GLCOLOR3FV, + APIHOOK_GLCOLOR4F, + APIHOOK_GLCOLOR4FV, + APIHOOK_GLCOLOR4UBV, + APIHOOK_GLCOLORPOINTER, + APIHOOK_GLVIEWPORT, + APIHOOK_GLFLUSH, + APIHOOK_GLUPERSPECTIVE, + APIHOOK_GLUQUADRICDRAWSTYLE, + APIHOOK_GLUTESSVERTEX, + APIHOOK_NULL +}; + +bool InstallSLHooks(HWND hwnd); +bool RemoveSLHooks(); +void InstallImportHooks(); +void RemoveImportHooks(); +void SaveImportHooks(); + +int ZeroDecode(char *src, int srclen, char *dest, int destlen) +{ + int zerolen = 0; + + if (src[0] & MSG_ZEROCODED) + { + memcpy(dest, src, 4); + zerolen += 4; + + for (int i = zerolen; i < srclen; i++) + { + if ((unsigned char)src[i] == 0x00) + { + for (unsigned char j = 0; j < (unsigned char)src[i+1]; j++) + dest[zerolen++] = 0x00; + + i++; + } + else + dest[zerolen++] = src[i]; + } + } + else + { + memcpy(dest, src, srclen); + zerolen = srclen; + } + + return zerolen; +} + +int ZeroEncode(char *src, int srclen, char *dest, int destlen) +{ + int zerolen = 0; + unsigned char zerocount = 0; + + if (src[0] & MSG_ZEROCODED) + { + memcpy(dest, src, 4); + zerolen += 4; + + for (int i = zerolen; i < srclen; i++) + { + if ((unsigned char)src[i] == 0x00) + { + zerocount++; + + if (zerocount == 0) + { + dest[zerolen++] = 0x00; + dest[zerolen++] = 0xff; + zerocount++; + } + } + else + { + if (zerocount) + { + dest[zerolen++] = 0x00; + dest[zerolen++] = zerocount; + zerocount = 0; + } + + dest[zerolen++] = src[i]; + } + } + + if (zerocount) + { + dest[zerolen++] = 0x00; + dest[zerolen++] = zerocount; + } + } + else + { + memcpy(dest, src, srclen); + zerolen = srclen; + } + + return zerolen; +} + +// Convert a "hex string" to an integer by Anders Molin +int httoi(const TCHAR *value) +{ + struct HEXMAP + { + TCHAR c; + int value; + }; + + const int nHexMap = 16; + + HEXMAP hmLookup[nHexMap] = + { + {'0', 0}, {'1', 1}, + {'2', 2}, {'3', 3}, + {'4', 4}, {'5', 5}, + {'6', 6}, {'7', 7}, + {'8', 8}, {'9', 9}, + {'A', 10}, {'B', 11}, + {'C', 12}, {'D', 13}, + {'E', 14}, {'F', 15} + }; + + TCHAR *mstr = _tcsupr(_tcsdup(value)); + TCHAR *s = mstr; + int result = 0; + + if (*s == '0' && *(s + 1) == 'X') + s += 2; + + bool firsttime = true; + + while (*s != '\0') + { + bool found = false; + + for (int i = 0; i < nHexMap; i++) + { + if (*s == hmLookup[i].c) + { + if (!firsttime) + result <<= 4; + + result |= hmLookup[i].value; + found = true; + break; + } + } + + if (!found) + break; + + s++; + firsttime = false; + } + + free(mstr); + + return result; +} + +// Trim beginning, ending, and excess embedded whitespace from a string +char *trim(char *szStr) +{ + char *iBuf, *oBuf; + + if (szStr) + { + for (iBuf = oBuf = szStr; *iBuf;) + { + while (*iBuf && (isspace(*iBuf))) + iBuf++; + + if (*iBuf && (oBuf != szStr)) + *(oBuf++) = ' '; + + while (*iBuf && (!isspace(*iBuf))) + *(oBuf++) = *(iBuf++); + } + + *oBuf = NULL; + } + + return(szStr); +} + +int get_var_type(TCHAR *lptszType) +{ + int i = 0; + + while (LLTYPES[i]) + { + if (!_tcscmp(lptszType, LLTYPES[i])) + { + //printf("Type: %s\n", LLTYPES[i]); + return i; + } + + i++; + } + + return -1; +} + +int get_keyword_pos(TCHAR *lptszKeyword) +{ + int i = 0; + + while (LLKEYWORDS[i]) + { + if (!_tcscmp(lptszKeyword, LLKEYWORDS[i])) + { + //printf("Keyword: %s\n", LLKEYWORDS[i]); + return i; + } + + i++; + } + + dprintf("Unhandled keyword: %s\n", lptszKeyword); + return -1; +} + +// Get message template block deliminator positions +bool get_block_markers(LPBYTE lpBuffer, DWORD &dwStart, DWORD &dwEnd, DWORD &dwChildren) +{ + DWORD dwStartBlock = 0; + DWORD dwEndBlock = 0; + DWORD dwDepth = 0; + + dwChildren = 0; + + for (DWORD dwPos = dwStart; dwPos <= dwEnd; dwPos++) + { + if (lpBuffer[dwPos] == '{') + { + dwDepth++; + + if (dwDepth == 1) + dwStartBlock = dwPos; + else if (dwDepth == 2 && !dwChildren) + dwChildren = dwPos; + } + + else if (lpBuffer[dwPos] == '}') + { + dwDepth--; + + if (dwDepth == 0 && dwStartBlock) + { + dwEndBlock = dwPos; + dwStart = dwStartBlock; + dwEnd = dwEndBlock; + return true; + } + } + } + + return false; +} + +// Parse the variables message template block of a struct +bool get_var_blocks(LPCOMMANDSTRUCT lpStruct, LPBYTE lpBuffer, DWORD dwStart, DWORD dwEnd) +{ + DWORD dwVarStart = dwStart; + DWORD dwVarEnd = dwEnd; + DWORD dwVarChildren = 0; + + while (get_block_markers(lpBuffer, dwVarStart, dwVarEnd, dwVarChildren)) + { + char szVarLine[256]; + DWORD dwVarLen = (dwVarChildren ? dwVarChildren - 1 : dwVarEnd - 1) - dwVarStart; + + memcpy(&szVarLine, &lpBuffer[dwVarStart+1], dwVarLen); + szVarLine[dwVarLen] = '\0'; + trim(szVarLine); + + //printf("\t\t%s\n", szVarLine); + + char *lpszVar = strtok(szVarLine, " "); + char *lpszType = strtok(NULL, " "); + char *lpszTypeLen = NULL; + int nKeywordPos = get_keyword_pos(lpszVar); + int nVarType = get_var_type(lpszType); + + LPCOMMANDVAR lpVar = lpStruct->vars; + + if (lpVar) + { + // Insert after an item + if (nKeywordPos > lpVar->nKeywordPos) + { + while (lpVar->lpNext && nKeywordPos > lpVar->lpNext->nKeywordPos) + lpVar = lpVar->lpNext; + + LPCOMMANDVAR lpBelow = lpVar->lpNext; + + lpVar->lpNext = (LPCOMMANDVAR)malloc(sizeof(COMMANDVAR)); + + if (!lpVar->lpNext) + return false; + + ZeroMemory(lpVar->lpNext, sizeof(COMMANDVAR)); + lpVar->lpNext->lpPrev = lpVar; + lpVar->lpNext->lpNext = lpBelow; + lpVar = lpVar->lpNext; + } + // Insert before all items + else + { + lpVar->lpPrev = (LPCOMMANDVAR)malloc(sizeof(COMMANDVAR)); + + if (!lpVar->lpPrev) + return false; + + ZeroMemory(lpVar->lpPrev, sizeof(COMMANDVAR)); + + lpVar->lpPrev->lpNext = lpVar; + lpVar->lpPrev->lpPrev = NULL; + lpVar = lpVar->lpPrev; + lpStruct->vars = lpVar; + } + } + // No existing list, create a new list with our entry + else + { + lpVar = (LPCOMMANDVAR)malloc(sizeof(COMMANDVAR)); + + if (!lpVar) + return false; + + ZeroMemory(lpVar, sizeof(COMMANDVAR)); + lpStruct->vars = lpVar; + } + + lpVar->lpszVar = strdup(lpszVar); + lpVar->nType = nVarType; + lpVar->nKeywordPos = nKeywordPos; + + if (nVarType == LLTYPE_VARIABLE || nVarType == LLTYPE_FIXED) + { + lpszTypeLen = strtok(NULL, " "); + lpVar->nTypeLen = atoi(lpszTypeLen); + } + + dwVarStart = dwVarEnd + 1; + dwVarEnd = dwEnd; + } + + return true; +} + +// Parse the struct message template block of a command +bool get_struct_blocks(LPCOMMAND lpCmd, LPBYTE lpBuffer, DWORD dwStart, DWORD dwEnd) +{ + DWORD dwStructStart = dwStart; + DWORD dwStructEnd = dwEnd; + DWORD dwStructChildren = 0; + + while (get_block_markers(lpBuffer, dwStructStart, dwStructEnd, dwStructChildren)) + { + char szStructLine[256]; + DWORD dwStructLen = (dwStructChildren ? dwStructChildren - 1 : dwStructEnd - 1) - dwStructStart; + + memcpy(&szStructLine, &lpBuffer[dwStructStart+1], dwStructLen); + szStructLine[dwStructLen] = '\0'; + trim(szStructLine); + + //printf("\t%s\n", szStructLine); + + char *lpszStruct = strtok(szStructLine, " "); + char *lpszType = strtok(NULL, " "); + int nKeywordPos = get_keyword_pos(lpszStruct); + int nVarType = get_var_type(lpszType); + + LPCOMMANDSTRUCT lpStruct = lpCmd->structs; + + if (lpStruct) + { + // Insert after an item + if (nKeywordPos > lpStruct->nKeywordPos) + { + while (lpStruct->lpNext && nKeywordPos > lpStruct->lpNext->nKeywordPos) + lpStruct = lpStruct->lpNext; + + LPCOMMANDSTRUCT lpBelow = lpStruct->lpNext; + + lpStruct->lpNext = (LPCOMMANDSTRUCT)malloc(sizeof(COMMANDSTRUCT)); + + if (!lpStruct->lpNext) + return false; + + ZeroMemory(lpStruct->lpNext, sizeof(COMMANDSTRUCT)); + lpStruct->lpNext->lpPrev = lpStruct; + lpStruct->lpNext->lpNext = lpBelow; + lpStruct = lpStruct->lpNext; + } + // Insert before all items + else + { + lpStruct->lpPrev = (LPCOMMANDSTRUCT)malloc(sizeof(COMMANDSTRUCT)); + + if (!lpStruct->lpPrev) + return false; + + ZeroMemory(lpStruct->lpPrev, sizeof(COMMANDSTRUCT)); + + lpStruct->lpPrev->lpNext = lpStruct; + lpStruct->lpPrev->lpPrev = NULL; + lpStruct = lpStruct->lpPrev; + lpCmd->structs = lpStruct; + } + } + // No existing list, create a new list with our entry + else + { + lpCmd->structs = (LPCOMMANDSTRUCT)malloc(sizeof(COMMANDSTRUCT)); + + if (!lpCmd->structs) + return false; + + ZeroMemory(lpCmd->structs, sizeof(COMMANDSTRUCT)); + lpStruct = lpCmd->structs; + } + + lpStruct->lpszStruct = strdup(lpszStruct); + lpStruct->nKeywordPos = nKeywordPos; + lpStruct->nType = nVarType; + + if (nVarType == LLTYPE_VARIABLE) + { + lpStruct->cItems = 1; + } + else if (nVarType == LLTYPE_MULTIPLE) + { + char *lpszTypeLen = strtok(NULL, " "); + lpStruct->cItems = atoi(lpszTypeLen); + } + + get_var_blocks(lpStruct, lpBuffer, dwStructStart + 1, dwStructEnd - 1); + + dwStructStart = dwStructEnd + 1; + dwStructEnd = dwEnd; + } + + return true; +} + +// Parse the command message template blocks +bool get_command_blocks(LPBYTE lpBuffer, DWORD dwStart, DWORD dwEnd) +{ + DWORD dwCmdStart = dwStart; + DWORD dwCmdEnd = dwEnd; + DWORD dwCmdChildren = 0; + + while (get_block_markers(lpBuffer, dwCmdStart, dwCmdEnd, dwCmdChildren)) + { + char szCmdLine[256]; + DWORD dwCmdLen = (dwCmdChildren ? dwCmdChildren - 1 : dwCmdEnd - 1) - dwCmdStart; + + memcpy(&szCmdLine, &lpBuffer[dwCmdStart+1], dwCmdLen); + szCmdLine[dwCmdLen] = '\0'; + trim(szCmdLine); + + //printf("%s\n", szCmdLine); + + char *lpszCmd = strtok(szCmdLine, " "); + char *lpszFreq = strtok(NULL, " "); + char *lpszFixed = NULL; + char *lpszTrust = NULL; + char *lpszCoding = NULL; + static DWORD dwLow = 1; + static DWORD dwMed = 1; + static DWORD dwHigh = 1; + COMMAND *lpCmd = NULL; + + // Get the commands frequency + if (!strnicmp(lpszFreq, "Fixed", 6)) + { + lpszFixed = strtok(NULL, " "); + DWORD dwFixed = (DWORD)httoi(lpszFixed) ^ 0xffff0000; + lpCmd = &cmds_low[dwFixed]; + } + else if (!strnicmp(lpszFreq, "Low", 4)) + { + lpCmd = &cmds_low[dwLow++]; + } + else if (!strnicmp(lpszFreq, "Medium", 7)) + { + lpCmd = &cmds_med[dwMed++]; + } + else if (!strnicmp(lpszFreq, "High", 5)) + { + lpCmd = &cmds_high[dwHigh++]; + } + + lpszTrust = strtok(NULL, " "); + lpszCoding = strtok(NULL, " "); + + lpCmd->lpszCmd = strdup(lpszCmd); + + // Is the command zero encoded? + if (!strnicmp(lpszCoding, "Zerocoded", 10)) + { + lpCmd->bZerocoded = true; + } + + // Is the command trusted? + if (!strnicmp(lpszTrust, "Trusted", 8)) + { + lpCmd->bTrusted = true; + } + + get_struct_blocks(lpCmd, lpBuffer, dwCmdStart + 1, dwCmdEnd - 1); + + //printf("----------------------\n"); + + dwCmdStart = dwCmdEnd + 1; + dwCmdEnd = dwEnd; + } + + return true; +} + +void dump_structs(LPCOMMANDSTRUCT lpStruct) +{ + while (lpStruct) + { + //dprintf("\t%04d %s (%s / %hu)\n", lpStruct->nKeywordPos, lpStruct->lpszStruct, LLTYPES[lpStruct->nType], lpStruct->cItems); + + LPCOMMANDVAR lpVar = lpStruct->vars; + + while (lpVar) + { + //dprintf("\t\t%04d %s (%s / %d)\n", lpVar->nKeywordPos, lpVar->lpszVar, LLTYPES[lpVar->nType], lpVar->nTypeLen); + lpVar = lpVar->lpNext; + } + +// if (lpStruct->lpNext) +// { + lpStruct = lpStruct->lpNext; +// SAFE_FREE(lpStruct->lpPrev->lpszStruct); +// SAFE_FREE(lpStruct->lpPrev); +// } +// else +// { +// SAFE_FREE(lpStruct->lpszStruct); +// SAFE_FREE(lpStruct); +// } + } +} + +void WINAPI parse_command(LPCOMMAND lpCommand, CServer *server, char *zerobuf, int *len, int pos) +{ + //dprintf("--- %s ---\n", lpCommand->lpszCmd); + + LPCOMMANDSTRUCT lpStruct = lpCommand->structs; + + while (lpStruct) + { + //dprintf("\t%04d %s (%s / %hu)\n", lpStruct->nKeywordPos, lpStruct->lpszStruct, LLTYPES[lpStruct->nType], lpStruct->cItems); + BYTE cItems = 1; + + if (lpStruct->nType == LLTYPE_VARIABLE) + { + memcpy(&cItems, &zerobuf[pos], sizeof(cItems)); + pos += sizeof(cItems); + } + else if (lpStruct->nType == LLTYPE_MULTIPLE) + { + cItems = lpStruct->cItems; + } + + for (BYTE c = 0; c < cItems; c++) + { + //dprintf("--- %s ----\n", lpStruct->lpszStruct); + + LPCOMMANDVAR lpVar = lpStruct->vars; + + while (lpVar) + { + //dprintf("\t\t%04d %s (%s / %d)\n", lpVar->nKeywordPos, lpVar->lpszVar, LLTYPES[lpVar->nType], lpVar->nTypeLen); + + switch (lpVar->nType) + { + case LLTYPE_U8: + { + unsigned char ubData; + memcpy(&ubData, &zerobuf[pos], sizeof(ubData)); + pos += sizeof(ubData); + //dprintf("%s: %hu\n", lpVar->lpszVar, ubData); + } + break; + + case LLTYPE_U16: + { + WORD wData; + memcpy(&wData, &zerobuf[pos], sizeof(wData)); + pos += sizeof(wData); + //dprintf("%s: %u\n", lpVar->lpszVar, wData); + } + break; + + case LLTYPE_U32: + { + DWORD dwData; + memcpy(&dwData, &zerobuf[pos], sizeof(dwData)); + pos += sizeof(dwData); + //dprintf("%s: %lu\n", lpVar->lpszVar, dwData); + } + break; + + case LLTYPE_U64: + { + ULONGLONG ullData; + memcpy(&ullData, &zerobuf[pos], sizeof(ullData)); + pos += sizeof(ullData); + //dprintf("%s: %I64u\n", lpVar->lpszVar, ullData); + } + break; + + case LLTYPE_S8: + { + BYTE bData; + memcpy(&bData, &zerobuf[pos], sizeof(bData)); + pos += sizeof(bData); + //dprintf("%s: %hd\n", lpVar->lpszVar, bData); + } + break; + + case LLTYPE_S16: + { + SHORT sData; + memcpy(&sData, &zerobuf[pos], sizeof(sData)); + pos += sizeof(sData); + //dprintf("%s: %d\n", lpVar->lpszVar, sData); + } + break; + + case LLTYPE_S32: + { + LONG nData; + memcpy(&nData, &zerobuf[pos], sizeof(nData)); + pos += sizeof(nData); + //dprintf("%s: %ld\n", lpVar->lpszVar, nData); + } + break; + + case LLTYPE_S64: + break; + + case LLTYPE_F8: + break; + + case LLTYPE_F16: + break; + + case LLTYPE_F32: + { + FLOAT fData; + memcpy(&fData, &zerobuf[pos], sizeof(fData)); + pos += sizeof(fData); + //dprintf("%s: %f\n", lpVar->lpszVar, fData); + } + break; + + case LLTYPE_F64: + { + double dData; + memcpy(&dData, &zerobuf[pos], sizeof(dData)); + pos += sizeof(dData); + //dprintf("%s: %f\n", lpVar->lpszVar, dData); + } + break; + + case LLTYPE_LLUUID: + { + BYTE bData[16]; + memcpy(&bData, &zerobuf[pos], sizeof(bData)); + pos += sizeof(bData); + //dprintf("%s: ", lpVar->lpszVar); + //for (int u = 0; u < sizeof(bData); u++) + //dprintf("%02x", bData[u]); + //dprintf("\n"); + } + break; + + case LLTYPE_BOOL: + { + BYTE bData; + memcpy(&bData, &zerobuf[pos], sizeof(bData)); + pos += sizeof(bData); + //dprintf("%s: %s\n", lpVar->lpszVar, (bData) ? "True" : "False"); + } + break; + + case LLTYPE_LLVECTOR3: + { + FLOAT fData[3]; + memcpy(&fData, &zerobuf[pos], sizeof(fData)); + pos += sizeof(fData); + //dprintf("%s: %f, %f, %f\n", lpVar->lpszVar, fData[0], fData[1], fData[2]); + } + break; + + case LLTYPE_LLVECTOR3D: + { + double dData[3]; + memcpy(&dData, &zerobuf[pos], sizeof(dData)); + pos += sizeof(dData); + //dprintf("%s: %f, %f, %f\n", lpVar->lpszVar, dData[0], dData[1], dData[2]); + } + break; + + /*case LLTYPE_VECTOR4: + { + FLOAT fData[4]; + memcpy(&fData, &zerobuf[pos], sizeof(fData)); + pos += sizeof(fData); + dprintf("%s: %f, %f, %f, %f\n", lpVar->lpszVar, fData[0], fData[1], fData[2], fData[3]); + } + break;*/ + + case LLTYPE_QUATERNION: + { + FLOAT fData[4]; + memcpy(&fData, &zerobuf[pos], sizeof(fData)); + pos += sizeof(fData); + //dprintf("%s: %f, %f, %f, %f\n", lpVar->lpszVar, fData[0], fData[1], fData[2], fData[3]); + } + break; + + case LLTYPE_IPADDR: + { + BYTE ipData[4]; + memcpy(&ipData, &zerobuf[pos], sizeof(ipData)); + pos += sizeof(ipData); + //dprintf("%s: %hu.%hu.%hu.%hu\n", lpVar->lpszVar, ipData[0], ipData[1], ipData[2], ipData[3]); + } + break; + + case LLTYPE_IPPORT: + { + WORD wData; + memcpy(&wData, &zerobuf[pos], sizeof(wData)); + pos += sizeof(wData); + //dprintf("%s: %hu\n", lpVar->lpszVar, htons(wData)); + } + break; + + case LLTYPE_VARIABLE: + { + if (lpVar->nTypeLen == 1) + { + BYTE cDataLen; + LPBYTE lpData = NULL; + + memcpy(&cDataLen, &zerobuf[pos], sizeof(cDataLen)); + pos += sizeof(cDataLen); + + if (cDataLen > 0) + lpData = (LPBYTE)malloc(cDataLen); + + if (lpData) + memcpy(lpData, &zerobuf[pos], cDataLen); + + pos += cDataLen; + + if (lpData) + { + bool bPrintable = true; + + for (int j = 0; j < cDataLen - 1; j++) + { + if (((unsigned char)lpData[j] < 0x20 || (unsigned char)lpData[j] > 0x7E) && (unsigned char)lpData[j] != 0x09 && (unsigned char)lpData[j] != 0x0D) + bPrintable = false; + } + + if (bPrintable && lpData[cDataLen - 1] == '\0') + { + //dprintf("%s: %s\n", lpVar->lpszVar, lpData); + } + else + { + for (int j = 0; j < cDataLen; j += 16) + { + //dprintf("%s: ", lpVar->lpszVar); + + for (int k = 0; k < 16; k++) + { + if ((j + k) < cDataLen) + { + //dprintf("%02x ", (unsigned char)lpData[j+k]); + } + else + { + //dprintf(" "); + } + } + + for (int k = 0; k < 16 && (j + k) < cDataLen; k++) + { + //dprintf("%c", ((unsigned char)lpData[j+k] >= 0x20 && (unsigned char)lpData[j+k] <= 0x7E) ? (unsigned char)lpData[j+k] : '.'); + } + + //dprintf("\n"); + } + } + } + + SAFE_FREE(lpData); + } + else if (lpVar->nTypeLen == 2) + { + WORD cDataLen; + LPBYTE lpData = NULL; + + memcpy(&cDataLen, &zerobuf[pos], sizeof(cDataLen)); + pos += sizeof(cDataLen); + + if (cDataLen > 0) + lpData = (LPBYTE)malloc(cDataLen); + + if (lpData) + memcpy(lpData, &zerobuf[pos], cDataLen); + + pos += cDataLen; + + if (lpData) + { + bool bPrintable = true; + + for (int j = 0; j < cDataLen - 1; j++) + { + if (((unsigned char)lpData[j] < 0x20 || (unsigned char)lpData[j] > 0x7E) && (unsigned char)lpData[j] != 0x09 && (unsigned char)lpData[j] != 0x0D) + bPrintable = false; + } + + if (bPrintable && lpData[cDataLen - 1] == '\0') + { + //dprintf("%s: %s\n", lpVar->lpszVar, lpData); + } + else + { + for (int j = 0; j < cDataLen; j += 16) + { + //dprintf("%s: ", lpVar->lpszVar); + + for (int k = 0; k < 16; k++) + { + if ((j + k) < cDataLen) + { + //dprintf("%02x ", (unsigned char)lpData[j+k]); + } + else + { + //dprintf(" "); + } + } + + for (int k = 0; k < 16 && (j + k) < cDataLen; k++) + { + //dprintf("%c", ((unsigned char)lpData[j+k] >= 0x20 && (unsigned char)lpData[j+k] <= 0x7E) ? (unsigned char)lpData[j+k] : '.'); + } + + //dprintf("\n"); + } + } + } + + SAFE_FREE(lpData); + } + } + break; + + case LLTYPE_FIXED: + { + LPBYTE lpData = NULL; + + if (lpVar->nTypeLen > 0) + lpData = (LPBYTE)malloc(lpVar->nTypeLen); + + if (lpData) + memcpy(lpData, &zerobuf[pos], lpVar->nTypeLen); + + pos += lpVar->nTypeLen; + + if (lpData) + { + bool bPrintable = true; + + for (int j = 0; j < lpVar->nTypeLen - 1; j++) + { + if (((unsigned char)lpData[j] < 0x20 || (unsigned char)lpData[j] > 0x7E) && (unsigned char)lpData[j] != 0x09 && (unsigned char)lpData[j] != 0x0D) + bPrintable = false; + } + + if (bPrintable && lpData[lpVar->nTypeLen - 1] == '\0') + { + //dprintf("%s: %s\n", lpVar->lpszVar, lpData); + } + else + { + for (int j = 0; j < lpVar->nTypeLen; j += 16) + { + //dprintf("%s: ", lpVar->lpszVar); + + for (int k = 0; k < 16; k++) + { + if ((j + k) < lpVar->nTypeLen) + { + //dprintf("%02x ", (unsigned char)lpData[j+k]); + } + else + { + //dprintf(" "); + } + } + + for (int k = 0; k < 16 && (j + k) < lpVar->nTypeLen; k++) + { + //dprintf("%c", ((unsigned char)lpData[j+k] >= 0x20 && (unsigned char)lpData[j+k] <= 0x7E) ? (unsigned char)lpData[j+k] : '.'); + } + + //dprintf("\n"); + } + } + } + + SAFE_FREE(lpData); + } + break; + + case LLTYPE_SINGLE: + case LLTYPE_MULTIPLE: + case LLTYPE_NULL: + default: + break; + } + + lpVar = lpVar->lpNext; + } + } + + lpStruct = lpStruct->lpNext; + } +} + +CMessage * WINAPI map_command(LPCOMMAND lpCommand, CServer *server, char *zerobuf, int *len, int pos) +{ +// dprintf("--- %s ---\n", lpCommand->lpszCmd); + + int oldPos = pos; + + CMessage *msg = new CMessage; + + if (!msg) + return NULL; + + msg->SetCommand(lpCommand->lpszCmd); + + LPCOMMANDSTRUCT lpStruct = lpCommand->structs; + + while (lpStruct) + { + //dprintf("\t%04d %s (%s / %hu)\n", lpStruct->nKeywordPos, lpStruct->lpszStruct, LLTYPES[lpStruct->nType], lpStruct->cItems); + BYTE cItems = 1; + + if (lpStruct->nType == LLTYPE_VARIABLE) + { + memcpy(&cItems, &zerobuf[pos], sizeof(cItems)); + pos += sizeof(cItems); + } + else if (lpStruct->nType == LLTYPE_MULTIPLE) + { + cItems = lpStruct->cItems; + } + + for (BYTE c = 0; c < cItems; c++) + { + //dprintf("--- %s ----\n", lpStruct->lpszStruct); + CBlock *block = new CBlock; + msg->AddBlock(lpStruct->lpszStruct, lpStruct->nType, block); + + LPCOMMANDVAR lpVar = lpStruct->vars; + + while (lpVar) + { + //dprintf("\t\t%04d %s (%s / %d)\n", lpVar->nKeywordPos, lpVar->lpszVar, LLTYPES[lpVar->nType], lpVar->nTypeLen); + CVar *var = new CVar; + var->SetVar(lpVar->lpszVar); + var->SetType(lpVar->nType, lpVar->nTypeLen); + pos += var->SetData((LPBYTE)&zerobuf[pos]); + block->AddVar(var); + lpVar = lpVar->lpNext; + } + } + + lpStruct = lpStruct->lpNext; + } + + BYTE bPack[4096]; + int nPackedSize = msg->Pack(bPack); + int diff = memcmp(bPack, &zerobuf[oldPos], nPackedSize); + + if (diff) + { + msg->Dump(); + dprintf("PACKED: %d / %d (%d) ===> %d\n", nPackedSize, *len, oldPos, diff); + } + + return msg; +} + +void WINAPI cmd_Silent(LPCOMMAND lpCommand, CServer *server, char *zerobuf, int *len, int pos) +{ +} + +void WINAPI cmd_Default(LPCOMMAND lpCommand, CServer *server, char *zerobuf, int *len, int pos) +{ + //dprintf("Flags: %u\n", zerobuf[0]); + CMessage *msg = map_command(lpCommand, server, zerobuf, len, pos); + msg->Dump(); + SAFE_DELETE(msg); +} + +void WINAPI cmd_LoginReply(LPCOMMAND lpCommand, CServer *server, char *zerobuf, int *len, int pos) +{ + parse_command(lpCommand, server, zerobuf, len, pos); +} + +CMDHOOK pCMDHooks[] = { + { _T("Default"), (PROC)cmd_Default }, + { _T("DirLandReply"), (PROC)cmd_Silent }, // Silence the most common + { _T("AvatarAnimation"), (PROC)cmd_Silent }, // packets + { _T("CoarseLocationUpdate"), (PROC)cmd_Silent }, + { _T("CompletePingCheck"), (PROC)cmd_Silent }, + { _T("LayerData"), (PROC)cmd_Silent }, + { _T("PacketAck"), (PROC)cmd_Silent }, + { _T("StartPingCheck"), (PROC)cmd_Silent }, + { _T("SimulatorViewerTimeMessage"), (PROC)cmd_Silent }, + { _T("ImagePacket"), (PROC)cmd_Silent }, + { _T("TransferPacket"), (PROC)cmd_Silent }, + { _T("ObjectUpdate"), (PROC)cmd_Silent }, + { _T("ObjectUpdateCompressed"), (PROC)cmd_Silent }, + { _T("AgentThrottle"), (PROC)cmd_Silent }, + { _T("CoarseLocationUpdate"), (PROC)cmd_Silent }, + { _T("UUIDNameReply"), (PROC)cmd_Silent }, + { _T("RequestImage"), (PROC)cmd_Silent }, + { _T("ImageData"), (PROC)cmd_Silent }, + { _T("SimStats"), (PROC)cmd_Silent }, + { _T("ViewerEffect"), (PROC)cmd_Silent }, + { _T("TransferRequest"), (PROC)cmd_Silent }, + { _T("DirClassifiedReply"), (PROC)cmd_Silent }, + { _T("DirEventsReply"), (PROC)cmd_Silent }, + { _T("DirPopularReply"), (PROC)cmd_Silent }, + { _T("DirLandReply"), (PROC)cmd_Silent }, + { _T("AgentUpdate"), (PROC)cmd_Silent }, + { _T("ObjectUpdateCached"), (PROC)cmd_Silent }, + { _T("ImprovedTerseObjectUpdate"), (PROC)cmd_Silent }, + { _T("RequestMultipleObjects"), (PROC)cmd_Silent }, + { _T("AttachedSound"), (PROC)cmd_Silent }, + { _T("ViewerStats"), (PROC)cmd_Silent }, + { _T("TransferInfo"), (PROC)cmd_Silent }, + { _T("ParcelOverlay"), (PROC)cmd_Silent }, + { _T("SendXferPacket"), (PROC)cmd_Silent }, + { _T("DirPlacesReply"), (PROC)cmd_Silent }, + { NULL, NULL } +}; + +int decomm() +{ + FILE *fpComm; + FILE *fpMsg; + + fpComm = fopen(g_pConfig->m_pCommDatPath, "rb"); + + if (!fpComm) + { + printf("Couldn't open %s for reading, aborting...\n", g_pConfig->m_pCommDatPath); + return -1; + } + + fpMsg = fopen(g_pConfig->m_pMessageTemplatePath, "wb"); + + if (!fpMsg) + { + printf("Couldn't open %s for writing, aborting...\n", g_pConfig->m_pMessageTemplatePath); + return -1; + } + + printf("Decrypting %s to %s\n", g_pConfig->m_pCommDatPath, g_pConfig->m_pMessageTemplatePath); + static unsigned char ucMagicKey = 0; + long lTemplateSize = 0; + + fseek(fpComm, 0, SEEK_END); + lTemplateSize = ftell(fpComm); + fseek(fpComm, 0, SEEK_SET); + + BYTE buffer[2048]; + BYTE stripped[2048]; + LPBYTE lpTemplate = (LPBYTE)malloc(lTemplateSize); + DWORD dwTemplateWrote = 0; + + if (!lpTemplate) + return -1; + + bool bComment = false; + + while (!feof(fpComm)) + { + size_t stRead = fread(&buffer, 1, sizeof(buffer), fpComm); + size_t stStripped = 0; + + for (size_t stCount = 0; stCount < stRead; stCount++) + { + buffer[stCount] ^= ucMagicKey; + + if (!bComment && buffer[stCount] != '/') + stripped[stStripped++] = buffer[stCount]; + + if (bComment && buffer[stCount] == '\n') + bComment = false; + + if (!bComment && buffer[stCount] == '/') + bComment = true; + + ucMagicKey += 43; + } + + memcpy(lpTemplate + dwTemplateWrote, &stripped, stStripped); + dwTemplateWrote += (DWORD)stStripped; + + size_t stWrote = fwrite(&stripped, 1, stStripped, fpMsg); + + printf("."); + fflush(stdout); + } + + printf("\nDone.\n"); + + printf("template size: %ld\n", lTemplateSize); + + ZeroMemory(&cmds_low, sizeof(cmds_low)); + ZeroMemory(&cmds_med, sizeof(cmds_med)); + ZeroMemory(&cmds_high, sizeof(cmds_high)); + + get_command_blocks(lpTemplate, 0, lTemplateSize); + + fclose(fpComm); + fclose(fpMsg); + + for (int i = 1; i < MAX_COMMANDS_LOW; i++) + { + if (cmds_low[i].lpszCmd) + { + //dprintf("LOW %05d - %s - %s - %s\n", i, cmds_low[i].lpszCmd, cmds_low[i].bTrusted ? "Trusted" : "Untrusted", cmds_low[i].bZerocoded ? "Zerocoded" : "Unencoded"); + dump_structs(cmds_low[i].structs); + //SAFE_FREE(cmds_low[i].lpszCmd); + } + } + + for (int i = 1; i < MAX_COMMANDS_MEDIUM; i++) + { + if (cmds_med[i].lpszCmd) + { + //dprintf("Medium %05d - %s\n", i, cmds_med[i].lpszCmd); + dump_structs(cmds_med[i].structs); + //SAFE_FREE(cmds_med[i].lpszCmd); + } + } + + for (int i = 1; i < MAX_COMMANDS_HIGH; i++) + { + if (cmds_high[i].lpszCmd) + { + //dprintf("High %05d - %s\n", i, cmds_high[i].lpszCmd); + dump_structs(cmds_high[i].structs); + //SAFE_FREE(cmds_high[i].lpszCmd); + } + } + + return 0; +} + +HMODULE WINAPI new_LoadLibraryA( + LPCSTR lpLibFileName + ) +{ + if (g_hOpenGL != NULL && !_tcsicmp(lpLibFileName, "OPENGL32")) + return g_hOpenGL; + +// dprintf("[LoadLibraryA] Filename(%s)\n", lpLibFileName); + + HMODULE hModule = NULL; + PROC pOldProc = pAPIHooks[APIHOOK_LOADLIBRARYA].pOldProc; + + if (pOldProc != NULL && !IsBadCodePtr((PROC)pOldProc)) + { + hModule = ((HMODULE (WINAPI *)(LPCSTR))pOldProc)(lpLibFileName); + if (hModule != NULL) + { + SaveImportHooks(); + InstallImportHooks(); + } + } + + if (!_tcsicmp(lpLibFileName, "OPENGL32")) + g_hOpenGL = hModule; + + return hModule; +} + +BOOL WINAPI new_FreeLibraryA( + HMODULE hLibModule + ) +{ + if (hLibModule == g_hOpenGL) + { + return TRUE; + } + + return ((BOOL (WINAPI *)(HMODULE))pAPIHooks[APIHOOK_FREELIBRARYA].pOldProc)(hLibModule); +} + +HMODULE WINAPI new_LoadLibraryW( + LPCWSTR lpLibFileName + ) +{ +// dprintf("[LoadLibraryW] Filename(%S)\n", lpLibFileName); + + HMODULE hModule = NULL; + PROC pOldProc = pAPIHooks[APIHOOK_LOADLIBRARYW].pOldProc; + + if (pOldProc != NULL && !IsBadCodePtr((PROC)pOldProc)) + { + hModule = ((HMODULE (WINAPI *)(LPCWSTR))pOldProc)(lpLibFileName); + if (hModule != NULL) + { + SaveImportHooks(); + InstallImportHooks(); + } + } + + return hModule; +} + +HMODULE WINAPI new_LoadLibraryExA( + LPCSTR lpLibFileName, + HANDLE hFile, + DWORD dwFlags + ) +{ +// dprintf("[LoadLibraryExA] Filename(%s)\n", lpLibFileName); + + HMODULE hModule = NULL; + PROC pOldProc = pAPIHooks[APIHOOK_LOADLIBRARYEXA].pOldProc; + + if (pOldProc != NULL && !IsBadCodePtr((PROC)pOldProc)) + { + hModule = ((HMODULE (WINAPI *)(LPCSTR, HANDLE, DWORD))pOldProc)(lpLibFileName, hFile, dwFlags); + if (hModule != NULL) + { + SaveImportHooks(); + InstallImportHooks(); + } + } + + return hModule; +} + +HMODULE WINAPI new_LoadLibraryExW( + LPCWSTR lpLibFileName, + HANDLE hFile, + DWORD dwFlags) +{ +// dprintf("[LoadLibraryExW] Filename(%S)\n", lpLibFileName); + + HMODULE hModule = NULL; + PROC pOldProc = pAPIHooks[APIHOOK_LOADLIBRARYEXW].pOldProc; + + if (pOldProc != NULL && !IsBadCodePtr((PROC)pOldProc)) + { + hModule = ((HMODULE (WINAPI *)(LPCWSTR, HANDLE, DWORD))pOldProc)(lpLibFileName, hFile, dwFlags); + if (hModule != NULL) + { + SaveImportHooks(); + InstallImportHooks(); + } + } + + return hModule; +} + +FARPROC WINAPI new_GetProcAddress(HMODULE hModule, LPCSTR lpProcName) +{ + TCHAR szMod[MAX_PATH]; + + GetModuleFileName(hModule, szMod, sizeof(szMod)); + + if (HIWORD((DWORD)lpProcName) == 0) + { + WORD wOrdinal = LOWORD((DWORD)lpProcName); +// dprintf(_T("[GetProcAddress] [%s][@%d]\n"), szMod, wOrdinal); + } + else + { + if (lpProcName != NULL && !IsBadCodePtr((PROC)lpProcName)) + { + if (!stricmp(lpProcName, "wglSwapBuffers")) + { + + } + else if (!stricmp(lpProcName, "InternetReadFile")) + { + dprintf(_T("[***GetProcAddress] [%s][%s]\n"), szMod, lpProcName); + return pAPIHooks[(int)APIHOOK_INTERNETREADFILE].pNewProc; + } + else if (!stricmp(lpProcName, "InternetOpenUrlA")) + { + dprintf(_T("[***GetProcAddress] [%s][%s]\n"), szMod, lpProcName); + return pAPIHooks[(int)APIHOOK_INTERNETOPENURLA].pNewProc; + } + else if (!stricmp(lpProcName, "CPEncrypt")) + { + dprintf(_T("[***CPEncrypt] [%s][%s]\n"), szMod, lpProcName); + return pAPIHooks[(int)APIHOOK_CPENCRYPT].pNewProc; + } + //else + //dprintf(_T("[GetProcAddress] [%s][%s]\n"), szMod, lpProcName); + } + //else + //dprintf(_T("[GetProcAddress] [%s][]\n"), szMod); + } + + return ((FARPROC (WINAPI *)(HMODULE, LPCSTR))pAPIHooks[(int)APIHOOK_GETPROCADDRESS].pOldProc)(hModule, lpProcName); +} + +struct hostent FAR * WINAPI new_gethostbyname( + const char FAR *name + ) +{ + dprintf("[new_gethostbyname] name(%s)\n", name); + + struct hostent FAR * hp = ((struct hostent FAR * (WINAPI *)(const char FAR *))pAPIHooks[(int)APIHOOK_GETHOSTBYNAME].pOldProc)(name); + + return hp; +} + +int WINAPI new_connect( + SOCKET s, + const struct sockaddr FAR *name, + int namelen + ) +{ + dprintf("[connect] socket(0x%08X) host(%s) port(%d)\n", s, inet_ntoa(((struct sockaddr_in *)name)->sin_addr), ntohs(((struct sockaddr_in *)name)->sin_port)); + + return ((int (WINAPI *)(SOCKET, const struct sockaddr FAR *, int))pAPIHooks[(int)APIHOOK_CONNECT].pOldProc)(s, name, namelen); +} + +int WINAPI new_recv( + SOCKET s, + char *buf, + int len, + int flags + ) +{ + //dprintf("[recv] socket(0x%08X)\n", s); + + int nRes = 0; + { + nRes = ((int (WINAPI *)(SOCKET, char *, int, int))pAPIHooks[APIHOOK_RECV].pOldProc)(s, buf, len, flags); + } +/* + for (int j = 0; j < nRes; j += 16) + { + for (int k = 0; k < 16; k++) + { + if ((j + k) < nRes) + { + dprintf("%02x ", (unsigned char)buf[j+k]); + } + else + { + dprintf(" "); + } + } + + for (int k = 0; k < 16 && (j + k) < nRes; k++) + { + dprintf("%c", ((unsigned char)buf[j+k] >= 0x20 && (unsigned char)buf[j+k] <= 0x7E) ? (unsigned char)buf[j+k] : '.'); + } + + dprintf("\n"); + } +*/ + return nRes; +} + +int WINAPI new_recvfrom( + SOCKET s, + char *buf, + int len, + int flags, + struct sockaddr *from, + int *fromlen + ) +{ + int nRes = 0; + WORD wSeq = 0; + int zerolen = 0; + static char zerobuf[8192]; + bool bZerocoded = false; + CServer *server = NULL; + CSequence *sequence = NULL; + + nRes = ((int (WINAPI *)(SOCKET, char *, int, int, struct sockaddr *, int *))pAPIHooks[APIHOOK_RECVFROM].pOldProc)(s, buf, len, flags, from, fromlen); + + // !!! + //return nRes; + + if (nRes > 0) + { + //dprintf("Receiving %u bytes\n", nRes); + + // Get packet sequence number + memcpy(&wSeq, &buf[2], sizeof(wSeq)); + wSeq = htons(wSeq); + + // Get current server + server = servers.FindServer((struct sockaddr_in *)from); + + // If server isn't in our list add it as new + if (!server) + { + server = new CServer((struct sockaddr_in *)from); + servers.AddServer(server); + } + + // Handle packet acks + BYTE bAppended[4096]; + int nAppendedLen = 0; + + if (buf[0] & MSG_APPENDED_ACKS) + { + //dprintf("APPENDED ACKS\n"); + + BYTE cPacketsItems = buf[nRes - 1]; + + int nOldRes = nRes; + + nRes = nOldRes - 1 - (cPacketsItems * sizeof(DWORD)); + //dprintf("NEW AND OLD: %d / %d\n", nRes, nOldRes); + nAppendedLen = nOldRes - nRes; + memcpy(bAppended, &buf[nRes], nAppendedLen); + } + zerolen = ZeroDecode(buf, nRes, zerobuf, sizeof(zerobuf)); + + if ((unsigned char)buf[4] != 0xff) + { + // High + //dprintf("parse high: %hu\n", zerobuf[4]); + + bool bCmdFound = false; + + for (int j = 0; pCMDHooks[j].szCommand; j++) + { + if (_tcsicmp(cmds_high[zerobuf[4]].lpszCmd, pCMDHooks[j].szCommand) == 0 && pCMDHooks[j].pProc != NULL && !IsBadCodePtr(pCMDHooks[j].pProc)) + { + bCmdFound = true; + ((void (WINAPI *)(LPCOMMAND, CServer *, char *, int *, int))pCMDHooks[j].pProc)(&cmds_high[zerobuf[4]], server, zerobuf, &zerolen, 5); + break; + } + } + + if (!bCmdFound) + { + ((void (WINAPI *)(LPCOMMAND, CServer *, char *, int *, int))pCMDHooks[0].pProc)(&cmds_high[zerobuf[4]], server, zerobuf, &zerolen, 5); + } + } + + else if ((unsigned char)buf[5] != 0xff) + { + // Medium + //dprintf("parse med: %hu\n", zerobuf[5]); + + bool bCmdFound = false; + + for (int j = 0; pCMDHooks[j].szCommand; j++) + { + if (!_tcsicmp(cmds_med[zerobuf[5]].lpszCmd, pCMDHooks[j].szCommand) && pCMDHooks[j].pProc != NULL && !IsBadCodePtr(pCMDHooks[j].pProc)) + { + bCmdFound = true; + ((void (WINAPI *)(LPCOMMAND, CServer *, char *, int *, int))pCMDHooks[j].pProc)(&cmds_med[zerobuf[5]], server, zerobuf, &zerolen, 6); + break; + } + } + + if (!bCmdFound) + { + ((void (WINAPI *)(LPCOMMAND, CServer *, char *, int *, int))pCMDHooks[0].pProc)(&cmds_med[zerobuf[5]], server, zerobuf, &zerolen, 6); + } + } + + else if ((unsigned char)buf[4] == 0xff && (unsigned char)buf[5] == 0xff) + { + // Fixed + // Low + + //dprintf("parse low: %hu\n", htons(wFreq)); + + bool bCmdFound = false; + WORD wFreq; + memcpy(&wFreq, &zerobuf[6], sizeof(wFreq)); + + for (int j = 0; pCMDHooks[j].szCommand; j++) + { + if (!_tcsicmp(cmds_low[htons(wFreq)].lpszCmd, pCMDHooks[j].szCommand) && pCMDHooks[j].pProc != NULL && !IsBadCodePtr(pCMDHooks[j].pProc)) + { + bCmdFound = true; + ((void (WINAPI *)(LPCOMMAND, CServer *, char *, int *, int))pCMDHooks[j].pProc)(&cmds_low[htons(wFreq)], server, zerobuf, &zerolen, 8); + break; + } + } + + if (!bCmdFound) + { + ((void (WINAPI *)(LPCOMMAND, CServer *, char *, int *, int))pCMDHooks[0].pProc)(&cmds_low[htons(wFreq)], server, zerobuf, &zerolen, 8); + } + } + + nRes = ZeroEncode(zerobuf, zerolen, buf, len); + + if (nAppendedLen > 0) + { + memcpy(&buf[nRes], bAppended, nAppendedLen); + nRes += nAppendedLen; + } + } + else + { + // We can use this area to synthesize incoming packets + } + + return nRes; +} + +int WINAPI new_send( + SOCKET s, + const char *buf, + int len, + int flags + ) +{ +// dprintf("[send] socket(0x%08X)\n", s); + + int nRes = 0; + { + nRes = ((int (WINAPI *)(SOCKET, const char *, int, int))pAPIHooks[APIHOOK_SEND].pOldProc)(s, buf, len, flags); + } + + return nRes; +} + +int WINAPI new_sendto( + SOCKET s, + char *buf, + int len, + int flags, + struct sockaddr *to, + int tolen + ) +{ + int nRes = 0; + WORD wSeq = 0; + int zerolen = 0; + char *zerobuf = NULL; + bool bZerocoded = false; + CServer *server = NULL; + CSequence *sequence = NULL; + + // Get packet sequence number + memcpy(&wSeq, &buf[2], sizeof(wSeq)); + wSeq = htons(wSeq); + + // Get current server + server = servers.FindServer((struct sockaddr_in *)to); + + // If server isn't in our list add it as new + if (!server) + { + server = new CServer((struct sockaddr_in *)to); + servers.AddServer(server); + } + + static int nDropPacket = 0; + + if (buf[0] & MSG_ZEROCODED) + { + bZerocoded = true; + zerolen = 4; + + for (int i = 4; i < len; i++) + { + if ((unsigned char)buf[i] == 0x00) + zerolen += (unsigned char)buf[++i]; + else + zerolen++; + } + + zerobuf = (char *)malloc(zerolen); + + if (!zerobuf) + { + dprintf("Couldn't allocate memory for zerocoded buffer\n"); + return -1; + } + + int j = 4; + memcpy(zerobuf, buf, 4); + + for (int i = 4; i < len; i++) + { + if ((unsigned char)buf[i] == 0x00) + { + for (int z = 0; z < (unsigned char)buf[i+1]; z++) + zerobuf[j++] = 0x00; + + i++; + } + else + zerobuf[j++] = buf[i]; + } + } + else + { + zerolen = len; + zerobuf = buf; + } + + nRes = ((int (WINAPI *)(SOCKET, char *, int, int, struct sockaddr *, int))pAPIHooks[APIHOOK_SENDTO].pOldProc)(s, buf, len, flags, to, tolen); + + // !!! + //return nRes; + + //dprintf("Sending %u bytes\n", nRes); + + if ((unsigned char)buf[4] != 0xff) + { + // High + //dprintf("parse high: %hu\n", zerobuf[4]); + + bool bCmdFound = false; + + for (int j = 0; pCMDHooks[j].szCommand; j++) + { + if (_tcsicmp(cmds_high[zerobuf[4]].lpszCmd, pCMDHooks[j].szCommand) == 0 && pCMDHooks[j].pProc != NULL && !IsBadCodePtr(pCMDHooks[j].pProc)) + { + bCmdFound = true; + ((void (WINAPI *)(LPCOMMAND, CServer *, char *, int *, int))pCMDHooks[j].pProc)(&cmds_high[zerobuf[4]], server, zerobuf, &zerolen, 5); + break; + } + } + + if (!bCmdFound) + { + ((void (WINAPI *)(LPCOMMAND, CServer *, char *, int *, int))pCMDHooks[0].pProc)(&cmds_high[zerobuf[4]], server, zerobuf, &zerolen, 5); + } + } + + else if ((unsigned char)buf[5] != 0xff) + { + // Medium + //dprintf("parse med: %hu\n", zerobuf[5]); + + bool bCmdFound = false; + + for (int j = 0; pCMDHooks[j].szCommand; j++) + { + if (!_tcsicmp(cmds_med[zerobuf[5]].lpszCmd, pCMDHooks[j].szCommand) && pCMDHooks[j].pProc != NULL && !IsBadCodePtr(pCMDHooks[j].pProc)) + { + bCmdFound = true; + ((void (WINAPI *)(LPCOMMAND, CServer *, char *, int *, int))pCMDHooks[j].pProc)(&cmds_med[zerobuf[5]], server, zerobuf, &zerolen, 6); + break; + } + } + + if (!bCmdFound) + { + ((void (WINAPI *)(LPCOMMAND, CServer *, char *, int *, int))pCMDHooks[0].pProc)(&cmds_med[zerobuf[5]], server, zerobuf, &zerolen, 6); + } + } + + else if ((unsigned char)buf[4] == 0xff && (unsigned char)buf[5] == 0xff) + { + // Fixed + // Low + + //dprintf("parse low: %hu\n", htons(wFreq)); + + bool bCmdFound = false; + WORD wFreq; + memcpy(&wFreq, &zerobuf[6], sizeof(wFreq)); + + for (int j = 0; pCMDHooks[j].szCommand; j++) + { + if (!_tcsicmp(cmds_low[htons(wFreq)].lpszCmd, pCMDHooks[j].szCommand) && pCMDHooks[j].pProc != NULL && !IsBadCodePtr(pCMDHooks[j].pProc)) + { + bCmdFound = true; + ((void (WINAPI *)(LPCOMMAND, CServer *, char *, int *, int))pCMDHooks[j].pProc)(&cmds_low[htons(wFreq)], server, zerobuf, &zerolen, 8); + break; + } + } + + if (!bCmdFound) + { + ((void (WINAPI *)(LPCOMMAND, CServer *, char *, int *, int))pCMDHooks[0].pProc)(&cmds_low[htons(wFreq)], server, zerobuf, &zerolen, 8); + } + } + else + { + dprintf("[sendto] *** UNKNOWN FREQUENCY TYPE ***\n", s); + int i, j; + + for (i = 0; i < len + 16; i += 16) + { + for (j = 0; j < 16; j++) + { + if ((i + j) < len) + { + dprintf("%02x ", (unsigned char)buf[i+j]); + } + else + { + dprintf(" "); + } + } + + for (j = 0; j < 16 && (i + j) < len; j++) + { + dprintf("%c", isprint(buf[i+j]) ? (unsigned char)buf[i+j] : '.'); + } + + dprintf("\n"); + } + + dprintf("\n"); + } + + if (bZerocoded && zerobuf) + free(zerobuf); + + return nRes; +} + +/* +LONG WINAPI new_SetWindowLongA( + HWND hWnd, + int nIndex, + LONG dwNewLong +) +{ + LONG nRes = 0; + + if (nIndex == GWL_WNDPROC && g_pMainFrm && hWnd == g_pMainFrm->m_hWnd) + { + dprintf(_T("[SetWindowLongA] %08x [%x] = "), hWnd, dwNewLong); + + nRes = ((LONG (WINAPI *)(HWND, int, LONG))pAPIHooks[APIHOOK_SETWINDOWLONGA].pOldProc)(hWnd, nIndex, dwNewLong); + + dprintf(_T("[%x]\n"), nRes); + } + else + { + if (nIndex == GWL_WNDPROC) + dprintf(_T("[SetWindowLongA] %08x [%x]\n"), hWnd, dwNewLong); + + nRes = ((LONG (WINAPI *)(HWND, int, LONG))pAPIHooks[APIHOOK_SETWINDOWLONGA].pOldProc)(hWnd, nIndex, dwNewLong); + } + + return nRes; +} + +LONG WINAPI new_SetWindowLongW( + HWND hWnd, + int nIndex, + LONG dwNewLong +) +{ + LONG nRes = 0; + + if (nIndex == GWL_WNDPROC) + { + dprintf(_T("[SetWindowLongW] %08x\n"), hWnd); + + nRes = ((LONG (WINAPI *)(HWND, int, LONG))pAPIHooks[APIHOOK_SETWINDOWLONGW].pOldProc)(hWnd, nIndex, dwNewLong); + } + else + { + nRes = ((LONG (WINAPI *)(HWND, int, LONG))pAPIHooks[APIHOOK_SETWINDOWLONGW].pOldProc)(hWnd, nIndex, dwNewLong); + } + + return nRes; +} +*/ +BOOL WINAPI new_InternetReadFile( + IN HINTERNET hFile, + IN LPVOID lpBuffer, + IN DWORD dwNumberOfBytesToRead, + OUT LPDWORD lpNumberOfBytesRead +) +{ + BOOL bRes = FALSE; + + bRes = ((BOOL (WINAPI *)(HINTERNET, LPVOID, DWORD, LPDWORD))pAPIHooks[APIHOOK_INTERNETREADFILE].pOldProc)(hFile, lpBuffer, dwNumberOfBytesToRead, lpNumberOfBytesRead); + + dprintf(_T("[InternetReadFile] [%s] %d\n"), lpBuffer, *lpNumberOfBytesRead); + + return bRes; +} + +HINTERNET WINAPI new_InternetOpenUrlA( + HINTERNET hInternet, + LPCTSTR lpszUrl, + LPCTSTR lpszHeaders, + DWORD dwHeadersLength, + DWORD dwFlags, + DWORD_PTR dwContext +) +{ + HINTERNET hNet = 0; + + dprintf(_T("[InternetOpenUrlA] [%s][%s]\n"), lpszUrl, lpszHeaders); + + hNet = ((HINTERNET (WINAPI *)(HINTERNET, LPCTSTR, LPCTSTR, DWORD, DWORD, DWORD_PTR))pAPIHooks[APIHOOK_INTERNETOPENURLA].pOldProc)(hInternet, lpszUrl, lpszHeaders, dwHeadersLength, dwFlags, dwContext); + + return hNet; +} + +BOOL WINAPI new_CPEncrypt( + HCRYPTPROV hProv, + HCRYPTKEY hKey, + HCRYPTHASH hHash, + BOOL Final, + DWORD dwFlags, + BYTE* pbData, + DWORD* pdwDataLen, + DWORD dwBufLen +) +{ + BOOL bRes = FALSE; + + bRes = ((BOOL (WINAPI *)(HCRYPTPROV, HCRYPTKEY, HCRYPTHASH, BOOL, DWORD, BYTE *, DWORD *, DWORD))pAPIHooks[APIHOOK_CPENCRYPT].pOldProc)(hProv, hKey, hHash, Final, dwFlags, pbData, pdwDataLen, dwBufLen); + + TCHAR szStr[2048]; + ZeroMemory(szStr, sizeof(szStr)); + memcpy(szStr, pbData, sizeof(szStr)); + + dprintf(_T("[CPEncrypt] [%s] %d\n"), szStr, 0); + + return bRes; +} + +BOOL WINAPI new_PeekMessageA( + LPMSG lpMsg, // pointer to structure for message + HWND hWnd, // handle to window + UINT wMsgFilterMin, // first message + UINT wMsgFilterMax, // last message + UINT wRemoveMsg // removal flags +) +{ + //dprintf(_T("[PeekMessageA] [%x]\n"), hWnd); + + BOOL bRes = FALSE; + static UINT uiAntiIdle = 0; + + bRes = ((BOOL (WINAPI *)(LPMSG, HWND, UINT, UINT, UINT))pAPIHooks[APIHOOK_PEEKMESSAGEA].pOldProc)(lpMsg, hWnd, wMsgFilterMin, wMsgFilterMax, wRemoveMsg); + + if (!bRes && GetFocus() == NULL) + { + // Wait for any message sent or posted to this queue + DWORD dwResult = MsgWaitForMultipleObjects(0, NULL, FALSE, 1000, QS_ALLINPUT); + + uiAntiIdle++; + + if (uiAntiIdle > 4) + { + //dprintf(_T("idle.. %d\n"), uiAntiIdle); + if (g_pMainFrm) + { + //dprintf(_T("sending anti.. idle...\n")); + PostMessage(g_pMainFrm->m_hWnd, WM_MOUSEMOVE, 0, MAKEWORD(10, 10)); + } + + uiAntiIdle = 0; + } + } + + static UINT uiAutoPilot = 0; + + if (g_pMainFrm) + { + //uiAutoPilot++; + + if (uiAutoPilot > 200) + { + WORD wRepeatCount = 1; + LPARAM lParam = MAKELPARAM(wRepeatCount, 0); + + lParam |= 1 << 24; + lParam |= 0 << 29; + lParam |= 1 << 30; + lParam |= 0 << 31; + + //PostMessage(g_pMainFrm->m_hWnd, WM_KEYDOWN, VK_UP, lParam); + + lParam |= 0 << 24; + //PostMessage(g_pMainFrm->m_hWnd, WM_KEYDOWN, 'E', 0); + + char sc = 0; + sc = MapVirtualKey('E', 0); + + for (int k = 0; k < 90; k++) + PostMessage(g_pMainFrm->m_hWnd, WM_KEYDOWN, 'E', 1 | (1 << 30) | (sc << 16)); + + //PostMessage(g_pMainFrm->m_hWnd, WM_KEYUP, 'E', 1 | (3 << 30) | (sc << 16)); + + uiAutoPilot = 0; + } + } + + return bRes; +} + +VOID WINAPI new_glEnable( + GLenum cap +) +{ + dprintf(_T("[glEnable] [0x%08x]\n"), cap); + +// if (cap != GL_TEXTURE_2D) + ((VOID (WINAPI *)(GLenum))pAPIHooks[APIHOOK_GLENABLE].pOldProc)(cap); +// else +// glDisable(GL_TEXTURE_2D); +} + +GLboolean WINAPI new_glIsEnabled( + GLenum cap +) +{ +// if (cap == GL_TEXTURE_2D) +// return GL_TRUE; + + return ((GLboolean (WINAPI *)(GLenum))pAPIHooks[APIHOOK_GLISENABLED].pOldProc)(cap); +} + +VOID WINAPI new_glTranslatef( + GLfloat x, + GLfloat y, + GLfloat z +) +{ + dprintf(_T("[glTranslatef]\n")); + ((VOID (WINAPI *)(GLfloat, GLfloat, GLfloat))pAPIHooks[APIHOOK_GLTRANSLATEF].pOldProc)(x, y, z); +} + +VOID WINAPI new_glTranslated( + GLdouble x, + GLdouble y, + GLdouble z +) +{ + dprintf(_T("[glTranslated]\n")); + ((VOID (WINAPI *)(GLdouble, GLdouble, GLdouble))pAPIHooks[APIHOOK_GLTRANSLATED].pOldProc)(x, y, z); +} + +VOID WINAPI new_glTexCoord2f( + GLfloat s, + GLfloat t +) +{ + ((VOID (WINAPI *)(GLfloat, GLfloat))pAPIHooks[APIHOOK_GLTEXCOORD2F].pOldProc)(s, t); +} + +VOID WINAPI new_glVertex2f( + GLfloat x, + GLfloat y +) +{ + dprintf("[glVertex2f]\n"); + ((VOID (WINAPI *)(GLfloat, GLfloat))pAPIHooks[APIHOOK_GLVERTEX2F].pOldProc)(x, y); +} + +VOID WINAPI new_glVertex3f( + GLfloat x, + GLfloat y, + GLfloat z +) +{ + dprintf("[glVertex3f]\n"); + ((VOID (WINAPI *)(GLfloat, GLfloat, GLfloat))pAPIHooks[APIHOOK_GLVERTEX3F].pOldProc)(x, y, z); +} + +// Moves floating name tags +VOID WINAPI new_glVertex3fv( + GLfloat *v +) +{ + dprintf("[glVertex3fv]\n"); + ((VOID (WINAPI *)(const GLfloat *v))pAPIHooks[APIHOOK_GLVERTEX3FV].pOldProc)(v); +} + +VOID WINAPI new_glVertex4f( + GLfloat x, + GLfloat y, + GLfloat z, + GLfloat w +) +{ + dprintf("[glVertex4f]\n"); + ((VOID (WINAPI *)(GLfloat, GLfloat, GLfloat, GLfloat))pAPIHooks[APIHOOK_GLVERTEX4F].pOldProc)(x, y, z, w); +} + +VOID WINAPI new_glVertex4fv( + GLfloat *v +) +{ + dprintf("[glVertex4v]\n"); + ((VOID (WINAPI *)(const GLfloat *v))pAPIHooks[APIHOOK_GLVERTEX4FV].pOldProc)(v); +} + +VOID WINAPI new_glTexCoord2fv( + GLfloat *v +) +{ + ((VOID (WINAPI *)(GLfloat *))pAPIHooks[APIHOOK_GLTEXCOORD2FV].pOldProc)(v); +} + +VOID WINAPI new_glColor4f( + GLfloat red, + GLfloat green, + GLfloat blue, + GLfloat alpha +) +{ + ((VOID (WINAPI *)(GLfloat, GLfloat, GLfloat, GLfloat))pAPIHooks[APIHOOK_GLCOLOR4F].pOldProc)(red, green, blue, alpha); +} + +VOID WINAPI new_glColor3f( + GLfloat red, + GLfloat green, + GLfloat blue +) +{ + GLfloat alpha; + alpha = 1.0f; + + ((VOID (WINAPI *)(GLfloat, GLfloat, GLfloat, GLfloat))pAPIHooks[APIHOOK_GLCOLOR4F].pOldProc)(red, green, blue, alpha); +} + +VOID WINAPI new_glColor4fv( + GLfloat *v +) +{ + ((VOID (WINAPI *)(const GLfloat *))pAPIHooks[APIHOOK_GLCOLOR4FV].pOldProc)(v); +} + +VOID WINAPI new_glColor4ubv( + GLubyte *v +) +{ + ((VOID (WINAPI *)(const GLubyte *))pAPIHooks[APIHOOK_GLCOLOR4UBV].pOldProc)(v); +} + +VOID WINAPI new_glColor3fv( + GLfloat *v +) +{ + GLfloat n[4]; + n[0] = v[0]; + n[1] = v[1]; + n[2] = v[2]; + n[3] = 1.0; + + ((VOID (WINAPI *)(const GLfloat *))pAPIHooks[APIHOOK_GLCOLOR4FV].pOldProc)(n); +} + +GLenum WINAPI new_glGetError( + void +) +{ + dprintf("[glGetError] "); + GLenum error = ((GLenum (WINAPI *)(void))pAPIHooks[APIHOOK_GLGETERROR].pOldProc)(); + + dprintf("0x%x\n", error); + if (error == GL_INVALID_OPERATION) + return GL_NO_ERROR; + else return error; +} + +VOID WINAPI new_glColorPointer( + GLint size, + GLenum type, + GLsizei stride, + const GLvoid *pointer +) +{ + dprintf("[glColorPointer]\n"); + ((VOID (WINAPI *)(GLint, GLenum, GLsizei, const GLvoid *))pAPIHooks[APIHOOK_GLCOLORPOINTER].pOldProc)(size, type, stride, pointer); +} + +// Used to render avatars and trees +VOID WINAPI new_glDrawElements( + GLenum mode, + GLsizei count, + GLenum type, + const GLvoid *indices +) +{ + //glColor4f(1.0, 1.0, 1.0, 0.2); + /*glBegin(GL_QUADS); + for (int i = 0; i < 10; i++) + { + GLfloat fPosX; + GLfloat fPosY; + GLfloat fPosZ; + + fPosX = (float)(rand() % 300) - 150.0f; + fPosY = -10;//(float)(rand() % 200) - 10.0f; + fPosZ = (float)(rand() % 300) - 150.0f; + + glTexCoord2f(0.0, 1.0); + glVertex3f(fPosX - 4.0f, fPosY + 1.0f, fPosZ - 4.0f); + + glTexCoord2f(0.0, 0.0); + glVertex3f(fPosX - 4.0f, fPosY + 1.0f, fPosZ + 4.0f); + + glTexCoord2f(1.0, 0.0); + glVertex3f(fPosX + 4.0f, fPosY + 1.0f, fPosZ + 4.0f); + + glTexCoord2f(1.0, 1.0); + glVertex3f(fPosX + 4.0f, fPosY + 1.0f, fPosZ - 4.0f); + + } + glEnd();*/ + + dprintf("[glDrawElements] %d\n", count); + ((VOID (WINAPI *)(GLenum, GLsizei, GLenum, const GLvoid *))pAPIHooks[APIHOOK_GLDRAWELEMENTS].pOldProc)(mode, count, type, indices); +} + +VOID WINAPI new_glDrawArrays( + GLenum mode, + GLint first, + GLsizei count +) +{ + dprintf("[glDrawArrays] %d\n", count); + ((VOID (WINAPI *)(GLenum, GLint, GLsizei))pAPIHooks[APIHOOK_GLDRAWARRAYS].pOldProc)(mode, first, count); +} + +VOID WINAPI new_glDrawPixels( + GLsizei width, + GLsizei height, + GLenum format, + GLenum type, + const GLvoid *pixels +) +{ + dprintf("[glDrawPixels]\n"); + ((VOID (WINAPI *)(GLsizei, GLsizei, GLenum, GLenum, const GLvoid))pAPIHooks[APIHOOK_GLDRAWPIXELS].pOldProc)(width, height, format, type, pixels); +} + +VOID WINAPI new_glVertexPointer( + GLint size, + GLenum type, + GLsizei stride, + const GLvoid *pointer +) +{ + ((VOID (WINAPI *)(GLint, GLenum, GLsizei, const GLvoid *))pAPIHooks[APIHOOK_GLVERTEXPOINTER].pOldProc)(size, type, stride, pointer); +} + +VOID WINAPI new_glNormalPointer( + GLenum type, + GLsizei stride, + const GLvoid *pointer +) +{ + dprintf("[glNormalPointer]\n"); + ((VOID (WINAPI *)(GLenum, GLsizei, const GLvoid *))pAPIHooks[APIHOOK_GLNORMALPOINTER].pOldProc)(type, stride, pointer); +} + +VOID WINAPI new_glTexCoordPointer( + GLint size, + GLenum type, + GLsizei stride, + const GLvoid *pointer +) +{ + ((VOID (WINAPI *)(GLint, GLenum, GLsizei, const GLvoid *))pAPIHooks[APIHOOK_GLTEXCOORDPOINTER].pOldProc)(size, type, stride, pointer); +} + +VOID WINAPI new_glViewport( + GLint x, + GLint y, + GLsizei width, + GLsizei height +) +{ + ((VOID (WINAPI *)(GLint, GLint, GLsizei, GLsizei))pAPIHooks[APIHOOK_GLVIEWPORT].pOldProc)(x, y, width, height); +} + +VOID WINAPI new_glTexImage2D( + GLenum target, + GLint level, + GLint components, + GLsizei width, + GLsizei height, + GLint border, + GLenum format, + GLenum type, + const GLvoid *pixels +) +{ + ((VOID (WINAPI *)(GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *))pAPIHooks[APIHOOK_GLTEXIMAGE2D].pOldProc)(target, level, components, width, height, border, format, type, pixels); +} + +VOID WINAPI new_gluPerspective( + GLdouble fovy, + GLdouble aspect, + GLdouble zNear, + GLdouble zFar +) +{ + ((VOID (WINAPI *)(GLdouble, GLdouble, GLdouble, GLdouble))pAPIHooks[APIHOOK_GLUPERSPECTIVE].pOldProc)(fovy, aspect, zNear, zFar); +} + +VOID WINAPI new_glBegin( + GLenum mode +) +{ + ((VOID (WINAPI *)(GLenum))pAPIHooks[APIHOOK_GLBEGIN].pOldProc)(mode); +} + +VOID WINAPI new_glFlush( + void +) +{ + ((VOID (WINAPI *)(void))pAPIHooks[APIHOOK_GLFLUSH].pOldProc)(); +} + +VOID WINAPI new_gluQuadricDrawStyle( + GLUquadricObj * qobj, + GLenum drawStyle + ) +{ + ((VOID (WINAPI *)(GLUquadricObj *, GLenum))pAPIHooks[APIHOOK_GLUQUADRICDRAWSTYLE].pOldProc)(qobj, drawStyle); +} + +VOID WINAPI new_gluTessVertex( + GLUtesselator * tess, + GLdouble coords[3], + void * data +) +{ + dprintf("[gluTessVertex]\n"); + ((VOID (WINAPI *)(GLUtesselator *, GLdouble[3], void *))pAPIHooks[APIHOOK_GLUTESSVERTEX].pOldProc)(tess, coords, data); +} + +BOOL WINAPI new_WriteFileA( + HANDLE hFile, // handle to file to write to + LPCVOID lpBuffer, // pointer to data to write to file + DWORD nNumberOfBytesToWrite, // number of bytes to write + LPDWORD lpNumberOfBytesWritten, // pointer to number of bytes written + LPOVERLAPPED lpOverlapped // pointer to structure for overlapped I/O +) +{ + return ((BOOL (WINAPI *)(HANDLE, LPCVOID, DWORD, LPDWORD, LPOVERLAPPED))pAPIHooks[APIHOOK_WRITEFILEA].pOldProc)(hFile, lpBuffer, nNumberOfBytesToWrite, lpNumberOfBytesWritten, lpOverlapped); +} + +BOOL WINAPI new_DeleteFileA( + LPCTSTR lpFileName // pointer to name of file to delete +) +{ + dprintf("[DeleteFileA] %s\n", lpFileName); + + //return TRUE; + return ((BOOL (WINAPI *)(LPCTSTR))pAPIHooks[APIHOOK_DELETEFILEA].pOldProc)(lpFileName); +} + +int WINAPI new_lstrcmpiA( + LPCTSTR lpString1, // pointer to first string + LPCTSTR lpString2 // pointer to second string +) +{ + //dprintf("[lstrcmpiA] %s <> %s\n", lpString1, lpString2); + return ((int (WINAPI *)(LPCTSTR, LPCTSTR))pAPIHooks[APIHOOK_LSTRCMPIA].pOldProc)(lpString1, lpString2); +} + +APIHOOK pAPIHooks[] = { + { NULL, _T("KERNEL32.DLL"), "GetProcAddress", FALSE, NULL, (PROC)new_GetProcAddress }, + { NULL, _T("KERNEL32.DLL"), "LoadLibraryA", FALSE, NULL, (PROC)new_LoadLibraryA }, + { NULL, _T("KERNEL32.DLL"), "LoadLibraryW", FALSE, NULL, (PROC)new_LoadLibraryW }, + { NULL, _T("KERNEL32.DLL"), "LoadLibraryExA", FALSE, NULL, (PROC)new_LoadLibraryExA }, + { NULL, _T("KERNEL32.DLL"), "LoadLibraryExW", FALSE, NULL, (PROC)new_LoadLibraryExW }, + { NULL, _T("KERNEL32.DLL"), "FreeLibraryA", FALSE, NULL, (PROC)new_FreeLibraryA }, + { NULL, _T("KERNEL32.DLL"), "DeleteFileA", FALSE, NULL, (PROC)new_DeleteFileA }, + { NULL, _T("XKERNEL32.DLL"), "WriteFileA", FALSE, NULL, (PROC)new_WriteFileA }, + { NULL, _T("XKERNEL32.DLL"), "lstrcmpiA", FALSE, NULL, (PROC)new_lstrcmpiA }, + { NULL, _T("WS2_32.DLL"), (LPCSTR)4, TRUE, NULL, (PROC)new_connect }, + { NULL, _T("WS2_32.DLL"), (LPCSTR)16, TRUE, NULL, (PROC)new_recv }, + { NULL, _T("WS2_32.DLL"), (LPCSTR)17, TRUE, NULL, (PROC)new_recvfrom }, + { NULL, _T("WS2_32.DLL"), (LPCSTR)19, TRUE, NULL, (PROC)new_send }, + { NULL, _T("WS2_32.DLL"), (LPCSTR)20, TRUE, NULL, (PROC)new_sendto }, + { NULL, _T("WS2_32.DLL"), (LPCSTR)52, TRUE, NULL, (PROC)new_gethostbyname }, +// { NULL, _T("USER32.DLL"), "SetWindowLongA", FALSE, NULL, (PROC)new_SetWindowLongA }, +// { NULL, _T("USER32.DLL"), "SetWindowLongW", FALSE, NULL, (PROC)new_SetWindowLongW }, + { NULL, _T("WININET.DLL"), "InternetReadFile", FALSE, NULL, (PROC)new_InternetReadFile }, + { NULL, _T("WININET.DLL"), "InternetOpenUrlA", FALSE, NULL, (PROC)new_InternetOpenUrlA }, + { NULL, _T("RSAENH.DLL"), "CPEncrypt", FALSE, NULL, (PROC)new_CPEncrypt }, + { NULL, _T("USER32.DLL"), "PeekMessageA", FALSE, NULL, (PROC)new_PeekMessageA }, +// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glGetError", FALSE, NULL, (PROC)new_glGetError }, +// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glBegin", FALSE, NULL, (PROC)new_glBegin }, +// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glEnable", FALSE, NULL, (PROC)new_glEnable }, +// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glIsEnabled", FALSE, NULL, (PROC)new_glIsEnabled }, +// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glTranslated", FALSE, NULL, (PROC)new_glTranslated }, +// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glTranslatef", FALSE, NULL, (PROC)new_glTranslatef }, +// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glTexCoord2f", FALSE, NULL, (PROC)new_glTexCoord2f }, +// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glTexCoord2fv", FALSE, NULL, (PROC)new_glTexCoord2fv }, +// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glVertex2f", FALSE, NULL, (PROC)new_glVertex2f }, +// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glVertex3f", FALSE, NULL, (PROC)new_glVertex3f }, +// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glVertex3fv", FALSE, NULL, (PROC)new_glVertex3fv }, +// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glVertex4f", FALSE, NULL, (PROC)new_glVertex4f }, +// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glVertex4fv", FALSE, NULL, (PROC)new_glVertex4fv }, +// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glVertexPointer", FALSE, NULL, (PROC)new_glVertexPointer }, +// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glTexCoordPointer", FALSE, NULL, (PROC)new_glTexCoordPointer }, +// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glNormalPointer", FALSE, NULL, (PROC)new_glNormalPointer }, +// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glDrawElements", FALSE, NULL, (PROC)new_glDrawElements }, +// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glDrawArrays", FALSE, NULL, (PROC)new_glDrawArrays }, +// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glDrawPixels", FALSE, NULL, (PROC)new_glDrawPixels }, +// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glTexImage2D", FALSE, NULL, (PROC)new_glTexImage2D }, +// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glColor3f", FALSE, NULL, (PROC)new_glColor3f }, +// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glColor3fv", FALSE, NULL, (PROC)new_glColor3fv }, +// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glColor4f", FALSE, NULL, (PROC)new_glColor4f }, +// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glColor4fv", FALSE, NULL, (PROC)new_glColor4fv }, +// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glColor4ubv", FALSE, NULL, (PROC)new_glColor4ubv }, +// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glColorPointer", FALSE, NULL, (PROC)new_glColorPointer }, +// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glViewport", FALSE, NULL, (PROC)new_glViewport }, +// { NULL, _T("UNCOMMENT"/*"OPENGL32.DLL"*/), "glFlush", FALSE, NULL, (PROC)new_glFlush }, +// { NULL, _T("UNCOMMENT"/*"GLU32.DLL"*/), "gluPerspective", FALSE, NULL, (PROC)new_gluPerspective }, +// { NULL, _T("UNCOMMENT"/*"GLU32.DLL"*/), "gluQuadricDrawStyle", FALSE, NULL, (PROC)new_gluQuadricDrawStyle }, +// { NULL, _T("UNCOMMENT"/*"GLU32.DLL"*/), "gluTessVertex", FALSE, NULL, (PROC)new_gluTessVertex }, + { NULL, NULL, NULL, FALSE, NULL, NULL } +}; + +PROC HookModuleImport(HMODULE hModule, LPCTSTR szModule, LPCSTR szImport, PROC pNewProc, BOOL bOrdinal) +{ + PIMAGE_DOS_HEADER pDOSHeader = (PIMAGE_DOS_HEADER)hModule; + + if (IsBadReadPtr(pDOSHeader, sizeof(IMAGE_DOS_HEADER)) || pDOSHeader->e_magic != IMAGE_DOS_SIGNATURE) + { + SetLastErrorEx(ERROR_INVALID_PARAMETER, SLE_ERROR); + return NULL; + } + + PIMAGE_NT_HEADERS pNTHeader = MAKEPTR (PIMAGE_NT_HEADERS, pDOSHeader, pDOSHeader->e_lfanew); + if (IsBadReadPtr(pNTHeader, sizeof(IMAGE_NT_HEADERS)) || pNTHeader->Signature != IMAGE_NT_SIGNATURE) + { + SetLastErrorEx(ERROR_INVALID_PARAMETER, SLE_ERROR); + return NULL; + } + + if (pNTHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].Size != 0) + { + PIMAGE_IMPORT_DESCRIPTOR pImportDesc = MAKEPTR(PIMAGE_IMPORT_DESCRIPTOR, pDOSHeader, pNTHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress); + while (pImportDesc && pImportDesc->Name != NULL) + { + PTSTR szImportModule = MAKEPTR(PTSTR, pDOSHeader, pImportDesc->Name); + if (szImportModule != NULL && _tcsicmp(szImportModule, szModule) == 0) + { + PIMAGE_THUNK_DATA pOrigThunk = MAKEPTR(PIMAGE_THUNK_DATA, hModule, pImportDesc->OriginalFirstThunk); + PIMAGE_THUNK_DATA pRealThunk = MAKEPTR(PIMAGE_THUNK_DATA, hModule, pImportDesc->FirstThunk); + while (pOrigThunk != NULL && pRealThunk != NULL && pOrigThunk->u1.Function != NULL && pRealThunk->u1.Function) + { + PIMAGE_IMPORT_BY_NAME pByName = MAKEPTR(PIMAGE_IMPORT_BY_NAME, hModule, pOrigThunk->u1.AddressOfData); + + if ((!bOrdinal && IMAGE_ORDINAL_FLAG != (pOrigThunk->u1.Ordinal & IMAGE_ORDINAL_FLAG) && pByName->Name[0] != 0 && stricmp((char*)pByName->Name, szImport) == 0) || (bOrdinal && IMAGE_ORDINAL(pOrigThunk->u1.Ordinal) == (DWORD)szImport)) + { + PROC pOldProc; + + /* + Retrieve memory information + */ + MEMORY_BASIC_INFORMATION mbi; + if (VirtualQuery(pRealThunk, &mbi, sizeof(MEMORY_BASIC_INFORMATION))) + { + /* + Give ourselves write access + */ + if (VirtualProtect(mbi.BaseAddress, mbi.RegionSize, PAGE_READWRITE, &mbi.Protect)) + { + /* + Store old function pointer for return value + */ + pOldProc = (PROC)pRealThunk->u1.Function; + /* + Only patch import table if the new function is different than the old one + */ + if (pNewProc != NULL && pOldProc != pNewProc) pRealThunk->u1.Function = (DWORD)pNewProc; + + /* + Restore old protection value + */ + DWORD dwOldProtect; + VirtualProtect(mbi.BaseAddress, mbi.RegionSize, mbi.Protect, &dwOldProtect); + } + +// TCHAR szModuleFileName[MAX_PATH]; +// GetModuleFileName(hModule, szModuleFileName, sizeof(szModuleFileName)); +// dprintf(_T("HOOKED [%s => %s]\n"), szImport, szModuleFileName); +// return pOldProc; + } + } + pOrigThunk++; + pRealThunk++; + } + } + pImportDesc++; + } + } + + return NULL; +} + +/////////////////////////////////////////////////////////////////////////////////////////// +// +// Retrieve the loaded modules for the specified process +// +// dwProccessID Process ID of the process whose loaded module list you wish to retrive. +// Specify 0 for the current process. +// +// pModules Pointer to an array of MODULEINFO structures to store the module list. +// Can be NULL. +// +// puiCount Specify 0 to retrieve the module count otherwise the maximum number of +// entries in the pModule array to return. +// +// Return Value +// +// Returns FALSE if failed +// +/////////////////////////////////////////////////////////////////////////////////////////// +BOOL GetModuleList(DWORD dwProcessID, PMODULEENTRY32 pModules, LPUINT puiCount) +{ +// dprintf(_T("[GetModuleList]\n")); + + HANDLE hSnapshot; + MODULEENTRY32 cME32; + UINT uiCount = 0; + + if (puiCount == NULL) + { + SetLastErrorEx(ERROR_INVALID_PARAMETER, SLE_ERROR); + return FALSE; + } + + hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, dwProcessID); + if (hSnapshot == INVALID_HANDLE_VALUE) + { + return FALSE; + } + + ZeroMemory(&cME32, sizeof(cME32)); + cME32.dwSize = sizeof(MODULEENTRY32); + if (Module32First(hSnapshot, &cME32) == TRUE) + { + do + { + if (pModules != NULL && *puiCount) + { + _tcsncpy(pModules[uiCount].szModule, cME32.szModule, MAX_PATH); + pModules[uiCount].hModule = cME32.hModule; + } + uiCount++; + } while (Module32Next(hSnapshot, &cME32) == TRUE && (*puiCount == 0 || uiCount < *puiCount)); + } + + CloseHandle(hSnapshot); + + *puiCount = uiCount; + + return TRUE; +} + +/////////////////////////////////////////////////////////////////////////////////////////// +// +// Save pointers to old functions +// +/////////////////////////////////////////////////////////////////////////////////////////// +void SaveImportHooks() +{ +// dprintf(_T("[SaveImportHooks]\n")); + + INT i; + + for (i = 0; pAPIHooks[i].szModule; i++) + { + /* + Only store pointers for any functions we haven't taken care of yet so this may be called multiple times + */ + if (pAPIHooks[i].pOldProc == NULL) + { + pAPIHooks[i].pOldProc = GetProcAddress(GetModuleHandle(pAPIHooks[i].szModule), (LPCSTR)pAPIHooks[i].szImport); +// dprintf(_T("Saved import for %s(%s) at 0x%08X\n"), pAPIHooks[i].szModule, pAPIHooks[i].szImport, pAPIHooks[i].pOldProc); + } + } +} + +/////////////////////////////////////////////////////////////////////////////////////////// +// +// Patch import table of all loaded modules +// +/////////////////////////////////////////////////////////////////////////////////////////// +void InstallImportHooks() +{ +// dprintf(_T("[InstallImportHooks]\n")); + + /* + Retrieve number of loaded modules + */ + UINT uiCount = 0; + INT i, j; + if (GetModuleList(0, NULL, &uiCount)) + { + /* + Allocate temporary table of loaded modules + */ + PMODULEENTRY32 pModules = (PMODULEENTRY32)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, uiCount*sizeof(MODULEENTRY32)); + if (pModules != NULL) + { + /* + Retrieve table of loaded modules + */ + if (GetModuleList(0, pModules, &uiCount)) + { + /* + Loop through each module and patch its import table + */ + for (i = 0; i < (INT)uiCount; i++) + { + /* + Loop through each API hook and patch import table for this module + HookModuleImport() takes care of dupe checking + */ + for (j = 0; pAPIHooks[j].szModule; j++) + { + if (_tcsicmp(pModules[i].szModule, _T("SNOWFLAKE.DLL")) && _tcsicmp(pModules[i].szModule, _T("FMOD.DLL")) && /*_tcsicmp(pModules[i].szModule, _T("NEWVIEW.EXE")) &&*/ _tcsicmp(pModules[i].szModule, pAPIHooks[j].szModule) && pAPIHooks[j].pNewProc != NULL && !IsBadCodePtr(pAPIHooks[j].pNewProc)) + { + HookModuleImport(pModules[i].hModule, pAPIHooks[j].szModule, pAPIHooks[j].szImport, pAPIHooks[j].pNewProc, pAPIHooks[j].bOrdinal); + } + } + } + } + GlobalFree(pModules); + } + } +} + +/////////////////////////////////////////////////////////////////////////////////////////// +// +// Removes the import table for all loaded modules back to the original saved functions +// +/////////////////////////////////////////////////////////////////////////////////////////// +void RemoveImportHooks() +{ + dprintf(_T("[RemoveImportHooks]\n")); + + /* + Retrieve number of loaded modules + */ + UINT uiCount = 0; + INT i, j; + if (GetModuleList(0, NULL, &uiCount)) + { + /* + Allocate temporary table of loaded modules + */ + PMODULEENTRY32 pModules = (PMODULEENTRY32)GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, uiCount*sizeof(MODULEENTRY32)); + if (pModules != NULL) + { + /* + Retrieve table of loaded modules + */ + if (GetModuleList(0, pModules, &uiCount)) + { + /* + Loop through each module and patch its import table + */ + for (i = 0; i < (INT)uiCount; i++) + { + /* + Loop through each API hook and restore import table for this module + */ +// dprintf("RESTORE [%s]\n", pModules[i].szModule); + for (j = 0; pAPIHooks[j].szModule; j++) + { + if (_tcsicmp(pModules[i].szModule, _T("SNOWFLAKE.DLL")) && /*_tcsicmp(pModules[i].szModule, _T("NEWVIEW.EXE")) &&*/ _tcsicmp(pModules[i].szModule, pAPIHooks[j].szModule) && pAPIHooks[j].pOldProc != NULL && !IsBadCodePtr(pAPIHooks[j].pOldProc)) + { +// dprintf(_T("REMOVE [%s => %s]\n"), pAPIHooks[j].szImport, pModules[i].szModule); + HookModuleImport(pModules[i].hModule, pAPIHooks[j].szModule, pAPIHooks[j].szImport, pAPIHooks[j].pOldProc, pAPIHooks[j].bOrdinal); + } + } + } + + for (j = 0; pAPIHooks[j].szModule; j++) + { + pAPIHooks[j].pOldProc = NULL; + } + } + GlobalFree(pModules); + } + } +} + +BOOL APIENTRY DllMain( HANDLE hModule, + DWORD ul_reason_for_call, + LPVOID lpReserved + ) +{ + if (ul_reason_for_call == DLL_PROCESS_ATTACH) + { + TCHAR szPath[MAX_PATH]; + + g_hinstDLL = (HINSTANCE)hModule; + _Module.Init(NULL, g_hinstDLL); + DisableThreadLibraryCalls(g_hinstDLL); + + if (GetModuleFileName(GetModuleHandle(0), szPath, MAX_PATH)) + { + _tcsupr(szPath); + + if (_tcsstr(szPath, _T("\\SECONDLIFE.EXE"))) + { + if (!g_pConfig) + g_pConfig = new CConfig(); + +#ifdef ECHO + AllocConsole(); + + if (!fpLog) + fpLog = fopen(g_pConfig->m_pSnowcrashTxtPath, "w"); +#endif + dprintf(_T("[snowflake] %s\n"), szPath); + + decomm(); + + SaveImportHooks(); + InstallImportHooks(); + } + } + } else if (ul_reason_for_call == DLL_PROCESS_DETACH) + { + RemoveSLHooks(); + RemoveImportHooks(); +#ifdef ECHO + FreeConsole(); + + if (fpLog) + { + fclose(fpLog); + fpLog = NULL; + } +#endif + _Module.Term(); + } + + return TRUE; +} + +LRESULT CALLBACK CBTHookProc(int nCode, WPARAM wParam, LPARAM lParam) +{ + switch(nCode) + { + case HCBT_ACTIVATE: + { + if (!g_pMainFrm) + { + TCHAR szClass[128]; + HWND hwnd = (HWND)wParam; + + if (GetClassName(hwnd, szClass, sizeof(szClass))) + { + if (_tcsicmp(szClass, _T("Second Life")) == 0) + { + TCHAR szTitle[256]; + GetWindowText(hwnd, szTitle, sizeof(szTitle)); + + if (_tcsstr(szTitle, "Second Life")) + { + dprintf(_T(">>> [%s][%s]\n"), szClass, szTitle); + InstallSLHooks(hwnd); + } + } + else + dprintf(_T(">>> [%s]\n"), szClass); + } + } + } + break; + + case HCBT_CREATEWND: + { + TCHAR szClass[128]; + HWND hwnd = (HWND)wParam; + LPCBT_CREATEWND lpcbt = (LPCBT_CREATEWND)lParam; + + if (GetClassName(hwnd, szClass, sizeof(szClass))) + { + //dprintf(_T(">>> [%s]\n"), szClass); + //if (_tcsicmp(szClass, _T("OpenGL")) == 0) + //{ + //dprintf(_T("[snowflake] SL window created\n")); + //InstallSLHooks(hwnd); + //} + } + } + break; + + case HCBT_DESTROYWND: + { + TCHAR szClass[128]; + HWND hwnd = (HWND)wParam; + + if (GetClassName(hwnd, szClass, sizeof(szClass))) + { + if (g_pMainFrm && g_pMainFrm->m_hWnd == hwnd) + { + dprintf(_T("[snowflake] SL window destroyed\n")); + RemoveSLHooks(); + } + } + } + break; + } + return ::CallNextHookEx(h_hCBTHook, nCode, wParam, lParam); +} + +SNOWFLAKE_API bool InstallSystemHook(void) +{ +// dprintf(_T("[InstallSystemHook]\n")); + + if (h_hCBTHook == NULL) + { + h_hCBTHook = ::SetWindowsHookEx(WH_CBT, CBTHookProc, g_hinstDLL, 0); + } + + return (h_hCBTHook != NULL); +} + +SNOWFLAKE_API BOOL RemoveSystemHook() +{ + dprintf(_T("[RemoveSystemHook]\n")); + + if (h_hCBTHook != NULL) + { + if (UnhookWindowsHookEx(h_hCBTHook)) + { + h_hCBTHook = NULL; + + return TRUE; + } + } + + return FALSE; +} + +bool InstallSLHooks(HWND hwnd) +{ + _Module.AddMessageLoop(&g_msgLoop); + + if (g_pMainFrm == NULL) + { + g_pMainFrm = new CMainFrame(); + + if (g_pMainFrm->SubclassWindow(hwnd)) + { + return true; + } + } + + return false; +} + +bool RemoveSLHooks() +{ + if (g_pMainFrm != NULL) + { + dprintf(_T("RemoveSLHooks MainFrm\n")); + if (g_pMainFrm->m_hWnd != NULL && ::IsWindow(*g_pMainFrm)) + { + dprintf(_T("RemoveSLHooks MainFrm Unsub\n")); + g_pMainFrm->UnsubclassWindow(TRUE); + g_pMainFrm->m_hWnd = NULL; + } else + g_pMainFrm->m_hWnd = NULL; + delete(g_pMainFrm); + g_pMainFrm = NULL; + + return true; + } + + return false; +} diff --git a/applications/snowcrash/snowflake/snowflake.h b/applications/snowcrash/snowflake/snowflake.h index 6923cdc9..021276f2 100644 --- a/applications/snowcrash/snowflake/snowflake.h +++ b/applications/snowcrash/snowflake/snowflake.h @@ -1,14 +1,14 @@ -// The following ifdef block is the standard way of creating macros which make exporting -// from a DLL simpler. All files within this DLL are compiled with the SNOWFLAKE_EXPORTS -// symbol defined on the command line. this symbol should not be defined on any project -// that uses this DLL. This way any other project whose source files include this file see -// SNOWFLAKE_API functions as being imported from a DLL, whereas this DLL sees symbols -// defined with this macro as being exported. -#ifdef SNOWFLAKE_EXPORTS -#define SNOWFLAKE_API __declspec(dllexport) -#else -#define SNOWFLAKE_API __declspec(dllimport) -#endif - -SNOWFLAKE_API bool InstallSystemHook(void); -SNOWFLAKE_API BOOL RemoveSystemHook(); +// The following ifdef block is the standard way of creating macros which make exporting +// from a DLL simpler. All files within this DLL are compiled with the SNOWFLAKE_EXPORTS +// symbol defined on the command line. this symbol should not be defined on any project +// that uses this DLL. This way any other project whose source files include this file see +// SNOWFLAKE_API functions as being imported from a DLL, whereas this DLL sees symbols +// defined with this macro as being exported. +#ifdef SNOWFLAKE_EXPORTS +#define SNOWFLAKE_API __declspec(dllexport) +#else +#define SNOWFLAKE_API __declspec(dllimport) +#endif + +SNOWFLAKE_API bool InstallSystemHook(void); +SNOWFLAKE_API BOOL RemoveSystemHook(); diff --git a/applications/snowcrash/snowflake/snowflake.vcproj b/applications/snowcrash/snowflake/snowflake.vcproj index bc98088f..b942c4dc 100644 --- a/applications/snowcrash/snowflake/snowflake.vcproj +++ b/applications/snowcrash/snowflake/snowflake.vcproj @@ -1,219 +1,219 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/applications/snowcrash/snowflake/stdafx.cpp b/applications/snowcrash/snowflake/stdafx.cpp index bc93367e..a061f93b 100644 --- a/applications/snowcrash/snowflake/stdafx.cpp +++ b/applications/snowcrash/snowflake/stdafx.cpp @@ -1,67 +1,67 @@ -// stdafx.cpp : source file that includes just the standard includes -// snowflake.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - -#ifdef ECHO -FILE *fpLog = NULL; -#endif - -#ifdef ECHODEBUG -void dprintf(TCHAR *format, ...) -{ - LPTSTR pBuffer = new TCHAR[8192]; - - if (pBuffer != NULL) - { - va_list args; - DWORD dwWrote; - - va_start(args, format); - _vsntprintf(pBuffer, 8192, format, args); - va_end(args); - - WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), pBuffer, (DWORD)_tcslen(pBuffer), &dwWrote, NULL); - - if (fpLog) - { - fwrite(pBuffer, 1, _tcslen(pBuffer), fpLog); - fflush(fpLog); - } - - delete [] pBuffer; - } -} -#else -#define dprintf -#endif - -#ifdef ECHONORMAL -void myprintf(TCHAR *format, ...) -{ - LPTSTR pBuffer = new TCHAR[8192]; - - if (pBuffer != NULL) - { - va_list args; - DWORD dwWrote; - - va_start(args, format); - _vsntprintf(pBuffer, 8192, format, args); - va_end(args); - - WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), pBuffer, (DWORD)_tcslen(pBuffer), &dwWrote, NULL); - - if (fpLog) - { - fwrite(pBuffer, 1, _tcslen(pBuffer), fpLog); - fflush(fpLog); - } - - delete [] pBuffer; - } -} -#else -#define myprintf -#endif +// stdafx.cpp : source file that includes just the standard includes +// snowflake.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + +#ifdef ECHO +FILE *fpLog = NULL; +#endif + +#ifdef ECHODEBUG +void dprintf(TCHAR *format, ...) +{ + LPTSTR pBuffer = new TCHAR[8192]; + + if (pBuffer != NULL) + { + va_list args; + DWORD dwWrote; + + va_start(args, format); + _vsntprintf(pBuffer, 8192, format, args); + va_end(args); + + WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), pBuffer, (DWORD)_tcslen(pBuffer), &dwWrote, NULL); + + if (fpLog) + { + fwrite(pBuffer, 1, _tcslen(pBuffer), fpLog); + fflush(fpLog); + } + + delete [] pBuffer; + } +} +#else +#define dprintf +#endif + +#ifdef ECHONORMAL +void myprintf(TCHAR *format, ...) +{ + LPTSTR pBuffer = new TCHAR[8192]; + + if (pBuffer != NULL) + { + va_list args; + DWORD dwWrote; + + va_start(args, format); + _vsntprintf(pBuffer, 8192, format, args); + va_end(args); + + WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE), pBuffer, (DWORD)_tcslen(pBuffer), &dwWrote, NULL); + + if (fpLog) + { + fwrite(pBuffer, 1, _tcslen(pBuffer), fpLog); + fflush(fpLog); + } + + delete [] pBuffer; + } +} +#else +#define myprintf +#endif diff --git a/applications/snowcrash/snowflake/stdafx.h b/applications/snowcrash/snowflake/stdafx.h index cb9977e3..70dfe3a9 100644 --- a/applications/snowcrash/snowflake/stdafx.h +++ b/applications/snowcrash/snowflake/stdafx.h @@ -1,106 +1,106 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#pragma once - - -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers -// Windows Header Files: -#include -#include -#include -#include -#include -#include - -extern CAppModule _Module; - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include "resource.h" - -//----------------------------------------------------------------------------- -// Miscellaneous helper functions -//----------------------------------------------------------------------------- -#define SAFE_FREE(p) { if(p) { free (p); (p)=NULL; } } -#define SAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } } -#define SAFE_DELETE_ARRAY(p) { if(p) { delete[] (p); (p)=NULL; } } -#define SAFE_RELEASE(p) { if(p) { (p)->Release(); (p)=NULL; } } - -#ifdef _DEBUG -#define ECHODEBUG -#define ECHONORMAL -#define ECHO -#else -#undef ECHODEBUG -#undef ECHONORMAL -#undef ECHO -#endif - -#ifdef ECHODEBUG -void dprintf(TCHAR *format, ...); -#else -#define dprintf -#endif - -#ifdef ECHONORMAL -void myprintf(TCHAR *format, ...); -#else -#define myprintf -#endif - -extern FILE *fpLog; - -// Bitmasks -#define BM_FLAG1 0x00000001 -#define BM_FLAG2 0x00000002 -#define BM_FLAG3 0x00000004 -#define BM_FLAG4 0x00000008 -#define BM_FLAG5 0x00000010 -#define BM_FLAG6 0x00000020 -#define BM_FLAG7 0x00000040 -#define BM_FLAG8 0x00000080 -#define BM_FLAG9 0x00000100 -#define BM_FLAG10 0x00000200 -#define BM_FLAG11 0x00000400 -#define BM_FLAG12 0x00000800 -#define BM_FLAG13 0x00001000 -#define BM_FLAG14 0x00002000 -#define BM_FLAG15 0x00004000 -#define BM_FLAG16 0x00008000 -#define BM_FLAG18 0x00010000 -#define BM_FLAG19 0x00020000 -#define BM_FLAG20 0x00040000 -#define BM_FLAG21 0x00080000 -#define BM_FLAGALL 0x000fffff - -#define MAP_NOT_SAFE 0x00000001 -#define MAP_UNKNOWN1 0x00000002 -#define MAP_UNKNOWN2 0x00000004 -#define MAP_UNKNOWN3 0x00000020 -#define MAP_UNKNOWN4 0x00000040 -#define MAP_UNKNOWN5 0x00000080 -#define MAP_SANDBOX 0x00000100 -#define MAP_UNKNOWN6 0x00008000 -#define MAP_UNKNOWN7 0x00010000 - -#define MSG_APPENDED_ACKS 0x10 -#define MSG_RESENT 0x20 -#define MSG_RELIABLE 0x40 -#define MSG_ZEROCODED 0x80 - -#define MSG_FREQ_HIGH 0x0000 -#define MSG_FREQ_MED 0xFF00 -#define MSG_FREQ_LOW 0xFFFF - +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#pragma once + + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +// Windows Header Files: +#include +#include +#include +#include +#include +#include + +extern CAppModule _Module; + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include "resource.h" + +//----------------------------------------------------------------------------- +// Miscellaneous helper functions +//----------------------------------------------------------------------------- +#define SAFE_FREE(p) { if(p) { free (p); (p)=NULL; } } +#define SAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } } +#define SAFE_DELETE_ARRAY(p) { if(p) { delete[] (p); (p)=NULL; } } +#define SAFE_RELEASE(p) { if(p) { (p)->Release(); (p)=NULL; } } + +#ifdef _DEBUG +#define ECHODEBUG +#define ECHONORMAL +#define ECHO +#else +#undef ECHODEBUG +#undef ECHONORMAL +#undef ECHO +#endif + +#ifdef ECHODEBUG +void dprintf(TCHAR *format, ...); +#else +#define dprintf +#endif + +#ifdef ECHONORMAL +void myprintf(TCHAR *format, ...); +#else +#define myprintf +#endif + +extern FILE *fpLog; + +// Bitmasks +#define BM_FLAG1 0x00000001 +#define BM_FLAG2 0x00000002 +#define BM_FLAG3 0x00000004 +#define BM_FLAG4 0x00000008 +#define BM_FLAG5 0x00000010 +#define BM_FLAG6 0x00000020 +#define BM_FLAG7 0x00000040 +#define BM_FLAG8 0x00000080 +#define BM_FLAG9 0x00000100 +#define BM_FLAG10 0x00000200 +#define BM_FLAG11 0x00000400 +#define BM_FLAG12 0x00000800 +#define BM_FLAG13 0x00001000 +#define BM_FLAG14 0x00002000 +#define BM_FLAG15 0x00004000 +#define BM_FLAG16 0x00008000 +#define BM_FLAG18 0x00010000 +#define BM_FLAG19 0x00020000 +#define BM_FLAG20 0x00040000 +#define BM_FLAG21 0x00080000 +#define BM_FLAGALL 0x000fffff + +#define MAP_NOT_SAFE 0x00000001 +#define MAP_UNKNOWN1 0x00000002 +#define MAP_UNKNOWN2 0x00000004 +#define MAP_UNKNOWN3 0x00000020 +#define MAP_UNKNOWN4 0x00000040 +#define MAP_UNKNOWN5 0x00000080 +#define MAP_SANDBOX 0x00000100 +#define MAP_UNKNOWN6 0x00008000 +#define MAP_UNKNOWN7 0x00010000 + +#define MSG_APPENDED_ACKS 0x10 +#define MSG_RESENT 0x20 +#define MSG_RELIABLE 0x40 +#define MSG_ZEROCODED 0x80 + +#define MSG_FREQ_HIGH 0x0000 +#define MSG_FREQ_MED 0xFF00 +#define MSG_FREQ_LOW 0xFFFF + #define REGION_MULTIPLIER 4294967296 \ No newline at end of file diff --git a/builds/libsl_office.prims b/builds/libsl_office.prims index e1516c7a..73b2d350 100644 --- a/builds/libsl_office.prims +++ b/builds/libsl_office.prims @@ -1,9560 +1,9560 @@ - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -FALSE -FALSE -FALSE - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FALSE +FALSE +FALSE + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libsecondlife-cs/AssemblyInfo.cs b/libsecondlife-cs/AssemblyInfo.cs index 9a6f924c..53f2eb42 100644 --- a/libsecondlife-cs/AssemblyInfo.cs +++ b/libsecondlife-cs/AssemblyInfo.cs @@ -1,58 +1,58 @@ -using System.Reflection; -using System.Runtime.CompilerServices; - -// -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -// -[assembly: AssemblyTitle("libsecondlife")] -[assembly: AssemblyDescription("Networking layer for the Second Life world")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Second Life Reverse Engineering Team")] -[assembly: AssemblyProduct("")] -[assembly: AssemblyCopyright("(c) 2006 Second Life Reverse Engineering Team")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Revision and Build Numbers -// by using the '*' as shown below: - -[assembly: AssemblyVersion("0.0.5.0")] - -// -// In order to sign your assembly you must specify a key to use. Refer to the -// Microsoft .NET Framework documentation for more information on assembly signing. -// -// Use the attributes below to control which key is used for signing. -// -// Notes: -// (*) If no key is specified, the assembly is not signed. -// (*) KeyName refers to a key that has been installed in the Crypto Service -// Provider (CSP) on your machine. KeyFile refers to a file which contains -// a key. -// (*) If the KeyFile and the KeyName values are both specified, the -// following processing occurs: -// (1) If the KeyName can be found in the CSP, that key is used. -// (2) If the KeyName does not exist and the KeyFile does exist, the key -// in the KeyFile is installed into the CSP and used. -// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. -// When specifying the KeyFile, the location of the KeyFile should be -// relative to the project output directory which is -// %Project Directory%\obj\. For example, if your KeyFile is -// located in the project directory, you would specify the AssemblyKeyFile -// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] -// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework -// documentation for more information on this. -// -[assembly: AssemblyDelaySign(false)] -[assembly: AssemblyKeyFile("")] -[assembly: AssemblyKeyName("")] +using System.Reflection; +using System.Runtime.CompilerServices; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly: AssemblyTitle("libsecondlife")] +[assembly: AssemblyDescription("Networking layer for the Second Life world")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Second Life Reverse Engineering Team")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("(c) 2006 Second Life Reverse Engineering Team")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly: AssemblyVersion("0.0.5.0")] + +// +// In order to sign your assembly you must specify a key to use. Refer to the +// Microsoft .NET Framework documentation for more information on assembly signing. +// +// Use the attributes below to control which key is used for signing. +// +// Notes: +// (*) If no key is specified, the assembly is not signed. +// (*) KeyName refers to a key that has been installed in the Crypto Service +// Provider (CSP) on your machine. KeyFile refers to a file which contains +// a key. +// (*) If the KeyFile and the KeyName values are both specified, the +// following processing occurs: +// (1) If the KeyName can be found in the CSP, that key is used. +// (2) If the KeyName does not exist and the KeyFile does exist, the key +// in the KeyFile is installed into the CSP and used. +// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. +// When specifying the KeyFile, the location of the KeyFile should be +// relative to the project output directory which is +// %Project Directory%\obj\. For example, if your KeyFile is +// located in the project directory, you would specify the AssemblyKeyFile +// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] +// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework +// documentation for more information on this. +// +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] +[assembly: AssemblyKeyName("")] diff --git a/libsecondlife-cs/AssetSystem/Asset.cs b/libsecondlife-cs/AssetSystem/Asset.cs index 694f23c0..36ef9862 100644 --- a/libsecondlife-cs/AssetSystem/Asset.cs +++ b/libsecondlife-cs/AssetSystem/Asset.cs @@ -1,93 +1,93 @@ -/* - * Copyright (c) 2006, Second Life Reverse Engineering Team - * All rights reserved. - * - * - Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - Neither the name of the Second Life Reverse Engineering Team nor the names - * of its contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -using System; - -using libsecondlife; - -namespace libsecondlife.AssetSystem -{ - /// - /// Summary description for Asset. - /// - public class Asset - { - public const sbyte ASSET_TYPE_NOTECARD = 7; - public const sbyte ASSET_TYPE_IMAGE = 0; - - public LLUUID AssetID; - - public sbyte Type; - public bool Tempfile; - - - private byte[] assetdata; - public byte[] AssetData - { - get { return assetdata; } - set - { - assetdata = value; - } - } - - - /// - /// - /// - /// - /// - /// - public Asset(LLUUID assetID, sbyte type, bool tempfile, byte[] assetData) - { - AssetID = assetID; - Type = (sbyte)type; - Tempfile = tempfile; - AssetData = assetData; - } - - /// - /// - /// - /// - /// - public Asset(LLUUID assetID, sbyte type, byte[] assetData) - { - AssetID = assetID; - Type = (sbyte)type; - Tempfile = false; - AssetData = assetData; - } - - /// - /// Return this asset's data as a pretty printable string. - /// - public string AssetDataToString() - { - return Helpers.FieldToString((byte[])AssetData); - } - } -} +/* + * Copyright (c) 2006, Second Life Reverse Engineering Team + * All rights reserved. + * + * - Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Neither the name of the Second Life Reverse Engineering Team nor the names + * of its contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +using System; + +using libsecondlife; + +namespace libsecondlife.AssetSystem +{ + /// + /// Summary description for Asset. + /// + public class Asset + { + public const sbyte ASSET_TYPE_NOTECARD = 7; + public const sbyte ASSET_TYPE_IMAGE = 0; + + public LLUUID AssetID; + + public sbyte Type; + public bool Tempfile; + + + private byte[] assetdata; + public byte[] AssetData + { + get { return assetdata; } + set + { + assetdata = value; + } + } + + + /// + /// + /// + /// + /// + /// + public Asset(LLUUID assetID, sbyte type, bool tempfile, byte[] assetData) + { + AssetID = assetID; + Type = (sbyte)type; + Tempfile = tempfile; + AssetData = assetData; + } + + /// + /// + /// + /// + /// + public Asset(LLUUID assetID, sbyte type, byte[] assetData) + { + AssetID = assetID; + Type = (sbyte)type; + Tempfile = false; + AssetData = assetData; + } + + /// + /// Return this asset's data as a pretty printable string. + /// + public string AssetDataToString() + { + return Helpers.FieldToString((byte[])AssetData); + } + } +} diff --git a/libsecondlife-cs/AssetSystem/AssetImage.cs b/libsecondlife-cs/AssetSystem/AssetImage.cs index 2f39c990..2adbc3a4 100644 --- a/libsecondlife-cs/AssetSystem/AssetImage.cs +++ b/libsecondlife-cs/AssetSystem/AssetImage.cs @@ -1,58 +1,58 @@ -/* - * Copyright (c) 2006, Second Life Reverse Engineering Team - * All rights reserved. - * - * - Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - Neither the name of the Second Life Reverse Engineering Team nor the names - * of its contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -using System; - -using libsecondlife; - -namespace libsecondlife.AssetSystem -{ - /// - /// Summary description for AssetNotecard. - /// - public class AssetImage : Asset - { - public byte[] J2CData - { - get - { - return base.AssetData; - } - } - - /// - /// - /// - /// - public AssetImage(LLUUID assetID, byte[] assetData) - : base(assetID, Asset.ASSET_TYPE_IMAGE, false, assetData) - { - } - - - - } -} +/* + * Copyright (c) 2006, Second Life Reverse Engineering Team + * All rights reserved. + * + * - Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Neither the name of the Second Life Reverse Engineering Team nor the names + * of its contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +using System; + +using libsecondlife; + +namespace libsecondlife.AssetSystem +{ + /// + /// Summary description for AssetNotecard. + /// + public class AssetImage : Asset + { + public byte[] J2CData + { + get + { + return base.AssetData; + } + } + + /// + /// + /// + /// + public AssetImage(LLUUID assetID, byte[] assetData) + : base(assetID, Asset.ASSET_TYPE_IMAGE, false, assetData) + { + } + + + + } +} diff --git a/libsecondlife-cs/AssetSystem/AssetManager.cs b/libsecondlife-cs/AssetSystem/AssetManager.cs index f2446df9..98db53fd 100644 --- a/libsecondlife-cs/AssetSystem/AssetManager.cs +++ b/libsecondlife-cs/AssetSystem/AssetManager.cs @@ -1,338 +1,338 @@ -/* - * Copyright (c) 2006, Second Life Reverse Engineering Team - * All rights reserved. - * - * - Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - Neither the name of the Second Life Reverse Engineering Team nor the names - * of its contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections; - -using libsecondlife; - -using libsecondlife.InventorySystem; - -using libsecondlife.Packets; - -namespace libsecondlife.AssetSystem -{ - /// - /// Summary description for AssetManager. - /// - public class AssetManager - { - private const bool DEBUG_PACKETS = true; - - - public const int SINK_FEE_IMAGE = 1; - - private SecondLife slClient; - - private TransferRequest curUploadRequest = null; - private Hashtable htDownloadRequests = new Hashtable(); - - private class TransferRequest - { - public bool Completed; - public bool Status; - public string StatusMsg; - - public int Size; - public int Received; - public uint LastPacketTime; - public uint LastPacketNumSent; - public byte[] AssetData; - - public LLUUID TransactionID; - public LLUUID AssetID; - } - - /// - /// - /// - internal AssetManager(SecondLife client) - { - slClient = client; - - // Used to upload small assets, or as an initial start packet for large transfers - PacketCallback AssetUploadCompleteCallback = new PacketCallback(AssetUploadCompleteCallbackHandler); - slClient.Network.RegisterCallback(PacketType.AssetUploadComplete, AssetUploadCompleteCallback); - - // Transfer Packets for downloading large assets - PacketCallback TransferInfoCallback = new PacketCallback(TransferInfoCallbackHandler); - slClient.Network.RegisterCallback(PacketType.TransferInfo, TransferInfoCallback); - - PacketCallback TransferPacketCallback = new PacketCallback(TransferPacketCallbackHandler); - slClient.Network.RegisterCallback(PacketType.TransferPacket, TransferPacketCallback); - - // XFer packets for uploading large assets - PacketCallback ConfirmXferPacketCallback = new PacketCallback(ConfirmXferPacketCallbackHandler); - slClient.Network.RegisterCallback(PacketType.ConfirmXferPacket, ConfirmXferPacketCallback); - - PacketCallback RequestXferCallback = new PacketCallback(RequestXferCallbackHandler); - slClient.Network.RegisterCallback(PacketType.RequestXfer, RequestXferCallback); - - } - - - /// - /// Handle the appropriate sink fee assoiacted with an asset upload - /// - /// - public void SinkFee(int sinkType) - { - switch( sinkType ) - { - case SINK_FEE_IMAGE: - slClient.Avatar.GiveMoney( new LLUUID(), 10, "Image Upload" ); - break; - default: - throw new Exception("AssetManager: Unknown sinktype (" + sinkType + ")"); - } - } - - /// - /// Upload an asset to Second Life - /// - /// The asset to be uploaded - /// The Asset ID of the completed upload - public LLUUID UploadAsset(Asset asset) - { - if (curUploadRequest != null) - { - throw new Exception("An existing asset upload is currently in-progress."); - } - - Packet packet; - curUploadRequest = new TransferRequest(); - curUploadRequest.Completed = false; - curUploadRequest.TransactionID = LLUUID.GenerateUUID(); - - if( asset.AssetData.Length > 500 ) - { - packet = AssetPacketHelpers.AssetUploadRequestHeaderOnly(asset, curUploadRequest.TransactionID); - slClient.Network.SendPacket(packet); - if (DEBUG_PACKETS) { Console.WriteLine(packet); } - curUploadRequest.AssetData = asset.AssetData; - } - else - { - packet = AssetPacketHelpers.AssetUploadRequest(asset, curUploadRequest.TransactionID); - slClient.Network.SendPacket(packet); - if (DEBUG_PACKETS) { Console.WriteLine(packet); } - } - - while( curUploadRequest.Completed == false ) - { - slClient.Tick(); - } - - if (curUploadRequest.Status == false) - { - throw new Exception(curUploadRequest.StatusMsg); - } else { - if( asset.Type == Asset.ASSET_TYPE_IMAGE ) - { - SinkFee( SINK_FEE_IMAGE ); - } - - asset.AssetID = curUploadRequest.AssetID; - - return asset.AssetID; - } - } - - /// - /// Get the Asset data for an item - /// - /// - public void GetInventoryAsset( InventoryItem item ) - { - LLUUID TransferID = LLUUID.GenerateUUID(); - - TransferRequest tr = new TransferRequest(); - tr.Completed = false; - tr.Size = int.MaxValue; // Number of bytes expected - tr.Received = 0; // Number of bytes received - tr.LastPacketTime = Helpers.GetUnixTime(); // last time we recevied a packet for this request - - htDownloadRequests[TransferID] = tr; - - Packet packet = AssetPacketHelpers.TransferRequest(slClient.Network.SessionID, slClient.Network.AgentID, TransferID, item ); - slClient.Network.SendPacket(packet); - if (DEBUG_PACKETS) { Console.WriteLine(packet); } - - while( tr.Completed == false ) - { - slClient.Tick(); - } - - item.SetAssetData( tr.AssetData ); - } - - private void AssetUploadCompleteCallbackHandler(Packet packet, Simulator simulator) - { - if (DEBUG_PACKETS) { Console.WriteLine(packet); } - Packets.AssetUploadCompletePacket reply = (AssetUploadCompletePacket)packet; - - curUploadRequest.AssetID = reply.AssetBlock.UUID; - bool Success = reply.AssetBlock.Success; - - if( Success ) - { - curUploadRequest.Completed = true; - curUploadRequest.Status = true; - curUploadRequest.StatusMsg = "Success"; - } - else - { - curUploadRequest.Completed = true; - curUploadRequest.Status = false; - curUploadRequest.StatusMsg = "Server returned failed"; - } - } - - private void RequestXferCallbackHandler(Packet packet, Simulator simulator) - { - if (DEBUG_PACKETS) { Console.WriteLine(packet); } - RequestXferPacket reply = (RequestXferPacket)packet; - - ulong XferID = reply.XferID.ID; - LLUUID AssetID = reply.XferID.VFileID; - - // Setup to send the first packet - curUploadRequest.LastPacketNumSent = 0; - - byte[] packetData = new byte[1004]; - - // Prefix the first Xfer packet with the data length - // FIXME: Apply endianness patch - Array.Copy(BitConverter.GetBytes((int)curUploadRequest.AssetData.Length), 0, packetData, 0, 4); - Array.Copy(curUploadRequest.AssetData, 0, packetData, 4, 1000); - - packet = AssetPacketHelpers.SendXferPacket(XferID, packetData, 0); - slClient.Network.SendPacket(packet); - if (DEBUG_PACKETS) { Console.WriteLine(packet); } - } - - private void ConfirmXferPacketCallbackHandler(Packet packet, Simulator simulator) - { - if (DEBUG_PACKETS) { Console.WriteLine(packet); } - ConfirmXferPacketPacket reply = (ConfirmXferPacketPacket)packet; - - ulong XferID = reply.XferID.ID; - uint PacketNumConfirmed = reply.XferID.Packet; - - if (PacketNumConfirmed == curUploadRequest.LastPacketNumSent) - { - curUploadRequest.LastPacketNumSent += 1; - - uint i = curUploadRequest.LastPacketNumSent; - int numPackets = curUploadRequest.AssetData.Length / 1000; - - if (i < numPackets) - { - byte[] packetData = new byte[1000]; - Array.Copy(curUploadRequest.AssetData, i * 1000, packetData, 0, 1000); - - packet = AssetPacketHelpers.SendXferPacket(XferID, packetData, i); - slClient.Network.SendPacket(packet); - if (DEBUG_PACKETS) { Console.WriteLine(packet); } - } - else - { - // The last packet has to be handled slightly differently - int lastLen = curUploadRequest.AssetData.Length - (numPackets * 1000); - byte[] packetData = new byte[lastLen]; - Array.Copy(curUploadRequest.AssetData, numPackets * 1000, packetData, 0, lastLen); - - uint lastPacket = (uint)int.MaxValue + (uint)numPackets + (uint)1; - packet = AssetPacketHelpers.SendXferPacket(XferID, packetData, lastPacket); - slClient.Network.SendPacket(packet); - if (DEBUG_PACKETS) { Console.WriteLine(packet); } - } - } else { - throw new Exception("Something is wrong with uploading assets, a confirmation came in for a packet we didn't send."); - } - } - - private void TransferInfoCallbackHandler(Packet packet, Simulator simulator) - { - if (DEBUG_PACKETS) { Console.WriteLine(packet); } - TransferInfoPacket reply = (TransferInfoPacket)packet; - - LLUUID TransferID = reply.TransferInfo.TransferID; - int Size = reply.TransferInfo.Size; - int Status = reply.TransferInfo.Status; - - // Lookup the request for this packet - TransferRequest tr = (TransferRequest)htDownloadRequests[TransferID]; - if (tr == null) - { - return; - } - - // Mark it as either not found or update the request information - if (Status == -2) - { - tr.Completed = true; - tr.Status = false; - tr.StatusMsg = "Asset Status -2 :: Likely Status Not Found"; - - tr.Size = 1; - tr.AssetData = new byte[1]; - - } - else - { - tr.Size = Size; - tr.AssetData = new byte[Size]; - } - } - - private void TransferPacketCallbackHandler(Packet packet, Simulator simulator) - { - if (DEBUG_PACKETS) { Console.WriteLine(packet); } - TransferPacketPacket reply = (TransferPacketPacket)packet; - - LLUUID TransferID = reply.TransferData.TransferID; - byte[] Data = reply.TransferData.Data; - - - // Append data to data received. - TransferRequest tr = (TransferRequest)htDownloadRequests[TransferID]; - if (tr == null) - { - return; - } - - Array.Copy(Data, 0, tr.AssetData, tr.Received, Data.Length); - tr.Received += Data.Length; - - // If we've gotten all the data, mark it completed. - if (tr.Received >= tr.Size) - { - tr.Completed = true; - } - } - } -} +/* + * Copyright (c) 2006, Second Life Reverse Engineering Team + * All rights reserved. + * + * - Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Neither the name of the Second Life Reverse Engineering Team nor the names + * of its contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; + +using libsecondlife; + +using libsecondlife.InventorySystem; + +using libsecondlife.Packets; + +namespace libsecondlife.AssetSystem +{ + /// + /// Summary description for AssetManager. + /// + public class AssetManager + { + private const bool DEBUG_PACKETS = true; + + + public const int SINK_FEE_IMAGE = 1; + + private SecondLife slClient; + + private TransferRequest curUploadRequest = null; + private Hashtable htDownloadRequests = new Hashtable(); + + private class TransferRequest + { + public bool Completed; + public bool Status; + public string StatusMsg; + + public int Size; + public int Received; + public uint LastPacketTime; + public uint LastPacketNumSent; + public byte[] AssetData; + + public LLUUID TransactionID; + public LLUUID AssetID; + } + + /// + /// + /// + internal AssetManager(SecondLife client) + { + slClient = client; + + // Used to upload small assets, or as an initial start packet for large transfers + PacketCallback AssetUploadCompleteCallback = new PacketCallback(AssetUploadCompleteCallbackHandler); + slClient.Network.RegisterCallback(PacketType.AssetUploadComplete, AssetUploadCompleteCallback); + + // Transfer Packets for downloading large assets + PacketCallback TransferInfoCallback = new PacketCallback(TransferInfoCallbackHandler); + slClient.Network.RegisterCallback(PacketType.TransferInfo, TransferInfoCallback); + + PacketCallback TransferPacketCallback = new PacketCallback(TransferPacketCallbackHandler); + slClient.Network.RegisterCallback(PacketType.TransferPacket, TransferPacketCallback); + + // XFer packets for uploading large assets + PacketCallback ConfirmXferPacketCallback = new PacketCallback(ConfirmXferPacketCallbackHandler); + slClient.Network.RegisterCallback(PacketType.ConfirmXferPacket, ConfirmXferPacketCallback); + + PacketCallback RequestXferCallback = new PacketCallback(RequestXferCallbackHandler); + slClient.Network.RegisterCallback(PacketType.RequestXfer, RequestXferCallback); + + } + + + /// + /// Handle the appropriate sink fee assoiacted with an asset upload + /// + /// + public void SinkFee(int sinkType) + { + switch( sinkType ) + { + case SINK_FEE_IMAGE: + slClient.Avatar.GiveMoney( new LLUUID(), 10, "Image Upload" ); + break; + default: + throw new Exception("AssetManager: Unknown sinktype (" + sinkType + ")"); + } + } + + /// + /// Upload an asset to Second Life + /// + /// The asset to be uploaded + /// The Asset ID of the completed upload + public LLUUID UploadAsset(Asset asset) + { + if (curUploadRequest != null) + { + throw new Exception("An existing asset upload is currently in-progress."); + } + + Packet packet; + curUploadRequest = new TransferRequest(); + curUploadRequest.Completed = false; + curUploadRequest.TransactionID = LLUUID.GenerateUUID(); + + if( asset.AssetData.Length > 500 ) + { + packet = AssetPacketHelpers.AssetUploadRequestHeaderOnly(asset, curUploadRequest.TransactionID); + slClient.Network.SendPacket(packet); + if (DEBUG_PACKETS) { Console.WriteLine(packet); } + curUploadRequest.AssetData = asset.AssetData; + } + else + { + packet = AssetPacketHelpers.AssetUploadRequest(asset, curUploadRequest.TransactionID); + slClient.Network.SendPacket(packet); + if (DEBUG_PACKETS) { Console.WriteLine(packet); } + } + + while( curUploadRequest.Completed == false ) + { + slClient.Tick(); + } + + if (curUploadRequest.Status == false) + { + throw new Exception(curUploadRequest.StatusMsg); + } else { + if( asset.Type == Asset.ASSET_TYPE_IMAGE ) + { + SinkFee( SINK_FEE_IMAGE ); + } + + asset.AssetID = curUploadRequest.AssetID; + + return asset.AssetID; + } + } + + /// + /// Get the Asset data for an item + /// + /// + public void GetInventoryAsset( InventoryItem item ) + { + LLUUID TransferID = LLUUID.GenerateUUID(); + + TransferRequest tr = new TransferRequest(); + tr.Completed = false; + tr.Size = int.MaxValue; // Number of bytes expected + tr.Received = 0; // Number of bytes received + tr.LastPacketTime = Helpers.GetUnixTime(); // last time we recevied a packet for this request + + htDownloadRequests[TransferID] = tr; + + Packet packet = AssetPacketHelpers.TransferRequest(slClient.Network.SessionID, slClient.Network.AgentID, TransferID, item ); + slClient.Network.SendPacket(packet); + if (DEBUG_PACKETS) { Console.WriteLine(packet); } + + while( tr.Completed == false ) + { + slClient.Tick(); + } + + item.SetAssetData( tr.AssetData ); + } + + private void AssetUploadCompleteCallbackHandler(Packet packet, Simulator simulator) + { + if (DEBUG_PACKETS) { Console.WriteLine(packet); } + Packets.AssetUploadCompletePacket reply = (AssetUploadCompletePacket)packet; + + curUploadRequest.AssetID = reply.AssetBlock.UUID; + bool Success = reply.AssetBlock.Success; + + if( Success ) + { + curUploadRequest.Completed = true; + curUploadRequest.Status = true; + curUploadRequest.StatusMsg = "Success"; + } + else + { + curUploadRequest.Completed = true; + curUploadRequest.Status = false; + curUploadRequest.StatusMsg = "Server returned failed"; + } + } + + private void RequestXferCallbackHandler(Packet packet, Simulator simulator) + { + if (DEBUG_PACKETS) { Console.WriteLine(packet); } + RequestXferPacket reply = (RequestXferPacket)packet; + + ulong XferID = reply.XferID.ID; + LLUUID AssetID = reply.XferID.VFileID; + + // Setup to send the first packet + curUploadRequest.LastPacketNumSent = 0; + + byte[] packetData = new byte[1004]; + + // Prefix the first Xfer packet with the data length + // FIXME: Apply endianness patch + Array.Copy(BitConverter.GetBytes((int)curUploadRequest.AssetData.Length), 0, packetData, 0, 4); + Array.Copy(curUploadRequest.AssetData, 0, packetData, 4, 1000); + + packet = AssetPacketHelpers.SendXferPacket(XferID, packetData, 0); + slClient.Network.SendPacket(packet); + if (DEBUG_PACKETS) { Console.WriteLine(packet); } + } + + private void ConfirmXferPacketCallbackHandler(Packet packet, Simulator simulator) + { + if (DEBUG_PACKETS) { Console.WriteLine(packet); } + ConfirmXferPacketPacket reply = (ConfirmXferPacketPacket)packet; + + ulong XferID = reply.XferID.ID; + uint PacketNumConfirmed = reply.XferID.Packet; + + if (PacketNumConfirmed == curUploadRequest.LastPacketNumSent) + { + curUploadRequest.LastPacketNumSent += 1; + + uint i = curUploadRequest.LastPacketNumSent; + int numPackets = curUploadRequest.AssetData.Length / 1000; + + if (i < numPackets) + { + byte[] packetData = new byte[1000]; + Array.Copy(curUploadRequest.AssetData, i * 1000, packetData, 0, 1000); + + packet = AssetPacketHelpers.SendXferPacket(XferID, packetData, i); + slClient.Network.SendPacket(packet); + if (DEBUG_PACKETS) { Console.WriteLine(packet); } + } + else + { + // The last packet has to be handled slightly differently + int lastLen = curUploadRequest.AssetData.Length - (numPackets * 1000); + byte[] packetData = new byte[lastLen]; + Array.Copy(curUploadRequest.AssetData, numPackets * 1000, packetData, 0, lastLen); + + uint lastPacket = (uint)int.MaxValue + (uint)numPackets + (uint)1; + packet = AssetPacketHelpers.SendXferPacket(XferID, packetData, lastPacket); + slClient.Network.SendPacket(packet); + if (DEBUG_PACKETS) { Console.WriteLine(packet); } + } + } else { + throw new Exception("Something is wrong with uploading assets, a confirmation came in for a packet we didn't send."); + } + } + + private void TransferInfoCallbackHandler(Packet packet, Simulator simulator) + { + if (DEBUG_PACKETS) { Console.WriteLine(packet); } + TransferInfoPacket reply = (TransferInfoPacket)packet; + + LLUUID TransferID = reply.TransferInfo.TransferID; + int Size = reply.TransferInfo.Size; + int Status = reply.TransferInfo.Status; + + // Lookup the request for this packet + TransferRequest tr = (TransferRequest)htDownloadRequests[TransferID]; + if (tr == null) + { + return; + } + + // Mark it as either not found or update the request information + if (Status == -2) + { + tr.Completed = true; + tr.Status = false; + tr.StatusMsg = "Asset Status -2 :: Likely Status Not Found"; + + tr.Size = 1; + tr.AssetData = new byte[1]; + + } + else + { + tr.Size = Size; + tr.AssetData = new byte[Size]; + } + } + + private void TransferPacketCallbackHandler(Packet packet, Simulator simulator) + { + if (DEBUG_PACKETS) { Console.WriteLine(packet); } + TransferPacketPacket reply = (TransferPacketPacket)packet; + + LLUUID TransferID = reply.TransferData.TransferID; + byte[] Data = reply.TransferData.Data; + + + // Append data to data received. + TransferRequest tr = (TransferRequest)htDownloadRequests[TransferID]; + if (tr == null) + { + return; + } + + Array.Copy(Data, 0, tr.AssetData, tr.Received, Data.Length); + tr.Received += Data.Length; + + // If we've gotten all the data, mark it completed. + if (tr.Received >= tr.Size) + { + tr.Completed = true; + } + } + } +} diff --git a/libsecondlife-cs/AssetSystem/AssetNotecard.cs b/libsecondlife-cs/AssetSystem/AssetNotecard.cs index bf4ca286..bd1a2a5b 100644 --- a/libsecondlife-cs/AssetSystem/AssetNotecard.cs +++ b/libsecondlife-cs/AssetSystem/AssetNotecard.cs @@ -1,114 +1,114 @@ -/* - * Copyright (c) 2006, Second Life Reverse Engineering Team - * All rights reserved. - * - * - Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - Neither the name of the Second Life Reverse Engineering Team nor the names - * of its contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -using System; - -using libsecondlife; - -namespace libsecondlife.AssetSystem -{ - /// - /// Summary description for AssetNotecard. - /// - public class AssetNotecard : Asset - { - private string _Body = ""; - public string Body - { - get { return _Body; } - set - { - _Body = value.Replace("\r", ""); - setAsset( _Body ); - } - } - - /// - /// - /// - /// - public AssetNotecard(LLUUID assetID, string body) - : base(assetID, Asset.ASSET_TYPE_NOTECARD, false, null) - { - _Body = body; - setAsset( body ); - } - - /// - /// - /// - /// - public AssetNotecard(LLUUID assetID, byte[] assetData) - : base(assetID, Asset.ASSET_TYPE_NOTECARD, false, null) - { - base.AssetData = assetData; - - string temp = System.Text.Encoding.UTF8.GetString(assetData).Trim(); - - // TODO: Calculate the correct header size to look for - // it's usually around 80 or so... - if( temp.Length > 50 ) - { - // Trim trailing null terminator - temp = temp.Substring(0,temp.Length-1); - - // Remove the header - temp = temp.Substring(temp.IndexOf("}") + 2); - temp = temp.Substring(temp.IndexOf('\n') + 1); - - // Remove trailing close brace - temp = temp.Substring(0,temp.Length-2); - } - _Body = temp; - } - - /// - /// - /// - private void setAsset(string body) - { - // Format the string body into Linden text - string lindenText = "Linden text version 1\n"; - lindenText += "{\n"; - lindenText += "LLEmbeddedItems version 1\n"; - lindenText += "{\n"; - lindenText += "count 0\n"; - lindenText += "}\n"; - lindenText += "Text length " + body.Length + "\n"; - lindenText += body; - lindenText += "}\n"; - - - - // Assume this is a string, add 1 for the null terminator - byte[] stringBytes = System.Text.Encoding.UTF8.GetBytes((string)lindenText); - byte[] assetData = new byte[stringBytes.Length + 1]; - Array.Copy(stringBytes, 0, assetData, 0, stringBytes.Length); - - base.AssetData = assetData; - } - } -} +/* + * Copyright (c) 2006, Second Life Reverse Engineering Team + * All rights reserved. + * + * - Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Neither the name of the Second Life Reverse Engineering Team nor the names + * of its contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +using System; + +using libsecondlife; + +namespace libsecondlife.AssetSystem +{ + /// + /// Summary description for AssetNotecard. + /// + public class AssetNotecard : Asset + { + private string _Body = ""; + public string Body + { + get { return _Body; } + set + { + _Body = value.Replace("\r", ""); + setAsset( _Body ); + } + } + + /// + /// + /// + /// + public AssetNotecard(LLUUID assetID, string body) + : base(assetID, Asset.ASSET_TYPE_NOTECARD, false, null) + { + _Body = body; + setAsset( body ); + } + + /// + /// + /// + /// + public AssetNotecard(LLUUID assetID, byte[] assetData) + : base(assetID, Asset.ASSET_TYPE_NOTECARD, false, null) + { + base.AssetData = assetData; + + string temp = System.Text.Encoding.UTF8.GetString(assetData).Trim(); + + // TODO: Calculate the correct header size to look for + // it's usually around 80 or so... + if( temp.Length > 50 ) + { + // Trim trailing null terminator + temp = temp.Substring(0,temp.Length-1); + + // Remove the header + temp = temp.Substring(temp.IndexOf("}") + 2); + temp = temp.Substring(temp.IndexOf('\n') + 1); + + // Remove trailing close brace + temp = temp.Substring(0,temp.Length-2); + } + _Body = temp; + } + + /// + /// + /// + private void setAsset(string body) + { + // Format the string body into Linden text + string lindenText = "Linden text version 1\n"; + lindenText += "{\n"; + lindenText += "LLEmbeddedItems version 1\n"; + lindenText += "{\n"; + lindenText += "count 0\n"; + lindenText += "}\n"; + lindenText += "Text length " + body.Length + "\n"; + lindenText += body; + lindenText += "}\n"; + + + + // Assume this is a string, add 1 for the null terminator + byte[] stringBytes = System.Text.Encoding.UTF8.GetBytes((string)lindenText); + byte[] assetData = new byte[stringBytes.Length + 1]; + Array.Copy(stringBytes, 0, assetData, 0, stringBytes.Length); + + base.AssetData = assetData; + } + } +} diff --git a/libsecondlife-cs/AssetSystem/AssetPacketHelpers.cs b/libsecondlife-cs/AssetSystem/AssetPacketHelpers.cs index 5d4fc2dc..d9337bb3 100644 --- a/libsecondlife-cs/AssetSystem/AssetPacketHelpers.cs +++ b/libsecondlife-cs/AssetSystem/AssetPacketHelpers.cs @@ -1,149 +1,149 @@ -/* - * Copyright (c) 2006, Second Life Reverse Engineering Team - * All rights reserved. - * - * - Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - Neither the name of the Second Life Reverse Engineering Team nor the names - * of its contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections; - -using libsecondlife; -using libsecondlife.InventorySystem; -using libsecondlife.Packets; - -namespace libsecondlife.AssetSystem -{ - /// - /// - public class AssetPacketHelpers - { - /// - /// Upload a small asset where the entire asset will fit in a single packet (less then 500 bytes) - /// - /// - public static Packet AssetUploadRequest(Asset asset, LLUUID TransactionID) - { - if (asset.AssetData.Length > 500) - { - throw new Exception("Asset too large to use AssetUploadRequest, use AssetUploadRequestHaderOnly() instead."); - } - - AssetUploadRequestPacket p = new AssetUploadRequestPacket(); - p.AssetBlock.TransactionID = TransactionID; - p.AssetBlock.Type = asset.Type; - p.AssetBlock.Tempfile = asset.Tempfile; - p.AssetBlock.AssetData = asset.AssetData; - p.AssetBlock.StoreLocal = false; - - return p; - } - - /// - /// Send header to SL to let it know that a large asset upload is about to proceed. - /// - /// - public static Packet AssetUploadRequestHeaderOnly(Asset asset, LLUUID TransactionID) - { - AssetUploadRequestPacket p = new AssetUploadRequestPacket(); - p.AssetBlock.TransactionID = TransactionID; - p.AssetBlock.Type = asset.Type; - p.AssetBlock.Tempfile = asset.Tempfile; - p.AssetBlock.AssetData = new byte[0]; - p.AssetBlock.StoreLocal = false; - - return p; - } - - - /// - /// Sends a packet of data to SL - /// - /// - /// First xferpacket data must include a prefixed S32 for the length of the asset. - /// - public static Packet SendXferPacket(ulong id, byte[] data, uint packetNum) - { - SendXferPacketPacket p = new SendXferPacketPacket(); - p.DataPacket.Data = data; - - p.XferID.ID = id; - p.XferID.Packet = (uint)packetNum; - - return p; - - } - - /// - /// Request the download of an asset - /// The params field consists of a number of individual data components: - /// Params: 1: OwnerID / *AgentID - /// Params: 2: SessionID - /// Params: 3: *OwnerID / AgentID - /// Params: 4: Unknown (Maybe Group ID) - /// Params: 5: ItemID - /// Params: 6: AssetID - /// Params: 7: Type - /// Params: 8: Last Three Bytes Unknown - /// - /// - /// - /// - /// - public static Packet TransferRequest(LLUUID SessionID, LLUUID AgentID, LLUUID TransferID, InventoryItem item) - { - byte[] param = new byte[100]; - int pos = 0; - - Array.Copy(AgentID.Data, 0, param, pos, 16); - pos += 16; - - Array.Copy(SessionID.Data, 0, param, pos, 16); - pos += 16; - - Array.Copy(item.OwnerID.Data, 0, param, pos, 16); - pos += 16; - - Array.Copy(item.GroupID.Data, 0, param, pos, 16); - pos += 16; - - Array.Copy(item.ItemID.Data, 0, param, pos, 16); - pos += 16; - - Array.Copy(item.AssetID.Data, 0, param, pos, 16); - pos += 16; - - param[pos] = (byte)item.Type; - pos += 1; - - - TransferRequestPacket p = new TransferRequestPacket(); - p.TransferInfo.TransferID = TransferID; - p.TransferInfo.Params = param; - p.TransferInfo.ChannelType = 2; - p.TransferInfo.SourceType = 3; - p.TransferInfo.Priority = (float)101.0; - return p; - } - - } -} +/* + * Copyright (c) 2006, Second Life Reverse Engineering Team + * All rights reserved. + * + * - Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Neither the name of the Second Life Reverse Engineering Team nor the names + * of its contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; + +using libsecondlife; +using libsecondlife.InventorySystem; +using libsecondlife.Packets; + +namespace libsecondlife.AssetSystem +{ + /// + /// + public class AssetPacketHelpers + { + /// + /// Upload a small asset where the entire asset will fit in a single packet (less then 500 bytes) + /// + /// + public static Packet AssetUploadRequest(Asset asset, LLUUID TransactionID) + { + if (asset.AssetData.Length > 500) + { + throw new Exception("Asset too large to use AssetUploadRequest, use AssetUploadRequestHaderOnly() instead."); + } + + AssetUploadRequestPacket p = new AssetUploadRequestPacket(); + p.AssetBlock.TransactionID = TransactionID; + p.AssetBlock.Type = asset.Type; + p.AssetBlock.Tempfile = asset.Tempfile; + p.AssetBlock.AssetData = asset.AssetData; + p.AssetBlock.StoreLocal = false; + + return p; + } + + /// + /// Send header to SL to let it know that a large asset upload is about to proceed. + /// + /// + public static Packet AssetUploadRequestHeaderOnly(Asset asset, LLUUID TransactionID) + { + AssetUploadRequestPacket p = new AssetUploadRequestPacket(); + p.AssetBlock.TransactionID = TransactionID; + p.AssetBlock.Type = asset.Type; + p.AssetBlock.Tempfile = asset.Tempfile; + p.AssetBlock.AssetData = new byte[0]; + p.AssetBlock.StoreLocal = false; + + return p; + } + + + /// + /// Sends a packet of data to SL + /// + /// + /// First xferpacket data must include a prefixed S32 for the length of the asset. + /// + public static Packet SendXferPacket(ulong id, byte[] data, uint packetNum) + { + SendXferPacketPacket p = new SendXferPacketPacket(); + p.DataPacket.Data = data; + + p.XferID.ID = id; + p.XferID.Packet = (uint)packetNum; + + return p; + + } + + /// + /// Request the download of an asset + /// The params field consists of a number of individual data components: + /// Params: 1: OwnerID / *AgentID + /// Params: 2: SessionID + /// Params: 3: *OwnerID / AgentID + /// Params: 4: Unknown (Maybe Group ID) + /// Params: 5: ItemID + /// Params: 6: AssetID + /// Params: 7: Type + /// Params: 8: Last Three Bytes Unknown + /// + /// + /// + /// + /// + public static Packet TransferRequest(LLUUID SessionID, LLUUID AgentID, LLUUID TransferID, InventoryItem item) + { + byte[] param = new byte[100]; + int pos = 0; + + Array.Copy(AgentID.Data, 0, param, pos, 16); + pos += 16; + + Array.Copy(SessionID.Data, 0, param, pos, 16); + pos += 16; + + Array.Copy(item.OwnerID.Data, 0, param, pos, 16); + pos += 16; + + Array.Copy(item.GroupID.Data, 0, param, pos, 16); + pos += 16; + + Array.Copy(item.ItemID.Data, 0, param, pos, 16); + pos += 16; + + Array.Copy(item.AssetID.Data, 0, param, pos, 16); + pos += 16; + + param[pos] = (byte)item.Type; + pos += 1; + + + TransferRequestPacket p = new TransferRequestPacket(); + p.TransferInfo.TransferID = TransferID; + p.TransferInfo.Params = param; + p.TransferInfo.ChannelType = 2; + p.TransferInfo.SourceType = 3; + p.TransferInfo.Priority = (float)101.0; + return p; + } + + } +} diff --git a/libsecondlife-cs/AssetSystem/ImageManager.cs b/libsecondlife-cs/AssetSystem/ImageManager.cs index d42edacb..92eb318e 100644 --- a/libsecondlife-cs/AssetSystem/ImageManager.cs +++ b/libsecondlife-cs/AssetSystem/ImageManager.cs @@ -1,214 +1,214 @@ -/* - * Copyright (c) 2006, Second Life Reverse Engineering Team - * All rights reserved. - * - * - Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - Neither the name of the Second Life Reverse Engineering Team nor the names - * of its contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections; - -using libsecondlife; -using libsecondlife.Packets; - -using libsecondlife.InventorySystem; - -namespace libsecondlife.AssetSystem -{ - /// - /// Manages the uploading and downloading of Images from SecondLife - /// - public class ImageManager - { - private SecondLife slClient; - - private ImagePacketHelpers ImagePacketHelper; - - private Hashtable htDownloadRequests = new Hashtable(); - - private class TransferRequest - { - public bool Completed; - public bool Status; - public string StatusMsg; - - public uint Size; - public uint Received; - public uint LastPacket; - public byte[] AssetData; - - public int BaseDataReceived; - - public TransferRequest() - { - Completed = false; - - Status = false; - StatusMsg = ""; - - AssetData = null; - BaseDataReceived = 0; - } - } - - /// - /// - /// - public ImageManager(SecondLife client) - { - slClient = client; - - ImagePacketHelper = new ImagePacketHelpers(client.Network.AgentID, client.Network.SessionID); - - PacketCallback ImageDataCallback = new PacketCallback(ImageDataCallbackHandler); - slClient.Network.RegisterCallback(PacketType.ImageData, ImageDataCallback); - - PacketCallback ImagePacketCallback = new PacketCallback(ImagePacketCallbackHandler); - slClient.Network.RegisterCallback(PacketType.ImagePacket, ImagePacketCallback); - - PacketCallback ImageNotInDatabaseCallback = new PacketCallback(ImageNotInDatabaseCallbackHandler); - slClient.Network.RegisterCallback(PacketType.ImageNotInDatabase, ImageNotInDatabaseCallback); - } - - /// - /// Requests an image from SecondLife and blocks until it's received. - /// - /// The Image's AssetID - public byte[] RequestImage(LLUUID ImageID) - { - TransferRequest tr = new TransferRequest(); - tr.Completed = false; - tr.Size = int.MaxValue; // Number of bytes expected - tr.Received = 0; // Number of bytes received - tr.LastPacket = Helpers.GetUnixTime(); // last time we recevied a packet for this request - - htDownloadRequests[ImageID] = tr; - - Packet packet = ImagePacketHelper.RequestImage(ImageID); - slClient.Network.SendPacket(packet); - Console.WriteLine(packet); - - while( tr.Completed == false ) - { - slClient.Tick(); - } - - if( tr.Status == true ) - { - return tr.AssetData; - } - else - { - throw new Exception( "RequestImage: " + tr.StatusMsg ); - } - - } - - - /// - /// Handles the Image Data packet, which includes the ID, and Size of the image, - /// along with the first block of data for the image. If the image is small enough - /// there will be no additional packets. - /// - /// - /// - public void ImageDataCallbackHandler(Packet packet, Simulator simulator) - { - Console.WriteLine(packet); - ImageDataPacket reply = (ImageDataPacket)packet; - - LLUUID ImageID = reply.ImageID.ID; - ushort Packets = reply.ImageID.Packets; - uint Size = reply.ImageID.Size; - byte[] Data = reply.ImageData.Data; - - // Lookup the request that this packet is for - TransferRequest tr = (TransferRequest)htDownloadRequests[ImageID]; - if( tr == null ) - { - // Received a packet for an image we didn't request... - return; - } - - // Initialize the request so that it's data buffer is the right size for the image - tr.Size = Size; - tr.AssetData = new byte[tr.Size]; - tr.BaseDataReceived = Data.Length; - - // Copy the first block of image data into the request. - Array.Copy(Data, 0, tr.AssetData, tr.Received, Data.Length); - tr.Received += (uint)Data.Length; - - // If we've gotten all the data, mark it completed. - if( tr.Received >= tr.Size ) - { - tr.Completed = true; - tr.Status = true; - } - } - - /// - /// Handles the remaining Image data that did not fit in the initial ImageData packet - /// - /// - /// - public void ImagePacketCallbackHandler(Packet packet, Simulator simulator) - { - Console.WriteLine(packet); - ImagePacketPacket reply = (ImagePacketPacket)packet; - - - // Lookup the request for this packet - TransferRequest tr = (TransferRequest)htDownloadRequests[reply.ImageID.ID]; - if( tr == null ) - { - // Received a packet that doesn't belong to any requests in our queue, strange... - return; - } - - - // TODO: Received data should probably be put into a temporary collection that's indected by ImageID.Packet - // then once we've received all data packets, it should be re-assembled into a complete array and marked - // completed. - - - // Add this packet's data to the request. - Array.Copy(reply.ImageData.Data, 0, tr.AssetData, tr.BaseDataReceived + (1000 * (reply.ImageID.Packet - 1)), reply.ImageData.Data.Length); - tr.Received += (uint)reply.ImageData.Data.Length; - - // If we've gotten all the data, mark it completed. - if( tr.Received >= tr.Size ) - { - tr.Completed = true; - tr.Status = true; - } - } - - /// - /// - /// - public void ImageNotInDatabaseCallbackHandler(Packet packet, Simulator simulator) - { - Console.WriteLine(packet); - } - } +/* + * Copyright (c) 2006, Second Life Reverse Engineering Team + * All rights reserved. + * + * - Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Neither the name of the Second Life Reverse Engineering Team nor the names + * of its contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; + +using libsecondlife; +using libsecondlife.Packets; + +using libsecondlife.InventorySystem; + +namespace libsecondlife.AssetSystem +{ + /// + /// Manages the uploading and downloading of Images from SecondLife + /// + public class ImageManager + { + private SecondLife slClient; + + private ImagePacketHelpers ImagePacketHelper; + + private Hashtable htDownloadRequests = new Hashtable(); + + private class TransferRequest + { + public bool Completed; + public bool Status; + public string StatusMsg; + + public uint Size; + public uint Received; + public uint LastPacket; + public byte[] AssetData; + + public int BaseDataReceived; + + public TransferRequest() + { + Completed = false; + + Status = false; + StatusMsg = ""; + + AssetData = null; + BaseDataReceived = 0; + } + } + + /// + /// + /// + public ImageManager(SecondLife client) + { + slClient = client; + + ImagePacketHelper = new ImagePacketHelpers(client.Network.AgentID, client.Network.SessionID); + + PacketCallback ImageDataCallback = new PacketCallback(ImageDataCallbackHandler); + slClient.Network.RegisterCallback(PacketType.ImageData, ImageDataCallback); + + PacketCallback ImagePacketCallback = new PacketCallback(ImagePacketCallbackHandler); + slClient.Network.RegisterCallback(PacketType.ImagePacket, ImagePacketCallback); + + PacketCallback ImageNotInDatabaseCallback = new PacketCallback(ImageNotInDatabaseCallbackHandler); + slClient.Network.RegisterCallback(PacketType.ImageNotInDatabase, ImageNotInDatabaseCallback); + } + + /// + /// Requests an image from SecondLife and blocks until it's received. + /// + /// The Image's AssetID + public byte[] RequestImage(LLUUID ImageID) + { + TransferRequest tr = new TransferRequest(); + tr.Completed = false; + tr.Size = int.MaxValue; // Number of bytes expected + tr.Received = 0; // Number of bytes received + tr.LastPacket = Helpers.GetUnixTime(); // last time we recevied a packet for this request + + htDownloadRequests[ImageID] = tr; + + Packet packet = ImagePacketHelper.RequestImage(ImageID); + slClient.Network.SendPacket(packet); + Console.WriteLine(packet); + + while( tr.Completed == false ) + { + slClient.Tick(); + } + + if( tr.Status == true ) + { + return tr.AssetData; + } + else + { + throw new Exception( "RequestImage: " + tr.StatusMsg ); + } + + } + + + /// + /// Handles the Image Data packet, which includes the ID, and Size of the image, + /// along with the first block of data for the image. If the image is small enough + /// there will be no additional packets. + /// + /// + /// + public void ImageDataCallbackHandler(Packet packet, Simulator simulator) + { + Console.WriteLine(packet); + ImageDataPacket reply = (ImageDataPacket)packet; + + LLUUID ImageID = reply.ImageID.ID; + ushort Packets = reply.ImageID.Packets; + uint Size = reply.ImageID.Size; + byte[] Data = reply.ImageData.Data; + + // Lookup the request that this packet is for + TransferRequest tr = (TransferRequest)htDownloadRequests[ImageID]; + if( tr == null ) + { + // Received a packet for an image we didn't request... + return; + } + + // Initialize the request so that it's data buffer is the right size for the image + tr.Size = Size; + tr.AssetData = new byte[tr.Size]; + tr.BaseDataReceived = Data.Length; + + // Copy the first block of image data into the request. + Array.Copy(Data, 0, tr.AssetData, tr.Received, Data.Length); + tr.Received += (uint)Data.Length; + + // If we've gotten all the data, mark it completed. + if( tr.Received >= tr.Size ) + { + tr.Completed = true; + tr.Status = true; + } + } + + /// + /// Handles the remaining Image data that did not fit in the initial ImageData packet + /// + /// + /// + public void ImagePacketCallbackHandler(Packet packet, Simulator simulator) + { + Console.WriteLine(packet); + ImagePacketPacket reply = (ImagePacketPacket)packet; + + + // Lookup the request for this packet + TransferRequest tr = (TransferRequest)htDownloadRequests[reply.ImageID.ID]; + if( tr == null ) + { + // Received a packet that doesn't belong to any requests in our queue, strange... + return; + } + + + // TODO: Received data should probably be put into a temporary collection that's indected by ImageID.Packet + // then once we've received all data packets, it should be re-assembled into a complete array and marked + // completed. + + + // Add this packet's data to the request. + Array.Copy(reply.ImageData.Data, 0, tr.AssetData, tr.BaseDataReceived + (1000 * (reply.ImageID.Packet - 1)), reply.ImageData.Data.Length); + tr.Received += (uint)reply.ImageData.Data.Length; + + // If we've gotten all the data, mark it completed. + if( tr.Received >= tr.Size ) + { + tr.Completed = true; + tr.Status = true; + } + } + + /// + /// + /// + public void ImageNotInDatabaseCallbackHandler(Packet packet, Simulator simulator) + { + Console.WriteLine(packet); + } + } } \ No newline at end of file diff --git a/libsecondlife-cs/AssetSystem/ImagePacketHelpers.cs b/libsecondlife-cs/AssetSystem/ImagePacketHelpers.cs index 856a8cd5..d67d770b 100644 --- a/libsecondlife-cs/AssetSystem/ImagePacketHelpers.cs +++ b/libsecondlife-cs/AssetSystem/ImagePacketHelpers.cs @@ -1,76 +1,76 @@ -/* - * Copyright (c) 2006, Second Life Reverse Engineering Team - * All rights reserved. - * - * - Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - Neither the name of the Second Life Reverse Engineering Team nor the names - * of its contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections; - -using libsecondlife; -using libsecondlife.Packets; - -namespace libsecondlife.AssetSystem -{ - /// - /// Helper functions for packets relating to images. - /// - public class ImagePacketHelpers - { - private LLUUID AgentID; - private LLUUID SessionID; - - public ImagePacketHelpers(LLUUID AgentID, LLUUID SessionID) - { - this.AgentID = AgentID; - this.SessionID = SessionID; - } - - - /// - /// Send a packet requesting an image. This will either fail silently, or result in - /// one ImageData packet, along with zero or more ImagePacket packets. - /// - /// LLUUID of the AssetID of an image. - public Packet RequestImage(LLUUID imageID) - { - RequestImagePacket p = new RequestImagePacket(); - p.RequestImage = new RequestImagePacket.RequestImageBlock[1]; - p.RequestImage[0] = new RequestImagePacket.RequestImageBlock(); - p.RequestImage[0].DownloadPriority = (float)1215000.0; - p.RequestImage[0].DiscardLevel = (int)0; - p.RequestImage[0].Packet = (uint)0; - p.RequestImage[0].Image = imageID; - - //FIXME: Find out what the appropriate values are here. - Console.WriteLine("Don't know what the valid value should be for Type in RequestImage"); - p.RequestImage[0].Type = 0; - - p.AgentData.AgentID = AgentID; - p.AgentData.SessionID = SessionID; - - return p; - } - - } -} +/* + * Copyright (c) 2006, Second Life Reverse Engineering Team + * All rights reserved. + * + * - Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Neither the name of the Second Life Reverse Engineering Team nor the names + * of its contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; + +using libsecondlife; +using libsecondlife.Packets; + +namespace libsecondlife.AssetSystem +{ + /// + /// Helper functions for packets relating to images. + /// + public class ImagePacketHelpers + { + private LLUUID AgentID; + private LLUUID SessionID; + + public ImagePacketHelpers(LLUUID AgentID, LLUUID SessionID) + { + this.AgentID = AgentID; + this.SessionID = SessionID; + } + + + /// + /// Send a packet requesting an image. This will either fail silently, or result in + /// one ImageData packet, along with zero or more ImagePacket packets. + /// + /// LLUUID of the AssetID of an image. + public Packet RequestImage(LLUUID imageID) + { + RequestImagePacket p = new RequestImagePacket(); + p.RequestImage = new RequestImagePacket.RequestImageBlock[1]; + p.RequestImage[0] = new RequestImagePacket.RequestImageBlock(); + p.RequestImage[0].DownloadPriority = (float)1215000.0; + p.RequestImage[0].DiscardLevel = (int)0; + p.RequestImage[0].Packet = (uint)0; + p.RequestImage[0].Image = imageID; + + //FIXME: Find out what the appropriate values are here. + Console.WriteLine("Don't know what the valid value should be for Type in RequestImage"); + p.RequestImage[0].Type = 0; + + p.AgentData.AgentID = AgentID; + p.AgentData.SessionID = SessionID; + + return p; + } + + } +} diff --git a/libsecondlife-cs/Avatar.cs b/libsecondlife-cs/Avatar.cs index c03baea7..ac4a5d63 100644 --- a/libsecondlife-cs/Avatar.cs +++ b/libsecondlife-cs/Avatar.cs @@ -1,713 +1,713 @@ -/* - * Copyright (c) 2006, Second Life Reverse Engineering Team - * All rights reserved. - * - * - Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - Neither the name of the Second Life Reverse Engineering Team nor the names - * of its contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Timers; -using System.Net; -using System.Collections; -using libsecondlife.Packets; - -namespace libsecondlife -{ - /// - /// - /// - /// - /// - /// - /// - /// - /// - public delegate void ChatCallback(string message, byte audible, byte type, byte sourcetype, - string fromName, LLUUID id); - - /// - /// Event is triggered when the L$ account balance for this avatar changes. - /// - /// The new account balance - public delegate void BalanceCallback(int balance); - - /// - /// Triggered whenever an instant message is received. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - public delegate void InstantMessageCallback(LLUUID fromAgentID, string fromAgentName, - LLUUID toAgentID, uint parentEstateID, LLUUID regionID, LLVector3 position, - bool dialog, bool groupIM, LLUUID imSessionID, DateTime timestamp, string message, - byte offline, byte[] binaryBucket); - - /// - /// Triggered after friend request packet is sent out. - /// - /// - /// - public delegate void FriendNotificationCallback(LLUUID agentID, bool online); - - /// - /// - /// - /// - public delegate void TeleportCallback(string message); - - /// - /// Basic class to hold other Avatar's data. - /// - public class Avatar - { - /// The Avatar's UUID, asset server - public LLUUID ID; - /// Avatar ID in Region (sim) it is in - public uint LocalID; - /// Full Name of Avatar - public string Name; - /// Active Group of Avatar - public string GroupName; - /// Online Status of Avatar - public bool Online; - /// Location of Avatar (x,y,z probably) - public LLVector3 Position; - /// Rotational Position of Avatar - public LLQuaternion Rotation; - /// Region (aka sim) the Avatar is in - public Region CurrentRegion; - } - - /// - /// Class to hold Client Avatar's data - /// - public class MainAvatar - { - /// - public event ChatCallback OnChat; - /// - public event InstantMessageCallback OnInstantMessage; - /// - public event FriendNotificationCallback OnFriendNotification; - /// - public event TeleportCallback OnTeleport; - /// - public event BalanceCallback OnBalanceUpdated; - - /// Your (client) Avatar UUID, asset server - public LLUUID ID; - /// Your (client) Avatar ID, local to Region/sim - public uint LocalID; - /// Avatar First Name (i.e. Philip) - public string FirstName; - /// Avatar Last Name (i.e. Linden) - public string LastName; - /// - public string TeleportMessage; - /// Current position of avatar - public LLVector3 Position; - /// Current rotation of avatar - public LLQuaternion Rotation; - /// The point the avatar is currently looking at - /// (may not stay updated) - public LLVector3 LookAt; - /// Position avatar client will goto when login to 'home' or during - /// teleport request to 'home' region. - public LLVector3 HomePosition; - /// LookAt point saved/restored with HomePosition - public LLVector3 HomeLookAt; - /// Gets the health of the agent - protected float health; - public float Health - { - get { return health; } - } - /// Gets the current balance of the agent - protected int balance; - public int Balance - { - get { return balance; } - } - - private SecondLife Client; - private int TeleportStatus; - private Timer TeleportTimer; - private bool TeleportTimeout; - private uint HeightWidthGenCounter; - - /// - /// 'CallBack Central' - Setup callbacks for most of the incoming packets. - /// - /// - public MainAvatar(SecondLife client) - { - PacketCallback callback; - Client = client; - TeleportMessage = ""; - - // Create emtpy vectors for now - HomeLookAt = HomePosition = Position = LookAt = new LLVector3(); - Rotation = new LLQuaternion(); - - // Coarse location callback - Client.Network.RegisterCallback(PacketType.CoarseLocationUpdate, new PacketCallback(CoarseLocationHandler)); - - // Teleport callbacks - callback = new PacketCallback(TeleportHandler); - Client.Network.RegisterCallback(PacketType.TeleportStart, callback); - Client.Network.RegisterCallback(PacketType.TeleportProgress, callback); - Client.Network.RegisterCallback(PacketType.TeleportFailed, callback); - Client.Network.RegisterCallback(PacketType.TeleportFinish, callback); - - // Instant Message callback - Client.Network.RegisterCallback(PacketType.ImprovedInstantMessage, new PacketCallback(InstantMessageHandler)); - - // Chat callback - Client.Network.RegisterCallback(PacketType.ChatFromSimulator, new PacketCallback(ChatHandler)); - - // Friend notification callback - callback = new PacketCallback(FriendNotificationHandler); - Client.Network.RegisterCallback(PacketType.OnlineNotification, callback); - Client.Network.RegisterCallback(PacketType.OfflineNotification, callback); - - TeleportTimer = new Timer(18000); - TeleportTimer.Elapsed += new ElapsedEventHandler(TeleportTimerEvent); - TeleportTimeout = false; - - // Movement complete callback - Client.Network.RegisterCallback(PacketType.AgentMovementComplete, new PacketCallback(MovementCompleteHandler)); - - // Health callback - Client.Network.RegisterCallback(PacketType.HealthMessage, new PacketCallback(HealthHandler)); - - // Money callbacks - callback = new PacketCallback(BalanceHandler); - Client.Network.RegisterCallback(PacketType.MoneyBalanceReply, callback); - Client.Network.RegisterCallback(PacketType.MoneySummaryReply, callback); - Client.Network.RegisterCallback(PacketType.AdjustBalance, callback); - } - - /// - /// - /// - /// - /// - public void InstantMessage(LLUUID target, string message) - { - InstantMessage(FirstName + " " + LastName, LLUUID.GenerateUUID(), target, message, null, LLUUID.GenerateUUID()); - } - - /// - /// - /// - /// - /// - /// - public void InstantMessage(LLUUID target, string message, LLUUID IMSessionID) - { - InstantMessage(FirstName + " " + LastName, LLUUID.GenerateUUID(), target, message, null, IMSessionID); - } - - /// - /// - /// - /// - /// - /// - /// - /// - public void InstantMessage(string fromName, LLUUID sessionID, LLUUID target, string message, LLUUID[] conferenceIDs) - { - InstantMessage(fromName, sessionID, target, message, conferenceIDs, LLUUID.GenerateUUID()); - } - - /// - /// - /// - /// Client's Avatar - /// - /// UUID of target Av. - /// Text Message being sent. - /// - /// - /// - /// TODO: Have fromName grabbed from elsewhere and remove argument, to prevent inadvertant spoofing. - /// - public void InstantMessage(string fromName, LLUUID sessionID, LLUUID target, string message, - LLUUID[] conferenceIDs, LLUUID IMSessionID) - { - ImprovedInstantMessagePacket im = new ImprovedInstantMessagePacket(); - im.AgentData.AgentID = this.ID; - im.AgentData.SessionID = Client.Network.SessionID; - im.MessageBlock.Dialog = 0; - im.MessageBlock.FromAgentName = Helpers.StringToField(fromName); - im.MessageBlock.FromGroup = false; - im.MessageBlock.ID = IMSessionID; - im.MessageBlock.Message = Helpers.StringToField(message); - im.MessageBlock.Offline = 1; - im.MessageBlock.ToAgentID = target; - if (conferenceIDs != null && conferenceIDs.Length > 0) - { - im.MessageBlock.BinaryBucket = new byte[16 * conferenceIDs.Length]; - - for (int i = 0; i < conferenceIDs.Length; ++i) - { - Array.Copy(conferenceIDs[i].Data, 0, im.MessageBlock.BinaryBucket, i * 16, 16); - } - } - else - { - im.MessageBlock.BinaryBucket = new byte[0]; - } - - // These fields are mandatory, even if we don't have valid values for them - im.MessageBlock.Position = new LLVector3(); - //TODO: Allow region id to be correctly set by caller or fetched from Client.* - im.MessageBlock.RegionID = new LLUUID(); - - - // Send the message - Client.Network.SendPacket((Packet)im); - } - - /// - /// Conversion type to denote Chat Packet types in an easier-to-understand format - /// - public enum ChatType - { - /// Whispers (5m radius) - Whisper = 0, - /// Normal chat (10/20m radius) - Why is this here twice? - Normal = 1, - /// Shouting! (100m radius) - Shout = 2, - /// Normal chat (10/20m radius) - Why is this here twice? - Say = 3, - /// Event message when an Avatar has begun to type - StartTyping = 4, - /// Event message when an Avatar has stopped typing - StopTyping = 5 - } - - /// - /// Send a Chat message. - /// - /// The Message you're sending out. - /// Channel number (0 would be default 'Say' message, other numbers - /// denote the equivalent of /# in normal client). - /// Chat Type, see above. - public void Chat(string message, int channel, ChatType type) - { - ChatFromViewerPacket chat = new ChatFromViewerPacket(); - chat.AgentData.AgentID = this.ID; - chat.AgentData.SessionID = Client.Network.SessionID; - chat.ChatData.Channel = channel; - chat.ChatData.Message = Helpers.StringToField(message); - chat.ChatData.Type = (byte)type; - - Client.Network.SendPacket((Packet)chat); - } - - /// - /// Set the height and the width of your avatar. This is used to scale - /// the avatar mesh. - /// - /// New height of the avatar - /// New width of the avatar - public void SetHeightWidth(ushort height, ushort width) - { - AgentHeightWidthPacket heightwidth = new AgentHeightWidthPacket(); - heightwidth.AgentData.AgentID = Client.Network.AgentID; - heightwidth.AgentData.SessionID = Client.Network.SessionID; - heightwidth.AgentData.CircuitCode = Client.Network.CurrentSim.CircuitCode; - heightwidth.HeightWidthBlock.Height = height; - heightwidth.HeightWidthBlock.Width = width; - heightwidth.HeightWidthBlock.GenCounter = HeightWidthGenCounter++; - - Client.Network.SendPacket((Packet)heightwidth); - } - - /// - /// Give Money to destination Avatar - /// - /// UUID of the Target Avatar - /// Amount in L$ - /// Reason (optional normally) - public void GiveMoney(LLUUID target, int amount, string description) - { - // 5001 - transaction type for av to av money transfers - GiveMoney(target, amount, description, 5001); - } - - /// - /// Give Money to destionation Object or Avatar - /// - /// UUID of the Target Object/Avatar - /// Amount in L$ - /// Reason (Optional normally) - /// The type of transaction. Currently only 5001 is - /// documented for Av->Av money transfers. - public void GiveMoney(LLUUID target, int amount, string description, int transactiontype) - { - MoneyTransferRequestPacket money = new MoneyTransferRequestPacket(); - money.AgentData.AgentID = this.ID; - money.AgentData.SessionID = Client.Network.SessionID; - money.MoneyData.Description = Helpers.StringToField(description); - money.MoneyData.DestID = target; - money.MoneyData.SourceID = this.ID; - money.MoneyData.TransactionType = transactiontype; - - Client.Network.SendPacket((Packet)money); - } - - /// - /// - /// - /// - /// - /// - public bool Teleport(ulong regionHandle, LLVector3 position) - { - return Teleport(regionHandle, position, new LLVector3(position.X + 1.0F, position.Y, position.Z)); - } - - /// - /// - /// - /// - /// - /// - /// - public bool Teleport(ulong regionHandle, LLVector3 position, LLVector3 lookAt) - { - TeleportStatus = 0; - - TeleportLocationRequestPacket teleport = new TeleportLocationRequestPacket(); - teleport.AgentData.AgentID = Client.Network.AgentID; - teleport.AgentData.SessionID = Client.Network.SessionID; - teleport.Info.LookAt = lookAt; - teleport.Info.Position = position; - - teleport.Info.RegionHandle = regionHandle; - teleport.Header.Reliable = true; - - Client.Log("Teleporting to region " + regionHandle.ToString(), Helpers.LogLevel.Info); - - // Start the timeout check - TeleportTimeout = false; - TeleportTimer.Start(); - - Client.Network.SendPacket((Packet)teleport); - - while (TeleportStatus == 0 && !TeleportTimeout) - { - Client.Tick(); - } - - TeleportTimer.Stop(); - - if (TeleportTimeout) - { - if (OnTeleport != null) { OnTeleport("Teleport timed out."); } - } - else - { - if (OnTeleport != null) { OnTeleport(TeleportMessage); } - } - - return (TeleportStatus == 1); - } - - /// - /// - /// - /// - /// - /// - public bool Teleport(string simName, LLVector3 position) - { - position.Z = 0; - return Teleport(simName, position, new LLVector3(0, 1.0F, 0)); - } - - /// - /// - /// - /// - /// - /// - /// - public bool Teleport(string simName, LLVector3 position, LLVector3 lookAt) - { - Client.Grid.AddSim(simName); - int attempts = 0; - - while (attempts++ < 5) - { - if (Client.Grid.Regions.ContainsKey(simName.ToLower())) - { - return Teleport(((GridRegion)Client.Grid.Regions[simName.ToLower()]).RegionHandle, position, lookAt); - } - else - { - System.Threading.Thread.Sleep(1000); - Client.Grid.AddSim(simName); - Client.Tick(); - } - } - if (OnTeleport != null) - { - OnTeleport("Unable to resolve name: " + simName); - } - return false; - } - - /// - /// - /// - /// - public void CompleteAgentMovement(Simulator simulator) - { - CompleteAgentMovementPacket move = new CompleteAgentMovementPacket(); - move.AgentData.AgentID = Client.Network.AgentID; - move.AgentData.SessionID = Client.Network.SessionID; - move.AgentData.CircuitCode = simulator.CircuitCode; - - Client.Network.SendPacket(move, simulator); - } - - public void UpdateCamera(bool reliable) - { - AgentUpdatePacket update = new AgentUpdatePacket(); - update.AgentData.AgentID = Client.Network.AgentID; - update.AgentData.SessionID = Client.Network.SessionID; - update.AgentData.State = 0; - update.AgentData.BodyRotation = new LLQuaternion(0, 0.6519076f, 0, 0); - update.AgentData.HeadRotation = new LLQuaternion(); - // Semi-sane default values - update.AgentData.CameraCenter = new LLVector3(9.549901f, 7.033957f, 11.75f); - update.AgentData.CameraAtAxis = new LLVector3(0.7f, 0.7f, 0); - update.AgentData.CameraLeftAxis = new LLVector3(-0.7f, 0.7f, 0); - update.AgentData.CameraUpAxis = new LLVector3(0.1822026f, 0.9828722f, 0); - update.AgentData.Far = 384; - update.AgentData.ControlFlags = 0; // TODO: What is this? - update.AgentData.Flags = 0; - update.Header.Reliable = reliable; - - Client.Network.SendPacket(update); - - // Send an AgentFOV packet widening our field of vision - /*AgentFOVPacket fovPacket = new AgentFOVPacket(); - fovPacket.AgentData.AgentID = this.ID; - fovPacket.AgentData.SessionID = Client.Network.SessionID; - fovPacket.AgentData.CircuitCode = simulator.CircuitCode; - fovPacket.FOVBlock.GenCounter = 0; - fovPacket.FOVBlock.VerticalAngle = 6.28318531f; - fovPacket.Header.Reliable = true; - Client.Network.SendPacket((Packet)fovPacket);*/ - } - - private void FriendNotificationHandler(Packet packet, Simulator simulator) - { - // If the agent is online... - if (packet.Type == PacketType.OnlineNotification) - { - foreach (OnlineNotificationPacket.AgentBlockBlock block in ((OnlineNotificationPacket)packet).AgentBlock) - { - Client.AddAvatar(block.AgentID); - #region AvatarsMutex - Client.AvatarsMutex.WaitOne(); - ((Avatar)Client.Avatars[block.AgentID]).Online = true; - Client.AvatarsMutex.ReleaseMutex(); - #endregion AvatarsMutex - - if (OnFriendNotification != null) - { - OnFriendNotification(block.AgentID, true); - } - } - } - - // If the agent is Offline... - if (packet.Type == PacketType.OfflineNotification) - { - foreach (OfflineNotificationPacket.AgentBlockBlock block in ((OfflineNotificationPacket)packet).AgentBlock) - { - Client.AddAvatar(block.AgentID); - #region AvatarsMutex - Client.AvatarsMutex.WaitOne(); - ((Avatar)Client.Avatars[block.AgentID]).Online = false; - Client.AvatarsMutex.ReleaseMutex(); - #endregion AvatarsMutex - - if (OnFriendNotification != null) - { - OnFriendNotification(block.AgentID, true); - } - } - } - } - - private void CoarseLocationHandler(Packet packet, Simulator simulator) - { - // TODO: This will be useful one day - } - - private void InstantMessageHandler(Packet packet, Simulator simulator) - { - if (packet.Type == PacketType.ImprovedInstantMessage) - { - ImprovedInstantMessagePacket im = (ImprovedInstantMessagePacket)packet; - - if (OnInstantMessage != null) - { - OnInstantMessage( - im.AgentData.AgentID - , Helpers.FieldToString(im.MessageBlock.FromAgentName), - im.MessageBlock.ToAgentID - , im.MessageBlock.ParentEstateID - , im.MessageBlock.RegionID - , im.MessageBlock.Position - , Convert.ToBoolean(im.MessageBlock.Dialog) - , im.MessageBlock.FromGroup - , im.MessageBlock.ID - , new DateTime(im.MessageBlock.Timestamp) - , Helpers.FieldToString(im.MessageBlock.Message) - , im.MessageBlock.Offline - , im.MessageBlock.BinaryBucket - ); - } - } - } - - private void ChatHandler(Packet packet, Simulator simulator) - { - if (packet.Type == PacketType.ChatFromSimulator) - { - ChatFromSimulatorPacket chat = (ChatFromSimulatorPacket)packet; - - if (OnChat != null) - { - OnChat(Helpers.FieldToString(chat.ChatData.Message), chat.ChatData.Audible, chat.ChatData.ChatType, - chat.ChatData.SourceType, Helpers.FieldToString(chat.ChatData.FromName), chat.ChatData.SourceID); - } - } - } - - private void MovementCompleteHandler(Packet packet, Simulator simulator) - { - AgentMovementCompletePacket movement = (AgentMovementCompletePacket)packet; - - this.Position = movement.Data.Position; - this.LookAt = movement.Data.LookAt; - } - - private void HealthHandler(Packet packet, Simulator simulator) - { - health = ((HealthMessagePacket)packet).HealthData.Health; - } - - private void BalanceHandler(Packet packet, Simulator simulator) - { - if (packet.Type == PacketType.MoneyBalanceReply) - { - balance = ((MoneyBalanceReplyPacket)packet).MoneyData.MoneyBalance; - } - else if (packet.Type == PacketType.MoneySummaryReply) - { - balance = ((MoneySummaryReplyPacket)packet).MoneyData.Balance; - } - else if (packet.Type == PacketType.AdjustBalance) - { - balance += ((AdjustBalancePacket)packet).AgentData.Delta; - } - - if (OnBalanceUpdated != null) - { - OnBalanceUpdated(balance); - } - } - - private void TeleportHandler(Packet packet, Simulator simulator) - { - if (packet.Type == PacketType.TeleportStart) - { - TeleportMessage = "Teleport started"; - } - else if (packet.Type == PacketType.TeleportProgress) - { - TeleportMessage = Helpers.FieldToString(((TeleportProgressPacket)packet).Info.Message); - } - else if (packet.Type == PacketType.TeleportFailed) - { - TeleportMessage = Helpers.FieldToString(((TeleportFailedPacket)packet).Info.Reason); - TeleportStatus = -1; - } - else if (packet.Type == PacketType.TeleportFinish) - { - TeleportFinishPacket finish = (TeleportFinishPacket)packet; - TeleportMessage = "Teleport finished"; - - Simulator sim = Client.Network.Connect(new IPAddress((long)finish.Info.SimIP), finish.Info.SimPort, - simulator.CircuitCode, true); - - if ( sim != null) - { - // Move the avatar in to this sim - CompleteAgentMovementPacket move = new CompleteAgentMovementPacket(); - move.AgentData.AgentID = this.ID; - move.AgentData.SessionID = Client.Network.SessionID; - move.AgentData.CircuitCode = simulator.CircuitCode; - Client.Network.SendPacket((Packet)move); - - Console.WriteLine(move); - - Client.Log("Moved to new sim " + Client.Network.CurrentSim.Region.Name + "(" + - Client.Network.CurrentSim.IPEndPoint.ToString() + ")", - Helpers.LogLevel.Info); - - // Sleep a little while so we can collect parcel information - System.Threading.Thread.Sleep(1000); - - TeleportStatus = 1; - } - else - { - TeleportStatus = -1; - } - } - } - - private void TeleportTimerEvent(object source, System.Timers.ElapsedEventArgs ea) - { - TeleportTimeout = true; - } - } -} +/* + * Copyright (c) 2006, Second Life Reverse Engineering Team + * All rights reserved. + * + * - Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Neither the name of the Second Life Reverse Engineering Team nor the names + * of its contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Timers; +using System.Net; +using System.Collections; +using libsecondlife.Packets; + +namespace libsecondlife +{ + /// + /// + /// + /// + /// + /// + /// + /// + /// + public delegate void ChatCallback(string message, byte audible, byte type, byte sourcetype, + string fromName, LLUUID id); + + /// + /// Event is triggered when the L$ account balance for this avatar changes. + /// + /// The new account balance + public delegate void BalanceCallback(int balance); + + /// + /// Triggered whenever an instant message is received. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public delegate void InstantMessageCallback(LLUUID fromAgentID, string fromAgentName, + LLUUID toAgentID, uint parentEstateID, LLUUID regionID, LLVector3 position, + bool dialog, bool groupIM, LLUUID imSessionID, DateTime timestamp, string message, + byte offline, byte[] binaryBucket); + + /// + /// Triggered after friend request packet is sent out. + /// + /// + /// + public delegate void FriendNotificationCallback(LLUUID agentID, bool online); + + /// + /// + /// + /// + public delegate void TeleportCallback(string message); + + /// + /// Basic class to hold other Avatar's data. + /// + public class Avatar + { + /// The Avatar's UUID, asset server + public LLUUID ID; + /// Avatar ID in Region (sim) it is in + public uint LocalID; + /// Full Name of Avatar + public string Name; + /// Active Group of Avatar + public string GroupName; + /// Online Status of Avatar + public bool Online; + /// Location of Avatar (x,y,z probably) + public LLVector3 Position; + /// Rotational Position of Avatar + public LLQuaternion Rotation; + /// Region (aka sim) the Avatar is in + public Region CurrentRegion; + } + + /// + /// Class to hold Client Avatar's data + /// + public class MainAvatar + { + /// + public event ChatCallback OnChat; + /// + public event InstantMessageCallback OnInstantMessage; + /// + public event FriendNotificationCallback OnFriendNotification; + /// + public event TeleportCallback OnTeleport; + /// + public event BalanceCallback OnBalanceUpdated; + + /// Your (client) Avatar UUID, asset server + public LLUUID ID; + /// Your (client) Avatar ID, local to Region/sim + public uint LocalID; + /// Avatar First Name (i.e. Philip) + public string FirstName; + /// Avatar Last Name (i.e. Linden) + public string LastName; + /// + public string TeleportMessage; + /// Current position of avatar + public LLVector3 Position; + /// Current rotation of avatar + public LLQuaternion Rotation; + /// The point the avatar is currently looking at + /// (may not stay updated) + public LLVector3 LookAt; + /// Position avatar client will goto when login to 'home' or during + /// teleport request to 'home' region. + public LLVector3 HomePosition; + /// LookAt point saved/restored with HomePosition + public LLVector3 HomeLookAt; + /// Gets the health of the agent + protected float health; + public float Health + { + get { return health; } + } + /// Gets the current balance of the agent + protected int balance; + public int Balance + { + get { return balance; } + } + + private SecondLife Client; + private int TeleportStatus; + private Timer TeleportTimer; + private bool TeleportTimeout; + private uint HeightWidthGenCounter; + + /// + /// 'CallBack Central' - Setup callbacks for most of the incoming packets. + /// + /// + public MainAvatar(SecondLife client) + { + PacketCallback callback; + Client = client; + TeleportMessage = ""; + + // Create emtpy vectors for now + HomeLookAt = HomePosition = Position = LookAt = new LLVector3(); + Rotation = new LLQuaternion(); + + // Coarse location callback + Client.Network.RegisterCallback(PacketType.CoarseLocationUpdate, new PacketCallback(CoarseLocationHandler)); + + // Teleport callbacks + callback = new PacketCallback(TeleportHandler); + Client.Network.RegisterCallback(PacketType.TeleportStart, callback); + Client.Network.RegisterCallback(PacketType.TeleportProgress, callback); + Client.Network.RegisterCallback(PacketType.TeleportFailed, callback); + Client.Network.RegisterCallback(PacketType.TeleportFinish, callback); + + // Instant Message callback + Client.Network.RegisterCallback(PacketType.ImprovedInstantMessage, new PacketCallback(InstantMessageHandler)); + + // Chat callback + Client.Network.RegisterCallback(PacketType.ChatFromSimulator, new PacketCallback(ChatHandler)); + + // Friend notification callback + callback = new PacketCallback(FriendNotificationHandler); + Client.Network.RegisterCallback(PacketType.OnlineNotification, callback); + Client.Network.RegisterCallback(PacketType.OfflineNotification, callback); + + TeleportTimer = new Timer(18000); + TeleportTimer.Elapsed += new ElapsedEventHandler(TeleportTimerEvent); + TeleportTimeout = false; + + // Movement complete callback + Client.Network.RegisterCallback(PacketType.AgentMovementComplete, new PacketCallback(MovementCompleteHandler)); + + // Health callback + Client.Network.RegisterCallback(PacketType.HealthMessage, new PacketCallback(HealthHandler)); + + // Money callbacks + callback = new PacketCallback(BalanceHandler); + Client.Network.RegisterCallback(PacketType.MoneyBalanceReply, callback); + Client.Network.RegisterCallback(PacketType.MoneySummaryReply, callback); + Client.Network.RegisterCallback(PacketType.AdjustBalance, callback); + } + + /// + /// + /// + /// + /// + public void InstantMessage(LLUUID target, string message) + { + InstantMessage(FirstName + " " + LastName, LLUUID.GenerateUUID(), target, message, null, LLUUID.GenerateUUID()); + } + + /// + /// + /// + /// + /// + /// + public void InstantMessage(LLUUID target, string message, LLUUID IMSessionID) + { + InstantMessage(FirstName + " " + LastName, LLUUID.GenerateUUID(), target, message, null, IMSessionID); + } + + /// + /// + /// + /// + /// + /// + /// + /// + public void InstantMessage(string fromName, LLUUID sessionID, LLUUID target, string message, LLUUID[] conferenceIDs) + { + InstantMessage(fromName, sessionID, target, message, conferenceIDs, LLUUID.GenerateUUID()); + } + + /// + /// + /// + /// Client's Avatar + /// + /// UUID of target Av. + /// Text Message being sent. + /// + /// + /// + /// TODO: Have fromName grabbed from elsewhere and remove argument, to prevent inadvertant spoofing. + /// + public void InstantMessage(string fromName, LLUUID sessionID, LLUUID target, string message, + LLUUID[] conferenceIDs, LLUUID IMSessionID) + { + ImprovedInstantMessagePacket im = new ImprovedInstantMessagePacket(); + im.AgentData.AgentID = this.ID; + im.AgentData.SessionID = Client.Network.SessionID; + im.MessageBlock.Dialog = 0; + im.MessageBlock.FromAgentName = Helpers.StringToField(fromName); + im.MessageBlock.FromGroup = false; + im.MessageBlock.ID = IMSessionID; + im.MessageBlock.Message = Helpers.StringToField(message); + im.MessageBlock.Offline = 1; + im.MessageBlock.ToAgentID = target; + if (conferenceIDs != null && conferenceIDs.Length > 0) + { + im.MessageBlock.BinaryBucket = new byte[16 * conferenceIDs.Length]; + + for (int i = 0; i < conferenceIDs.Length; ++i) + { + Array.Copy(conferenceIDs[i].Data, 0, im.MessageBlock.BinaryBucket, i * 16, 16); + } + } + else + { + im.MessageBlock.BinaryBucket = new byte[0]; + } + + // These fields are mandatory, even if we don't have valid values for them + im.MessageBlock.Position = new LLVector3(); + //TODO: Allow region id to be correctly set by caller or fetched from Client.* + im.MessageBlock.RegionID = new LLUUID(); + + + // Send the message + Client.Network.SendPacket((Packet)im); + } + + /// + /// Conversion type to denote Chat Packet types in an easier-to-understand format + /// + public enum ChatType + { + /// Whispers (5m radius) + Whisper = 0, + /// Normal chat (10/20m radius) - Why is this here twice? + Normal = 1, + /// Shouting! (100m radius) + Shout = 2, + /// Normal chat (10/20m radius) - Why is this here twice? + Say = 3, + /// Event message when an Avatar has begun to type + StartTyping = 4, + /// Event message when an Avatar has stopped typing + StopTyping = 5 + } + + /// + /// Send a Chat message. + /// + /// The Message you're sending out. + /// Channel number (0 would be default 'Say' message, other numbers + /// denote the equivalent of /# in normal client). + /// Chat Type, see above. + public void Chat(string message, int channel, ChatType type) + { + ChatFromViewerPacket chat = new ChatFromViewerPacket(); + chat.AgentData.AgentID = this.ID; + chat.AgentData.SessionID = Client.Network.SessionID; + chat.ChatData.Channel = channel; + chat.ChatData.Message = Helpers.StringToField(message); + chat.ChatData.Type = (byte)type; + + Client.Network.SendPacket((Packet)chat); + } + + /// + /// Set the height and the width of your avatar. This is used to scale + /// the avatar mesh. + /// + /// New height of the avatar + /// New width of the avatar + public void SetHeightWidth(ushort height, ushort width) + { + AgentHeightWidthPacket heightwidth = new AgentHeightWidthPacket(); + heightwidth.AgentData.AgentID = Client.Network.AgentID; + heightwidth.AgentData.SessionID = Client.Network.SessionID; + heightwidth.AgentData.CircuitCode = Client.Network.CurrentSim.CircuitCode; + heightwidth.HeightWidthBlock.Height = height; + heightwidth.HeightWidthBlock.Width = width; + heightwidth.HeightWidthBlock.GenCounter = HeightWidthGenCounter++; + + Client.Network.SendPacket((Packet)heightwidth); + } + + /// + /// Give Money to destination Avatar + /// + /// UUID of the Target Avatar + /// Amount in L$ + /// Reason (optional normally) + public void GiveMoney(LLUUID target, int amount, string description) + { + // 5001 - transaction type for av to av money transfers + GiveMoney(target, amount, description, 5001); + } + + /// + /// Give Money to destionation Object or Avatar + /// + /// UUID of the Target Object/Avatar + /// Amount in L$ + /// Reason (Optional normally) + /// The type of transaction. Currently only 5001 is + /// documented for Av->Av money transfers. + public void GiveMoney(LLUUID target, int amount, string description, int transactiontype) + { + MoneyTransferRequestPacket money = new MoneyTransferRequestPacket(); + money.AgentData.AgentID = this.ID; + money.AgentData.SessionID = Client.Network.SessionID; + money.MoneyData.Description = Helpers.StringToField(description); + money.MoneyData.DestID = target; + money.MoneyData.SourceID = this.ID; + money.MoneyData.TransactionType = transactiontype; + + Client.Network.SendPacket((Packet)money); + } + + /// + /// + /// + /// + /// + /// + public bool Teleport(ulong regionHandle, LLVector3 position) + { + return Teleport(regionHandle, position, new LLVector3(position.X + 1.0F, position.Y, position.Z)); + } + + /// + /// + /// + /// + /// + /// + /// + public bool Teleport(ulong regionHandle, LLVector3 position, LLVector3 lookAt) + { + TeleportStatus = 0; + + TeleportLocationRequestPacket teleport = new TeleportLocationRequestPacket(); + teleport.AgentData.AgentID = Client.Network.AgentID; + teleport.AgentData.SessionID = Client.Network.SessionID; + teleport.Info.LookAt = lookAt; + teleport.Info.Position = position; + + teleport.Info.RegionHandle = regionHandle; + teleport.Header.Reliable = true; + + Client.Log("Teleporting to region " + regionHandle.ToString(), Helpers.LogLevel.Info); + + // Start the timeout check + TeleportTimeout = false; + TeleportTimer.Start(); + + Client.Network.SendPacket((Packet)teleport); + + while (TeleportStatus == 0 && !TeleportTimeout) + { + Client.Tick(); + } + + TeleportTimer.Stop(); + + if (TeleportTimeout) + { + if (OnTeleport != null) { OnTeleport("Teleport timed out."); } + } + else + { + if (OnTeleport != null) { OnTeleport(TeleportMessage); } + } + + return (TeleportStatus == 1); + } + + /// + /// + /// + /// + /// + /// + public bool Teleport(string simName, LLVector3 position) + { + position.Z = 0; + return Teleport(simName, position, new LLVector3(0, 1.0F, 0)); + } + + /// + /// + /// + /// + /// + /// + /// + public bool Teleport(string simName, LLVector3 position, LLVector3 lookAt) + { + Client.Grid.AddSim(simName); + int attempts = 0; + + while (attempts++ < 5) + { + if (Client.Grid.Regions.ContainsKey(simName.ToLower())) + { + return Teleport(((GridRegion)Client.Grid.Regions[simName.ToLower()]).RegionHandle, position, lookAt); + } + else + { + System.Threading.Thread.Sleep(1000); + Client.Grid.AddSim(simName); + Client.Tick(); + } + } + if (OnTeleport != null) + { + OnTeleport("Unable to resolve name: " + simName); + } + return false; + } + + /// + /// + /// + /// + public void CompleteAgentMovement(Simulator simulator) + { + CompleteAgentMovementPacket move = new CompleteAgentMovementPacket(); + move.AgentData.AgentID = Client.Network.AgentID; + move.AgentData.SessionID = Client.Network.SessionID; + move.AgentData.CircuitCode = simulator.CircuitCode; + + Client.Network.SendPacket(move, simulator); + } + + public void UpdateCamera(bool reliable) + { + AgentUpdatePacket update = new AgentUpdatePacket(); + update.AgentData.AgentID = Client.Network.AgentID; + update.AgentData.SessionID = Client.Network.SessionID; + update.AgentData.State = 0; + update.AgentData.BodyRotation = new LLQuaternion(0, 0.6519076f, 0, 0); + update.AgentData.HeadRotation = new LLQuaternion(); + // Semi-sane default values + update.AgentData.CameraCenter = new LLVector3(9.549901f, 7.033957f, 11.75f); + update.AgentData.CameraAtAxis = new LLVector3(0.7f, 0.7f, 0); + update.AgentData.CameraLeftAxis = new LLVector3(-0.7f, 0.7f, 0); + update.AgentData.CameraUpAxis = new LLVector3(0.1822026f, 0.9828722f, 0); + update.AgentData.Far = 384; + update.AgentData.ControlFlags = 0; // TODO: What is this? + update.AgentData.Flags = 0; + update.Header.Reliable = reliable; + + Client.Network.SendPacket(update); + + // Send an AgentFOV packet widening our field of vision + /*AgentFOVPacket fovPacket = new AgentFOVPacket(); + fovPacket.AgentData.AgentID = this.ID; + fovPacket.AgentData.SessionID = Client.Network.SessionID; + fovPacket.AgentData.CircuitCode = simulator.CircuitCode; + fovPacket.FOVBlock.GenCounter = 0; + fovPacket.FOVBlock.VerticalAngle = 6.28318531f; + fovPacket.Header.Reliable = true; + Client.Network.SendPacket((Packet)fovPacket);*/ + } + + private void FriendNotificationHandler(Packet packet, Simulator simulator) + { + // If the agent is online... + if (packet.Type == PacketType.OnlineNotification) + { + foreach (OnlineNotificationPacket.AgentBlockBlock block in ((OnlineNotificationPacket)packet).AgentBlock) + { + Client.AddAvatar(block.AgentID); + #region AvatarsMutex + Client.AvatarsMutex.WaitOne(); + ((Avatar)Client.Avatars[block.AgentID]).Online = true; + Client.AvatarsMutex.ReleaseMutex(); + #endregion AvatarsMutex + + if (OnFriendNotification != null) + { + OnFriendNotification(block.AgentID, true); + } + } + } + + // If the agent is Offline... + if (packet.Type == PacketType.OfflineNotification) + { + foreach (OfflineNotificationPacket.AgentBlockBlock block in ((OfflineNotificationPacket)packet).AgentBlock) + { + Client.AddAvatar(block.AgentID); + #region AvatarsMutex + Client.AvatarsMutex.WaitOne(); + ((Avatar)Client.Avatars[block.AgentID]).Online = false; + Client.AvatarsMutex.ReleaseMutex(); + #endregion AvatarsMutex + + if (OnFriendNotification != null) + { + OnFriendNotification(block.AgentID, true); + } + } + } + } + + private void CoarseLocationHandler(Packet packet, Simulator simulator) + { + // TODO: This will be useful one day + } + + private void InstantMessageHandler(Packet packet, Simulator simulator) + { + if (packet.Type == PacketType.ImprovedInstantMessage) + { + ImprovedInstantMessagePacket im = (ImprovedInstantMessagePacket)packet; + + if (OnInstantMessage != null) + { + OnInstantMessage( + im.AgentData.AgentID + , Helpers.FieldToString(im.MessageBlock.FromAgentName), + im.MessageBlock.ToAgentID + , im.MessageBlock.ParentEstateID + , im.MessageBlock.RegionID + , im.MessageBlock.Position + , Convert.ToBoolean(im.MessageBlock.Dialog) + , im.MessageBlock.FromGroup + , im.MessageBlock.ID + , new DateTime(im.MessageBlock.Timestamp) + , Helpers.FieldToString(im.MessageBlock.Message) + , im.MessageBlock.Offline + , im.MessageBlock.BinaryBucket + ); + } + } + } + + private void ChatHandler(Packet packet, Simulator simulator) + { + if (packet.Type == PacketType.ChatFromSimulator) + { + ChatFromSimulatorPacket chat = (ChatFromSimulatorPacket)packet; + + if (OnChat != null) + { + OnChat(Helpers.FieldToString(chat.ChatData.Message), chat.ChatData.Audible, chat.ChatData.ChatType, + chat.ChatData.SourceType, Helpers.FieldToString(chat.ChatData.FromName), chat.ChatData.SourceID); + } + } + } + + private void MovementCompleteHandler(Packet packet, Simulator simulator) + { + AgentMovementCompletePacket movement = (AgentMovementCompletePacket)packet; + + this.Position = movement.Data.Position; + this.LookAt = movement.Data.LookAt; + } + + private void HealthHandler(Packet packet, Simulator simulator) + { + health = ((HealthMessagePacket)packet).HealthData.Health; + } + + private void BalanceHandler(Packet packet, Simulator simulator) + { + if (packet.Type == PacketType.MoneyBalanceReply) + { + balance = ((MoneyBalanceReplyPacket)packet).MoneyData.MoneyBalance; + } + else if (packet.Type == PacketType.MoneySummaryReply) + { + balance = ((MoneySummaryReplyPacket)packet).MoneyData.Balance; + } + else if (packet.Type == PacketType.AdjustBalance) + { + balance += ((AdjustBalancePacket)packet).AgentData.Delta; + } + + if (OnBalanceUpdated != null) + { + OnBalanceUpdated(balance); + } + } + + private void TeleportHandler(Packet packet, Simulator simulator) + { + if (packet.Type == PacketType.TeleportStart) + { + TeleportMessage = "Teleport started"; + } + else if (packet.Type == PacketType.TeleportProgress) + { + TeleportMessage = Helpers.FieldToString(((TeleportProgressPacket)packet).Info.Message); + } + else if (packet.Type == PacketType.TeleportFailed) + { + TeleportMessage = Helpers.FieldToString(((TeleportFailedPacket)packet).Info.Reason); + TeleportStatus = -1; + } + else if (packet.Type == PacketType.TeleportFinish) + { + TeleportFinishPacket finish = (TeleportFinishPacket)packet; + TeleportMessage = "Teleport finished"; + + Simulator sim = Client.Network.Connect(new IPAddress((long)finish.Info.SimIP), finish.Info.SimPort, + simulator.CircuitCode, true); + + if ( sim != null) + { + // Move the avatar in to this sim + CompleteAgentMovementPacket move = new CompleteAgentMovementPacket(); + move.AgentData.AgentID = this.ID; + move.AgentData.SessionID = Client.Network.SessionID; + move.AgentData.CircuitCode = simulator.CircuitCode; + Client.Network.SendPacket((Packet)move); + + Console.WriteLine(move); + + Client.Log("Moved to new sim " + Client.Network.CurrentSim.Region.Name + "(" + + Client.Network.CurrentSim.IPEndPoint.ToString() + ")", + Helpers.LogLevel.Info); + + // Sleep a little while so we can collect parcel information + System.Threading.Thread.Sleep(1000); + + TeleportStatus = 1; + } + else + { + TeleportStatus = -1; + } + } + } + + private void TeleportTimerEvent(object source, System.Timers.ElapsedEventArgs ea) + { + TeleportTimeout = true; + } + } +} diff --git a/libsecondlife-cs/EstateTools.cs b/libsecondlife-cs/EstateTools.cs index e449fa4d..82e3c6cd 100644 --- a/libsecondlife-cs/EstateTools.cs +++ b/libsecondlife-cs/EstateTools.cs @@ -1,95 +1,95 @@ -/* - * Copyright (c) 2006, Second Life Reverse Engineering Team - * All rights reserved. - * - * - Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - Neither the name of the Second Life Reverse Engineering Team nor the names - * of its contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -using System; -using libsecondlife.Packets; - -namespace libsecondlife -{ - /// - /// Summary description for EstateTools. - /// - public class EstateTools - { - private SecondLife Client; - - /// - /// - /// - /// - public EstateTools(SecondLife client) - { - Client = client; - } - - /// - /// - /// - /// - public void KickUser(LLUUID prey) - { - EstateOwnerMessagePacket estate = new EstateOwnerMessagePacket(); - estate.AgentData.AgentID = Client.Network.AgentID; - estate.AgentData.SessionID = Client.Network.SessionID; - estate.MethodData.Invoice = LLUUID.GenerateUUID(); - estate.MethodData.Method = Helpers.StringToField("kick"); - estate.ParamList = new EstateOwnerMessagePacket.ParamListBlock[2]; - estate.ParamList[0].Parameter = Helpers.StringToField(Client.Network.AgentID.ToStringHyphenated()); - estate.ParamList[1].Parameter = Helpers.StringToField(prey.ToStringHyphenated()); - - Client.Network.SendPacket((Packet)estate); - } - - /// - /// - /// - /// - public void BanUser(LLUUID prey) - { - // FIXME: - //Client.Network.SendPacket(Packets.Estate.EstateBan(Client.Protocol,Client.Avatar.ID,Client.Network.SessionID,prey)); - } - - /// - /// - /// - /// - public void UnBanUser(LLUUID prey) - { - // FIXME: - //Client.Network.SendPacket(Packets.Estate.EstateUnBan(Client.Protocol,Client.Avatar.ID,Client.Network.SessionID,prey)); - } - - /// - /// - /// - /// - public void TeleportHomeUser(LLUUID prey) - { - // FIXME: - //Client.Network.SendPacket(Packets.Estate.EstateTeleportUser(Client.Protocol,Client.Avatar.ID,Client.Network.SessionID,prey)); - } - } -} +/* + * Copyright (c) 2006, Second Life Reverse Engineering Team + * All rights reserved. + * + * - Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Neither the name of the Second Life Reverse Engineering Team nor the names + * of its contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +using System; +using libsecondlife.Packets; + +namespace libsecondlife +{ + /// + /// Summary description for EstateTools. + /// + public class EstateTools + { + private SecondLife Client; + + /// + /// + /// + /// + public EstateTools(SecondLife client) + { + Client = client; + } + + /// + /// + /// + /// + public void KickUser(LLUUID prey) + { + EstateOwnerMessagePacket estate = new EstateOwnerMessagePacket(); + estate.AgentData.AgentID = Client.Network.AgentID; + estate.AgentData.SessionID = Client.Network.SessionID; + estate.MethodData.Invoice = LLUUID.GenerateUUID(); + estate.MethodData.Method = Helpers.StringToField("kick"); + estate.ParamList = new EstateOwnerMessagePacket.ParamListBlock[2]; + estate.ParamList[0].Parameter = Helpers.StringToField(Client.Network.AgentID.ToStringHyphenated()); + estate.ParamList[1].Parameter = Helpers.StringToField(prey.ToStringHyphenated()); + + Client.Network.SendPacket((Packet)estate); + } + + /// + /// + /// + /// + public void BanUser(LLUUID prey) + { + // FIXME: + //Client.Network.SendPacket(Packets.Estate.EstateBan(Client.Protocol,Client.Avatar.ID,Client.Network.SessionID,prey)); + } + + /// + /// + /// + /// + public void UnBanUser(LLUUID prey) + { + // FIXME: + //Client.Network.SendPacket(Packets.Estate.EstateUnBan(Client.Protocol,Client.Avatar.ID,Client.Network.SessionID,prey)); + } + + /// + /// + /// + /// + public void TeleportHomeUser(LLUUID prey) + { + // FIXME: + //Client.Network.SendPacket(Packets.Estate.EstateTeleportUser(Client.Protocol,Client.Avatar.ID,Client.Network.SessionID,prey)); + } + } +} diff --git a/libsecondlife-cs/GridManager.cs b/libsecondlife-cs/GridManager.cs index 411e0e8f..1f38bb2b 100644 --- a/libsecondlife-cs/GridManager.cs +++ b/libsecondlife-cs/GridManager.cs @@ -1,208 +1,208 @@ -/* - * Copyright (c) 2006, Second Life Reverse Engineering Team - * All rights reserved. - * - * - Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - Neither the name of the Second Life Reverse Engineering Team nor the names - * of its contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections; -using libsecondlife.Packets; - -namespace libsecondlife -{ - public delegate void AddRegionCallback(GridRegion region); - - /// - /// Class for regions on the world map - /// - public class GridRegion - { - /// - public int X; - /// - public int Y; - /// - public string Name; - /// - public byte Access; - /// - public uint RegionFlags; - /// - public byte WaterHeight; - /// - public byte Agents; - /// - public LLUUID MapImageID; - /// Used for teleporting - public ulong RegionHandle; - - /// - /// - /// - public GridRegion() - { - } - } - - /// - /// Manages grid-wide tasks such as the world map - /// - public class GridManager - { - public event AddRegionCallback OnRegionAdd; - - /// A hashtable of all the regions, indexed by region ID - public Hashtable Regions; - /// Current direction of the sun - public LLVector3 SunDirection; - - private SecondLife Client; - - /// - /// - /// - /// - public GridManager(SecondLife client) - { - Client = client; - Regions = new Hashtable(); - SunDirection = new LLVector3(); - - Client.Network.RegisterCallback(PacketType.MapBlockReply, new PacketCallback(MapBlockReplyHandler)); - Client.Network.RegisterCallback(PacketType.SimulatorViewerTimeMessage, new PacketCallback(TimeMessageHandler)); - } - - /// - /// - /// - /// - public void AddSim(string name) - { - if(!Regions.ContainsKey(name)) - { - MapNameRequestPacket map = new MapNameRequestPacket(); - map.AgentData.AgentID = Client.Network.AgentID; - map.AgentData.SessionID = Client.Network.SessionID; - - map.NameData.Name = Helpers.StringToField(name.ToLower()); - - Client.Network.SendPacket((Packet)map); - } - } - - public void AddEstateSims() - { - MapLayerRequestPacket request = new MapLayerRequestPacket(); - request.AgentData.AgentID = Client.Network.AgentID; - request.AgentData.SessionID = Client.Network.SessionID; - request.AgentData.Godlike = true; - request.AgentData.Flags = 0; - request.AgentData.EstateID = 0; // TODO get a better value here. - - Client.Network.SendPacket((Packet)request); - } - - public void AddLindenSims() - { - MapBlockRequestPacket request = new MapBlockRequestPacket(); - request.AgentData.AgentID = Client.Network.AgentID; - request.AgentData.SessionID = Client.Network.SessionID; - request.AgentData.EstateID = 0; - request.AgentData.Flags = 0; - request.PositionData.MaxX = 65535; - request.PositionData.MaxY = 65535; - request.PositionData.MinX = 0; - request.PositionData.MinY = 0; - - Client.Network.SendPacket((Packet)request); - } - - /// - /// - /// - public void AddAllSims() - { - AddLindenSims(); - AddEstateSims(); - } - - /// - /// - /// - /// - /// - public GridRegion GetSim(string name) - { - if(Regions.ContainsKey(name)) - return (GridRegion)Regions[name]; - - AddSim(name); - System.Threading.Thread.Sleep(1000); - - if(Regions.ContainsKey(name)) - return (GridRegion)Regions[name]; - else - { - //TODO: Put some better handling inplace here with some retry code - Client.Log("GetSim(): Returned a sim that we aren't tracking",Helpers.LogLevel.Warning); - return new GridRegion(); - } - } - - private void MapBlockReplyHandler(Packet packet, Simulator simulator) - { - GridRegion region; - MapBlockReplyPacket map = (MapBlockReplyPacket)packet; - - foreach (MapBlockReplyPacket.DataBlock block in map.Data) - { - region = new GridRegion(); - - region.X = block.X; - region.Y = block.Y; - region.Name = Helpers.FieldToString(block.Name); - region.RegionFlags = block.RegionFlags; - region.WaterHeight = block.WaterHeight; - region.Agents = block.Agents; - region.Access = block.Access; - region.MapImageID = block.MapImageID; - region.RegionHandle = Helpers.UIntsToLong((uint)region.X * (uint)256, (uint)region.Y * (uint)256); - - if (region.Name != "" && region.X != 0 && region.Y != 0) - { - Regions[region.Name.ToLower()] = region; - } - - if (OnRegionAdd != null) - { - OnRegionAdd(region); - } - } - } - - private void TimeMessageHandler(Packet packet, Simulator simulator) - { - SunDirection = ((SimulatorViewerTimeMessagePacket)packet).TimeInfo.SunDirection; - } - } -} +/* + * Copyright (c) 2006, Second Life Reverse Engineering Team + * All rights reserved. + * + * - Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Neither the name of the Second Life Reverse Engineering Team nor the names + * of its contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using libsecondlife.Packets; + +namespace libsecondlife +{ + public delegate void AddRegionCallback(GridRegion region); + + /// + /// Class for regions on the world map + /// + public class GridRegion + { + /// + public int X; + /// + public int Y; + /// + public string Name; + /// + public byte Access; + /// + public uint RegionFlags; + /// + public byte WaterHeight; + /// + public byte Agents; + /// + public LLUUID MapImageID; + /// Used for teleporting + public ulong RegionHandle; + + /// + /// + /// + public GridRegion() + { + } + } + + /// + /// Manages grid-wide tasks such as the world map + /// + public class GridManager + { + public event AddRegionCallback OnRegionAdd; + + /// A hashtable of all the regions, indexed by region ID + public Hashtable Regions; + /// Current direction of the sun + public LLVector3 SunDirection; + + private SecondLife Client; + + /// + /// + /// + /// + public GridManager(SecondLife client) + { + Client = client; + Regions = new Hashtable(); + SunDirection = new LLVector3(); + + Client.Network.RegisterCallback(PacketType.MapBlockReply, new PacketCallback(MapBlockReplyHandler)); + Client.Network.RegisterCallback(PacketType.SimulatorViewerTimeMessage, new PacketCallback(TimeMessageHandler)); + } + + /// + /// + /// + /// + public void AddSim(string name) + { + if(!Regions.ContainsKey(name)) + { + MapNameRequestPacket map = new MapNameRequestPacket(); + map.AgentData.AgentID = Client.Network.AgentID; + map.AgentData.SessionID = Client.Network.SessionID; + + map.NameData.Name = Helpers.StringToField(name.ToLower()); + + Client.Network.SendPacket((Packet)map); + } + } + + public void AddEstateSims() + { + MapLayerRequestPacket request = new MapLayerRequestPacket(); + request.AgentData.AgentID = Client.Network.AgentID; + request.AgentData.SessionID = Client.Network.SessionID; + request.AgentData.Godlike = true; + request.AgentData.Flags = 0; + request.AgentData.EstateID = 0; // TODO get a better value here. + + Client.Network.SendPacket((Packet)request); + } + + public void AddLindenSims() + { + MapBlockRequestPacket request = new MapBlockRequestPacket(); + request.AgentData.AgentID = Client.Network.AgentID; + request.AgentData.SessionID = Client.Network.SessionID; + request.AgentData.EstateID = 0; + request.AgentData.Flags = 0; + request.PositionData.MaxX = 65535; + request.PositionData.MaxY = 65535; + request.PositionData.MinX = 0; + request.PositionData.MinY = 0; + + Client.Network.SendPacket((Packet)request); + } + + /// + /// + /// + public void AddAllSims() + { + AddLindenSims(); + AddEstateSims(); + } + + /// + /// + /// + /// + /// + public GridRegion GetSim(string name) + { + if(Regions.ContainsKey(name)) + return (GridRegion)Regions[name]; + + AddSim(name); + System.Threading.Thread.Sleep(1000); + + if(Regions.ContainsKey(name)) + return (GridRegion)Regions[name]; + else + { + //TODO: Put some better handling inplace here with some retry code + Client.Log("GetSim(): Returned a sim that we aren't tracking",Helpers.LogLevel.Warning); + return new GridRegion(); + } + } + + private void MapBlockReplyHandler(Packet packet, Simulator simulator) + { + GridRegion region; + MapBlockReplyPacket map = (MapBlockReplyPacket)packet; + + foreach (MapBlockReplyPacket.DataBlock block in map.Data) + { + region = new GridRegion(); + + region.X = block.X; + region.Y = block.Y; + region.Name = Helpers.FieldToString(block.Name); + region.RegionFlags = block.RegionFlags; + region.WaterHeight = block.WaterHeight; + region.Agents = block.Agents; + region.Access = block.Access; + region.MapImageID = block.MapImageID; + region.RegionHandle = Helpers.UIntsToLong((uint)region.X * (uint)256, (uint)region.Y * (uint)256); + + if (region.Name != "" && region.X != 0 && region.Y != 0) + { + Regions[region.Name.ToLower()] = region; + } + + if (OnRegionAdd != null) + { + OnRegionAdd(region); + } + } + } + + private void TimeMessageHandler(Packet packet, Simulator simulator) + { + SunDirection = ((SimulatorViewerTimeMessagePacket)packet).TimeInfo.SunDirection; + } + } +} diff --git a/libsecondlife-cs/GroupManager.cs b/libsecondlife-cs/GroupManager.cs index f328d76c..d7e508ab 100644 --- a/libsecondlife-cs/GroupManager.cs +++ b/libsecondlife-cs/GroupManager.cs @@ -1,425 +1,425 @@ -/* - * Copyright (c) 2006, Second Life Reverse Engineering Team - * All rights reserved. - * - * - Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - Neither the name of the Second Life Reverse Engineering Team nor the names - * of its contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections; -using System.Threading; -using libsecondlife.Packets; - -namespace libsecondlife -{ - public class GroupMember - { - public LLUUID ID; - public int Contribution; - public string OnlineStatus; - public ulong Powers; - public string Title; - public bool IsOwner; - - public GroupMember(LLUUID id) - { - ID = id; - } - } - - public class GroupRole - { - public LLUUID ID; - public string Name; - public string Title; - public string Description; - public ulong Powers; - /// (LLUUID,GroupMember) Contains all the group members - /// belonging to this role - public Hashtable Members; - - public GroupRole(LLUUID id) - { - ID = id; - Members = new Hashtable(); - } - } - - /// - /// Represents a group in Second Life - /// - public class Group - { - public LLUUID ID; - public LLUUID InsigniaID; - public LLUUID FounderID; - public LLUUID OwnerRole; - public string Name; - public string Charter; - public string MemberTitle; - public bool OpenEnrollment; - public bool ShowInList; - public ulong Powers; - public bool AcceptNotices; - public bool AllowPublish; - public bool MaturePublish; - public int MembershipFee; - public int Money; - public int Contribution; - public int GroupMembershipCount; - public int GroupRolesCount; - /// (LLUUID,?) - public Hashtable Titles; - /// (LLUUID,GroupRole) List of all the roles in this group - public Hashtable Roles; - /// (LLUUID,GroupMember) List of all the members in this group - public Hashtable Members; - /// Used for internal state tracking - public LLUUID TitlesRequestID; - /// Used for internal state tracking - public LLUUID RolesRequestID; - /// Used for internal state tracking - public LLUUID MembersRequestID; - - public Group(LLUUID id) - { - ID = id; - InsigniaID = new LLUUID(); - - Titles = new Hashtable(); - Roles = new Hashtable(); - Members = new Hashtable(); - - TitlesRequestID = new LLUUID(); - RolesRequestID = new LLUUID(); - MembersRequestID = new LLUUID(); - } - - public override string ToString() - { - return Name; - } - } - - public class GroupManager - { - /// - /// Called whenever the group membership list is updated - /// - /// - public delegate void GroupsUpdatedCallback(); - - /// - public Hashtable Groups; - private Mutex GroupsMutex; - - /// Called whenever the group membership list is updated - public event GroupsUpdatedCallback OnGroupsUpdated; - - private SecondLife Client; - - public GroupManager(SecondLife client) - { - Groups = new Hashtable(); - GroupsMutex = new Mutex(false, "GroupsMutex"); - Client = client; - - Client.Network.RegisterCallback(PacketType.AgentGroupDataUpdate, new PacketCallback(GroupDataHandler)); - Client.Network.RegisterCallback(PacketType.GroupTitlesReply, new PacketCallback(GroupTitlesHandler)); - Client.Network.RegisterCallback(PacketType.GroupProfileReply, new PacketCallback(GroupProfileHandler)); - Client.Network.RegisterCallback(PacketType.GroupMembersReply, new PacketCallback(GroupMembersHandler)); - Client.Network.RegisterCallback(PacketType.GroupRoleDataReply, new PacketCallback(GroupRoleDataHandler)); - Client.Network.RegisterCallback(PacketType.GroupRoleMembersReply, new PacketCallback(GroupRoleMembersHandler)); - Client.Network.RegisterCallback(PacketType.GroupActiveProposalItemReply, new PacketCallback(GroupActiveProposalItemHandler)); - Client.Network.RegisterCallback(PacketType.GroupVoteHistoryItemReply, new PacketCallback(GroupVoteHistoryItemHandler)); - Client.Network.RegisterCallback(PacketType.GroupAccountSummaryReply, new PacketCallback(GroupAccountSummaryHandler)); - Client.Network.RegisterCallback(PacketType.GroupAccountDetailsReply, new PacketCallback(GroupAccountDetailsHandler)); - Client.Network.RegisterCallback(PacketType.GroupAccountTransactionsReply, new PacketCallback(GroupAccountTransactionsHandler)); - } - - private void GroupDataHandler(Packet packet, Simulator simulator) - { - // FIXME: Add an additional list, such as MyGroups that will distinguish the groups we are - // actually in versus the ones we are just collecting data on. Or should there be a better - // way to temporarily collect data for transient requests? - AgentGroupDataUpdatePacket update = (AgentGroupDataUpdatePacket)packet; - - #region GroupsMutex - GroupsMutex.WaitOne(); - - // Flush out the groups list - Groups.Clear(); - - foreach (AgentGroupDataUpdatePacket.GroupDataBlock block in update.GroupData) - { - Group group = new Group(block.GroupID); - - group.InsigniaID = block.GroupInsigniaID; - group.Name = Helpers.FieldToString(block.GroupName); - group.Powers = block.GroupPowers; - group.Contribution = block.Contribution; - group.AcceptNotices = block.AcceptNotices; - - Groups[group.ID] = group; - } - - GroupsMutex.ReleaseMutex(); - #endregion GroupsMutex - - if (OnGroupsUpdated != null) - { - OnGroupsUpdated(); - } - } - - private void GroupTitlesHandler(Packet packet, Simulator simulator) - { - Group thisGroup; - GroupTitlesReplyPacket titles = (GroupTitlesReplyPacket)packet; - - #region GroupsMutex - GroupsMutex.WaitOne(); - - // Attempt to locate the group that these titles belong to - if (Groups.ContainsKey(titles.AgentData.GroupID)) - { - thisGroup = (Group)Groups[titles.AgentData.GroupID]; - } - else - { - // Avoid throwing this data away by creating a new group - thisGroup = new Group(titles.AgentData.GroupID); - thisGroup.TitlesRequestID = titles.AgentData.RequestID; - Groups[titles.AgentData.GroupID] = thisGroup; - } - - if (titles.AgentData.RequestID == thisGroup.TitlesRequestID) - { - foreach (GroupTitlesReplyPacket.GroupDataBlock block in titles.GroupData) - { - thisGroup.Titles[Helpers.FieldToString(block.Title)] = block.RoleID; - // TODO: Do something with block.Selected - } - } - - GroupsMutex.ReleaseMutex(); - #endregion - } - - private void GroupProfileHandler(Packet packet, Simulator simulator) - { - Group thisGroup; - GroupProfileReplyPacket profile = (GroupProfileReplyPacket)packet; - - #region GroupsMutex - GroupsMutex.WaitOne(); - - // Attempt to locate the group that these titles belong to - if (Groups.ContainsKey(profile.GroupData.GroupID)) - { - thisGroup = (Group)Groups[profile.GroupData.GroupID]; - } - else - { - thisGroup = new Group(profile.GroupData.GroupID); - Groups[profile.GroupData.GroupID] = thisGroup; - } - - thisGroup.AllowPublish = profile.GroupData.AllowPublish; - thisGroup.Charter = Helpers.FieldToString(profile.GroupData.Charter); - thisGroup.FounderID = profile.GroupData.FounderID; - thisGroup.GroupMembershipCount = profile.GroupData.GroupMembershipCount; - thisGroup.GroupRolesCount = profile.GroupData.GroupRolesCount; - thisGroup.InsigniaID = profile.GroupData.InsigniaID; - thisGroup.MaturePublish = profile.GroupData.MaturePublish; - thisGroup.MembershipFee = profile.GroupData.MembershipFee; - thisGroup.MemberTitle = Helpers.FieldToString(profile.GroupData.MemberTitle); - thisGroup.Money = profile.GroupData.Money; - thisGroup.Name = Helpers.FieldToString(profile.GroupData.Name); - thisGroup.OpenEnrollment = profile.GroupData.OpenEnrollment; - thisGroup.OwnerRole = profile.GroupData.OwnerRole; - thisGroup.Powers = profile.GroupData.PowersMask; - thisGroup.ShowInList = profile.GroupData.ShowInList; - - GroupsMutex.ReleaseMutex(); - #endregion - } - - private void GroupMembersHandler(Packet packet, Simulator simulator) - { - Group thisGroup; - GroupMembersReplyPacket members = (GroupMembersReplyPacket)packet; - - #region GroupsMutex - GroupsMutex.WaitOne(); - - if (Groups.ContainsKey(members.GroupData.GroupID)) - { - thisGroup = (Group)Groups[members.GroupData.GroupID]; - } - else - { - thisGroup = new Group(members.GroupData.GroupID); - Groups[members.GroupData.GroupID] = thisGroup; - } - - if (members.GroupData.RequestID == thisGroup.MembersRequestID) - { - foreach (GroupMembersReplyPacket.MemberDataBlock block in members.MemberData) - { - GroupMember member = new GroupMember(block.AgentID); - - member.Contribution = block.Contribution; - member.ID = block.AgentID; - member.IsOwner = block.IsOwner; - member.OnlineStatus = Helpers.FieldToString(block.OnlineStatus); - member.Powers = block.AgentPowers; - member.Title = Helpers.FieldToString(block.Title); - - thisGroup.Members[member.ID] = member; - } - } - - GroupsMutex.ReleaseMutex(); - #endregion - } - - private void GroupRoleDataHandler(Packet packet, Simulator simulator) - { - Group thisGroup; - GroupRole thisRole; - GroupRoleDataReplyPacket roles = (GroupRoleDataReplyPacket)packet; - - #region GroupsMutex - GroupsMutex.WaitOne(); - - if (Groups.ContainsKey(roles.GroupData.GroupID)) - { - thisGroup = (Group)Groups[roles.GroupData.GroupID]; - } - else - { - thisGroup = new Group(roles.GroupData.GroupID); - Groups[roles.GroupData.GroupID] = thisGroup; - } - - foreach (GroupRoleDataReplyPacket.RoleDataBlock block in roles.RoleData) - { - if (thisGroup.Roles.ContainsKey(block.RoleID)) - { - thisRole = (GroupRole)thisGroup.Roles[block.RoleID]; - } - else - { - thisRole = new GroupRole(block.RoleID); - thisGroup.Roles[block.RoleID] = thisRole; - } - - thisRole.Description = Helpers.FieldToString(block.Description); - thisRole.Name = Helpers.FieldToString(block.Name); - thisRole.Powers = block.Powers; - thisRole.Title = Helpers.FieldToString(block.Title); - } - - GroupsMutex.ReleaseMutex(); - #endregion - } - - private void GroupRoleMembersHandler(Packet packet, Simulator simulator) - { - Group thisGroup; - GroupRole thisRole; - GroupMember thisMember; - GroupRoleMembersReplyPacket members = (GroupRoleMembersReplyPacket)packet; - - #region GroupsMutex - GroupsMutex.WaitOne(); - - if (Groups.ContainsKey(members.AgentData.GroupID)) - { - thisGroup = (Group)Groups[members.AgentData.GroupID]; - } - else - { - thisGroup = new Group(members.AgentData.GroupID); - Groups[members.AgentData.GroupID] = thisGroup; - } - - foreach (GroupRoleMembersReplyPacket.MemberDataBlock block in members.MemberData) - { - if (thisGroup.Roles.ContainsKey(block.RoleID)) - { - thisRole = (GroupRole)thisGroup.Roles[block.RoleID]; - } - else - { - thisRole = new GroupRole(block.RoleID); - thisGroup.Roles[block.RoleID] = thisRole; - } - - if (thisGroup.Members.ContainsKey(block.MemberID)) - { - thisMember = (GroupMember)thisGroup.Members[block.MemberID]; - } - else - { - thisMember = new GroupMember(block.MemberID); - thisGroup.Members[block.MemberID] = thisMember; - } - - // Add this member to this block if it doesn't already exist there - if (!thisRole.Members.ContainsKey(block.MemberID)) - { - thisRole.Members[block.MemberID] = thisMember; - } - } - - GroupsMutex.ReleaseMutex(); - #endregion - } - - private void GroupActiveProposalItemHandler(Packet packet, Simulator simulator) - { - ; - } - - private void GroupVoteHistoryItemHandler(Packet packet, Simulator simulator) - { - ; - } - - private void GroupAccountSummaryHandler(Packet packet, Simulator simulator) - { - ; - } - - private void GroupAccountDetailsHandler(Packet packet, Simulator simulator) - { - ; - } - - private void GroupAccountTransactionsHandler(Packet packet, Simulator simulator) - { - ; - } - } -} +/* + * Copyright (c) 2006, Second Life Reverse Engineering Team + * All rights reserved. + * + * - Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Neither the name of the Second Life Reverse Engineering Team nor the names + * of its contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using System.Threading; +using libsecondlife.Packets; + +namespace libsecondlife +{ + public class GroupMember + { + public LLUUID ID; + public int Contribution; + public string OnlineStatus; + public ulong Powers; + public string Title; + public bool IsOwner; + + public GroupMember(LLUUID id) + { + ID = id; + } + } + + public class GroupRole + { + public LLUUID ID; + public string Name; + public string Title; + public string Description; + public ulong Powers; + /// (LLUUID,GroupMember) Contains all the group members + /// belonging to this role + public Hashtable Members; + + public GroupRole(LLUUID id) + { + ID = id; + Members = new Hashtable(); + } + } + + /// + /// Represents a group in Second Life + /// + public class Group + { + public LLUUID ID; + public LLUUID InsigniaID; + public LLUUID FounderID; + public LLUUID OwnerRole; + public string Name; + public string Charter; + public string MemberTitle; + public bool OpenEnrollment; + public bool ShowInList; + public ulong Powers; + public bool AcceptNotices; + public bool AllowPublish; + public bool MaturePublish; + public int MembershipFee; + public int Money; + public int Contribution; + public int GroupMembershipCount; + public int GroupRolesCount; + /// (LLUUID,?) + public Hashtable Titles; + /// (LLUUID,GroupRole) List of all the roles in this group + public Hashtable Roles; + /// (LLUUID,GroupMember) List of all the members in this group + public Hashtable Members; + /// Used for internal state tracking + public LLUUID TitlesRequestID; + /// Used for internal state tracking + public LLUUID RolesRequestID; + /// Used for internal state tracking + public LLUUID MembersRequestID; + + public Group(LLUUID id) + { + ID = id; + InsigniaID = new LLUUID(); + + Titles = new Hashtable(); + Roles = new Hashtable(); + Members = new Hashtable(); + + TitlesRequestID = new LLUUID(); + RolesRequestID = new LLUUID(); + MembersRequestID = new LLUUID(); + } + + public override string ToString() + { + return Name; + } + } + + public class GroupManager + { + /// + /// Called whenever the group membership list is updated + /// + /// + public delegate void GroupsUpdatedCallback(); + + /// + public Hashtable Groups; + private Mutex GroupsMutex; + + /// Called whenever the group membership list is updated + public event GroupsUpdatedCallback OnGroupsUpdated; + + private SecondLife Client; + + public GroupManager(SecondLife client) + { + Groups = new Hashtable(); + GroupsMutex = new Mutex(false, "GroupsMutex"); + Client = client; + + Client.Network.RegisterCallback(PacketType.AgentGroupDataUpdate, new PacketCallback(GroupDataHandler)); + Client.Network.RegisterCallback(PacketType.GroupTitlesReply, new PacketCallback(GroupTitlesHandler)); + Client.Network.RegisterCallback(PacketType.GroupProfileReply, new PacketCallback(GroupProfileHandler)); + Client.Network.RegisterCallback(PacketType.GroupMembersReply, new PacketCallback(GroupMembersHandler)); + Client.Network.RegisterCallback(PacketType.GroupRoleDataReply, new PacketCallback(GroupRoleDataHandler)); + Client.Network.RegisterCallback(PacketType.GroupRoleMembersReply, new PacketCallback(GroupRoleMembersHandler)); + Client.Network.RegisterCallback(PacketType.GroupActiveProposalItemReply, new PacketCallback(GroupActiveProposalItemHandler)); + Client.Network.RegisterCallback(PacketType.GroupVoteHistoryItemReply, new PacketCallback(GroupVoteHistoryItemHandler)); + Client.Network.RegisterCallback(PacketType.GroupAccountSummaryReply, new PacketCallback(GroupAccountSummaryHandler)); + Client.Network.RegisterCallback(PacketType.GroupAccountDetailsReply, new PacketCallback(GroupAccountDetailsHandler)); + Client.Network.RegisterCallback(PacketType.GroupAccountTransactionsReply, new PacketCallback(GroupAccountTransactionsHandler)); + } + + private void GroupDataHandler(Packet packet, Simulator simulator) + { + // FIXME: Add an additional list, such as MyGroups that will distinguish the groups we are + // actually in versus the ones we are just collecting data on. Or should there be a better + // way to temporarily collect data for transient requests? + AgentGroupDataUpdatePacket update = (AgentGroupDataUpdatePacket)packet; + + #region GroupsMutex + GroupsMutex.WaitOne(); + + // Flush out the groups list + Groups.Clear(); + + foreach (AgentGroupDataUpdatePacket.GroupDataBlock block in update.GroupData) + { + Group group = new Group(block.GroupID); + + group.InsigniaID = block.GroupInsigniaID; + group.Name = Helpers.FieldToString(block.GroupName); + group.Powers = block.GroupPowers; + group.Contribution = block.Contribution; + group.AcceptNotices = block.AcceptNotices; + + Groups[group.ID] = group; + } + + GroupsMutex.ReleaseMutex(); + #endregion GroupsMutex + + if (OnGroupsUpdated != null) + { + OnGroupsUpdated(); + } + } + + private void GroupTitlesHandler(Packet packet, Simulator simulator) + { + Group thisGroup; + GroupTitlesReplyPacket titles = (GroupTitlesReplyPacket)packet; + + #region GroupsMutex + GroupsMutex.WaitOne(); + + // Attempt to locate the group that these titles belong to + if (Groups.ContainsKey(titles.AgentData.GroupID)) + { + thisGroup = (Group)Groups[titles.AgentData.GroupID]; + } + else + { + // Avoid throwing this data away by creating a new group + thisGroup = new Group(titles.AgentData.GroupID); + thisGroup.TitlesRequestID = titles.AgentData.RequestID; + Groups[titles.AgentData.GroupID] = thisGroup; + } + + if (titles.AgentData.RequestID == thisGroup.TitlesRequestID) + { + foreach (GroupTitlesReplyPacket.GroupDataBlock block in titles.GroupData) + { + thisGroup.Titles[Helpers.FieldToString(block.Title)] = block.RoleID; + // TODO: Do something with block.Selected + } + } + + GroupsMutex.ReleaseMutex(); + #endregion + } + + private void GroupProfileHandler(Packet packet, Simulator simulator) + { + Group thisGroup; + GroupProfileReplyPacket profile = (GroupProfileReplyPacket)packet; + + #region GroupsMutex + GroupsMutex.WaitOne(); + + // Attempt to locate the group that these titles belong to + if (Groups.ContainsKey(profile.GroupData.GroupID)) + { + thisGroup = (Group)Groups[profile.GroupData.GroupID]; + } + else + { + thisGroup = new Group(profile.GroupData.GroupID); + Groups[profile.GroupData.GroupID] = thisGroup; + } + + thisGroup.AllowPublish = profile.GroupData.AllowPublish; + thisGroup.Charter = Helpers.FieldToString(profile.GroupData.Charter); + thisGroup.FounderID = profile.GroupData.FounderID; + thisGroup.GroupMembershipCount = profile.GroupData.GroupMembershipCount; + thisGroup.GroupRolesCount = profile.GroupData.GroupRolesCount; + thisGroup.InsigniaID = profile.GroupData.InsigniaID; + thisGroup.MaturePublish = profile.GroupData.MaturePublish; + thisGroup.MembershipFee = profile.GroupData.MembershipFee; + thisGroup.MemberTitle = Helpers.FieldToString(profile.GroupData.MemberTitle); + thisGroup.Money = profile.GroupData.Money; + thisGroup.Name = Helpers.FieldToString(profile.GroupData.Name); + thisGroup.OpenEnrollment = profile.GroupData.OpenEnrollment; + thisGroup.OwnerRole = profile.GroupData.OwnerRole; + thisGroup.Powers = profile.GroupData.PowersMask; + thisGroup.ShowInList = profile.GroupData.ShowInList; + + GroupsMutex.ReleaseMutex(); + #endregion + } + + private void GroupMembersHandler(Packet packet, Simulator simulator) + { + Group thisGroup; + GroupMembersReplyPacket members = (GroupMembersReplyPacket)packet; + + #region GroupsMutex + GroupsMutex.WaitOne(); + + if (Groups.ContainsKey(members.GroupData.GroupID)) + { + thisGroup = (Group)Groups[members.GroupData.GroupID]; + } + else + { + thisGroup = new Group(members.GroupData.GroupID); + Groups[members.GroupData.GroupID] = thisGroup; + } + + if (members.GroupData.RequestID == thisGroup.MembersRequestID) + { + foreach (GroupMembersReplyPacket.MemberDataBlock block in members.MemberData) + { + GroupMember member = new GroupMember(block.AgentID); + + member.Contribution = block.Contribution; + member.ID = block.AgentID; + member.IsOwner = block.IsOwner; + member.OnlineStatus = Helpers.FieldToString(block.OnlineStatus); + member.Powers = block.AgentPowers; + member.Title = Helpers.FieldToString(block.Title); + + thisGroup.Members[member.ID] = member; + } + } + + GroupsMutex.ReleaseMutex(); + #endregion + } + + private void GroupRoleDataHandler(Packet packet, Simulator simulator) + { + Group thisGroup; + GroupRole thisRole; + GroupRoleDataReplyPacket roles = (GroupRoleDataReplyPacket)packet; + + #region GroupsMutex + GroupsMutex.WaitOne(); + + if (Groups.ContainsKey(roles.GroupData.GroupID)) + { + thisGroup = (Group)Groups[roles.GroupData.GroupID]; + } + else + { + thisGroup = new Group(roles.GroupData.GroupID); + Groups[roles.GroupData.GroupID] = thisGroup; + } + + foreach (GroupRoleDataReplyPacket.RoleDataBlock block in roles.RoleData) + { + if (thisGroup.Roles.ContainsKey(block.RoleID)) + { + thisRole = (GroupRole)thisGroup.Roles[block.RoleID]; + } + else + { + thisRole = new GroupRole(block.RoleID); + thisGroup.Roles[block.RoleID] = thisRole; + } + + thisRole.Description = Helpers.FieldToString(block.Description); + thisRole.Name = Helpers.FieldToString(block.Name); + thisRole.Powers = block.Powers; + thisRole.Title = Helpers.FieldToString(block.Title); + } + + GroupsMutex.ReleaseMutex(); + #endregion + } + + private void GroupRoleMembersHandler(Packet packet, Simulator simulator) + { + Group thisGroup; + GroupRole thisRole; + GroupMember thisMember; + GroupRoleMembersReplyPacket members = (GroupRoleMembersReplyPacket)packet; + + #region GroupsMutex + GroupsMutex.WaitOne(); + + if (Groups.ContainsKey(members.AgentData.GroupID)) + { + thisGroup = (Group)Groups[members.AgentData.GroupID]; + } + else + { + thisGroup = new Group(members.AgentData.GroupID); + Groups[members.AgentData.GroupID] = thisGroup; + } + + foreach (GroupRoleMembersReplyPacket.MemberDataBlock block in members.MemberData) + { + if (thisGroup.Roles.ContainsKey(block.RoleID)) + { + thisRole = (GroupRole)thisGroup.Roles[block.RoleID]; + } + else + { + thisRole = new GroupRole(block.RoleID); + thisGroup.Roles[block.RoleID] = thisRole; + } + + if (thisGroup.Members.ContainsKey(block.MemberID)) + { + thisMember = (GroupMember)thisGroup.Members[block.MemberID]; + } + else + { + thisMember = new GroupMember(block.MemberID); + thisGroup.Members[block.MemberID] = thisMember; + } + + // Add this member to this block if it doesn't already exist there + if (!thisRole.Members.ContainsKey(block.MemberID)) + { + thisRole.Members[block.MemberID] = thisMember; + } + } + + GroupsMutex.ReleaseMutex(); + #endregion + } + + private void GroupActiveProposalItemHandler(Packet packet, Simulator simulator) + { + ; + } + + private void GroupVoteHistoryItemHandler(Packet packet, Simulator simulator) + { + ; + } + + private void GroupAccountSummaryHandler(Packet packet, Simulator simulator) + { + ; + } + + private void GroupAccountDetailsHandler(Packet packet, Simulator simulator) + { + ; + } + + private void GroupAccountTransactionsHandler(Packet packet, Simulator simulator) + { + ; + } + } +} diff --git a/libsecondlife-cs/InventorySystem/InventoryBase.cs b/libsecondlife-cs/InventorySystem/InventoryBase.cs index f69f8c78..2c627c93 100644 --- a/libsecondlife-cs/InventorySystem/InventoryBase.cs +++ b/libsecondlife-cs/InventorySystem/InventoryBase.cs @@ -1,57 +1,57 @@ -using System; - -using libsecondlife; -using libsecondlife.AssetSystem; - -namespace libsecondlife.InventorySystem -{ - /// - /// Base class for Inventory items - /// - abstract public class InventoryBase - { - protected InventoryManager iManager; - - internal string _Name; - - /// - /// - /// - internal InventoryBase(InventoryManager manager) - { - if( manager == null ) - { - throw new Exception( "Inventory Manager cannot be null" ); - } - iManager = manager; - } - - /// - /// Output this item as XML - /// - /// Include an asset data as well, TRUE/FALSE - abstract public string toXML(bool outputAssets); - - /// - /// Utility function to simply making text XML safe - /// - /// - protected string xmlSafe(string str) - { - if( str != null ) - { - string clean = str.Replace("&","&"); - clean = clean.Replace("<","<"); - clean = clean.Replace(">",">"); - clean = clean.Replace("'","'"); - clean = clean.Replace("\"","""); - return clean; - } - else - { - return ""; - } - } - - } -} +using System; + +using libsecondlife; +using libsecondlife.AssetSystem; + +namespace libsecondlife.InventorySystem +{ + /// + /// Base class for Inventory items + /// + abstract public class InventoryBase + { + protected InventoryManager iManager; + + internal string _Name; + + /// + /// + /// + internal InventoryBase(InventoryManager manager) + { + if( manager == null ) + { + throw new Exception( "Inventory Manager cannot be null" ); + } + iManager = manager; + } + + /// + /// Output this item as XML + /// + /// Include an asset data as well, TRUE/FALSE + abstract public string toXML(bool outputAssets); + + /// + /// Utility function to simply making text XML safe + /// + /// + protected string xmlSafe(string str) + { + if( str != null ) + { + string clean = str.Replace("&","&"); + clean = clean.Replace("<","<"); + clean = clean.Replace(">",">"); + clean = clean.Replace("'","'"); + clean = clean.Replace("\"","""); + return clean; + } + else + { + return ""; + } + } + + } +} diff --git a/libsecondlife-cs/InventorySystem/InventoryFolder.cs b/libsecondlife-cs/InventorySystem/InventoryFolder.cs index 152a0b4f..cedddbcb 100644 --- a/libsecondlife-cs/InventorySystem/InventoryFolder.cs +++ b/libsecondlife-cs/InventorySystem/InventoryFolder.cs @@ -1,163 +1,163 @@ -using System.Collections; -using System; -using libsecondlife; - -namespace libsecondlife.InventorySystem -{ - /// - /// Summary description for InventoryFolder. - /// - public class InventoryFolder : InventoryBase - { - public string Name - { - get { return _Name; } - set - { - _Name = value; - base.iManager.FolderRename( this ); - } - } - - - private LLUUID _FolderID; - public LLUUID FolderID - { - get { return _FolderID; } - } - - private LLUUID _ParentID; - public LLUUID ParentID - { - get { return _ParentID; } - set - { - InventoryFolder ifParent = iManager.getFolder( this.ParentID ); - ifParent.alContents.Remove( this ); - - ifParent = iManager.getFolder( value ); - ifParent.alContents.Add( this ); - - this._ParentID = value; - - base.iManager.FolderMove( this, value ); - } - } - - internal sbyte _Type; - public sbyte Type - { - get { return _Type; } - } - - public ArrayList alContents = new ArrayList(); - - internal InventoryFolder( InventoryManager manager ) : base(manager) - { - _Name = ""; - _FolderID = new LLUUID(); - _ParentID = new LLUUID(); - _Type = -1; - } - - internal InventoryFolder( InventoryManager manager, String name, LLUUID folderID, LLUUID parentID ) : base(manager) - { - this._Name = name; - this._FolderID = folderID; - this._ParentID = parentID; - this._Type = 0; - } - - internal InventoryFolder( InventoryManager manager, String name, LLUUID folderID, LLUUID parentID, sbyte Type ) : base(manager) - { - this._Name = name; - this._FolderID = folderID; - this._ParentID = parentID; - this._Type = Type; - } - - internal InventoryFolder( InventoryManager manager, Hashtable htData ) : base(manager) - { - this._Name = (string)htData["name"]; - this._FolderID = new LLUUID( (string)htData["folder_id"] ); - this._ParentID = new LLUUID( (string)htData["parent_id"] ); - this._Type = sbyte.Parse( htData["type_default"].ToString() ); - } - - - public InventoryFolder CreateFolder( string name ) - { - return base.iManager.FolderCreate( name, FolderID ); - } - - public void Delete() - { - iManager.getFolder( this.ParentID ).alContents.Remove(this); - iManager.FolderRemove(this); - } - - public void MoveTo( InventoryFolder newParent ) - { - MoveTo( newParent.FolderID ); - } - - public void MoveTo( LLUUID newParentID ) - { - this.ParentID = newParentID; - } - - public InventoryNotecard NewNotecard( string name, string description, string body ) - { - return base.iManager.NewNotecard( name, description, body, this.FolderID ); - } - - public InventoryImage NewImage( string name, string description, byte[] j2cdata ) - { - return base.iManager.NewImage( name, description, j2cdata, this.FolderID ); - } - - public ArrayList GetItemByName( string name ) - { - ArrayList items = new ArrayList(); - foreach( InventoryBase ib in alContents ) - { - if( ib is InventoryFolder ) - { - items.AddRange( ((InventoryFolder)ib).GetItemByName(name) ); - } else if ( ib is InventoryItem ) { - if( ((InventoryItem)ib).Name.Equals( name ) ) - { - items.Add( ib ); - } - } - } - - return items; - } - - /// - /// Output this folder as XML - /// - /// Include an asset data as well, TRUE/FALSE - override public string toXML(bool outputAssets) - { - string output = " + /// Summary description for InventoryFolder. + /// + public class InventoryFolder : InventoryBase + { + public string Name + { + get { return _Name; } + set + { + _Name = value; + base.iManager.FolderRename( this ); + } + } + + + private LLUUID _FolderID; + public LLUUID FolderID + { + get { return _FolderID; } + } + + private LLUUID _ParentID; + public LLUUID ParentID + { + get { return _ParentID; } + set + { + InventoryFolder ifParent = iManager.getFolder( this.ParentID ); + ifParent.alContents.Remove( this ); + + ifParent = iManager.getFolder( value ); + ifParent.alContents.Add( this ); + + this._ParentID = value; + + base.iManager.FolderMove( this, value ); + } + } + + internal sbyte _Type; + public sbyte Type + { + get { return _Type; } + } + + public ArrayList alContents = new ArrayList(); + + internal InventoryFolder( InventoryManager manager ) : base(manager) + { + _Name = ""; + _FolderID = new LLUUID(); + _ParentID = new LLUUID(); + _Type = -1; + } + + internal InventoryFolder( InventoryManager manager, String name, LLUUID folderID, LLUUID parentID ) : base(manager) + { + this._Name = name; + this._FolderID = folderID; + this._ParentID = parentID; + this._Type = 0; + } + + internal InventoryFolder( InventoryManager manager, String name, LLUUID folderID, LLUUID parentID, sbyte Type ) : base(manager) + { + this._Name = name; + this._FolderID = folderID; + this._ParentID = parentID; + this._Type = Type; + } + + internal InventoryFolder( InventoryManager manager, Hashtable htData ) : base(manager) + { + this._Name = (string)htData["name"]; + this._FolderID = new LLUUID( (string)htData["folder_id"] ); + this._ParentID = new LLUUID( (string)htData["parent_id"] ); + this._Type = sbyte.Parse( htData["type_default"].ToString() ); + } + + + public InventoryFolder CreateFolder( string name ) + { + return base.iManager.FolderCreate( name, FolderID ); + } + + public void Delete() + { + iManager.getFolder( this.ParentID ).alContents.Remove(this); + iManager.FolderRemove(this); + } + + public void MoveTo( InventoryFolder newParent ) + { + MoveTo( newParent.FolderID ); + } + + public void MoveTo( LLUUID newParentID ) + { + this.ParentID = newParentID; + } + + public InventoryNotecard NewNotecard( string name, string description, string body ) + { + return base.iManager.NewNotecard( name, description, body, this.FolderID ); + } + + public InventoryImage NewImage( string name, string description, byte[] j2cdata ) + { + return base.iManager.NewImage( name, description, j2cdata, this.FolderID ); + } + + public ArrayList GetItemByName( string name ) + { + ArrayList items = new ArrayList(); + foreach( InventoryBase ib in alContents ) + { + if( ib is InventoryFolder ) + { + items.AddRange( ((InventoryFolder)ib).GetItemByName(name) ); + } else if ( ib is InventoryItem ) { + if( ((InventoryItem)ib).Name.Equals( name ) ) + { + items.Add( ib ); + } + } + } + + return items; + } + + /// + /// Output this folder as XML + /// + /// Include an asset data as well, TRUE/FALSE + override public string toXML(bool outputAssets) + { + string output = " - /// Summary description for InventoryNotecard. - /// - public class InventoryImage : InventoryItem - { - - public byte[] J2CData - { - get - { - if( Asset != null ) - { - return ((AssetImage)Asset).J2CData; - } - else - { - if( (AssetID != null) && (AssetID != new LLUUID()) ) - { - base.iManager.AssetManager.GetInventoryAsset( this ); - return ((AssetImage)Asset).J2CData; - } - } - - return null; - } - - set - { - base._Asset = new AssetImage( LLUUID.GenerateUUID(), value ); - LLUUID TransactionID = base.iManager.AssetManager.UploadAsset( Asset ); - base.SetAssetTransactionIDs( Asset.AssetID, TransactionID ); - } - - } - - internal InventoryImage( InventoryManager manager, string name, string description, LLUUID folderID, LLUUID uuidOwnerCreater ) - : base(manager, name, description, folderID, 0, 0, uuidOwnerCreater) - { - - } - - internal InventoryImage( InventoryManager manager, InventoryItem ii ) - : base( manager, ii._Name, ii._Description, ii._FolderID, ii._InvType, ii._Type, ii._CreatorID) - { - if( (ii.InvType != 0) || (ii.Type != Asset.ASSET_TYPE_IMAGE) ) - { - throw new Exception("The InventoryItem cannot be converted to a Image/Texture, wrong InvType/Type."); - } - - this.iManager = manager; - this._Asset = ii._Asset; - this._AssetID = ii._AssetID; - this._BaseMask = ii._BaseMask; - this._CRC = ii._CRC; - this._CreationDate = ii._CreationDate; - this._EveryoneMask = ii._EveryoneMask; - this._Flags = ii._Flags; - this._GroupID = ii._GroupID; - this._GroupMask = ii._GroupMask; - this._GroupOwned = ii._GroupOwned; - this._InvType = ii._InvType; - this._NextOwnerMask = ii._NextOwnerMask; - this._OwnerID = ii._OwnerID; - this._OwnerMask = ii._OwnerMask; - this._SalePrice = ii._SalePrice; - this._SaleType = ii._SaleType; - this._Type = ii._Type; - } - - - override internal void SetAssetData( byte[] assetData ) - { - if( Asset == null ) - { - if( AssetID != null ) - { - _Asset = new AssetImage( AssetID, assetData ); - } - else - { - _Asset = new AssetImage( LLUUID.GenerateUUID(), assetData ); - _AssetID = _Asset.AssetID; - } - } - else - { - Asset.AssetData = assetData; - } - - } - - /// - /// Output this image as XML - /// - /// Include an asset data as well, TRUE/FALSE - override public string toXML(bool outputAssets) - { - string output = " + /// Summary description for InventoryNotecard. + /// + public class InventoryImage : InventoryItem + { + + public byte[] J2CData + { + get + { + if( Asset != null ) + { + return ((AssetImage)Asset).J2CData; + } + else + { + if( (AssetID != null) && (AssetID != new LLUUID()) ) + { + base.iManager.AssetManager.GetInventoryAsset( this ); + return ((AssetImage)Asset).J2CData; + } + } + + return null; + } + + set + { + base._Asset = new AssetImage( LLUUID.GenerateUUID(), value ); + LLUUID TransactionID = base.iManager.AssetManager.UploadAsset( Asset ); + base.SetAssetTransactionIDs( Asset.AssetID, TransactionID ); + } + + } + + internal InventoryImage( InventoryManager manager, string name, string description, LLUUID folderID, LLUUID uuidOwnerCreater ) + : base(manager, name, description, folderID, 0, 0, uuidOwnerCreater) + { + + } + + internal InventoryImage( InventoryManager manager, InventoryItem ii ) + : base( manager, ii._Name, ii._Description, ii._FolderID, ii._InvType, ii._Type, ii._CreatorID) + { + if( (ii.InvType != 0) || (ii.Type != Asset.ASSET_TYPE_IMAGE) ) + { + throw new Exception("The InventoryItem cannot be converted to a Image/Texture, wrong InvType/Type."); + } + + this.iManager = manager; + this._Asset = ii._Asset; + this._AssetID = ii._AssetID; + this._BaseMask = ii._BaseMask; + this._CRC = ii._CRC; + this._CreationDate = ii._CreationDate; + this._EveryoneMask = ii._EveryoneMask; + this._Flags = ii._Flags; + this._GroupID = ii._GroupID; + this._GroupMask = ii._GroupMask; + this._GroupOwned = ii._GroupOwned; + this._InvType = ii._InvType; + this._NextOwnerMask = ii._NextOwnerMask; + this._OwnerID = ii._OwnerID; + this._OwnerMask = ii._OwnerMask; + this._SalePrice = ii._SalePrice; + this._SaleType = ii._SaleType; + this._Type = ii._Type; + } + + + override internal void SetAssetData( byte[] assetData ) + { + if( Asset == null ) + { + if( AssetID != null ) + { + _Asset = new AssetImage( AssetID, assetData ); + } + else + { + _Asset = new AssetImage( LLUUID.GenerateUUID(), assetData ); + _AssetID = _Asset.AssetID; + } + } + else + { + Asset.AssetData = assetData; + } + + } + + /// + /// Output this image as XML + /// + /// Include an asset data as well, TRUE/FALSE + override public string toXML(bool outputAssets) + { + string output = " - /// Base class for most inventory items, providing a lot of general inventory management functions. - /// - public class InventoryItem : InventoryBase - { - private const uint FULL_MASK_PERMISSIONS = 2147483647; - - public string Name - { - get{ return base._Name; } - set - { - _Name = value; - UpdateItem(); - } - } - - internal LLUUID _FolderID = new LLUUID(); - public LLUUID FolderID - { - get{ return _FolderID; } - set - { - InventoryFolder iTargetFolder = base.iManager.getFolder( value ); - if( iTargetFolder == null ) - { - throw new Exception("Target Folder [" + value + "] does not exist."); - } - - base.iManager.getFolder( this.FolderID ).alContents.Remove( this ); - iTargetFolder.alContents.Add( this ); - - _FolderID = value; - UpdateItem(); - } - } - - internal LLUUID _ItemID = null; - public LLUUID ItemID - { - set { - if (_ItemID == null) - { - _ItemID = value; - } - else - { - throw new Exception("You can not change an item's ID once it's been set."); - } - } - get { return _ItemID; } - } - - internal sbyte _InvType = 0; - public sbyte InvType - { - get{ return _InvType; } - } - - internal sbyte _Type = 0; - public sbyte Type - { - get{ return _Type; } - set - { - _Type = value; - UpdateItem(); - } - } - - - internal string _Description = ""; - public string Description - { - get{ return _Description; } - set - { - _Description = value; - UpdateItem(); - } - } - - internal uint _CRC = 0; - public uint CRC - { - get { return _CRC; } - set - { - _CRC = value; - } - } - - - internal LLUUID _OwnerID = new LLUUID(); - public LLUUID OwnerID - { - get { return _OwnerID; } - } - - internal LLUUID _CreatorID = new LLUUID(); - public LLUUID CreatorID - { - get { return _CreatorID; } - } - - internal Asset _Asset; - public Asset Asset - { - get { - if( _Asset != null ) - { - return _Asset; - } - else - { - if( (AssetID != null) && (AssetID != new LLUUID()) ) - { - base.iManager.AssetManager.GetInventoryAsset( this ); - return Asset; - } - } - return null; - } - } - - internal LLUUID _TransactionID = new LLUUID(); - public LLUUID TransactionID - { - get { return _TransactionID; } - } - - internal LLUUID _AssetID = new LLUUID(); - public LLUUID AssetID - { - get { return _AssetID; } - } - - - internal LLUUID _GroupID = new LLUUID(); - public LLUUID GroupID - { - get { return _GroupID; } - set - { - _GroupID = value; - UpdateItem(); - } - } - - internal bool _GroupOwned = false; - public bool GroupOwned - { - get { return _GroupOwned; } - set - { - _GroupOwned = value; - UpdateItem(); - } - } - - internal int _CreationDate = (int)((TimeSpan)(DateTime.UtcNow - new DateTime(1970, 1, 1))).TotalSeconds; - public int CreationDate - { - get { return _CreationDate; } - } - - internal byte _SaleType = 0; - public byte SaleType - { - get { return _SaleType; } - set - { - _SaleType = value; - UpdateItem(); - } - } - - internal uint _BaseMask = FULL_MASK_PERMISSIONS; - public uint BaseMask - { - get { return _BaseMask; } - } - - internal int _SalePrice = 0; - public int SalePrice - { - get { return _SalePrice; } - set - { - _SalePrice = value; - UpdateItem(); - } - } - - internal uint _EveryoneMask = 0; - public uint EveryoneMask - { - get { return _EveryoneMask; } - set - { - _EveryoneMask = value; - UpdateItem(); - } - } - - internal uint _Flags = 0; - public uint Flags - { - get { return _Flags; } - set - { - _Flags = value; - UpdateItem(); - } - } - - internal uint _NextOwnerMask = FULL_MASK_PERMISSIONS; - public uint NextOwnerMask - { - get { return _NextOwnerMask; } - set - { - _NextOwnerMask = value; - UpdateItem(); - } - } - - internal uint _GroupMask = 0; - public uint GroupMask - { - get { return _GroupMask; } - set - { - _GroupMask = value; - UpdateItem(); - } - } - - internal uint _OwnerMask = FULL_MASK_PERMISSIONS; - public uint OwnerMask - { - get { return _OwnerMask; } - } - - - - internal InventoryItem(InventoryManager manager) : base(manager) - { - } - - internal InventoryItem(InventoryManager manager, InventoryDescendentsPacket.ItemDataBlock itemData) - : base(manager) - { - _Name = System.Text.Encoding.UTF8.GetString(itemData.Name).Trim().Replace("\0", ""); - _Description = System.Text.Encoding.UTF8.GetString(itemData.Description).Trim().Replace("\0", ""); - _CreationDate = itemData.CreationDate; - - _InvType = itemData.InvType; - _Type = itemData.Type; - - _AssetID = itemData.AssetID; - _FolderID = itemData.FolderID; - - _GroupOwned = itemData.GroupOwned; - _GroupID = itemData.GroupID; - _GroupMask = itemData.GroupMask; - - _CreatorID = itemData.CreatorID; - _OwnerID = itemData.OwnerID; - _OwnerMask = itemData.OwnerMask; - - - _Flags = itemData.Flags; - _BaseMask = itemData.BaseMask; - _EveryoneMask = itemData.EveryoneMask; - _NextOwnerMask = itemData.NextOwnerMask; - - _SaleType = itemData.SaleType; - _SalePrice = itemData.SalePrice; - - _CRC = itemData.CRC; - } - - internal InventoryItem( InventoryManager manager, string name, LLUUID folderID, sbyte invType, sbyte type, LLUUID uuidOwnerCreater ) : base(manager) - { - _Name = name; - _FolderID = folderID; - _InvType = invType; - _Type = type; - _OwnerID = uuidOwnerCreater; - _CreatorID = uuidOwnerCreater; - - UpdateCRC(); - } - - internal InventoryItem( InventoryManager manager, string name, string description, LLUUID folderID, sbyte invType, sbyte type, LLUUID uuidOwnerCreater ) : base(manager) - { - _Name = name; - _Description = description; - _FolderID = folderID; - _InvType = invType; - _Type = type; - _OwnerID = uuidOwnerCreater; - _CreatorID = uuidOwnerCreater; - - UpdateCRC(); - } - - /// - /// - protected void SetAssetTransactionIDs(LLUUID assetID, LLUUID transactionID) - { - _AssetID = assetID; - _TransactionID = transactionID; - UpdateItem(); - } - - /// - /// - /// - public override bool Equals(object o) - { - if( (o is InventoryItem) == false ) - { - return false; - } - - return this._ItemID == ((InventoryItem)o)._ItemID; - } - - /// - /// - public override int GetHashCode() - { - return this._ItemID.GetHashCode(); - } - - /// - /// CompareTo provided so that items can be sorted by name - /// - /// - public int CompareTo(object obj) - { - if(obj is InventoryBase) - { - InventoryBase temp = (InventoryBase) obj; - return this._Name.CompareTo(temp._Name); - } - throw new ArgumentException("object is not an InventoryItem"); - } - - private void UpdateItem() - { - UpdateCRC(); - base.iManager.ItemUpdate( this ); - } - - private void UpdateCRC() - { - _CRC = InventoryPacketHelper.InventoryUpdateCRC(this); - } - - /// - /// Move this item to the target folder - /// - /// - public void MoveTo(InventoryFolder targetFolder) - { - this.FolderID = targetFolder.FolderID; - } - - /// - /// Move this item to the target folder - /// - /// - public void MoveTo(LLUUID targetFolderID) - { - this.FolderID = targetFolderID; - } - - /// - /// If you have Copy permission, a copy is placed in the target folder - /// - /// - public void CopyTo(LLUUID targetFolder) - { - base.iManager.ItemCopy( this.ItemID, targetFolder ); - } - - /// - /// Give this item to another agent. If you have Copy permission, a copy will be given - /// - /// - public void GiveTo(LLUUID ToAgentID) - { - base.iManager.ItemGiveTo( this, ToAgentID ); - } - - /// - /// Delete this item from Second Life - /// - public void Delete() - { - base.iManager.getFolder( this.FolderID ).alContents.Remove( this ); - base.iManager.ItemRemove( this ); - - } - - /// - /// - /// - virtual internal void SetAssetData(byte[] assetData) - { - if( _Asset == null ) - { - if( AssetID != null ) - { - _Asset = new Asset( AssetID, Type, assetData ); - } else { - _Asset = new Asset( LLUUID.GenerateUUID(), Type, assetData ); - _AssetID = _Asset.AssetID; - } - } else { - _Asset.AssetData = assetData; - } - } - - /// - /// Output this item as XML - /// - /// Include an asset data as well, TRUE/FALSE - override public string toXML(bool outputAssets) - { - string output = " + /// Base class for most inventory items, providing a lot of general inventory management functions. + /// + public class InventoryItem : InventoryBase + { + private const uint FULL_MASK_PERMISSIONS = 2147483647; + + public string Name + { + get{ return base._Name; } + set + { + _Name = value; + UpdateItem(); + } + } + + internal LLUUID _FolderID = new LLUUID(); + public LLUUID FolderID + { + get{ return _FolderID; } + set + { + InventoryFolder iTargetFolder = base.iManager.getFolder( value ); + if( iTargetFolder == null ) + { + throw new Exception("Target Folder [" + value + "] does not exist."); + } + + base.iManager.getFolder( this.FolderID ).alContents.Remove( this ); + iTargetFolder.alContents.Add( this ); + + _FolderID = value; + UpdateItem(); + } + } + + internal LLUUID _ItemID = null; + public LLUUID ItemID + { + set { + if (_ItemID == null) + { + _ItemID = value; + } + else + { + throw new Exception("You can not change an item's ID once it's been set."); + } + } + get { return _ItemID; } + } + + internal sbyte _InvType = 0; + public sbyte InvType + { + get{ return _InvType; } + } + + internal sbyte _Type = 0; + public sbyte Type + { + get{ return _Type; } + set + { + _Type = value; + UpdateItem(); + } + } + + + internal string _Description = ""; + public string Description + { + get{ return _Description; } + set + { + _Description = value; + UpdateItem(); + } + } + + internal uint _CRC = 0; + public uint CRC + { + get { return _CRC; } + set + { + _CRC = value; + } + } + + + internal LLUUID _OwnerID = new LLUUID(); + public LLUUID OwnerID + { + get { return _OwnerID; } + } + + internal LLUUID _CreatorID = new LLUUID(); + public LLUUID CreatorID + { + get { return _CreatorID; } + } + + internal Asset _Asset; + public Asset Asset + { + get { + if( _Asset != null ) + { + return _Asset; + } + else + { + if( (AssetID != null) && (AssetID != new LLUUID()) ) + { + base.iManager.AssetManager.GetInventoryAsset( this ); + return Asset; + } + } + return null; + } + } + + internal LLUUID _TransactionID = new LLUUID(); + public LLUUID TransactionID + { + get { return _TransactionID; } + } + + internal LLUUID _AssetID = new LLUUID(); + public LLUUID AssetID + { + get { return _AssetID; } + } + + + internal LLUUID _GroupID = new LLUUID(); + public LLUUID GroupID + { + get { return _GroupID; } + set + { + _GroupID = value; + UpdateItem(); + } + } + + internal bool _GroupOwned = false; + public bool GroupOwned + { + get { return _GroupOwned; } + set + { + _GroupOwned = value; + UpdateItem(); + } + } + + internal int _CreationDate = (int)((TimeSpan)(DateTime.UtcNow - new DateTime(1970, 1, 1))).TotalSeconds; + public int CreationDate + { + get { return _CreationDate; } + } + + internal byte _SaleType = 0; + public byte SaleType + { + get { return _SaleType; } + set + { + _SaleType = value; + UpdateItem(); + } + } + + internal uint _BaseMask = FULL_MASK_PERMISSIONS; + public uint BaseMask + { + get { return _BaseMask; } + } + + internal int _SalePrice = 0; + public int SalePrice + { + get { return _SalePrice; } + set + { + _SalePrice = value; + UpdateItem(); + } + } + + internal uint _EveryoneMask = 0; + public uint EveryoneMask + { + get { return _EveryoneMask; } + set + { + _EveryoneMask = value; + UpdateItem(); + } + } + + internal uint _Flags = 0; + public uint Flags + { + get { return _Flags; } + set + { + _Flags = value; + UpdateItem(); + } + } + + internal uint _NextOwnerMask = FULL_MASK_PERMISSIONS; + public uint NextOwnerMask + { + get { return _NextOwnerMask; } + set + { + _NextOwnerMask = value; + UpdateItem(); + } + } + + internal uint _GroupMask = 0; + public uint GroupMask + { + get { return _GroupMask; } + set + { + _GroupMask = value; + UpdateItem(); + } + } + + internal uint _OwnerMask = FULL_MASK_PERMISSIONS; + public uint OwnerMask + { + get { return _OwnerMask; } + } + + + + internal InventoryItem(InventoryManager manager) : base(manager) + { + } + + internal InventoryItem(InventoryManager manager, InventoryDescendentsPacket.ItemDataBlock itemData) + : base(manager) + { + _Name = System.Text.Encoding.UTF8.GetString(itemData.Name).Trim().Replace("\0", ""); + _Description = System.Text.Encoding.UTF8.GetString(itemData.Description).Trim().Replace("\0", ""); + _CreationDate = itemData.CreationDate; + + _InvType = itemData.InvType; + _Type = itemData.Type; + + _AssetID = itemData.AssetID; + _FolderID = itemData.FolderID; + + _GroupOwned = itemData.GroupOwned; + _GroupID = itemData.GroupID; + _GroupMask = itemData.GroupMask; + + _CreatorID = itemData.CreatorID; + _OwnerID = itemData.OwnerID; + _OwnerMask = itemData.OwnerMask; + + + _Flags = itemData.Flags; + _BaseMask = itemData.BaseMask; + _EveryoneMask = itemData.EveryoneMask; + _NextOwnerMask = itemData.NextOwnerMask; + + _SaleType = itemData.SaleType; + _SalePrice = itemData.SalePrice; + + _CRC = itemData.CRC; + } + + internal InventoryItem( InventoryManager manager, string name, LLUUID folderID, sbyte invType, sbyte type, LLUUID uuidOwnerCreater ) : base(manager) + { + _Name = name; + _FolderID = folderID; + _InvType = invType; + _Type = type; + _OwnerID = uuidOwnerCreater; + _CreatorID = uuidOwnerCreater; + + UpdateCRC(); + } + + internal InventoryItem( InventoryManager manager, string name, string description, LLUUID folderID, sbyte invType, sbyte type, LLUUID uuidOwnerCreater ) : base(manager) + { + _Name = name; + _Description = description; + _FolderID = folderID; + _InvType = invType; + _Type = type; + _OwnerID = uuidOwnerCreater; + _CreatorID = uuidOwnerCreater; + + UpdateCRC(); + } + + /// + /// + protected void SetAssetTransactionIDs(LLUUID assetID, LLUUID transactionID) + { + _AssetID = assetID; + _TransactionID = transactionID; + UpdateItem(); + } + + /// + /// + /// + public override bool Equals(object o) + { + if( (o is InventoryItem) == false ) + { + return false; + } + + return this._ItemID == ((InventoryItem)o)._ItemID; + } + + /// + /// + public override int GetHashCode() + { + return this._ItemID.GetHashCode(); + } + + /// + /// CompareTo provided so that items can be sorted by name + /// + /// + public int CompareTo(object obj) + { + if(obj is InventoryBase) + { + InventoryBase temp = (InventoryBase) obj; + return this._Name.CompareTo(temp._Name); + } + throw new ArgumentException("object is not an InventoryItem"); + } + + private void UpdateItem() + { + UpdateCRC(); + base.iManager.ItemUpdate( this ); + } + + private void UpdateCRC() + { + _CRC = InventoryPacketHelper.InventoryUpdateCRC(this); + } + + /// + /// Move this item to the target folder + /// + /// + public void MoveTo(InventoryFolder targetFolder) + { + this.FolderID = targetFolder.FolderID; + } + + /// + /// Move this item to the target folder + /// + /// + public void MoveTo(LLUUID targetFolderID) + { + this.FolderID = targetFolderID; + } + + /// + /// If you have Copy permission, a copy is placed in the target folder + /// + /// + public void CopyTo(LLUUID targetFolder) + { + base.iManager.ItemCopy( this.ItemID, targetFolder ); + } + + /// + /// Give this item to another agent. If you have Copy permission, a copy will be given + /// + /// + public void GiveTo(LLUUID ToAgentID) + { + base.iManager.ItemGiveTo( this, ToAgentID ); + } + + /// + /// Delete this item from Second Life + /// + public void Delete() + { + base.iManager.getFolder( this.FolderID ).alContents.Remove( this ); + base.iManager.ItemRemove( this ); + + } + + /// + /// + /// + virtual internal void SetAssetData(byte[] assetData) + { + if( _Asset == null ) + { + if( AssetID != null ) + { + _Asset = new Asset( AssetID, Type, assetData ); + } else { + _Asset = new Asset( LLUUID.GenerateUUID(), Type, assetData ); + _AssetID = _Asset.AssetID; + } + } else { + _Asset.AssetData = assetData; + } + } + + /// + /// Output this item as XML + /// + /// Include an asset data as well, TRUE/FALSE + override public string toXML(bool outputAssets) + { + string output = " - /// Summary description for Inventory. - /// - public class InventoryManager - { - private const bool DEBUG_PACKETS = true; - - - // Reference to the SLClient Library - private SecondLife slClient; - - // Reference to the Asset Manager - private static AssetManager slAssetManager; - internal AssetManager AssetManager - { - get{ return slAssetManager; } - } - - public InventoryPacketHelper InvPacketHelper = null; - - // UUID of Root Inventory Folder - private LLUUID uuidRootFolder; - - // Setup a hashtable to easily lookup folders by UUID - private Hashtable htFoldersByUUID = new Hashtable(); - - // Setup a Hashtable to track download progress - private Hashtable htFolderDownloadStatus; - private ArrayList alFolderRequestQueue; - - // Used to track current item being created - private InventoryItem iiCreationInProgress; - private bool ItemCreationInProgress; - - private uint LastPacketRecieved; - - // Each InventorySystem needs to be initialized with a client and root folder. - public InventoryManager( SecondLife client, LLUUID rootFolder ) - { - slClient = client; - if( slAssetManager == null ) - { - slAssetManager = new AssetManager( slClient ); - } - - InvPacketHelper = new InventoryPacketHelper(slClient.Network.AgentID, slClient.Network.SessionID); - - uuidRootFolder = rootFolder; - - resetFoldersByUUID(); - - // Setup the callback for Inventory Downloads - PacketCallback InventoryDescendentsCallback = new PacketCallback(InventoryDescendentsHandler); - slClient.Network.RegisterCallback(PacketType.InventoryDescendents, InventoryDescendentsCallback); - - // Setup the callback for Inventory Creation Update - PacketCallback UpdateCreateInventoryItemCallback = new PacketCallback(UpdateCreateInventoryItemHandler); - slClient.Network.RegisterCallback(PacketType.UpdateCreateInventoryItem, UpdateCreateInventoryItemCallback); - - } - - // Used primarily for debugging and testing - public AssetManager getAssetManager() - { - Console.WriteLine("It is not recommended that you access the asset manager directly"); - return AssetManager; - } - - private void resetFoldersByUUID() - { - // Init folder structure with root - htFoldersByUUID = new Hashtable(); - - InventoryFolder ifRootFolder = new InventoryFolder(this, "My Inventory", uuidRootFolder, null); - htFoldersByUUID[uuidRootFolder] = ifRootFolder; - } - - public InventoryFolder getRootFolder() - { - return (InventoryFolder)htFoldersByUUID[uuidRootFolder]; - } - - public InventoryFolder getFolder( LLUUID folderID ) - { - return (InventoryFolder)htFoldersByUUID[folderID]; - } - - public InventoryFolder getFolder( String sFolderPath ) - { - string sSecretConst = "+@#%$#$%^%^%$^$%SV$#%FR$G"; - sFolderPath = sFolderPath.Replace("//",sSecretConst); - - if (sFolderPath.StartsWith("/")) - { - sFolderPath = sFolderPath.Remove(0, 1); - } - - if (sFolderPath.Length == 0) - { - return getRootFolder(); - } - - char[] seperators = { '/' }; - string[] sFolderPathParts = sFolderPath.Split(seperators); - - for( int i = 0; i 0) || (alFolderRequestQueue.Count > 0) ) - { - if( htFolderDownloadStatus.Count == 0 ) - { - DescendentRequest dr = (DescendentRequest)alFolderRequestQueue[0]; - alFolderRequestQueue.RemoveAt(0); - RequestFolder( dr ); - } - - if ((Helpers.GetUnixTime() - LastPacketRecieved) > 10) - { - Console.WriteLine("Time-out while waiting for packets (" + (Helpers.GetUnixTime() - LastPacketRecieved) + " seconds since last packet)"); - Console.WriteLine("Current Status:"); - - // have to make a seperate list otherwise we run into modifying the original array - // while still enumerating it. - ArrayList alRestartList = new ArrayList(); - - if (htFolderDownloadStatus[0] != null) - { - Console.WriteLine(htFolderDownloadStatus[0].GetType()); - } - - foreach( DescendentRequest dr in htFolderDownloadStatus.Values ) - { - Console.WriteLine( dr.FolderID + " " + dr.Expected + " / " + dr.Received + " / " + dr.LastReceived ); - - alRestartList.Add( dr ); - } - - LastPacketRecieved = Helpers.GetUnixTime(); - foreach( DescendentRequest dr in alRestartList ) - { - RequestFolder( dr ); - } - - } - slClient.Tick(); - - } - } - - - - public void UpdateCreateInventoryItemHandler(Packet packet, Simulator simulator) - { - if (DEBUG_PACKETS) { Console.WriteLine(packet); } - - if (ItemCreationInProgress) - { - UpdateCreateInventoryItemPacket reply = (UpdateCreateInventoryItemPacket)packet; - - // User internal variable references, so we don't fire off any update code by using the public accessors - - iiCreationInProgress._ItemID = reply.InventoryData[0].ItemID; - - iiCreationInProgress._GroupOwned = reply.InventoryData[0].GroupOwned; - iiCreationInProgress._SaleType = reply.InventoryData[0].SaleType; - iiCreationInProgress._CreationDate = reply.InventoryData[0].CreationDate; - iiCreationInProgress._BaseMask = reply.InventoryData[0].BaseMask; - - iiCreationInProgress._Name = Helpers.FieldToString(reply.InventoryData[0].Name); - iiCreationInProgress._InvType = reply.InventoryData[0].InvType; - iiCreationInProgress._Type = reply.InventoryData[0].Type; - iiCreationInProgress._AssetID = reply.InventoryData[0].AssetID; - iiCreationInProgress._GroupID = reply.InventoryData[0].GroupID; - iiCreationInProgress._SalePrice = reply.InventoryData[0].SalePrice; - iiCreationInProgress._OwnerID = reply.InventoryData[0].OwnerID; - iiCreationInProgress._CreatorID = reply.InventoryData[0].CreatorID; - iiCreationInProgress._ItemID = reply.InventoryData[0].ItemID; - iiCreationInProgress._FolderID = reply.InventoryData[0].FolderID; - iiCreationInProgress._EveryoneMask = reply.InventoryData[0].EveryoneMask; - iiCreationInProgress._Description = Helpers.FieldToString(reply.InventoryData[0].Description); - iiCreationInProgress._NextOwnerMask = reply.InventoryData[0].NextOwnerMask; - iiCreationInProgress._GroupMask = reply.InventoryData[0].GroupMask; - iiCreationInProgress._OwnerMask = reply.InventoryData[0].OwnerMask; - - // NOT USED YET: iiCreationInProgress._CallbackID = reply.InventoryData[0].CallbackID; - - ItemCreationInProgress = false; - } - else - { - Console.WriteLine(packet); - throw new Exception("Received a packet for item creation, but no such response was expected. This is probably a bad thing..."); - } - } - - - public void InventoryDescendentsHandler(Packet packet, Simulator simulator) - { - InventoryDescendentsPacket reply = (InventoryDescendentsPacket)packet; - - LastPacketRecieved = Helpers.GetUnixTime(); - - InventoryItem invItem; - InventoryFolder invFolder; - - LLUUID uuidFolderID = new LLUUID(); - - int iDescendentsExpected = int.MaxValue; - int iDescendentsReceivedThisBlock = 0; - - foreach (InventoryDescendentsPacket.ItemDataBlock itemBlock in reply.ItemData) - { - // There is always an item block, even if there isn't any items - // the "filler" block will not have a name - if (itemBlock.Name.Length != 0) - { - iDescendentsReceivedThisBlock++; - - invItem = new InventoryItem(this, itemBlock); - - InventoryFolder ifolder = (InventoryFolder)htFoldersByUUID[invItem.FolderID]; - - if (ifolder.alContents.Contains(invItem) == false) - { - if ((invItem.InvType == 7) && (invItem.Type == Asset.ASSET_TYPE_NOTECARD)) - { - InventoryItem temp = new InventoryNotecard(this, invItem); - invItem = temp; - } - - if ((invItem.InvType == 0) && (invItem.Type == Asset.ASSET_TYPE_IMAGE)) - { - InventoryItem temp = new InventoryImage(this, invItem); - invItem = temp; - } - - ifolder.alContents.Add(invItem); - } - - } - } - - - foreach (InventoryDescendentsPacket.FolderDataBlock folderBlock in reply.FolderData) - { - String name = System.Text.Encoding.UTF8.GetString(folderBlock.Name).Trim().Replace("\0", ""); - LLUUID folderid = folderBlock.FolderID; - LLUUID parentid = folderBlock.ParentID; - sbyte type = folderBlock.Type; - - // There is always an folder block, even if there isn't any folders - // the "filler" block will not have a name - if (folderBlock.Name.Length != 0) - { - invFolder = new InventoryFolder(this, name, folderid, parentid); - - iDescendentsReceivedThisBlock++; - - // Add folder to Parent - InventoryFolder ifolder = (InventoryFolder)htFoldersByUUID[invFolder.ParentID]; - if( ifolder.alContents.Contains(invFolder) == false ) - { - ifolder.alContents.Add(invFolder); - } - - - // Add folder to UUID Lookup - htFoldersByUUID[invFolder.FolderID] = invFolder; - - - // It's not the root, should be safe to "recurse" - if( !invFolder.FolderID.Equals( uuidRootFolder ) ) - { - bool alreadyQueued = false; - foreach( DescendentRequest dr in alFolderRequestQueue ) - { - if( dr.FolderID == invFolder.FolderID ) - { - alreadyQueued = true; - break; - } - } - - if( !alreadyQueued ) - { - alFolderRequestQueue.Add( new DescendentRequest( invFolder.FolderID ) ); - } - } - } - } - - - // Check how many descendents we're actually supposed to receive - iDescendentsExpected = reply.AgentData.Descendents; - uuidFolderID = reply.AgentData.FolderID; - - // Update download status for this folder - if( iDescendentsReceivedThisBlock >= iDescendentsExpected ) - { - // We received all the descendents we're expecting for this folder - // in this packet, so go ahead and remove folder from status list. - htFolderDownloadStatus.Remove(uuidFolderID); - } - else - { - - // This one packet didn't have all the descendents we're expecting - // so update the total we're expecting, and update the total downloaded - - DescendentRequest dr = (DescendentRequest)htFolderDownloadStatus[uuidFolderID]; - dr.Expected = iDescendentsExpected; - dr.Received += iDescendentsReceivedThisBlock; - dr.LastReceived = Helpers.GetUnixTime(); - - if( dr.Received >= dr.Expected ) - { - // Looks like after updating, we have all the descendents, - // remove from folder status. - htFolderDownloadStatus.Remove(uuidFolderID); - } - else - { - htFolderDownloadStatus[uuidFolderID] = dr; -// Console.WriteLine( uuidFolderID + " is expecting " + (iDescendentsExpected - iStatus[1]) + " more packets." ); - } - } - } - - private class DescendentRequest - { - public LLUUID FolderID; - - public int Expected = int.MaxValue; - public int Received = 0; - public uint LastReceived = 0; - - public bool FetchFolders = true; - public bool FetchItems = true; - - public DescendentRequest(LLUUID folderID) - { - FolderID = folderID; - LastReceived = Helpers.GetUnixTime(); - } - - public DescendentRequest(LLUUID folderID, bool fetchFolders, bool fetchItems) - { - FolderID = folderID; - FetchFolders = fetchFolders; - FetchItems = fetchItems; - LastReceived = Helpers.GetUnixTime(); - } - - } - } -} +/* + * Copyright (c) 2006, Second Life Reverse Engineering Team + * All rights reserved. + * + * - Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Neither the name of the Second Life Reverse Engineering Team nor the names + * of its contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; + +using libsecondlife; +using libsecondlife.AssetSystem; +using libsecondlife.Packets; + + +namespace libsecondlife.InventorySystem +{ + + /// + /// Summary description for Inventory. + /// + public class InventoryManager + { + private const bool DEBUG_PACKETS = true; + + + // Reference to the SLClient Library + private SecondLife slClient; + + // Reference to the Asset Manager + private static AssetManager slAssetManager; + internal AssetManager AssetManager + { + get{ return slAssetManager; } + } + + public InventoryPacketHelper InvPacketHelper = null; + + // UUID of Root Inventory Folder + private LLUUID uuidRootFolder; + + // Setup a hashtable to easily lookup folders by UUID + private Hashtable htFoldersByUUID = new Hashtable(); + + // Setup a Hashtable to track download progress + private Hashtable htFolderDownloadStatus; + private ArrayList alFolderRequestQueue; + + // Used to track current item being created + private InventoryItem iiCreationInProgress; + private bool ItemCreationInProgress; + + private uint LastPacketRecieved; + + // Each InventorySystem needs to be initialized with a client and root folder. + public InventoryManager( SecondLife client, LLUUID rootFolder ) + { + slClient = client; + if( slAssetManager == null ) + { + slAssetManager = new AssetManager( slClient ); + } + + InvPacketHelper = new InventoryPacketHelper(slClient.Network.AgentID, slClient.Network.SessionID); + + uuidRootFolder = rootFolder; + + resetFoldersByUUID(); + + // Setup the callback for Inventory Downloads + PacketCallback InventoryDescendentsCallback = new PacketCallback(InventoryDescendentsHandler); + slClient.Network.RegisterCallback(PacketType.InventoryDescendents, InventoryDescendentsCallback); + + // Setup the callback for Inventory Creation Update + PacketCallback UpdateCreateInventoryItemCallback = new PacketCallback(UpdateCreateInventoryItemHandler); + slClient.Network.RegisterCallback(PacketType.UpdateCreateInventoryItem, UpdateCreateInventoryItemCallback); + + } + + // Used primarily for debugging and testing + public AssetManager getAssetManager() + { + Console.WriteLine("It is not recommended that you access the asset manager directly"); + return AssetManager; + } + + private void resetFoldersByUUID() + { + // Init folder structure with root + htFoldersByUUID = new Hashtable(); + + InventoryFolder ifRootFolder = new InventoryFolder(this, "My Inventory", uuidRootFolder, null); + htFoldersByUUID[uuidRootFolder] = ifRootFolder; + } + + public InventoryFolder getRootFolder() + { + return (InventoryFolder)htFoldersByUUID[uuidRootFolder]; + } + + public InventoryFolder getFolder( LLUUID folderID ) + { + return (InventoryFolder)htFoldersByUUID[folderID]; + } + + public InventoryFolder getFolder( String sFolderPath ) + { + string sSecretConst = "+@#%$#$%^%^%$^$%SV$#%FR$G"; + sFolderPath = sFolderPath.Replace("//",sSecretConst); + + if (sFolderPath.StartsWith("/")) + { + sFolderPath = sFolderPath.Remove(0, 1); + } + + if (sFolderPath.Length == 0) + { + return getRootFolder(); + } + + char[] seperators = { '/' }; + string[] sFolderPathParts = sFolderPath.Split(seperators); + + for( int i = 0; i 0) || (alFolderRequestQueue.Count > 0) ) + { + if( htFolderDownloadStatus.Count == 0 ) + { + DescendentRequest dr = (DescendentRequest)alFolderRequestQueue[0]; + alFolderRequestQueue.RemoveAt(0); + RequestFolder( dr ); + } + + if ((Helpers.GetUnixTime() - LastPacketRecieved) > 10) + { + Console.WriteLine("Time-out while waiting for packets (" + (Helpers.GetUnixTime() - LastPacketRecieved) + " seconds since last packet)"); + Console.WriteLine("Current Status:"); + + // have to make a seperate list otherwise we run into modifying the original array + // while still enumerating it. + ArrayList alRestartList = new ArrayList(); + + if (htFolderDownloadStatus[0] != null) + { + Console.WriteLine(htFolderDownloadStatus[0].GetType()); + } + + foreach( DescendentRequest dr in htFolderDownloadStatus.Values ) + { + Console.WriteLine( dr.FolderID + " " + dr.Expected + " / " + dr.Received + " / " + dr.LastReceived ); + + alRestartList.Add( dr ); + } + + LastPacketRecieved = Helpers.GetUnixTime(); + foreach( DescendentRequest dr in alRestartList ) + { + RequestFolder( dr ); + } + + } + slClient.Tick(); + + } + } + + + + public void UpdateCreateInventoryItemHandler(Packet packet, Simulator simulator) + { + if (DEBUG_PACKETS) { Console.WriteLine(packet); } + + if (ItemCreationInProgress) + { + UpdateCreateInventoryItemPacket reply = (UpdateCreateInventoryItemPacket)packet; + + // User internal variable references, so we don't fire off any update code by using the public accessors + + iiCreationInProgress._ItemID = reply.InventoryData[0].ItemID; + + iiCreationInProgress._GroupOwned = reply.InventoryData[0].GroupOwned; + iiCreationInProgress._SaleType = reply.InventoryData[0].SaleType; + iiCreationInProgress._CreationDate = reply.InventoryData[0].CreationDate; + iiCreationInProgress._BaseMask = reply.InventoryData[0].BaseMask; + + iiCreationInProgress._Name = Helpers.FieldToString(reply.InventoryData[0].Name); + iiCreationInProgress._InvType = reply.InventoryData[0].InvType; + iiCreationInProgress._Type = reply.InventoryData[0].Type; + iiCreationInProgress._AssetID = reply.InventoryData[0].AssetID; + iiCreationInProgress._GroupID = reply.InventoryData[0].GroupID; + iiCreationInProgress._SalePrice = reply.InventoryData[0].SalePrice; + iiCreationInProgress._OwnerID = reply.InventoryData[0].OwnerID; + iiCreationInProgress._CreatorID = reply.InventoryData[0].CreatorID; + iiCreationInProgress._ItemID = reply.InventoryData[0].ItemID; + iiCreationInProgress._FolderID = reply.InventoryData[0].FolderID; + iiCreationInProgress._EveryoneMask = reply.InventoryData[0].EveryoneMask; + iiCreationInProgress._Description = Helpers.FieldToString(reply.InventoryData[0].Description); + iiCreationInProgress._NextOwnerMask = reply.InventoryData[0].NextOwnerMask; + iiCreationInProgress._GroupMask = reply.InventoryData[0].GroupMask; + iiCreationInProgress._OwnerMask = reply.InventoryData[0].OwnerMask; + + // NOT USED YET: iiCreationInProgress._CallbackID = reply.InventoryData[0].CallbackID; + + ItemCreationInProgress = false; + } + else + { + Console.WriteLine(packet); + throw new Exception("Received a packet for item creation, but no such response was expected. This is probably a bad thing..."); + } + } + + + public void InventoryDescendentsHandler(Packet packet, Simulator simulator) + { + InventoryDescendentsPacket reply = (InventoryDescendentsPacket)packet; + + LastPacketRecieved = Helpers.GetUnixTime(); + + InventoryItem invItem; + InventoryFolder invFolder; + + LLUUID uuidFolderID = new LLUUID(); + + int iDescendentsExpected = int.MaxValue; + int iDescendentsReceivedThisBlock = 0; + + foreach (InventoryDescendentsPacket.ItemDataBlock itemBlock in reply.ItemData) + { + // There is always an item block, even if there isn't any items + // the "filler" block will not have a name + if (itemBlock.Name.Length != 0) + { + iDescendentsReceivedThisBlock++; + + invItem = new InventoryItem(this, itemBlock); + + InventoryFolder ifolder = (InventoryFolder)htFoldersByUUID[invItem.FolderID]; + + if (ifolder.alContents.Contains(invItem) == false) + { + if ((invItem.InvType == 7) && (invItem.Type == Asset.ASSET_TYPE_NOTECARD)) + { + InventoryItem temp = new InventoryNotecard(this, invItem); + invItem = temp; + } + + if ((invItem.InvType == 0) && (invItem.Type == Asset.ASSET_TYPE_IMAGE)) + { + InventoryItem temp = new InventoryImage(this, invItem); + invItem = temp; + } + + ifolder.alContents.Add(invItem); + } + + } + } + + + foreach (InventoryDescendentsPacket.FolderDataBlock folderBlock in reply.FolderData) + { + String name = System.Text.Encoding.UTF8.GetString(folderBlock.Name).Trim().Replace("\0", ""); + LLUUID folderid = folderBlock.FolderID; + LLUUID parentid = folderBlock.ParentID; + sbyte type = folderBlock.Type; + + // There is always an folder block, even if there isn't any folders + // the "filler" block will not have a name + if (folderBlock.Name.Length != 0) + { + invFolder = new InventoryFolder(this, name, folderid, parentid); + + iDescendentsReceivedThisBlock++; + + // Add folder to Parent + InventoryFolder ifolder = (InventoryFolder)htFoldersByUUID[invFolder.ParentID]; + if( ifolder.alContents.Contains(invFolder) == false ) + { + ifolder.alContents.Add(invFolder); + } + + + // Add folder to UUID Lookup + htFoldersByUUID[invFolder.FolderID] = invFolder; + + + // It's not the root, should be safe to "recurse" + if( !invFolder.FolderID.Equals( uuidRootFolder ) ) + { + bool alreadyQueued = false; + foreach( DescendentRequest dr in alFolderRequestQueue ) + { + if( dr.FolderID == invFolder.FolderID ) + { + alreadyQueued = true; + break; + } + } + + if( !alreadyQueued ) + { + alFolderRequestQueue.Add( new DescendentRequest( invFolder.FolderID ) ); + } + } + } + } + + + // Check how many descendents we're actually supposed to receive + iDescendentsExpected = reply.AgentData.Descendents; + uuidFolderID = reply.AgentData.FolderID; + + // Update download status for this folder + if( iDescendentsReceivedThisBlock >= iDescendentsExpected ) + { + // We received all the descendents we're expecting for this folder + // in this packet, so go ahead and remove folder from status list. + htFolderDownloadStatus.Remove(uuidFolderID); + } + else + { + + // This one packet didn't have all the descendents we're expecting + // so update the total we're expecting, and update the total downloaded + + DescendentRequest dr = (DescendentRequest)htFolderDownloadStatus[uuidFolderID]; + dr.Expected = iDescendentsExpected; + dr.Received += iDescendentsReceivedThisBlock; + dr.LastReceived = Helpers.GetUnixTime(); + + if( dr.Received >= dr.Expected ) + { + // Looks like after updating, we have all the descendents, + // remove from folder status. + htFolderDownloadStatus.Remove(uuidFolderID); + } + else + { + htFolderDownloadStatus[uuidFolderID] = dr; +// Console.WriteLine( uuidFolderID + " is expecting " + (iDescendentsExpected - iStatus[1]) + " more packets." ); + } + } + } + + private class DescendentRequest + { + public LLUUID FolderID; + + public int Expected = int.MaxValue; + public int Received = 0; + public uint LastReceived = 0; + + public bool FetchFolders = true; + public bool FetchItems = true; + + public DescendentRequest(LLUUID folderID) + { + FolderID = folderID; + LastReceived = Helpers.GetUnixTime(); + } + + public DescendentRequest(LLUUID folderID, bool fetchFolders, bool fetchItems) + { + FolderID = folderID; + FetchFolders = fetchFolders; + FetchItems = fetchItems; + LastReceived = Helpers.GetUnixTime(); + } + + } + } +} diff --git a/libsecondlife-cs/InventorySystem/InventoryNotecard.cs b/libsecondlife-cs/InventorySystem/InventoryNotecard.cs index 92367a30..2435d491 100644 --- a/libsecondlife-cs/InventorySystem/InventoryNotecard.cs +++ b/libsecondlife-cs/InventorySystem/InventoryNotecard.cs @@ -1,160 +1,160 @@ -using System; - -using libsecondlife; -using libsecondlife.AssetSystem; - -namespace libsecondlife.InventorySystem -{ - /// - /// Summary description for InventoryNotecard. - /// - public class InventoryNotecard : InventoryItem - { - public string Body - { - get - { - if( Asset != null ) - { - return ((AssetNotecard)Asset).Body; - } else { - if( (AssetID != null) && (AssetID != new LLUUID()) ) - { - base.iManager.AssetManager.GetInventoryAsset( this ); - return ((AssetNotecard)Asset).Body; - } - } - - return null; - } - - set - { - base._Asset = new AssetNotecard( LLUUID.GenerateUUID(), value ); - LLUUID TransactionID = base.iManager.AssetManager.UploadAsset( Asset ); - base.SetAssetTransactionIDs(Asset.AssetID, TransactionID); - } - } - - - /// - /// - /// - /// - /// - /// - /// - /// - internal InventoryNotecard(InventoryManager manager, string name, string description, LLUUID folderID, LLUUID uuidOwnerCreater) - : base(manager, name, description, folderID, 7, 7, uuidOwnerCreater) - { - - } - - /// - /// - /// - /// - internal InventoryNotecard(InventoryManager manager, InventoryItem ii) - : base( manager, ii._Name, ii._Description, ii._FolderID, ii._InvType, ii._Type, ii._CreatorID) - { - if( (ii.InvType != 7) || (ii.Type != Asset.ASSET_TYPE_NOTECARD) ) - { - throw new Exception("The InventoryItem cannot be converted to a Notecard, wrong InvType/Type."); - } - - this.iManager = manager; - this._Asset = ii._Asset; - this._AssetID = ii._AssetID; - this._BaseMask = ii._BaseMask; - this._CRC = ii._CRC; - this._CreationDate = ii._CreationDate; - this._EveryoneMask = ii._EveryoneMask; - this._Flags = ii._Flags; - this._GroupID = ii._GroupID; - this._GroupMask = ii._GroupMask; - this._GroupOwned = ii._GroupOwned; - this._InvType = ii._InvType; - this._NextOwnerMask = ii._NextOwnerMask; - this._OwnerID = ii._OwnerID; - this._OwnerMask = ii._OwnerMask; - this._SalePrice = ii._SalePrice; - this._SaleType = ii._SaleType; - this._Type = ii._Type; - } - - /// - /// - /// - override internal void SetAssetData(byte[] assetData) - { - if( _Asset == null ) - { - if( AssetID != null ) - { - _Asset = new AssetNotecard( AssetID, assetData ); - } - else - { - _Asset = new AssetNotecard( LLUUID.GenerateUUID(), assetData ); - _AssetID = _Asset.AssetID; - } - } - else - { - _Asset.AssetData = assetData; - } - - } - - /// - /// Output this item as XML - /// - /// Include an asset data as well, TRUE/FALSE - override public string toXML(bool outputAssets) - { - string output = " + /// Summary description for InventoryNotecard. + /// + public class InventoryNotecard : InventoryItem + { + public string Body + { + get + { + if( Asset != null ) + { + return ((AssetNotecard)Asset).Body; + } else { + if( (AssetID != null) && (AssetID != new LLUUID()) ) + { + base.iManager.AssetManager.GetInventoryAsset( this ); + return ((AssetNotecard)Asset).Body; + } + } + + return null; + } + + set + { + base._Asset = new AssetNotecard( LLUUID.GenerateUUID(), value ); + LLUUID TransactionID = base.iManager.AssetManager.UploadAsset( Asset ); + base.SetAssetTransactionIDs(Asset.AssetID, TransactionID); + } + } + + + /// + /// + /// + /// + /// + /// + /// + /// + internal InventoryNotecard(InventoryManager manager, string name, string description, LLUUID folderID, LLUUID uuidOwnerCreater) + : base(manager, name, description, folderID, 7, 7, uuidOwnerCreater) + { + + } + + /// + /// + /// + /// + internal InventoryNotecard(InventoryManager manager, InventoryItem ii) + : base( manager, ii._Name, ii._Description, ii._FolderID, ii._InvType, ii._Type, ii._CreatorID) + { + if( (ii.InvType != 7) || (ii.Type != Asset.ASSET_TYPE_NOTECARD) ) + { + throw new Exception("The InventoryItem cannot be converted to a Notecard, wrong InvType/Type."); + } + + this.iManager = manager; + this._Asset = ii._Asset; + this._AssetID = ii._AssetID; + this._BaseMask = ii._BaseMask; + this._CRC = ii._CRC; + this._CreationDate = ii._CreationDate; + this._EveryoneMask = ii._EveryoneMask; + this._Flags = ii._Flags; + this._GroupID = ii._GroupID; + this._GroupMask = ii._GroupMask; + this._GroupOwned = ii._GroupOwned; + this._InvType = ii._InvType; + this._NextOwnerMask = ii._NextOwnerMask; + this._OwnerID = ii._OwnerID; + this._OwnerMask = ii._OwnerMask; + this._SalePrice = ii._SalePrice; + this._SaleType = ii._SaleType; + this._Type = ii._Type; + } + + /// + /// + /// + override internal void SetAssetData(byte[] assetData) + { + if( _Asset == null ) + { + if( AssetID != null ) + { + _Asset = new AssetNotecard( AssetID, assetData ); + } + else + { + _Asset = new AssetNotecard( LLUUID.GenerateUUID(), assetData ); + _AssetID = _Asset.AssetID; + } + } + else + { + _Asset.AssetData = assetData; + } + + } + + /// + /// Output this item as XML + /// + /// Include an asset data as well, TRUE/FALSE + override public string toXML(bool outputAssets) + { + string output = " - /// Summary description for Other. - /// - public class InventoryPacketHelper - { - private LLUUID AgentID; - private LLUUID SessionID; - - public InventoryPacketHelper(LLUUID AgentID, LLUUID SessionID) - { - this.AgentID = AgentID; - this.SessionID = SessionID; - } - - public const int FETCH_INVENTORY_SORT_NAME = 0; - public const int FETCH_INVENTORY_SORT_TIME = 1; - - - public Packet FetchInventoryDescendents( LLUUID folderID ) - { - return FetchInventoryDescendents( folderID, true, true ); - } - - public Packet FetchInventoryDescendents( LLUUID folderID, bool fetchFolders, bool fetchItems ) - { - FetchInventoryDescendentsPacket p = new FetchInventoryDescendentsPacket(); - p.InventoryData.OwnerID = AgentID; - p.InventoryData.FolderID = folderID; - p.InventoryData.SortOrder = FETCH_INVENTORY_SORT_NAME; - p.InventoryData.FetchFolders = fetchFolders; - p.InventoryData.FetchItems = fetchItems; - - p.AgentData.AgentID = AgentID; - p.AgentData.SessionID = SessionID; - - return p; - } - - public Packet FetchInventory(LLUUID OwnerID, LLUUID ItemID) - { - FetchInventoryPacket p = new FetchInventoryPacket(); - p.InventoryData = new FetchInventoryPacket.InventoryDataBlock[1]; - p.InventoryData[0] = new FetchInventoryPacket.InventoryDataBlock(); - p.InventoryData[0].OwnerID = OwnerID; - p.InventoryData[0].ItemID = ItemID; - - p.AgentData.AgentID = AgentID; - p.AgentData.SessionID = SessionID; - - return p; - } - - public Packet CreateInventoryFolder( - string name - , LLUUID parentID - , sbyte type - , LLUUID folderID - ) - { - CreateInventoryFolderPacket p = new CreateInventoryFolderPacket(); - p.AgentData.AgentID = AgentID; - p.AgentData.SessionID = SessionID; - - p.FolderData.Name = Helpers.StringToField(name); - p.FolderData.ParentID = parentID; - p.FolderData.Type = type; - p.FolderData.FolderID = folderID; - - return p; - } - - - - public Packet MoveInventoryFolder( - LLUUID parentID - , LLUUID folderID - ) - { - MoveInventoryFolderPacket p = new MoveInventoryFolderPacket(); - p.AgentData.AgentID = AgentID; - p.AgentData.SessionID = SessionID; - p.AgentData.Stamp = false; - - p.InventoryData = new MoveInventoryFolderPacket.InventoryDataBlock[1]; - p.InventoryData[0] = new MoveInventoryFolderPacket.InventoryDataBlock(); - - p.InventoryData[0].ParentID = parentID; - p.InventoryData[0].FolderID = folderID; - - return p; - - } - - - public Packet RemoveInventoryFolder( - LLUUID folderID - ) - { - RemoveInventoryFolderPacket p = new RemoveInventoryFolderPacket(); - p.AgentData.AgentID = AgentID; - p.AgentData.SessionID = SessionID; - - p.FolderData = new RemoveInventoryFolderPacket.FolderDataBlock[1]; - p.FolderData[0] = new RemoveInventoryFolderPacket.FolderDataBlock(); - - p.FolderData[0].FolderID = folderID; - - return p; - - } - - - public Packet UpdateInventoryFolder( - string name - , LLUUID parentID - , sbyte type - , LLUUID folderID - ) - { - UpdateInventoryFolderPacket p = new UpdateInventoryFolderPacket(); - p.AgentData.AgentID = AgentID; - p.AgentData.SessionID = SessionID; - - p.FolderData = new UpdateInventoryFolderPacket.FolderDataBlock[1]; - p.FolderData[0] = new UpdateInventoryFolderPacket.FolderDataBlock(); - - - p.FolderData[0].Name = Helpers.StringToField(name); - p.FolderData[0].ParentID = parentID; - p.FolderData[0].Type = type; - p.FolderData[0].FolderID = folderID; - - return p; - - } - - public Packet MoveInventoryItem( - LLUUID itemID - , LLUUID folderID - ) - { - MoveInventoryItemPacket p = new MoveInventoryItemPacket(); - p.AgentData.AgentID = AgentID; - p.AgentData.SessionID = SessionID; - p.AgentData.Stamp = true; - - p.InventoryData = new MoveInventoryItemPacket.InventoryDataBlock[1]; - p.InventoryData[0] = new MoveInventoryItemPacket.InventoryDataBlock(); - - p.InventoryData[0].ItemID = itemID; - p.InventoryData[0].FolderID = folderID; - - return p; - - } - - public Packet CopyInventoryItem( - LLUUID itemID - , LLUUID folderID - ) - { - CopyInventoryItemPacket p = new CopyInventoryItemPacket(); - p.AgentData.AgentID = AgentID; - p.AgentData.SessionID = SessionID; - - p.InventoryData = new CopyInventoryItemPacket.InventoryDataBlock[1]; - p.InventoryData[0] = new CopyInventoryItemPacket.InventoryDataBlock(); - - p.InventoryData[0].CallbackID = 0; - p.InventoryData[0].OldAgentID = AgentID; //TODO: Find out what this is supposed to be. Added field 10/11/06, no docs in Message Template - - p.InventoryData[0].OldItemID = itemID; - p.InventoryData[0].NewFolderID = folderID; - - return p; - } - - public Packet RemoveInventoryItem( - LLUUID itemID - ) - { - RemoveInventoryItemPacket p = new RemoveInventoryItemPacket(); - p.AgentData.AgentID = AgentID; - p.AgentData.SessionID = SessionID; - - p.InventoryData = new RemoveInventoryItemPacket.InventoryDataBlock[1]; - p.InventoryData[0] = new RemoveInventoryItemPacket.InventoryDataBlock(); - - p.InventoryData[0].ItemID = itemID; - - return p; - - } - - public Packet ImprovedInstantMessage( - LLUUID ID - , LLUUID ToAgentID - , String FromAgentName - , LLVector3 FromAgentLoc - , InventoryItem Item - ) - { - byte[] BinaryBucket = new byte[17]; - BinaryBucket[0] = (byte)Item.Type; - Array.Copy(Item.ItemID.Data, 0, BinaryBucket, 1, 16); - - ImprovedInstantMessagePacket p = new ImprovedInstantMessagePacket(); - p.AgentData.AgentID = AgentID; - p.AgentData.SessionID = SessionID; - - p.MessageBlock.ID = ID; - p.MessageBlock.ToAgentID = ToAgentID; - p.MessageBlock.Offline = (byte)0; - p.MessageBlock.Timestamp = Helpers.GetUnixTime(); - p.MessageBlock.Message = Helpers.StringToField(Item.Name); - p.MessageBlock.Dialog = (byte)4; - p.MessageBlock.BinaryBucket = BinaryBucket; - p.MessageBlock.FromAgentName = Helpers.StringToField(FromAgentName); - p.MessageBlock.Position = FromAgentLoc; - - // TODO: Either overload this method to allow inclusion of region info or - // overload the ImprovedInstantMessage in the avatar class to allow item payloads - p.MessageBlock.RegionID = new LLUUID(); - p.MessageBlock.ParentEstateID = (uint)0; - - return p; - } - - - - public Packet CreateInventoryItem(InventoryItem iitem) - { - CreateInventoryItemPacket p = new CreateInventoryItemPacket(); - - p.InventoryBlock.CallbackID = 0; - p.InventoryBlock.TransactionID = new LLUUID(); - - p.InventoryBlock.WearableType = 0; //TODO: Specify the current type here - p.InventoryBlock.Type = iitem.Type; - p.InventoryBlock.InvType = iitem.InvType; - - p.InventoryBlock.Name = Helpers.StringToField(iitem.Name); - p.InventoryBlock.FolderID = iitem.FolderID; - p.InventoryBlock.Description = Helpers.StringToField(iitem.Description); - - p.InventoryBlock.NextOwnerMask = iitem.NextOwnerMask; - - p.AgentData.AgentID = AgentID; - p.AgentData.SessionID = SessionID; - - return p; - - } - - public Packet UpdateInventoryItem(InventoryItem iitem) - { - UpdateInventoryItemPacket p = new UpdateInventoryItemPacket(); - p.InventoryData = new UpdateInventoryItemPacket.InventoryDataBlock[1]; - p.InventoryData[0] = new UpdateInventoryItemPacket.InventoryDataBlock(); - - p.InventoryData[0].TransactionID = iitem.TransactionID; - - p.InventoryData[0].GroupOwned = iitem.GroupOwned; - p.InventoryData[0].CRC = iitem.CRC; - p.InventoryData[0].CreationDate = iitem.CreationDate; - p.InventoryData[0].SaleType = iitem.SaleType; - p.InventoryData[0].BaseMask = iitem.BaseMask; - p.InventoryData[0].Name = Helpers.StringToField(iitem.Name); - p.InventoryData[0].InvType = iitem.InvType; - p.InventoryData[0].Type = iitem.Type; - p.InventoryData[0].GroupID = iitem.GroupID; - p.InventoryData[0].SalePrice = iitem.SalePrice; - p.InventoryData[0].OwnerID = iitem.OwnerID; - p.InventoryData[0].CreatorID = iitem.CreatorID; - p.InventoryData[0].ItemID = iitem.ItemID; - p.InventoryData[0].FolderID = iitem.FolderID; - p.InventoryData[0].EveryoneMask = iitem.EveryoneMask; - p.InventoryData[0].Description = Helpers.StringToField(iitem.Description); - p.InventoryData[0].Flags = iitem.Flags; - p.InventoryData[0].NextOwnerMask= iitem.NextOwnerMask; - p.InventoryData[0].GroupMask = iitem.GroupMask; - p.InventoryData[0].OwnerMask = iitem.OwnerMask; - - - p.AgentData.AgentID = AgentID; - p.AgentData.SessionID = SessionID; - - return p; - } - -/* - // Confirm InventoryUpdate CRC - uint test = libsecondlife.Packets.InventoryPackets.InventoryUpdateCRC - ( - (int)1159214416 - , (byte)0 - , (sbyte)7 - , (sbyte)7 - , (LLUUID)"00000000000000000000000000000000" - , (LLUUID)"00000000000000000000000000000000" - , (int)10 - , (LLUUID)"25472683cb324516904a6cd0ecabf128" - , (LLUUID)"25472683cb324516904a6cd0ecabf128" - , (LLUUID)"77364021f09f13dfb692f036be53b9e2" - , (LLUUID)"a4947fc066c247518d9854aaf90097f4" - , (uint)0 - , (uint)0 - , (uint)2147483647 - , (uint)0 - , (uint)2147483647 - ); - - if( test != (uint)895206313 ) - { - Console.WriteLine("CRC Generation is no longer correct."); - return; - } -*/ - - public static uint InventoryUpdateCRC(InventoryItem iitem) - { - uint CRC = 0; - - /* IDs */ - CRC += iitem.AssetID.CRC(); // AssetID - CRC += iitem.FolderID.CRC(); // FolderID - CRC += iitem.ItemID==null?new LLUUID().CRC():iitem.ItemID.CRC(); // ItemID - - /* Permission stuff */ - CRC += iitem.CreatorID.CRC(); // CreatorID - CRC += iitem.OwnerID.CRC(); // OwnerID - CRC += iitem.GroupID.CRC(); // GroupID - - /* CRC += another 4 words which always seem to be zero -- unclear if this is a LLUUID or what */ - CRC += iitem.OwnerMask; //owner_mask; // Either owner_mask or next_owner_mask may need to be - CRC += iitem.NextOwnerMask; //next_owner_mask; // switched with base_mask -- 2 values go here and in my - CRC += iitem.EveryoneMask; //everyone_mask; // study item, the three were identical. - CRC += iitem.GroupMask; //group_mask; - - /* The rest of the CRC fields */ - CRC += iitem.Flags; // Flags - CRC += (uint)iitem.InvType; // InvType - CRC += (uint)iitem.Type; // Type - CRC += (uint)iitem.CreationDate; // CreationDate - CRC += (uint)iitem.SalePrice; // SalePrice - CRC += (uint)((uint)iitem.SaleType * 0x07073096); // SaleType - - return CRC; - } - } -} +using System; +using System.Collections; + +using libsecondlife; +using libsecondlife.Packets; + +namespace libsecondlife.InventorySystem +{ + /// + /// Summary description for Other. + /// + public class InventoryPacketHelper + { + private LLUUID AgentID; + private LLUUID SessionID; + + public InventoryPacketHelper(LLUUID AgentID, LLUUID SessionID) + { + this.AgentID = AgentID; + this.SessionID = SessionID; + } + + public const int FETCH_INVENTORY_SORT_NAME = 0; + public const int FETCH_INVENTORY_SORT_TIME = 1; + + + public Packet FetchInventoryDescendents( LLUUID folderID ) + { + return FetchInventoryDescendents( folderID, true, true ); + } + + public Packet FetchInventoryDescendents( LLUUID folderID, bool fetchFolders, bool fetchItems ) + { + FetchInventoryDescendentsPacket p = new FetchInventoryDescendentsPacket(); + p.InventoryData.OwnerID = AgentID; + p.InventoryData.FolderID = folderID; + p.InventoryData.SortOrder = FETCH_INVENTORY_SORT_NAME; + p.InventoryData.FetchFolders = fetchFolders; + p.InventoryData.FetchItems = fetchItems; + + p.AgentData.AgentID = AgentID; + p.AgentData.SessionID = SessionID; + + return p; + } + + public Packet FetchInventory(LLUUID OwnerID, LLUUID ItemID) + { + FetchInventoryPacket p = new FetchInventoryPacket(); + p.InventoryData = new FetchInventoryPacket.InventoryDataBlock[1]; + p.InventoryData[0] = new FetchInventoryPacket.InventoryDataBlock(); + p.InventoryData[0].OwnerID = OwnerID; + p.InventoryData[0].ItemID = ItemID; + + p.AgentData.AgentID = AgentID; + p.AgentData.SessionID = SessionID; + + return p; + } + + public Packet CreateInventoryFolder( + string name + , LLUUID parentID + , sbyte type + , LLUUID folderID + ) + { + CreateInventoryFolderPacket p = new CreateInventoryFolderPacket(); + p.AgentData.AgentID = AgentID; + p.AgentData.SessionID = SessionID; + + p.FolderData.Name = Helpers.StringToField(name); + p.FolderData.ParentID = parentID; + p.FolderData.Type = type; + p.FolderData.FolderID = folderID; + + return p; + } + + + + public Packet MoveInventoryFolder( + LLUUID parentID + , LLUUID folderID + ) + { + MoveInventoryFolderPacket p = new MoveInventoryFolderPacket(); + p.AgentData.AgentID = AgentID; + p.AgentData.SessionID = SessionID; + p.AgentData.Stamp = false; + + p.InventoryData = new MoveInventoryFolderPacket.InventoryDataBlock[1]; + p.InventoryData[0] = new MoveInventoryFolderPacket.InventoryDataBlock(); + + p.InventoryData[0].ParentID = parentID; + p.InventoryData[0].FolderID = folderID; + + return p; + + } + + + public Packet RemoveInventoryFolder( + LLUUID folderID + ) + { + RemoveInventoryFolderPacket p = new RemoveInventoryFolderPacket(); + p.AgentData.AgentID = AgentID; + p.AgentData.SessionID = SessionID; + + p.FolderData = new RemoveInventoryFolderPacket.FolderDataBlock[1]; + p.FolderData[0] = new RemoveInventoryFolderPacket.FolderDataBlock(); + + p.FolderData[0].FolderID = folderID; + + return p; + + } + + + public Packet UpdateInventoryFolder( + string name + , LLUUID parentID + , sbyte type + , LLUUID folderID + ) + { + UpdateInventoryFolderPacket p = new UpdateInventoryFolderPacket(); + p.AgentData.AgentID = AgentID; + p.AgentData.SessionID = SessionID; + + p.FolderData = new UpdateInventoryFolderPacket.FolderDataBlock[1]; + p.FolderData[0] = new UpdateInventoryFolderPacket.FolderDataBlock(); + + + p.FolderData[0].Name = Helpers.StringToField(name); + p.FolderData[0].ParentID = parentID; + p.FolderData[0].Type = type; + p.FolderData[0].FolderID = folderID; + + return p; + + } + + public Packet MoveInventoryItem( + LLUUID itemID + , LLUUID folderID + ) + { + MoveInventoryItemPacket p = new MoveInventoryItemPacket(); + p.AgentData.AgentID = AgentID; + p.AgentData.SessionID = SessionID; + p.AgentData.Stamp = true; + + p.InventoryData = new MoveInventoryItemPacket.InventoryDataBlock[1]; + p.InventoryData[0] = new MoveInventoryItemPacket.InventoryDataBlock(); + + p.InventoryData[0].ItemID = itemID; + p.InventoryData[0].FolderID = folderID; + + return p; + + } + + public Packet CopyInventoryItem( + LLUUID itemID + , LLUUID folderID + ) + { + CopyInventoryItemPacket p = new CopyInventoryItemPacket(); + p.AgentData.AgentID = AgentID; + p.AgentData.SessionID = SessionID; + + p.InventoryData = new CopyInventoryItemPacket.InventoryDataBlock[1]; + p.InventoryData[0] = new CopyInventoryItemPacket.InventoryDataBlock(); + + p.InventoryData[0].CallbackID = 0; + p.InventoryData[0].OldAgentID = AgentID; //TODO: Find out what this is supposed to be. Added field 10/11/06, no docs in Message Template + + p.InventoryData[0].OldItemID = itemID; + p.InventoryData[0].NewFolderID = folderID; + + return p; + } + + public Packet RemoveInventoryItem( + LLUUID itemID + ) + { + RemoveInventoryItemPacket p = new RemoveInventoryItemPacket(); + p.AgentData.AgentID = AgentID; + p.AgentData.SessionID = SessionID; + + p.InventoryData = new RemoveInventoryItemPacket.InventoryDataBlock[1]; + p.InventoryData[0] = new RemoveInventoryItemPacket.InventoryDataBlock(); + + p.InventoryData[0].ItemID = itemID; + + return p; + + } + + public Packet ImprovedInstantMessage( + LLUUID ID + , LLUUID ToAgentID + , String FromAgentName + , LLVector3 FromAgentLoc + , InventoryItem Item + ) + { + byte[] BinaryBucket = new byte[17]; + BinaryBucket[0] = (byte)Item.Type; + Array.Copy(Item.ItemID.Data, 0, BinaryBucket, 1, 16); + + ImprovedInstantMessagePacket p = new ImprovedInstantMessagePacket(); + p.AgentData.AgentID = AgentID; + p.AgentData.SessionID = SessionID; + + p.MessageBlock.ID = ID; + p.MessageBlock.ToAgentID = ToAgentID; + p.MessageBlock.Offline = (byte)0; + p.MessageBlock.Timestamp = Helpers.GetUnixTime(); + p.MessageBlock.Message = Helpers.StringToField(Item.Name); + p.MessageBlock.Dialog = (byte)4; + p.MessageBlock.BinaryBucket = BinaryBucket; + p.MessageBlock.FromAgentName = Helpers.StringToField(FromAgentName); + p.MessageBlock.Position = FromAgentLoc; + + // TODO: Either overload this method to allow inclusion of region info or + // overload the ImprovedInstantMessage in the avatar class to allow item payloads + p.MessageBlock.RegionID = new LLUUID(); + p.MessageBlock.ParentEstateID = (uint)0; + + return p; + } + + + + public Packet CreateInventoryItem(InventoryItem iitem) + { + CreateInventoryItemPacket p = new CreateInventoryItemPacket(); + + p.InventoryBlock.CallbackID = 0; + p.InventoryBlock.TransactionID = new LLUUID(); + + p.InventoryBlock.WearableType = 0; //TODO: Specify the current type here + p.InventoryBlock.Type = iitem.Type; + p.InventoryBlock.InvType = iitem.InvType; + + p.InventoryBlock.Name = Helpers.StringToField(iitem.Name); + p.InventoryBlock.FolderID = iitem.FolderID; + p.InventoryBlock.Description = Helpers.StringToField(iitem.Description); + + p.InventoryBlock.NextOwnerMask = iitem.NextOwnerMask; + + p.AgentData.AgentID = AgentID; + p.AgentData.SessionID = SessionID; + + return p; + + } + + public Packet UpdateInventoryItem(InventoryItem iitem) + { + UpdateInventoryItemPacket p = new UpdateInventoryItemPacket(); + p.InventoryData = new UpdateInventoryItemPacket.InventoryDataBlock[1]; + p.InventoryData[0] = new UpdateInventoryItemPacket.InventoryDataBlock(); + + p.InventoryData[0].TransactionID = iitem.TransactionID; + + p.InventoryData[0].GroupOwned = iitem.GroupOwned; + p.InventoryData[0].CRC = iitem.CRC; + p.InventoryData[0].CreationDate = iitem.CreationDate; + p.InventoryData[0].SaleType = iitem.SaleType; + p.InventoryData[0].BaseMask = iitem.BaseMask; + p.InventoryData[0].Name = Helpers.StringToField(iitem.Name); + p.InventoryData[0].InvType = iitem.InvType; + p.InventoryData[0].Type = iitem.Type; + p.InventoryData[0].GroupID = iitem.GroupID; + p.InventoryData[0].SalePrice = iitem.SalePrice; + p.InventoryData[0].OwnerID = iitem.OwnerID; + p.InventoryData[0].CreatorID = iitem.CreatorID; + p.InventoryData[0].ItemID = iitem.ItemID; + p.InventoryData[0].FolderID = iitem.FolderID; + p.InventoryData[0].EveryoneMask = iitem.EveryoneMask; + p.InventoryData[0].Description = Helpers.StringToField(iitem.Description); + p.InventoryData[0].Flags = iitem.Flags; + p.InventoryData[0].NextOwnerMask= iitem.NextOwnerMask; + p.InventoryData[0].GroupMask = iitem.GroupMask; + p.InventoryData[0].OwnerMask = iitem.OwnerMask; + + + p.AgentData.AgentID = AgentID; + p.AgentData.SessionID = SessionID; + + return p; + } + +/* + // Confirm InventoryUpdate CRC + uint test = libsecondlife.Packets.InventoryPackets.InventoryUpdateCRC + ( + (int)1159214416 + , (byte)0 + , (sbyte)7 + , (sbyte)7 + , (LLUUID)"00000000000000000000000000000000" + , (LLUUID)"00000000000000000000000000000000" + , (int)10 + , (LLUUID)"25472683cb324516904a6cd0ecabf128" + , (LLUUID)"25472683cb324516904a6cd0ecabf128" + , (LLUUID)"77364021f09f13dfb692f036be53b9e2" + , (LLUUID)"a4947fc066c247518d9854aaf90097f4" + , (uint)0 + , (uint)0 + , (uint)2147483647 + , (uint)0 + , (uint)2147483647 + ); + + if( test != (uint)895206313 ) + { + Console.WriteLine("CRC Generation is no longer correct."); + return; + } +*/ + + public static uint InventoryUpdateCRC(InventoryItem iitem) + { + uint CRC = 0; + + /* IDs */ + CRC += iitem.AssetID.CRC(); // AssetID + CRC += iitem.FolderID.CRC(); // FolderID + CRC += iitem.ItemID==null?new LLUUID().CRC():iitem.ItemID.CRC(); // ItemID + + /* Permission stuff */ + CRC += iitem.CreatorID.CRC(); // CreatorID + CRC += iitem.OwnerID.CRC(); // OwnerID + CRC += iitem.GroupID.CRC(); // GroupID + + /* CRC += another 4 words which always seem to be zero -- unclear if this is a LLUUID or what */ + CRC += iitem.OwnerMask; //owner_mask; // Either owner_mask or next_owner_mask may need to be + CRC += iitem.NextOwnerMask; //next_owner_mask; // switched with base_mask -- 2 values go here and in my + CRC += iitem.EveryoneMask; //everyone_mask; // study item, the three were identical. + CRC += iitem.GroupMask; //group_mask; + + /* The rest of the CRC fields */ + CRC += iitem.Flags; // Flags + CRC += (uint)iitem.InvType; // InvType + CRC += (uint)iitem.Type; // Type + CRC += (uint)iitem.CreationDate; // CreationDate + CRC += (uint)iitem.SalePrice; // SalePrice + CRC += (uint)((uint)iitem.SaleType * 0x07073096); // SaleType + + return CRC; + } + } +} diff --git a/libsecondlife-cs/JSON/JSONArray.cs b/libsecondlife-cs/JSON/JSONArray.cs index 9ce043f4..893d9df3 100644 --- a/libsecondlife-cs/JSON/JSONArray.cs +++ b/libsecondlife-cs/JSON/JSONArray.cs @@ -1,172 +1,172 @@ -using System; -using System.Collections; -using System.Text; - -namespace Nii.JSON -{ - /// - /// - /// A JSONArray is an ordered sequence of values. Its external form is a string - /// wrapped in square brackets with commas between the values. The internal form - /// is an object having get() and opt() methods for accessing the values by - /// index, and put() methods for adding or replacing values. The values can be - /// any of these types: Boolean, JSONArray, JSONObject, Number, String, or the - /// JSONObject.NULL object. - /// - /// - /// The constructor can convert a JSON external form string into an - /// internal form Java object. The toString() method creates an external - /// form string. - /// - /// - /// A get() method returns a value if one can be found, and throws an exception - /// if one cannot be found. An opt() method returns a default value instead of - /// throwing an exception, and so is useful for obtaining optional values. - /// - /// - /// The generic get() and opt() methods return an object which you can cast or - /// query for type. There are also typed get() and opt() methods that do typing - /// checking and type coersion for you. - /// - /// - /// The texts produced by the toString() methods are very strict. - /// The constructors are more forgiving in the texts they will accept. - /// - /// - /// - /// An extra comma may appear just before the closing bracket. - /// Strings may be quoted with single quotes. - /// Strings do not need to be quoted at all if they do not contain leading - /// or trailing spaces, and if they do not contain any of these characters: - /// { } [ ] / \ : , - /// Numbers may have the 0- (octal) or 0x- (hex) prefix. - /// - /// - /// - /// Public Domain 2002 JSON.org - /// @author JSON.org - /// @version 0.1 - /// - /// Ported to C# by Are Bjolseth, teleplan.no - /// TODO: - /// 1. Implement Custom exceptions - /// 2. Add indexer JSONObject[i] = object, and object = JSONObject[i]; - /// 3. Add indexer JSONObject["key"] = object, and object = JSONObject["key"] - /// 4. Add unit testing - /// 5. Add log4net - /// 6. Make get/put methods private, to force use of indexer instead? - /// - public class JSONArray - { - /// The ArrayList where the JSONArray's properties are kept. - private ArrayList myArrayList; - - - /// - /// Construct an empty JSONArray - /// - public JSONArray() - { - myArrayList = new ArrayList(); - } - - /// - /// Construct a JSONArray from a JSONTokener. - /// - /// A JSONTokener - public JSONArray(JSONTokener x) : this() - { - if (x.nextClean() != '[') - { - throw new Exception("A JSONArray must start with '['"); - } - if (x.nextClean() == ']') - { - return; - } - x.back(); - while (true) - { - myArrayList.Add(x.nextObject()); - switch (x.nextClean()) - { - case ',': - if (x.nextClean() == ']') - { - return; - } - x.back(); - break; - case ']': - return; - default: - throw new Exception("Expected a ',' or ']'"); - } - } - } - - /// - /// Alternate to Java get/put method, by using indexer - /// - public object this[int i] - { - get - { - return opt(i); - } - set - { - //myArrayList[i] = value; - put(i, value); - } - } - - /// - /// Get the optional object value associated with an index. - /// - /// index subscript - /// object at that index. - public object opt(int i) - { - if (i < 0 || i >= myArrayList.Count) - throw new ArgumentOutOfRangeException("int i", i, "Index out of bounds!"); - - return myArrayList[i]; - } - - /// - /// Put or replace a boolean value in the JSONArray. - /// - /// - /// The subscript. If the index is greater than the length of - /// the JSONArray, then null elements will be added as necessary to pad it out. - /// - /// An object value. - /// this (JSONArray) - public JSONArray put(int i, object val) - { - if (i < 0) - { - throw new ArgumentOutOfRangeException("i", i, "Negative indexes illegal"); - } - else if (val == null) - { - throw new ArgumentNullException("val", "Object cannt be null"); - } - else if (i < myArrayList.Count) - { - myArrayList.Insert(i, val); - } - // NOTE! Since i is >= Count, fill null vals before index i, then append new object at i - else - { - while (i != myArrayList.Count) - { - myArrayList.Add(null); - } - myArrayList.Add(val); - } - return this; - } - } -} +using System; +using System.Collections; +using System.Text; + +namespace Nii.JSON +{ + /// + /// + /// A JSONArray is an ordered sequence of values. Its external form is a string + /// wrapped in square brackets with commas between the values. The internal form + /// is an object having get() and opt() methods for accessing the values by + /// index, and put() methods for adding or replacing values. The values can be + /// any of these types: Boolean, JSONArray, JSONObject, Number, String, or the + /// JSONObject.NULL object. + /// + /// + /// The constructor can convert a JSON external form string into an + /// internal form Java object. The toString() method creates an external + /// form string. + /// + /// + /// A get() method returns a value if one can be found, and throws an exception + /// if one cannot be found. An opt() method returns a default value instead of + /// throwing an exception, and so is useful for obtaining optional values. + /// + /// + /// The generic get() and opt() methods return an object which you can cast or + /// query for type. There are also typed get() and opt() methods that do typing + /// checking and type coersion for you. + /// + /// + /// The texts produced by the toString() methods are very strict. + /// The constructors are more forgiving in the texts they will accept. + /// + /// + /// + /// An extra comma may appear just before the closing bracket. + /// Strings may be quoted with single quotes. + /// Strings do not need to be quoted at all if they do not contain leading + /// or trailing spaces, and if they do not contain any of these characters: + /// { } [ ] / \ : , + /// Numbers may have the 0- (octal) or 0x- (hex) prefix. + /// + /// + /// + /// Public Domain 2002 JSON.org + /// @author JSON.org + /// @version 0.1 + /// + /// Ported to C# by Are Bjolseth, teleplan.no + /// TODO: + /// 1. Implement Custom exceptions + /// 2. Add indexer JSONObject[i] = object, and object = JSONObject[i]; + /// 3. Add indexer JSONObject["key"] = object, and object = JSONObject["key"] + /// 4. Add unit testing + /// 5. Add log4net + /// 6. Make get/put methods private, to force use of indexer instead? + /// + public class JSONArray + { + /// The ArrayList where the JSONArray's properties are kept. + private ArrayList myArrayList; + + + /// + /// Construct an empty JSONArray + /// + public JSONArray() + { + myArrayList = new ArrayList(); + } + + /// + /// Construct a JSONArray from a JSONTokener. + /// + /// A JSONTokener + public JSONArray(JSONTokener x) : this() + { + if (x.nextClean() != '[') + { + throw new Exception("A JSONArray must start with '['"); + } + if (x.nextClean() == ']') + { + return; + } + x.back(); + while (true) + { + myArrayList.Add(x.nextObject()); + switch (x.nextClean()) + { + case ',': + if (x.nextClean() == ']') + { + return; + } + x.back(); + break; + case ']': + return; + default: + throw new Exception("Expected a ',' or ']'"); + } + } + } + + /// + /// Alternate to Java get/put method, by using indexer + /// + public object this[int i] + { + get + { + return opt(i); + } + set + { + //myArrayList[i] = value; + put(i, value); + } + } + + /// + /// Get the optional object value associated with an index. + /// + /// index subscript + /// object at that index. + public object opt(int i) + { + if (i < 0 || i >= myArrayList.Count) + throw new ArgumentOutOfRangeException("int i", i, "Index out of bounds!"); + + return myArrayList[i]; + } + + /// + /// Put or replace a boolean value in the JSONArray. + /// + /// + /// The subscript. If the index is greater than the length of + /// the JSONArray, then null elements will be added as necessary to pad it out. + /// + /// An object value. + /// this (JSONArray) + public JSONArray put(int i, object val) + { + if (i < 0) + { + throw new ArgumentOutOfRangeException("i", i, "Negative indexes illegal"); + } + else if (val == null) + { + throw new ArgumentNullException("val", "Object cannt be null"); + } + else if (i < myArrayList.Count) + { + myArrayList.Insert(i, val); + } + // NOTE! Since i is >= Count, fill null vals before index i, then append new object at i + else + { + while (i != myArrayList.Count) + { + myArrayList.Add(null); + } + myArrayList.Add(val); + } + return this; + } + } +} diff --git a/libsecondlife-cs/JSON/JSONFacade.cs b/libsecondlife-cs/JSON/JSONFacade.cs index 045e0489..eeb3f2de 100644 --- a/libsecondlife-cs/JSON/JSONFacade.cs +++ b/libsecondlife-cs/JSON/JSONFacade.cs @@ -1,26 +1,26 @@ -using System; -using System.Collections; -using System.Collections.Specialized; -using System.Reflection; -using System.Text; - -namespace Nii.JSON -{ - /// - /// Summary description for JsonFacade. - /// - public sealed class JsonFacade - { - /// - /// Parse JSON formatted string and return a Hashtable - /// - /// - /// - public static IDictionary fromJSON(string sJSON) - { - JSONObject jsob = new JSONObject(sJSON); - IDictionary idict = jsob.getDictionary(); - return idict; - } - } -} +using System; +using System.Collections; +using System.Collections.Specialized; +using System.Reflection; +using System.Text; + +namespace Nii.JSON +{ + /// + /// Summary description for JsonFacade. + /// + public sealed class JsonFacade + { + /// + /// Parse JSON formatted string and return a Hashtable + /// + /// + /// + public static IDictionary fromJSON(string sJSON) + { + JSONObject jsob = new JSONObject(sJSON); + IDictionary idict = jsob.getDictionary(); + return idict; + } + } +} diff --git a/libsecondlife-cs/NetworkManager.cs b/libsecondlife-cs/NetworkManager.cs index 8048069a..65839711 100644 --- a/libsecondlife-cs/NetworkManager.cs +++ b/libsecondlife-cs/NetworkManager.cs @@ -1,1435 +1,1435 @@ -/* - * Copyright (c) 2006, Second Life Reverse Engineering Team - * All rights reserved. - * - * - Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - Neither the name of the Second Life Reverse Engineering Team nor the names - * of its contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Text; -using System.Timers; -using System.Collections; -using System.Net; -using System.Net.Sockets; -using System.Threading; -using System.Security.Cryptography; -using Nwc.XmlRpc; -using Nii.JSON; -using libsecondlife.Packets; - -namespace libsecondlife -{ - /// - /// - /// - /// - /// - public delegate void PacketCallback(Packet packet, Simulator simulator); - /// - /// - /// - /// - /// - public delegate void SimDisconnectCallback(Simulator simulator, DisconnectType reason); - /// - /// - /// - /// - /// - public delegate void DisconnectCallback(DisconnectType reason, string message); - - /// - /// - /// - public enum DisconnectType - { - /// - ClientInitiated, - /// - ServerInitiated, - /// - NetworkTimeout - } - - /// - /// This exception is thrown whenever a network operation is attempted - /// without a network connection. - /// - public class NotConnectedException : ApplicationException { } - - internal class AcceptAllCertificatePolicy : ICertificatePolicy - { - public AcceptAllCertificatePolicy() - { - } - - public bool CheckValidationResult(ServicePoint sPoint, - System.Security.Cryptography.X509Certificates.X509Certificate cert, - WebRequest wRequest,int certProb) - { - // Always accept - return true; - } - } - - /// - /// Simulator is a wrapper for a network connection to a simulator and the - /// Region class representing the block of land in the metaverse. - /// - public class Simulator - { - /// - /// The Region class that this Simulator wraps - /// - public Region Region; - - /// - /// The ID number associated with this particular connection to the - /// simulator, used to emulate TCP connections. This is used - /// internally for packets that have a CircuitCode field. - /// - public uint CircuitCode - { - get { return circuitCode; } - set { circuitCode = value; } - } - - /// - /// The IP address and port of the server. - /// - public IPEndPoint IPEndPoint - { - get { return ipEndPoint; } - } - - /// - /// A boolean representing whether there is a working connection to the - /// simulator or not. - /// - public bool Connected - { - get { return connected; } - } - - /// - /// Used internally to track sim disconnections, do not modify this - /// variable. - /// - public bool DisconnectCandidate; - - private SecondLife Client; - private NetworkManager Network; - private Hashtable Callbacks; - private ushort Sequence; - private byte[] RecvBuffer; - private Mutex RecvBufferMutex = new Mutex(false, "RecvBufferMutex"); - private Socket Connection; - private AsyncCallback ReceivedData; - private Hashtable NeedAck; - private Mutex NeedAckMutex; - private SortedList Inbox; - private ArrayList PendingAcks; - private Mutex InboxMutex; - private bool connected; - private uint circuitCode; - private IPEndPoint ipEndPoint; - private EndPoint endPoint; - private System.Timers.Timer AckTimer; - - /// - /// - /// - /// - /// - /// - /// - /// - public Simulator(SecondLife client, Hashtable callbacks, uint circuit, - IPAddress ip, int port) - { - Client = client; - Network = client.Network; - Callbacks = callbacks; - Region = new Region(client); - circuitCode = circuit; - Sequence = 0; - RecvBuffer = new byte[2048]; - Connection = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); - connected = false; - DisconnectCandidate = false; - AckTimer = new System.Timers.Timer(500); - AckTimer.Elapsed += new ElapsedEventHandler(AckTimer_Elapsed); - - // Initialize the hashtable for reliable packets waiting on ACKs from the server - NeedAck = new Hashtable(); - - // Initialize the lists of sequence numbers we've received so far - Inbox = new SortedList(); - PendingAcks = new ArrayList(); - - NeedAckMutex = new Mutex(false, "NeedAckMutex"); - InboxMutex = new Mutex(false, "InboxMutex"); - - Client.Log("Connecting to " + ip.ToString() + ":" + port, Helpers.LogLevel.Info); - - try - { - // Setup the callback - ReceivedData = new AsyncCallback(OnReceivedData); - - // Create an endpoint that we will be communicating with (need it in two - // types due to .NET weirdness) - ipEndPoint = new IPEndPoint(ip, port); - endPoint = (EndPoint)ipEndPoint; - - // Associate this simulator's socket with the given ip/port and start listening - Connection.Connect(endPoint); - Connection.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref endPoint, ReceivedData, null); - - // Send the UseCircuitCode packet to initiate the connection - UseCircuitCodePacket use = new UseCircuitCodePacket(); - use.CircuitCode.Code = circuitCode; - use.CircuitCode.ID = Network.AgentID; - use.CircuitCode.SessionID = Network.SessionID; - - // Start the ACK timer - AckTimer.Start(); - - // Send the initial packet out - SendPacket(use, true); - - // Track the current time for timeout purposes - int start = Environment.TickCount; - - while (true) - { - if (connected || Environment.TickCount - start > 8000) - { - return; - } - Thread.Sleep(10); - } - } - catch (Exception e) - { - Console.WriteLine(e.ToString()); - Client.Log(e.ToString(), Helpers.LogLevel.Error); - } - } - - /// - /// - /// - public void Disconnect() - { - // Send the CloseCircuit notice - CloseCircuitPacket close = new CloseCircuitPacket(); - - try - { - Connection.Send(close.ToBytes()); - } - catch (SocketException) - { - // There's a high probability of this failing if the network is - // disconnected, so don't even bother logging the error - } - - try - { - // Shut the socket communication down - Connection.Shutdown(SocketShutdown.Both); - } - catch (SocketException e) - { - Client.Log(e.ToString(), Helpers.LogLevel.Error); - } - - connected = false; - } - - /// - /// - /// - /// - /// - public void SendPacket(Packet packet, bool incrementSequence) - { - byte[] buffer; - int bytes; - - if (!connected && packet.Type != PacketType.UseCircuitCode) - { - Client.Log("Trying to send a " + packet.Type.ToString() + " packet when the socket is closed", - Helpers.LogLevel.Warning); - - throw new NotConnectedException(); - } - - if (incrementSequence) - { - // Set the sequence number here since we are manually serializing the packet - packet.Header.Sequence = ++Sequence; - - if (packet.Header.Reliable) - { - // Keep track of when this packet was sent out - packet.TickCount = Environment.TickCount; - - #region NeedAckMutex - NeedAckMutex.WaitOne(); - if (!NeedAck.ContainsKey(packet.Header.Sequence)) - { - NeedAck.Add(packet.Header.Sequence, packet); - } - else - { - Client.Log("Attempted to add a duplicate sequence number (" + - packet.Header.Sequence + ") to the NeedAck hashtable for packet type " + - packet.Type.ToString(), Helpers.LogLevel.Warning); - } - NeedAckMutex.ReleaseMutex(); - #endregion NeedAckMutex - - // Append any ACKs that need to be sent out to this packet - #region InboxMutex - InboxMutex.WaitOne(); - try - { - if (PendingAcks.Count > 0 && packet.Type != PacketType.PacketAck && - packet.Type != PacketType.LogoutRequest) - { - packet.Header.AckList = new uint[PendingAcks.Count]; - - int i = 0; - - foreach (uint ack in PendingAcks) - { - packet.Header.AckList[i] = ack; - i++; - } - - PendingAcks.Clear(); - packet.Header.AppendedAcks = true; - } - } - catch (Exception e) - { - Client.Log(e.ToString(), Helpers.LogLevel.Error); - } - finally - { - InboxMutex.ReleaseMutex(); - } - #endregion InboxMutex - } - } - - // Serialize the packet - buffer = packet.ToBytes(); - bytes = buffer.Length; - - // Zerocode if needed - if (packet.Header.Zerocoded) - { - byte[] zeroBuffer = new byte[4096]; - bytes = Helpers.ZeroEncode(buffer, bytes, zeroBuffer); - - buffer = zeroBuffer; - } - - try - { - Connection.Send(buffer, bytes, SocketFlags.None); - } - catch (SocketException e) - { - Client.Log(e.ToString(), Helpers.LogLevel.Error); - } - } - - /// - /// - /// - /// - public void SendPacket(byte[] payload) - { - if (!connected) - { - throw new NotConnectedException(); - } - - try - { - Connection.Send(payload, payload.Length, SocketFlags.None); - } - catch (SocketException e) - { - Client.Log(e.ToString(), Helpers.LogLevel.Error); - } - } - - private void OnReceivedData(IAsyncResult result) - { - Packet packet = null; - int numBytes; - - // If we're receiving data the sim connection is open - connected = true; - - #region RecvBufferMutex - try - { - RecvBufferMutex.WaitOne(); - - // Update the disconnect flag so this sim doesn't time out - DisconnectCandidate = false; - - // Retrieve the incoming packet - try - { - numBytes = Connection.EndReceiveFrom(result, ref endPoint); - } - catch (SocketException) - { - Client.Log("Socket error, shutting down " + this.Region.Name + - " (" + endPoint.ToString() + ")", Helpers.LogLevel.Warning); - - connected = false; - RecvBufferMutex.ReleaseMutex(); - Network.DisconnectSim(this); - - return; - } - - int packetEnd = numBytes - 1; - packet = Packet.BuildPacket(RecvBuffer, ref packetEnd); - } - catch (Exception e) - { - Client.Log(e.ToString(), Helpers.LogLevel.Error); - } - finally - { - RecvBufferMutex.ReleaseMutex(); - - try - { - Connection.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref endPoint, ReceivedData, null); - } - catch (Exception) - { - } - } - #endregion RecvBufferMutex - - // Fail-safe checks - if (packet == null) - { - Client.Log("OnReceivedData() fail-safe reached, exiting", Helpers.LogLevel.Warning); - return; - } - - // Track the sequence number for this packet if it's marked as reliable - if (packet.Header.Reliable) - { - // Check if we already received this packet - #region InboxMutex - try - { - InboxMutex.WaitOne(); - - if (Inbox.Contains(packet.Header.Sequence)) - { - Client.Log("Received a duplicate " + packet.Type.ToString() + ", sequence=" + - packet.Header.Sequence + ", resent=" + ((packet.Header.Resent) ? "Yes" : "No"), - Helpers.LogLevel.Info); - - // Avoid firing a callback twice for the same packet - return; - } - else - { - Inbox.Add(packet.Header.Sequence, packet.Header.Sequence); - PendingAcks.Add((uint)packet.Header.Sequence); - } - } - catch (Exception e) - { - Client.Log(e.ToString(), Helpers.LogLevel.Error); - } - finally - { - InboxMutex.ReleaseMutex(); - } - #endregion InboxMutex - } - - // Handle ACK packets - if (packet.Header.AppendedAcks || packet.Type == PacketType.PacketAck) - { - #region NeedAckMutex - try - { - NeedAckMutex.WaitOne(); - - // Handle PacketAck packets - if (packet.Type == PacketType.PacketAck) - { - PacketAckPacket ackPacket = (PacketAckPacket)packet; - - foreach (PacketAckPacket.PacketsBlock block in ackPacket.Packets) - { - NeedAck.Remove((ushort)block.ID); - } - } - - // Handle appended ACKs - if (packet.Header.AppendedAcks) - { - foreach (ushort ack in packet.Header.AckList) - { - if (NeedAck.ContainsKey(ack)) - { - NeedAck.Remove(ack); - } - else - { - Client.Log("Appended ACK for a packet we didn't send: " + ack, Helpers.LogLevel.Warning); - } - } - } - } - catch (Exception e) - { - Client.Log(e.ToString(), Helpers.LogLevel.Error); - } - finally - { - NeedAckMutex.ReleaseMutex(); - } - #endregion NeedAckMutex - } - - // Fire the registered packet events - #region FireCallbacks - try - { - if (Callbacks.ContainsKey(packet.Type)) - { - ArrayList callbackArray = (ArrayList)Callbacks[packet.Type]; - - // Fire any registered callbacks - foreach (PacketCallback callback in callbackArray) - { - if (callback != null) - { - callback(packet, this); - } - } - } - - if (Callbacks.ContainsKey(PacketType.Default)) - { - ArrayList callbackArray = (ArrayList)Callbacks[PacketType.Default]; - - // Fire any registered callbacks - foreach (PacketCallback callback in callbackArray) - { - if (callback != null) - { - callback(packet, this); - } - } - } - } - catch (Exception e) - { - Client.Log("Caught an exception in a packet callback: " + e.ToString(), Helpers.LogLevel.Warning); - } - #endregion FireCallbacks - } - - private void AckTimer_Elapsed(object sender, ElapsedEventArgs ea) - { - if (!connected) - { - AckTimer.Stop(); - return; - } - - #region InboxMutex - try - { - InboxMutex.WaitOne(); - - if (PendingAcks.Count > 0) - { - int i = 0; - PacketAckPacket acks = new PacketAckPacket(); - acks.Packets = new PacketAckPacket.PacketsBlock[PendingAcks.Count]; - acks.Header.Reliable = false; - - foreach (uint ack in PendingAcks) - { - acks.Packets[i] = new PacketAckPacket.PacketsBlock(); - acks.Packets[i].ID = ack; - i++; - } - - SendPacket(acks, true); - - PendingAcks.Clear(); - } - } - catch (Exception e) - { - Client.Log(e.ToString(), Helpers.LogLevel.Error); - } - finally - { - InboxMutex.ReleaseMutex(); - } - #endregion InboxMutex - } - } - - /// - /// NetworkManager is responsible for managing the network layer of - /// libsecondlife. It tracks all the server connections, serializes - /// outgoing traffic and deserializes incoming traffic, and provides - /// instances of delegates for network-related events. - /// - public class NetworkManager - { - /// - /// The permanent UUID for the logged in avatar - /// - public LLUUID AgentID; - /// - /// A temporary UUID assigned to this session, used for secure - /// transactions - /// - public LLUUID SessionID; - /// - /// A string holding a descriptive error on login failure, empty - /// otherwise - /// - public string LoginError; - /// - /// The simulator that the logged in avatar is currently occupying - /// - public Simulator CurrentSim; - /// - /// The complete hashtable of all the login values returned by the - /// RPC login server, converted to native data types wherever possible - /// - public Hashtable LoginValues; - /// - /// Shows whether the network layer is logged in to the grid or not - /// - public bool Connected - { - get { return connected; } - } - /// - /// An event for the connection to a simulator other than the currently - /// occupied one disconnecting - /// - public SimDisconnectCallback OnSimDisconnected; - /// - /// An event for being logged out either through client request, server - /// forced, or network error - /// - public DisconnectCallback OnDisconnected; - - private Hashtable Callbacks; - private SecondLife Client; - private ArrayList Simulators; - private Mutex SimulatorsMutex; - private System.Timers.Timer DisconnectTimer; - private bool connected; - - /// - /// - /// - /// - public NetworkManager(SecondLife client) - { - Client = client; - Simulators = new ArrayList(); - SimulatorsMutex = new Mutex(false, "SimulatorsMutex"); - Callbacks = new Hashtable(); - CurrentSim = null; - LoginValues = null; - - // Register the internal callbacks - RegisterCallback(PacketType.RegionHandshake, new PacketCallback(RegionHandshakeHandler)); - RegisterCallback(PacketType.StartPingCheck, new PacketCallback(StartPingCheckHandler)); - RegisterCallback(PacketType.ParcelOverlay, new PacketCallback(ParcelOverlayHandler)); - RegisterCallback(PacketType.EnableSimulator, new PacketCallback(EnableSimulatorHandler)); - RegisterCallback(PacketType.KickUser, new PacketCallback(KickUserHandler)); - - // Disconnect a sim if no network traffic has been received for 15 seconds - DisconnectTimer = new System.Timers.Timer(15000); - DisconnectTimer.Elapsed += new ElapsedEventHandler(DisconnectTimer_Elapsed); - } - - /// - /// - /// - /// - /// - public void RegisterCallback(PacketType type, PacketCallback callback) - { - if (!Callbacks.ContainsKey(type)) - { - Callbacks[type] = new ArrayList(); - } - - ArrayList callbackArray = (ArrayList)Callbacks[type]; - callbackArray.Add(callback); - } - - /// - /// - /// - /// - /// - public void UnregisterCallback(PacketType type, PacketCallback callback) - { - if (!Callbacks.ContainsKey(type)) - { - Client.Log("Trying to unregister a callback for packet " + type.ToString() + - " when no callbacks are setup for that packet", Helpers.LogLevel.Info); - return; - } - - ArrayList callbackArray = (ArrayList)Callbacks[type]; - - if (callbackArray.Contains(callback)) - { - callbackArray.Remove(callback); - } - else - { - Client.Log("Trying to unregister a non-existant callback for packet " + type.ToString(), - Helpers.LogLevel.Info); - } - } - - /// - /// - /// - /// - public void SendPacket(Packet packet) - { - if (CurrentSim != null && CurrentSim.Connected) - { - CurrentSim.SendPacket(packet, true); - } - } - - /// - /// - /// - /// - /// - public void SendPacket(Packet packet, Simulator simulator) - { - if (simulator.Connected) - { - simulator.SendPacket(packet, true); - } - } - - /// - /// - /// - /// - public void SendPacket(byte[] payload) - { - if (CurrentSim != null) - { - CurrentSim.SendPacket(payload); - } - else - { - throw new NotConnectedException(); - } - } - - /// - /// - /// - /// - /// - /// - /// - /// - /// - public static Hashtable DefaultLoginValues(string firstName, string lastName, string password, - string userAgent, string author) - { - return DefaultLoginValues(firstName, lastName, password, "00:00:00:00:00:00", "last", - 1, 50, 50, 50, "Win", "0", userAgent, author); - } - - public static Hashtable DefaultLoginValues(string firstName, string lastName, string password, string mac, - string startLocation, string platform, string viewerDigest, string userAgent, string author) - { - return DefaultLoginValues(firstName, lastName, password, mac, startLocation, - 1, 50, 50, 50, platform, viewerDigest, userAgent, author); - } - - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - public static Hashtable DefaultLoginValues(string firstName, string lastName, string password, string mac, - string startLocation, int major, int minor, int patch, int build, string platform, string viewerDigest, - string userAgent, string author) - { - Hashtable values = new Hashtable(); - - // Generate an MD5 hash of the password - MD5 md5 = new MD5CryptoServiceProvider(); - byte[] hash = md5.ComputeHash(Encoding.ASCII.GetBytes(password)); - StringBuilder passwordDigest = new StringBuilder(); - // Convert the hash to a hex string - foreach(byte b in hash) - { - passwordDigest.AppendFormat("{0:x2}", b); - } - - values["first"] = firstName; - values["last"] = lastName; - values["passwd"] = "$1$" + passwordDigest; - values["start"] = startLocation; - values["major"] = major; - values["minor"] = minor; - values["patch"] = patch; - values["build"] = build; - values["platform"] = platform; - values["mac"] = mac; - values["agree_to_tos"] = "true"; - values["viewer_digest"] = viewerDigest; - values["user-agent"] = userAgent + " (" + Helpers.VERSION + ")"; - values["author"] = author; - - // Build the options array - ArrayList optionsArray = new ArrayList(); - optionsArray.Add("inventory-root"); - optionsArray.Add("inventory-skeleton"); - optionsArray.Add("inventory-lib-root"); - optionsArray.Add("inventory-lib-owner"); - optionsArray.Add("inventory-skel-lib"); - optionsArray.Add("initial-outfit"); - optionsArray.Add("gestures"); - optionsArray.Add("event_categories"); - optionsArray.Add("event_notifications"); - optionsArray.Add("classified_categories"); - optionsArray.Add("buddy-list"); - optionsArray.Add("ui-config"); - optionsArray.Add("login-flags"); - optionsArray.Add("global-textures"); - - values["options"] = optionsArray; - - return values; - } - - /// - /// - /// - /// - /// - public bool Login(Hashtable loginParams) - { - return Login(loginParams, "https://login.agni.lindenlab.com/cgi-bin/login.cgi"); - } - - /// - /// - /// - /// - /// - /// - public bool Login(Hashtable loginParams, string url) - { - XmlRpcResponse result; - XmlRpcRequest xmlrpc = new XmlRpcRequest(); - xmlrpc.MethodName = "login_to_simulator"; - xmlrpc.Params.Clear(); - xmlrpc.Params.Add(loginParams); - - try - { - result = (XmlRpcResponse)xmlrpc.Send(url); - } - catch (Exception e) - { - LoginError = e.Message; - LoginValues = null; - return false; - } - - if (result.IsFault) - { - Client.Log("Fault " + result.FaultCode + ": " + result.FaultString, Helpers.LogLevel.Error); - LoginError = "Fault " + result.FaultCode + ": " + result.FaultString; - LoginValues = null; - return false; - } - - LoginValues = (Hashtable)result.Value; - - if ((string)LoginValues["login"] == "indeterminate") - { - //FIXME: We need to do another XML-RPC, handle this case - LoginError = "Got a redirect, login with the official client to update"; - return false; - } - else if ((string)LoginValues["login"] == "false") - { - LoginError = LoginValues["reason"] + ": " + LoginValues["message"]; - return false; - } - else if ((string)LoginValues["login"] != "true") - { - LoginError = "Unknown error"; - return false; - } - - System.Text.RegularExpressions.Regex LLSDtoJSON = - new System.Text.RegularExpressions.Regex(@"('|r([0-9])|r(\-))"); - string json; - IDictionary jsonObject = null; - LLVector3 vector = null; - LLVector3 posVector = null; - LLVector3 lookatVector = null; - ulong regionHandle = 0; - - try - { - if (LoginValues.Contains("look_at")) - { - // Replace LLSD variables with object representations - - // Convert LLSD string to JSON - json = "{vector:" + LLSDtoJSON.Replace((string)LoginValues["look_at"], "$2") + "}"; - - // Convert JSON string to a JSON object - jsonObject = JsonFacade.fromJSON(json); - JSONArray jsonVector = (JSONArray)jsonObject["vector"]; - - // Convert the JSON object to an LLVector3 - vector = new LLVector3(Convert.ToSingle(jsonVector[0]), - Convert.ToSingle(jsonVector[1]), Convert.ToSingle(jsonVector[2])); - - LoginValues["look_at"] = vector; - } - - if (LoginValues.Contains("home")) - { - Hashtable home; - - // Convert LLSD string to JSON - json = LLSDtoJSON.Replace((string)LoginValues["home"], "$2"); - - // Convert JSON string to an object - jsonObject = JsonFacade.fromJSON(json); - - // Create the position vector - JSONArray array = (JSONArray)jsonObject["position"]; - posVector = new LLVector3(Convert.ToSingle(array[0]), Convert.ToSingle(array[1]), - Convert.ToSingle(array[2])); - - // Create the look_at vector - array = (JSONArray)jsonObject["look_at"]; - lookatVector = new LLVector3(Convert.ToSingle(array[0]), - Convert.ToSingle(array[1]), Convert.ToSingle(array[2])); - - // Create the regionhandle - array = (JSONArray)jsonObject["region_handle"]; - regionHandle = Helpers.UIntsToLong((uint)(int)array[0], (uint)(int)array[1]); - - Client.Avatar.Position = posVector; - Client.Avatar.LookAt = lookatVector; - - // Create a hashtable to hold the home values - home = new Hashtable(); - home["position"] = posVector; - home["look_at"] = lookatVector; - home["region_handle"] = regionHandle; - LoginValues["home"] = home; - } - - this.AgentID = new LLUUID((string)LoginValues["agent_id"]); - this.SessionID = new LLUUID((string)LoginValues["session_id"]); - Client.Avatar.ID = this.AgentID; - Client.Avatar.FirstName = (string)LoginValues["first_name"]; - Client.Avatar.LastName = (string)LoginValues["last_name"]; - Client.Avatar.LookAt = vector; - Client.Avatar.HomePosition = posVector; - Client.Avatar.HomeLookAt = lookatVector; - - // Connect to the sim given in the login reply - Simulator simulator = new Simulator(Client, this.Callbacks, (uint)(int)LoginValues["circuit_code"], - IPAddress.Parse((string)LoginValues["sim_ip"]), (int)LoginValues["sim_port"]); - if (!simulator.Connected) - { - return false; - } - - simulator.Region.Handle = regionHandle; - CurrentSim = simulator; - - // Simulator is successfully connected, add it to the list and set it as default - Simulators.Add(simulator); - - // Move our agent in to the sim to complete the connection - Client.Avatar.CompleteAgentMovement(simulator); - - SendInitialPackets(); - - DisconnectTimer.Start(); - connected = true; - return true; - } - catch (Exception e) - { - Client.Log("Login error: " + e.ToString(), Helpers.LogLevel.Error); - return false; - } - } - - /// - /// - /// - /// - /// - /// - /// - /// - public Simulator Connect(IPAddress ip, ushort port, uint circuitCode, bool setDefault) - { - Simulator simulator = new Simulator(Client, this.Callbacks, circuitCode, ip, (int)port); - - if (!simulator.Connected) - { - simulator = null; - return null; - } - - #region SimulatorsMutex - try - { - SimulatorsMutex.WaitOne(); - Simulators.Add(simulator); - } - catch (Exception e) - { - Client.Log(e.ToString(), Helpers.LogLevel.Error); - } - finally - { - SimulatorsMutex.ReleaseMutex(); - } - #endregion SimulatorsMutex - - if (setDefault) - { - CurrentSim = simulator; - } - - DisconnectTimer.Start(); - connected = true; - return simulator; - } - - /// - /// - /// - public void Logout() - { - // This will catch a Logout when the client is not logged in - if (CurrentSim == null || !connected) - { - return; - } - - DisconnectTimer.Stop(); - connected = false; - - // Send a logout request to the current sim - LogoutRequestPacket logout = new LogoutRequestPacket(); - logout.AgentData.AgentID = AgentID; - logout.AgentData.SessionID = SessionID; - - CurrentSim.SendPacket(logout, true); - - // TODO: We should probably check if the server actually received the logout request - - // Shutdown the network layer - Shutdown(); - - if (OnDisconnected != null) - { - OnDisconnected(DisconnectType.ClientInitiated, ""); - } - } - - /// - /// - /// - /// - public void DisconnectSim(Simulator sim) - { - sim.Disconnect(); - - // Fire the SimDisconnected event if a handler is registered - if (OnSimDisconnected != null) - { - OnSimDisconnected(sim, DisconnectType.NetworkTimeout); - } - - #region SimulatorsMutex - try - { - SimulatorsMutex.WaitOne(); - Simulators.Remove(sim); - } - catch (Exception e) - { - Client.Log(e.ToString(), Helpers.LogLevel.Error); - } - finally - { - SimulatorsMutex.ReleaseMutex(); - } - #endregion SimulatorsMutex - } - - /// - /// Shutdown will disconnect all the sims except for the current sim - /// first, and then kill the connection to CurrentSim. - /// - private void Shutdown() - { - #region SimulatorsMutex - try - { - SimulatorsMutex.WaitOne(); - - // Disconnect all simulators except the current one - foreach (Simulator simulator in Simulators) - { - // Don't disconnect the current sim, we'll use LogoutRequest for that - if (simulator != CurrentSim) - { - simulator.Disconnect(); - - // Fire the SimDisconnected event if a handler is registered - if (OnSimDisconnected != null) - { - OnSimDisconnected(simulator, DisconnectType.NetworkTimeout); - } - } - } - } - catch (Exception e) - { - Client.Log(e.ToString(), Helpers.LogLevel.Error); - } - finally - { - Simulators.Clear(); - SimulatorsMutex.ReleaseMutex(); - } - #endregion SimulatorsMutex - - CurrentSim.Disconnect(); - CurrentSim = null; - } - - private void SendInitialPackets() - { - // Request the economy data - SendPacket(new EconomyDataRequestPacket()); - - // TODO: The client sends this early in the login sequence, should we? - //ViewerEffectPacket effect = new ViewerEffectPacket(); - //effect.Effect = new ViewerEffectPacket.EffectBlock[1]; - //effect.Effect[0] = new ViewerEffectPacket.EffectBlock(); - //effect.Effect[0].Color = new byte[] { 0xFF, 0xFF, 0xFF, 0xFF }; - //effect.Effect[0].Duration = 0.5f; - //effect.Effect[0].ID = new LLUUID("c696075e53c6153f3d8e0c3e24541936"); - //effect.Effect[0].Type = 9; - //effect.Effect[0].TypeData = new byte[56]; - //Array.Copy(new byte[] { 0x28, 0xF0, 0x10, 0x41 }, 0, effect.Effect[0].TypeData, 36, 4); - //Array.Copy(new byte[] { 0x50, 0xD0, 0x0E, 0x41 }, 0, effect.Effect[0].TypeData, 44, 4); - //Array.Copy(new byte[] { 0x24, 0x40 }, 0, effect.Effect[0].TypeData, 54, 2); - //effect.Header.Reliable = false; - //SendPacket(effect); - - // TODO: Is this throttle necessary/good, and what does it do? - AgentThrottlePacket throttle = new AgentThrottlePacket(); - throttle.AgentData.AgentID = this.AgentID; - throttle.AgentData.SessionID = this.SessionID; - throttle.AgentData.CircuitCode = this.CurrentSim.CircuitCode; - throttle.Throttle.GenCounter = 0; - throttle.Throttle.Throttles = new byte[] - { 0x00, 0x00, 0x96, 0x47, 0x00, 0x00, 0xAA, 0x47, 0x00, 0x00, 0x88, 0x46, 0x00, 0x00, 0x88, 0x46, - 0x00, 0x00, 0x5F, 0x48, 0x00, 0x00, 0x5F, 0x48, 0x00, 0x00, 0xDC, 0x47 }; - SendPacket(throttle); - - // TODO: We should be setting the initial avatar height/width around here - //Client.Avatar.SetHeightWidth(676, 909); - - // Set the initial avatar camera position - Client.Avatar.UpdateCamera(true); - - // TODO: What animation are we stopping here? - AgentAnimationPacket animation = new AgentAnimationPacket(); - animation.AgentData.AgentID = AgentID; - animation.AgentData.SessionID = SessionID; - animation.AnimationList = new AgentAnimationPacket.AnimationListBlock[1]; - animation.AnimationList[0] = new AgentAnimationPacket.AnimationListBlock(); - animation.AnimationList[0].AnimID = new LLUUID("efcf670c2d188128973a034ebc806b67"); - animation.AnimationList[0].StartAnim = false; - SendPacket(animation); - - // TODO: Do we ever want to set this to true? - SetAlwaysRunPacket run = new SetAlwaysRunPacket(); - run.AgentData.AgentID = AgentID; - run.AgentData.SessionID = SessionID; - run.AgentData.AlwaysRun = false; - SendPacket(run); - - // TODO: This information is currently unused - MuteListRequestPacket mute = new MuteListRequestPacket(); - mute.AgentData.AgentID = AgentID; - mute.AgentData.SessionID = SessionID; - mute.MuteData.MuteCRC = 0; - SendPacket(mute); - - // Get the current avatar balance - MoneyBalanceRequestPacket money = new MoneyBalanceRequestPacket(); - money.AgentData.AgentID = AgentID; - money.AgentData.SessionID = SessionID; - money.MoneyData.TransactionID = new LLUUID(); - SendPacket(money); - - // Request info about our avatar - AgentDataUpdateRequestPacket update = new AgentDataUpdateRequestPacket(); - update.AgentData.AgentID = AgentID; - update.AgentData.SessionID = SessionID; - SendPacket(update); - - // TODO: What is the purpose of this? Information is currently unused - RequestGrantedProxiesPacket proxies = new RequestGrantedProxiesPacket(); - proxies.AgentData.AgentID = AgentID; - proxies.AgentData.SessionID = SessionID; - SendPacket(proxies); - } - - private void DisconnectTimer_Elapsed(object sender, ElapsedEventArgs ev) - { - #region SimulatorsMutex - try - { - SimulatorsMutex.WaitOne(); - - Beginning: - - foreach (Simulator sim in Simulators) - { - if (sim.DisconnectCandidate == true) - { - if (sim == CurrentSim) - { - Client.Log("Network timeout for the current simulator (" + - sim.Region.Name + "), logging out", Helpers.LogLevel.Warning); - - DisconnectTimer.Stop(); - connected = false; - - // Shutdown the network layer - Shutdown(); - - if (OnDisconnected != null) - { - OnDisconnected(DisconnectType.NetworkTimeout, ""); - } - - // We're completely logged out and shut down, leave this function - return; - } - else - { - // This sim hasn't received any network traffic since the - // timer last elapsed, consider it disconnected - Client.Log("Network timeout for simulator " + sim.Region.Name + - ", disconnecting", Helpers.LogLevel.Warning); - - SimulatorsMutex.ReleaseMutex(); - DisconnectSim(sim); - SimulatorsMutex.WaitOne(); - - // Reset the iterator since we removed an element - goto Beginning; - } - } - else - { - sim.DisconnectCandidate = true; - } - } - } - catch (Exception e) - { - Client.Log(e.ToString(), Helpers.LogLevel.Error); - } - finally - { - SimulatorsMutex.ReleaseMutex(); - } - #endregion SimulatorsMutex - } - - private void StartPingCheckHandler(Packet packet, Simulator simulator) - { - StartPingCheckPacket incomingPing = (StartPingCheckPacket)packet; - CompletePingCheckPacket ping = new CompletePingCheckPacket(); - ping.PingID.PingID = incomingPing.PingID.PingID; - - // TODO: We can use OldestUnacked to correct transmission errors - - SendPacket((Packet)ping, simulator); - } - - private void RegionHandshakeHandler(Packet packet, Simulator simulator) - { - // Send a RegionHandshakeReply - RegionHandshakeReplyPacket reply = new RegionHandshakeReplyPacket(); - reply.AgentData.AgentID = AgentID; - reply.AgentData.SessionID = SessionID; - reply.RegionInfo.Flags = 0; - SendPacket(reply, simulator); - - // TODO: Do we need to send an AgentUpdate to each sim upon connection? - - RegionHandshakePacket handshake = (RegionHandshakePacket)packet; - - simulator.Region.ID = handshake.RegionInfo.CacheID; - - // FIXME: - //handshake.RegionInfo.BillableFactor; - //handshake.RegionInfo.RegionFlags; - //handshake.RegionInfo.SimAccess; - - simulator.Region.IsEstateManager = handshake.RegionInfo.IsEstateManager; - simulator.Region.Name = Helpers.FieldToString(handshake.RegionInfo.SimName); - simulator.Region.SimOwner = handshake.RegionInfo.SimOwner; - simulator.Region.TerrainBase0 = handshake.RegionInfo.TerrainBase0; - simulator.Region.TerrainBase1 = handshake.RegionInfo.TerrainBase1; - simulator.Region.TerrainBase2 = handshake.RegionInfo.TerrainBase2; - simulator.Region.TerrainBase3 = handshake.RegionInfo.TerrainBase3; - simulator.Region.TerrainDetail0 = handshake.RegionInfo.TerrainDetail0; - simulator.Region.TerrainDetail1 = handshake.RegionInfo.TerrainDetail1; - simulator.Region.TerrainDetail2 = handshake.RegionInfo.TerrainDetail2; - simulator.Region.TerrainDetail3 = handshake.RegionInfo.TerrainDetail3; - simulator.Region.TerrainHeightRange00 = handshake.RegionInfo.TerrainHeightRange00; - simulator.Region.TerrainHeightRange01 = handshake.RegionInfo.TerrainHeightRange01; - simulator.Region.TerrainHeightRange10 = handshake.RegionInfo.TerrainHeightRange10; - simulator.Region.TerrainHeightRange11 = handshake.RegionInfo.TerrainHeightRange11; - simulator.Region.TerrainStartHeight00 = handshake.RegionInfo.TerrainStartHeight00; - simulator.Region.TerrainStartHeight01 = handshake.RegionInfo.TerrainStartHeight01; - simulator.Region.TerrainStartHeight10 = handshake.RegionInfo.TerrainStartHeight10; - simulator.Region.TerrainStartHeight11 = handshake.RegionInfo.TerrainStartHeight11; - simulator.Region.WaterHeight = handshake.RegionInfo.WaterHeight; - - Client.Log("Received a region handshake for " + simulator.Region.Name, Helpers.LogLevel.Info); - } - - private void ParcelOverlayHandler(Packet packet, Simulator simulator) - { - ParcelOverlayPacket overlay = (ParcelOverlayPacket)packet; - - if (overlay.ParcelData.SequenceID >= 0 && overlay.ParcelData.SequenceID <= 3) - { - Array.Copy(overlay.ParcelData.Data, 0, simulator.Region.ParcelOverlay, - overlay.ParcelData.SequenceID * 1024, 1024); - simulator.Region.ParcelOverlaysReceived++; - - if (simulator.Region.ParcelOverlaysReceived > 3) - { - Client.Log("Finished building the " + simulator.Region.Name + " parcel overlay", - Helpers.LogLevel.Info); - } - } - else - { - Client.Log("Parcel overlay with sequence ID of " + overlay.ParcelData.SequenceID + - " received from " + simulator.Region.Name, Helpers.LogLevel.Warning); - } - } - - private void EnableSimulatorHandler(Packet packet, Simulator simulator) - { - // TODO: Actually connect to the simulator - - // TODO: Sending ConfirmEnableSimulator completely screws things up. :-? - - // Respond to the simulator connection request - //Packet replyPacket = Packets.Network.ConfirmEnableSimulator(Protocol, AgentID, SessionID); - //SendPacket(replyPacket, circuit); - } - - private void KickUserHandler(Packet packet, Simulator simulator) - { - string message = Helpers.FieldToString(((KickUserPacket)packet).UserInfo.Reason); - - // Shutdown the network layer - Shutdown(); - - if (OnDisconnected != null) - { - OnDisconnected(DisconnectType.ServerInitiated, message); - } - } - } -} +/* + * Copyright (c) 2006, Second Life Reverse Engineering Team + * All rights reserved. + * + * - Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Neither the name of the Second Life Reverse Engineering Team nor the names + * of its contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Text; +using System.Timers; +using System.Collections; +using System.Net; +using System.Net.Sockets; +using System.Threading; +using System.Security.Cryptography; +using Nwc.XmlRpc; +using Nii.JSON; +using libsecondlife.Packets; + +namespace libsecondlife +{ + /// + /// + /// + /// + /// + public delegate void PacketCallback(Packet packet, Simulator simulator); + /// + /// + /// + /// + /// + public delegate void SimDisconnectCallback(Simulator simulator, DisconnectType reason); + /// + /// + /// + /// + /// + public delegate void DisconnectCallback(DisconnectType reason, string message); + + /// + /// + /// + public enum DisconnectType + { + /// + ClientInitiated, + /// + ServerInitiated, + /// + NetworkTimeout + } + + /// + /// This exception is thrown whenever a network operation is attempted + /// without a network connection. + /// + public class NotConnectedException : ApplicationException { } + + internal class AcceptAllCertificatePolicy : ICertificatePolicy + { + public AcceptAllCertificatePolicy() + { + } + + public bool CheckValidationResult(ServicePoint sPoint, + System.Security.Cryptography.X509Certificates.X509Certificate cert, + WebRequest wRequest,int certProb) + { + // Always accept + return true; + } + } + + /// + /// Simulator is a wrapper for a network connection to a simulator and the + /// Region class representing the block of land in the metaverse. + /// + public class Simulator + { + /// + /// The Region class that this Simulator wraps + /// + public Region Region; + + /// + /// The ID number associated with this particular connection to the + /// simulator, used to emulate TCP connections. This is used + /// internally for packets that have a CircuitCode field. + /// + public uint CircuitCode + { + get { return circuitCode; } + set { circuitCode = value; } + } + + /// + /// The IP address and port of the server. + /// + public IPEndPoint IPEndPoint + { + get { return ipEndPoint; } + } + + /// + /// A boolean representing whether there is a working connection to the + /// simulator or not. + /// + public bool Connected + { + get { return connected; } + } + + /// + /// Used internally to track sim disconnections, do not modify this + /// variable. + /// + public bool DisconnectCandidate; + + private SecondLife Client; + private NetworkManager Network; + private Hashtable Callbacks; + private ushort Sequence; + private byte[] RecvBuffer; + private Mutex RecvBufferMutex = new Mutex(false, "RecvBufferMutex"); + private Socket Connection; + private AsyncCallback ReceivedData; + private Hashtable NeedAck; + private Mutex NeedAckMutex; + private SortedList Inbox; + private ArrayList PendingAcks; + private Mutex InboxMutex; + private bool connected; + private uint circuitCode; + private IPEndPoint ipEndPoint; + private EndPoint endPoint; + private System.Timers.Timer AckTimer; + + /// + /// + /// + /// + /// + /// + /// + /// + public Simulator(SecondLife client, Hashtable callbacks, uint circuit, + IPAddress ip, int port) + { + Client = client; + Network = client.Network; + Callbacks = callbacks; + Region = new Region(client); + circuitCode = circuit; + Sequence = 0; + RecvBuffer = new byte[2048]; + Connection = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); + connected = false; + DisconnectCandidate = false; + AckTimer = new System.Timers.Timer(500); + AckTimer.Elapsed += new ElapsedEventHandler(AckTimer_Elapsed); + + // Initialize the hashtable for reliable packets waiting on ACKs from the server + NeedAck = new Hashtable(); + + // Initialize the lists of sequence numbers we've received so far + Inbox = new SortedList(); + PendingAcks = new ArrayList(); + + NeedAckMutex = new Mutex(false, "NeedAckMutex"); + InboxMutex = new Mutex(false, "InboxMutex"); + + Client.Log("Connecting to " + ip.ToString() + ":" + port, Helpers.LogLevel.Info); + + try + { + // Setup the callback + ReceivedData = new AsyncCallback(OnReceivedData); + + // Create an endpoint that we will be communicating with (need it in two + // types due to .NET weirdness) + ipEndPoint = new IPEndPoint(ip, port); + endPoint = (EndPoint)ipEndPoint; + + // Associate this simulator's socket with the given ip/port and start listening + Connection.Connect(endPoint); + Connection.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref endPoint, ReceivedData, null); + + // Send the UseCircuitCode packet to initiate the connection + UseCircuitCodePacket use = new UseCircuitCodePacket(); + use.CircuitCode.Code = circuitCode; + use.CircuitCode.ID = Network.AgentID; + use.CircuitCode.SessionID = Network.SessionID; + + // Start the ACK timer + AckTimer.Start(); + + // Send the initial packet out + SendPacket(use, true); + + // Track the current time for timeout purposes + int start = Environment.TickCount; + + while (true) + { + if (connected || Environment.TickCount - start > 8000) + { + return; + } + Thread.Sleep(10); + } + } + catch (Exception e) + { + Console.WriteLine(e.ToString()); + Client.Log(e.ToString(), Helpers.LogLevel.Error); + } + } + + /// + /// + /// + public void Disconnect() + { + // Send the CloseCircuit notice + CloseCircuitPacket close = new CloseCircuitPacket(); + + try + { + Connection.Send(close.ToBytes()); + } + catch (SocketException) + { + // There's a high probability of this failing if the network is + // disconnected, so don't even bother logging the error + } + + try + { + // Shut the socket communication down + Connection.Shutdown(SocketShutdown.Both); + } + catch (SocketException e) + { + Client.Log(e.ToString(), Helpers.LogLevel.Error); + } + + connected = false; + } + + /// + /// + /// + /// + /// + public void SendPacket(Packet packet, bool incrementSequence) + { + byte[] buffer; + int bytes; + + if (!connected && packet.Type != PacketType.UseCircuitCode) + { + Client.Log("Trying to send a " + packet.Type.ToString() + " packet when the socket is closed", + Helpers.LogLevel.Warning); + + throw new NotConnectedException(); + } + + if (incrementSequence) + { + // Set the sequence number here since we are manually serializing the packet + packet.Header.Sequence = ++Sequence; + + if (packet.Header.Reliable) + { + // Keep track of when this packet was sent out + packet.TickCount = Environment.TickCount; + + #region NeedAckMutex + NeedAckMutex.WaitOne(); + if (!NeedAck.ContainsKey(packet.Header.Sequence)) + { + NeedAck.Add(packet.Header.Sequence, packet); + } + else + { + Client.Log("Attempted to add a duplicate sequence number (" + + packet.Header.Sequence + ") to the NeedAck hashtable for packet type " + + packet.Type.ToString(), Helpers.LogLevel.Warning); + } + NeedAckMutex.ReleaseMutex(); + #endregion NeedAckMutex + + // Append any ACKs that need to be sent out to this packet + #region InboxMutex + InboxMutex.WaitOne(); + try + { + if (PendingAcks.Count > 0 && packet.Type != PacketType.PacketAck && + packet.Type != PacketType.LogoutRequest) + { + packet.Header.AckList = new uint[PendingAcks.Count]; + + int i = 0; + + foreach (uint ack in PendingAcks) + { + packet.Header.AckList[i] = ack; + i++; + } + + PendingAcks.Clear(); + packet.Header.AppendedAcks = true; + } + } + catch (Exception e) + { + Client.Log(e.ToString(), Helpers.LogLevel.Error); + } + finally + { + InboxMutex.ReleaseMutex(); + } + #endregion InboxMutex + } + } + + // Serialize the packet + buffer = packet.ToBytes(); + bytes = buffer.Length; + + // Zerocode if needed + if (packet.Header.Zerocoded) + { + byte[] zeroBuffer = new byte[4096]; + bytes = Helpers.ZeroEncode(buffer, bytes, zeroBuffer); + + buffer = zeroBuffer; + } + + try + { + Connection.Send(buffer, bytes, SocketFlags.None); + } + catch (SocketException e) + { + Client.Log(e.ToString(), Helpers.LogLevel.Error); + } + } + + /// + /// + /// + /// + public void SendPacket(byte[] payload) + { + if (!connected) + { + throw new NotConnectedException(); + } + + try + { + Connection.Send(payload, payload.Length, SocketFlags.None); + } + catch (SocketException e) + { + Client.Log(e.ToString(), Helpers.LogLevel.Error); + } + } + + private void OnReceivedData(IAsyncResult result) + { + Packet packet = null; + int numBytes; + + // If we're receiving data the sim connection is open + connected = true; + + #region RecvBufferMutex + try + { + RecvBufferMutex.WaitOne(); + + // Update the disconnect flag so this sim doesn't time out + DisconnectCandidate = false; + + // Retrieve the incoming packet + try + { + numBytes = Connection.EndReceiveFrom(result, ref endPoint); + } + catch (SocketException) + { + Client.Log("Socket error, shutting down " + this.Region.Name + + " (" + endPoint.ToString() + ")", Helpers.LogLevel.Warning); + + connected = false; + RecvBufferMutex.ReleaseMutex(); + Network.DisconnectSim(this); + + return; + } + + int packetEnd = numBytes - 1; + packet = Packet.BuildPacket(RecvBuffer, ref packetEnd); + } + catch (Exception e) + { + Client.Log(e.ToString(), Helpers.LogLevel.Error); + } + finally + { + RecvBufferMutex.ReleaseMutex(); + + try + { + Connection.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref endPoint, ReceivedData, null); + } + catch (Exception) + { + } + } + #endregion RecvBufferMutex + + // Fail-safe checks + if (packet == null) + { + Client.Log("OnReceivedData() fail-safe reached, exiting", Helpers.LogLevel.Warning); + return; + } + + // Track the sequence number for this packet if it's marked as reliable + if (packet.Header.Reliable) + { + // Check if we already received this packet + #region InboxMutex + try + { + InboxMutex.WaitOne(); + + if (Inbox.Contains(packet.Header.Sequence)) + { + Client.Log("Received a duplicate " + packet.Type.ToString() + ", sequence=" + + packet.Header.Sequence + ", resent=" + ((packet.Header.Resent) ? "Yes" : "No"), + Helpers.LogLevel.Info); + + // Avoid firing a callback twice for the same packet + return; + } + else + { + Inbox.Add(packet.Header.Sequence, packet.Header.Sequence); + PendingAcks.Add((uint)packet.Header.Sequence); + } + } + catch (Exception e) + { + Client.Log(e.ToString(), Helpers.LogLevel.Error); + } + finally + { + InboxMutex.ReleaseMutex(); + } + #endregion InboxMutex + } + + // Handle ACK packets + if (packet.Header.AppendedAcks || packet.Type == PacketType.PacketAck) + { + #region NeedAckMutex + try + { + NeedAckMutex.WaitOne(); + + // Handle PacketAck packets + if (packet.Type == PacketType.PacketAck) + { + PacketAckPacket ackPacket = (PacketAckPacket)packet; + + foreach (PacketAckPacket.PacketsBlock block in ackPacket.Packets) + { + NeedAck.Remove((ushort)block.ID); + } + } + + // Handle appended ACKs + if (packet.Header.AppendedAcks) + { + foreach (ushort ack in packet.Header.AckList) + { + if (NeedAck.ContainsKey(ack)) + { + NeedAck.Remove(ack); + } + else + { + Client.Log("Appended ACK for a packet we didn't send: " + ack, Helpers.LogLevel.Warning); + } + } + } + } + catch (Exception e) + { + Client.Log(e.ToString(), Helpers.LogLevel.Error); + } + finally + { + NeedAckMutex.ReleaseMutex(); + } + #endregion NeedAckMutex + } + + // Fire the registered packet events + #region FireCallbacks + try + { + if (Callbacks.ContainsKey(packet.Type)) + { + ArrayList callbackArray = (ArrayList)Callbacks[packet.Type]; + + // Fire any registered callbacks + foreach (PacketCallback callback in callbackArray) + { + if (callback != null) + { + callback(packet, this); + } + } + } + + if (Callbacks.ContainsKey(PacketType.Default)) + { + ArrayList callbackArray = (ArrayList)Callbacks[PacketType.Default]; + + // Fire any registered callbacks + foreach (PacketCallback callback in callbackArray) + { + if (callback != null) + { + callback(packet, this); + } + } + } + } + catch (Exception e) + { + Client.Log("Caught an exception in a packet callback: " + e.ToString(), Helpers.LogLevel.Warning); + } + #endregion FireCallbacks + } + + private void AckTimer_Elapsed(object sender, ElapsedEventArgs ea) + { + if (!connected) + { + AckTimer.Stop(); + return; + } + + #region InboxMutex + try + { + InboxMutex.WaitOne(); + + if (PendingAcks.Count > 0) + { + int i = 0; + PacketAckPacket acks = new PacketAckPacket(); + acks.Packets = new PacketAckPacket.PacketsBlock[PendingAcks.Count]; + acks.Header.Reliable = false; + + foreach (uint ack in PendingAcks) + { + acks.Packets[i] = new PacketAckPacket.PacketsBlock(); + acks.Packets[i].ID = ack; + i++; + } + + SendPacket(acks, true); + + PendingAcks.Clear(); + } + } + catch (Exception e) + { + Client.Log(e.ToString(), Helpers.LogLevel.Error); + } + finally + { + InboxMutex.ReleaseMutex(); + } + #endregion InboxMutex + } + } + + /// + /// NetworkManager is responsible for managing the network layer of + /// libsecondlife. It tracks all the server connections, serializes + /// outgoing traffic and deserializes incoming traffic, and provides + /// instances of delegates for network-related events. + /// + public class NetworkManager + { + /// + /// The permanent UUID for the logged in avatar + /// + public LLUUID AgentID; + /// + /// A temporary UUID assigned to this session, used for secure + /// transactions + /// + public LLUUID SessionID; + /// + /// A string holding a descriptive error on login failure, empty + /// otherwise + /// + public string LoginError; + /// + /// The simulator that the logged in avatar is currently occupying + /// + public Simulator CurrentSim; + /// + /// The complete hashtable of all the login values returned by the + /// RPC login server, converted to native data types wherever possible + /// + public Hashtable LoginValues; + /// + /// Shows whether the network layer is logged in to the grid or not + /// + public bool Connected + { + get { return connected; } + } + /// + /// An event for the connection to a simulator other than the currently + /// occupied one disconnecting + /// + public SimDisconnectCallback OnSimDisconnected; + /// + /// An event for being logged out either through client request, server + /// forced, or network error + /// + public DisconnectCallback OnDisconnected; + + private Hashtable Callbacks; + private SecondLife Client; + private ArrayList Simulators; + private Mutex SimulatorsMutex; + private System.Timers.Timer DisconnectTimer; + private bool connected; + + /// + /// + /// + /// + public NetworkManager(SecondLife client) + { + Client = client; + Simulators = new ArrayList(); + SimulatorsMutex = new Mutex(false, "SimulatorsMutex"); + Callbacks = new Hashtable(); + CurrentSim = null; + LoginValues = null; + + // Register the internal callbacks + RegisterCallback(PacketType.RegionHandshake, new PacketCallback(RegionHandshakeHandler)); + RegisterCallback(PacketType.StartPingCheck, new PacketCallback(StartPingCheckHandler)); + RegisterCallback(PacketType.ParcelOverlay, new PacketCallback(ParcelOverlayHandler)); + RegisterCallback(PacketType.EnableSimulator, new PacketCallback(EnableSimulatorHandler)); + RegisterCallback(PacketType.KickUser, new PacketCallback(KickUserHandler)); + + // Disconnect a sim if no network traffic has been received for 15 seconds + DisconnectTimer = new System.Timers.Timer(15000); + DisconnectTimer.Elapsed += new ElapsedEventHandler(DisconnectTimer_Elapsed); + } + + /// + /// + /// + /// + /// + public void RegisterCallback(PacketType type, PacketCallback callback) + { + if (!Callbacks.ContainsKey(type)) + { + Callbacks[type] = new ArrayList(); + } + + ArrayList callbackArray = (ArrayList)Callbacks[type]; + callbackArray.Add(callback); + } + + /// + /// + /// + /// + /// + public void UnregisterCallback(PacketType type, PacketCallback callback) + { + if (!Callbacks.ContainsKey(type)) + { + Client.Log("Trying to unregister a callback for packet " + type.ToString() + + " when no callbacks are setup for that packet", Helpers.LogLevel.Info); + return; + } + + ArrayList callbackArray = (ArrayList)Callbacks[type]; + + if (callbackArray.Contains(callback)) + { + callbackArray.Remove(callback); + } + else + { + Client.Log("Trying to unregister a non-existant callback for packet " + type.ToString(), + Helpers.LogLevel.Info); + } + } + + /// + /// + /// + /// + public void SendPacket(Packet packet) + { + if (CurrentSim != null && CurrentSim.Connected) + { + CurrentSim.SendPacket(packet, true); + } + } + + /// + /// + /// + /// + /// + public void SendPacket(Packet packet, Simulator simulator) + { + if (simulator.Connected) + { + simulator.SendPacket(packet, true); + } + } + + /// + /// + /// + /// + public void SendPacket(byte[] payload) + { + if (CurrentSim != null) + { + CurrentSim.SendPacket(payload); + } + else + { + throw new NotConnectedException(); + } + } + + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static Hashtable DefaultLoginValues(string firstName, string lastName, string password, + string userAgent, string author) + { + return DefaultLoginValues(firstName, lastName, password, "00:00:00:00:00:00", "last", + 1, 50, 50, 50, "Win", "0", userAgent, author); + } + + public static Hashtable DefaultLoginValues(string firstName, string lastName, string password, string mac, + string startLocation, string platform, string viewerDigest, string userAgent, string author) + { + return DefaultLoginValues(firstName, lastName, password, mac, startLocation, + 1, 50, 50, 50, platform, viewerDigest, userAgent, author); + } + + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static Hashtable DefaultLoginValues(string firstName, string lastName, string password, string mac, + string startLocation, int major, int minor, int patch, int build, string platform, string viewerDigest, + string userAgent, string author) + { + Hashtable values = new Hashtable(); + + // Generate an MD5 hash of the password + MD5 md5 = new MD5CryptoServiceProvider(); + byte[] hash = md5.ComputeHash(Encoding.ASCII.GetBytes(password)); + StringBuilder passwordDigest = new StringBuilder(); + // Convert the hash to a hex string + foreach(byte b in hash) + { + passwordDigest.AppendFormat("{0:x2}", b); + } + + values["first"] = firstName; + values["last"] = lastName; + values["passwd"] = "$1$" + passwordDigest; + values["start"] = startLocation; + values["major"] = major; + values["minor"] = minor; + values["patch"] = patch; + values["build"] = build; + values["platform"] = platform; + values["mac"] = mac; + values["agree_to_tos"] = "true"; + values["viewer_digest"] = viewerDigest; + values["user-agent"] = userAgent + " (" + Helpers.VERSION + ")"; + values["author"] = author; + + // Build the options array + ArrayList optionsArray = new ArrayList(); + optionsArray.Add("inventory-root"); + optionsArray.Add("inventory-skeleton"); + optionsArray.Add("inventory-lib-root"); + optionsArray.Add("inventory-lib-owner"); + optionsArray.Add("inventory-skel-lib"); + optionsArray.Add("initial-outfit"); + optionsArray.Add("gestures"); + optionsArray.Add("event_categories"); + optionsArray.Add("event_notifications"); + optionsArray.Add("classified_categories"); + optionsArray.Add("buddy-list"); + optionsArray.Add("ui-config"); + optionsArray.Add("login-flags"); + optionsArray.Add("global-textures"); + + values["options"] = optionsArray; + + return values; + } + + /// + /// + /// + /// + /// + public bool Login(Hashtable loginParams) + { + return Login(loginParams, "https://login.agni.lindenlab.com/cgi-bin/login.cgi"); + } + + /// + /// + /// + /// + /// + /// + public bool Login(Hashtable loginParams, string url) + { + XmlRpcResponse result; + XmlRpcRequest xmlrpc = new XmlRpcRequest(); + xmlrpc.MethodName = "login_to_simulator"; + xmlrpc.Params.Clear(); + xmlrpc.Params.Add(loginParams); + + try + { + result = (XmlRpcResponse)xmlrpc.Send(url); + } + catch (Exception e) + { + LoginError = e.Message; + LoginValues = null; + return false; + } + + if (result.IsFault) + { + Client.Log("Fault " + result.FaultCode + ": " + result.FaultString, Helpers.LogLevel.Error); + LoginError = "Fault " + result.FaultCode + ": " + result.FaultString; + LoginValues = null; + return false; + } + + LoginValues = (Hashtable)result.Value; + + if ((string)LoginValues["login"] == "indeterminate") + { + //FIXME: We need to do another XML-RPC, handle this case + LoginError = "Got a redirect, login with the official client to update"; + return false; + } + else if ((string)LoginValues["login"] == "false") + { + LoginError = LoginValues["reason"] + ": " + LoginValues["message"]; + return false; + } + else if ((string)LoginValues["login"] != "true") + { + LoginError = "Unknown error"; + return false; + } + + System.Text.RegularExpressions.Regex LLSDtoJSON = + new System.Text.RegularExpressions.Regex(@"('|r([0-9])|r(\-))"); + string json; + IDictionary jsonObject = null; + LLVector3 vector = null; + LLVector3 posVector = null; + LLVector3 lookatVector = null; + ulong regionHandle = 0; + + try + { + if (LoginValues.Contains("look_at")) + { + // Replace LLSD variables with object representations + + // Convert LLSD string to JSON + json = "{vector:" + LLSDtoJSON.Replace((string)LoginValues["look_at"], "$2") + "}"; + + // Convert JSON string to a JSON object + jsonObject = JsonFacade.fromJSON(json); + JSONArray jsonVector = (JSONArray)jsonObject["vector"]; + + // Convert the JSON object to an LLVector3 + vector = new LLVector3(Convert.ToSingle(jsonVector[0]), + Convert.ToSingle(jsonVector[1]), Convert.ToSingle(jsonVector[2])); + + LoginValues["look_at"] = vector; + } + + if (LoginValues.Contains("home")) + { + Hashtable home; + + // Convert LLSD string to JSON + json = LLSDtoJSON.Replace((string)LoginValues["home"], "$2"); + + // Convert JSON string to an object + jsonObject = JsonFacade.fromJSON(json); + + // Create the position vector + JSONArray array = (JSONArray)jsonObject["position"]; + posVector = new LLVector3(Convert.ToSingle(array[0]), Convert.ToSingle(array[1]), + Convert.ToSingle(array[2])); + + // Create the look_at vector + array = (JSONArray)jsonObject["look_at"]; + lookatVector = new LLVector3(Convert.ToSingle(array[0]), + Convert.ToSingle(array[1]), Convert.ToSingle(array[2])); + + // Create the regionhandle + array = (JSONArray)jsonObject["region_handle"]; + regionHandle = Helpers.UIntsToLong((uint)(int)array[0], (uint)(int)array[1]); + + Client.Avatar.Position = posVector; + Client.Avatar.LookAt = lookatVector; + + // Create a hashtable to hold the home values + home = new Hashtable(); + home["position"] = posVector; + home["look_at"] = lookatVector; + home["region_handle"] = regionHandle; + LoginValues["home"] = home; + } + + this.AgentID = new LLUUID((string)LoginValues["agent_id"]); + this.SessionID = new LLUUID((string)LoginValues["session_id"]); + Client.Avatar.ID = this.AgentID; + Client.Avatar.FirstName = (string)LoginValues["first_name"]; + Client.Avatar.LastName = (string)LoginValues["last_name"]; + Client.Avatar.LookAt = vector; + Client.Avatar.HomePosition = posVector; + Client.Avatar.HomeLookAt = lookatVector; + + // Connect to the sim given in the login reply + Simulator simulator = new Simulator(Client, this.Callbacks, (uint)(int)LoginValues["circuit_code"], + IPAddress.Parse((string)LoginValues["sim_ip"]), (int)LoginValues["sim_port"]); + if (!simulator.Connected) + { + return false; + } + + simulator.Region.Handle = regionHandle; + CurrentSim = simulator; + + // Simulator is successfully connected, add it to the list and set it as default + Simulators.Add(simulator); + + // Move our agent in to the sim to complete the connection + Client.Avatar.CompleteAgentMovement(simulator); + + SendInitialPackets(); + + DisconnectTimer.Start(); + connected = true; + return true; + } + catch (Exception e) + { + Client.Log("Login error: " + e.ToString(), Helpers.LogLevel.Error); + return false; + } + } + + /// + /// + /// + /// + /// + /// + /// + /// + public Simulator Connect(IPAddress ip, ushort port, uint circuitCode, bool setDefault) + { + Simulator simulator = new Simulator(Client, this.Callbacks, circuitCode, ip, (int)port); + + if (!simulator.Connected) + { + simulator = null; + return null; + } + + #region SimulatorsMutex + try + { + SimulatorsMutex.WaitOne(); + Simulators.Add(simulator); + } + catch (Exception e) + { + Client.Log(e.ToString(), Helpers.LogLevel.Error); + } + finally + { + SimulatorsMutex.ReleaseMutex(); + } + #endregion SimulatorsMutex + + if (setDefault) + { + CurrentSim = simulator; + } + + DisconnectTimer.Start(); + connected = true; + return simulator; + } + + /// + /// + /// + public void Logout() + { + // This will catch a Logout when the client is not logged in + if (CurrentSim == null || !connected) + { + return; + } + + DisconnectTimer.Stop(); + connected = false; + + // Send a logout request to the current sim + LogoutRequestPacket logout = new LogoutRequestPacket(); + logout.AgentData.AgentID = AgentID; + logout.AgentData.SessionID = SessionID; + + CurrentSim.SendPacket(logout, true); + + // TODO: We should probably check if the server actually received the logout request + + // Shutdown the network layer + Shutdown(); + + if (OnDisconnected != null) + { + OnDisconnected(DisconnectType.ClientInitiated, ""); + } + } + + /// + /// + /// + /// + public void DisconnectSim(Simulator sim) + { + sim.Disconnect(); + + // Fire the SimDisconnected event if a handler is registered + if (OnSimDisconnected != null) + { + OnSimDisconnected(sim, DisconnectType.NetworkTimeout); + } + + #region SimulatorsMutex + try + { + SimulatorsMutex.WaitOne(); + Simulators.Remove(sim); + } + catch (Exception e) + { + Client.Log(e.ToString(), Helpers.LogLevel.Error); + } + finally + { + SimulatorsMutex.ReleaseMutex(); + } + #endregion SimulatorsMutex + } + + /// + /// Shutdown will disconnect all the sims except for the current sim + /// first, and then kill the connection to CurrentSim. + /// + private void Shutdown() + { + #region SimulatorsMutex + try + { + SimulatorsMutex.WaitOne(); + + // Disconnect all simulators except the current one + foreach (Simulator simulator in Simulators) + { + // Don't disconnect the current sim, we'll use LogoutRequest for that + if (simulator != CurrentSim) + { + simulator.Disconnect(); + + // Fire the SimDisconnected event if a handler is registered + if (OnSimDisconnected != null) + { + OnSimDisconnected(simulator, DisconnectType.NetworkTimeout); + } + } + } + } + catch (Exception e) + { + Client.Log(e.ToString(), Helpers.LogLevel.Error); + } + finally + { + Simulators.Clear(); + SimulatorsMutex.ReleaseMutex(); + } + #endregion SimulatorsMutex + + CurrentSim.Disconnect(); + CurrentSim = null; + } + + private void SendInitialPackets() + { + // Request the economy data + SendPacket(new EconomyDataRequestPacket()); + + // TODO: The client sends this early in the login sequence, should we? + //ViewerEffectPacket effect = new ViewerEffectPacket(); + //effect.Effect = new ViewerEffectPacket.EffectBlock[1]; + //effect.Effect[0] = new ViewerEffectPacket.EffectBlock(); + //effect.Effect[0].Color = new byte[] { 0xFF, 0xFF, 0xFF, 0xFF }; + //effect.Effect[0].Duration = 0.5f; + //effect.Effect[0].ID = new LLUUID("c696075e53c6153f3d8e0c3e24541936"); + //effect.Effect[0].Type = 9; + //effect.Effect[0].TypeData = new byte[56]; + //Array.Copy(new byte[] { 0x28, 0xF0, 0x10, 0x41 }, 0, effect.Effect[0].TypeData, 36, 4); + //Array.Copy(new byte[] { 0x50, 0xD0, 0x0E, 0x41 }, 0, effect.Effect[0].TypeData, 44, 4); + //Array.Copy(new byte[] { 0x24, 0x40 }, 0, effect.Effect[0].TypeData, 54, 2); + //effect.Header.Reliable = false; + //SendPacket(effect); + + // TODO: Is this throttle necessary/good, and what does it do? + AgentThrottlePacket throttle = new AgentThrottlePacket(); + throttle.AgentData.AgentID = this.AgentID; + throttle.AgentData.SessionID = this.SessionID; + throttle.AgentData.CircuitCode = this.CurrentSim.CircuitCode; + throttle.Throttle.GenCounter = 0; + throttle.Throttle.Throttles = new byte[] + { 0x00, 0x00, 0x96, 0x47, 0x00, 0x00, 0xAA, 0x47, 0x00, 0x00, 0x88, 0x46, 0x00, 0x00, 0x88, 0x46, + 0x00, 0x00, 0x5F, 0x48, 0x00, 0x00, 0x5F, 0x48, 0x00, 0x00, 0xDC, 0x47 }; + SendPacket(throttle); + + // TODO: We should be setting the initial avatar height/width around here + //Client.Avatar.SetHeightWidth(676, 909); + + // Set the initial avatar camera position + Client.Avatar.UpdateCamera(true); + + // TODO: What animation are we stopping here? + AgentAnimationPacket animation = new AgentAnimationPacket(); + animation.AgentData.AgentID = AgentID; + animation.AgentData.SessionID = SessionID; + animation.AnimationList = new AgentAnimationPacket.AnimationListBlock[1]; + animation.AnimationList[0] = new AgentAnimationPacket.AnimationListBlock(); + animation.AnimationList[0].AnimID = new LLUUID("efcf670c2d188128973a034ebc806b67"); + animation.AnimationList[0].StartAnim = false; + SendPacket(animation); + + // TODO: Do we ever want to set this to true? + SetAlwaysRunPacket run = new SetAlwaysRunPacket(); + run.AgentData.AgentID = AgentID; + run.AgentData.SessionID = SessionID; + run.AgentData.AlwaysRun = false; + SendPacket(run); + + // TODO: This information is currently unused + MuteListRequestPacket mute = new MuteListRequestPacket(); + mute.AgentData.AgentID = AgentID; + mute.AgentData.SessionID = SessionID; + mute.MuteData.MuteCRC = 0; + SendPacket(mute); + + // Get the current avatar balance + MoneyBalanceRequestPacket money = new MoneyBalanceRequestPacket(); + money.AgentData.AgentID = AgentID; + money.AgentData.SessionID = SessionID; + money.MoneyData.TransactionID = new LLUUID(); + SendPacket(money); + + // Request info about our avatar + AgentDataUpdateRequestPacket update = new AgentDataUpdateRequestPacket(); + update.AgentData.AgentID = AgentID; + update.AgentData.SessionID = SessionID; + SendPacket(update); + + // TODO: What is the purpose of this? Information is currently unused + RequestGrantedProxiesPacket proxies = new RequestGrantedProxiesPacket(); + proxies.AgentData.AgentID = AgentID; + proxies.AgentData.SessionID = SessionID; + SendPacket(proxies); + } + + private void DisconnectTimer_Elapsed(object sender, ElapsedEventArgs ev) + { + #region SimulatorsMutex + try + { + SimulatorsMutex.WaitOne(); + + Beginning: + + foreach (Simulator sim in Simulators) + { + if (sim.DisconnectCandidate == true) + { + if (sim == CurrentSim) + { + Client.Log("Network timeout for the current simulator (" + + sim.Region.Name + "), logging out", Helpers.LogLevel.Warning); + + DisconnectTimer.Stop(); + connected = false; + + // Shutdown the network layer + Shutdown(); + + if (OnDisconnected != null) + { + OnDisconnected(DisconnectType.NetworkTimeout, ""); + } + + // We're completely logged out and shut down, leave this function + return; + } + else + { + // This sim hasn't received any network traffic since the + // timer last elapsed, consider it disconnected + Client.Log("Network timeout for simulator " + sim.Region.Name + + ", disconnecting", Helpers.LogLevel.Warning); + + SimulatorsMutex.ReleaseMutex(); + DisconnectSim(sim); + SimulatorsMutex.WaitOne(); + + // Reset the iterator since we removed an element + goto Beginning; + } + } + else + { + sim.DisconnectCandidate = true; + } + } + } + catch (Exception e) + { + Client.Log(e.ToString(), Helpers.LogLevel.Error); + } + finally + { + SimulatorsMutex.ReleaseMutex(); + } + #endregion SimulatorsMutex + } + + private void StartPingCheckHandler(Packet packet, Simulator simulator) + { + StartPingCheckPacket incomingPing = (StartPingCheckPacket)packet; + CompletePingCheckPacket ping = new CompletePingCheckPacket(); + ping.PingID.PingID = incomingPing.PingID.PingID; + + // TODO: We can use OldestUnacked to correct transmission errors + + SendPacket((Packet)ping, simulator); + } + + private void RegionHandshakeHandler(Packet packet, Simulator simulator) + { + // Send a RegionHandshakeReply + RegionHandshakeReplyPacket reply = new RegionHandshakeReplyPacket(); + reply.AgentData.AgentID = AgentID; + reply.AgentData.SessionID = SessionID; + reply.RegionInfo.Flags = 0; + SendPacket(reply, simulator); + + // TODO: Do we need to send an AgentUpdate to each sim upon connection? + + RegionHandshakePacket handshake = (RegionHandshakePacket)packet; + + simulator.Region.ID = handshake.RegionInfo.CacheID; + + // FIXME: + //handshake.RegionInfo.BillableFactor; + //handshake.RegionInfo.RegionFlags; + //handshake.RegionInfo.SimAccess; + + simulator.Region.IsEstateManager = handshake.RegionInfo.IsEstateManager; + simulator.Region.Name = Helpers.FieldToString(handshake.RegionInfo.SimName); + simulator.Region.SimOwner = handshake.RegionInfo.SimOwner; + simulator.Region.TerrainBase0 = handshake.RegionInfo.TerrainBase0; + simulator.Region.TerrainBase1 = handshake.RegionInfo.TerrainBase1; + simulator.Region.TerrainBase2 = handshake.RegionInfo.TerrainBase2; + simulator.Region.TerrainBase3 = handshake.RegionInfo.TerrainBase3; + simulator.Region.TerrainDetail0 = handshake.RegionInfo.TerrainDetail0; + simulator.Region.TerrainDetail1 = handshake.RegionInfo.TerrainDetail1; + simulator.Region.TerrainDetail2 = handshake.RegionInfo.TerrainDetail2; + simulator.Region.TerrainDetail3 = handshake.RegionInfo.TerrainDetail3; + simulator.Region.TerrainHeightRange00 = handshake.RegionInfo.TerrainHeightRange00; + simulator.Region.TerrainHeightRange01 = handshake.RegionInfo.TerrainHeightRange01; + simulator.Region.TerrainHeightRange10 = handshake.RegionInfo.TerrainHeightRange10; + simulator.Region.TerrainHeightRange11 = handshake.RegionInfo.TerrainHeightRange11; + simulator.Region.TerrainStartHeight00 = handshake.RegionInfo.TerrainStartHeight00; + simulator.Region.TerrainStartHeight01 = handshake.RegionInfo.TerrainStartHeight01; + simulator.Region.TerrainStartHeight10 = handshake.RegionInfo.TerrainStartHeight10; + simulator.Region.TerrainStartHeight11 = handshake.RegionInfo.TerrainStartHeight11; + simulator.Region.WaterHeight = handshake.RegionInfo.WaterHeight; + + Client.Log("Received a region handshake for " + simulator.Region.Name, Helpers.LogLevel.Info); + } + + private void ParcelOverlayHandler(Packet packet, Simulator simulator) + { + ParcelOverlayPacket overlay = (ParcelOverlayPacket)packet; + + if (overlay.ParcelData.SequenceID >= 0 && overlay.ParcelData.SequenceID <= 3) + { + Array.Copy(overlay.ParcelData.Data, 0, simulator.Region.ParcelOverlay, + overlay.ParcelData.SequenceID * 1024, 1024); + simulator.Region.ParcelOverlaysReceived++; + + if (simulator.Region.ParcelOverlaysReceived > 3) + { + Client.Log("Finished building the " + simulator.Region.Name + " parcel overlay", + Helpers.LogLevel.Info); + } + } + else + { + Client.Log("Parcel overlay with sequence ID of " + overlay.ParcelData.SequenceID + + " received from " + simulator.Region.Name, Helpers.LogLevel.Warning); + } + } + + private void EnableSimulatorHandler(Packet packet, Simulator simulator) + { + // TODO: Actually connect to the simulator + + // TODO: Sending ConfirmEnableSimulator completely screws things up. :-? + + // Respond to the simulator connection request + //Packet replyPacket = Packets.Network.ConfirmEnableSimulator(Protocol, AgentID, SessionID); + //SendPacket(replyPacket, circuit); + } + + private void KickUserHandler(Packet packet, Simulator simulator) + { + string message = Helpers.FieldToString(((KickUserPacket)packet).UserInfo.Reason); + + // Shutdown the network layer + Shutdown(); + + if (OnDisconnected != null) + { + OnDisconnected(DisconnectType.ServerInitiated, message); + } + } + } +} diff --git a/libsecondlife-cs/ObjectManager.cs b/libsecondlife-cs/ObjectManager.cs index b9eff118..f9f4e000 100644 --- a/libsecondlife-cs/ObjectManager.cs +++ b/libsecondlife-cs/ObjectManager.cs @@ -1,538 +1,538 @@ -/* - * Copyright (c) 2006, Second Life Reverse Engineering Team - * All rights reserved. - * - * - Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - Neither the name of the Second Life Reverse Engineering Team nor the names - * of its contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections; -using libsecondlife.Packets; - -namespace libsecondlife -{ - /// - /// - /// - /// - /// - /// - /// - public delegate void NewPrimCallback(Simulator simulator, PrimObject prim, ulong regionHandle, ushort timeDilation); - /// - /// - /// - /// - /// - /// - /// - public delegate void NewAvatarCallback(Simulator simulator, Avatar avatar, ulong regionHandle, ushort timeDilation); - /// - /// - /// - /// - /// - /// - /// - public delegate void PrimMovedCallback(Simulator simulator, PrimUpdate prim, ulong regionHandle, ushort timeDilation); - /// - /// - /// - /// - /// - /// - /// - public delegate void AvatarMovedCallback(Simulator simulator, AvatarUpdate avatar, ulong regionHandle, ushort timeDilation); - /// - /// - /// - /// - /// - public delegate void KillObjectCallback(Simulator simulator, uint objectID); - - /// - /// Contains all of the variables sent in an object update packet for a - /// prim object. Used to track position and movement of prims. - /// - public struct PrimUpdate - { - /// - public uint LocalID; - /// - public byte State; - /// - public LLVector3 Position; - /// - public LLVector3 Velocity; - /// - public LLVector3 Acceleration; - /// - public LLQuaternion Rotation; - /// - public LLVector3 RotationVelocity; - } - - /// - /// Contains all of the variables sent in an object update packet for an - /// avatar. Used to track position and movement of avatars. - /// - public struct AvatarUpdate - { - /// - public uint LocalID; - /// - public byte State; - /// - public LLVector4 CollisionPlane; - /// - public LLVector3 Position; - /// - public LLVector3 Velocity; - /// - public LLVector3 Acceleration; - /// - public LLQuaternion Rotation; - /// - public LLVector3 RotationVelocity; - } - - /// - /// Handles all network traffic related to prims and avatar positions and - /// movement. - /// - public class ObjectManager - { - /// - /// This event will be raised for every ObjectUpdate block that - /// contains a new prim. - /// Depending on the circumstances a client could - /// receive two or more of these events for the same object, if you - /// or the object left the current sim and returned for example. Client - /// applications are responsible for tracking and storing objects. - /// - /// - public event NewPrimCallback OnNewPrim; - /// - /// This event will be raised for every ObjectUpdate block that - /// contains a new avatar. - /// Depending on the circumstances a client - /// could receive two or more of these events for the same avatar, if - /// you or the other avatar left the current sim and returned for - /// example. Client applications are responsible for tracking and - /// storing objects. - /// - public event NewAvatarCallback OnNewAvatar; - /// - /// This event will be raised when a prim movement packet is received, - /// containing the updated position, rotation, and movement-related - /// vectors. - /// - public event PrimMovedCallback OnPrimMoved; - /// - /// This event will be raised when an avatar movement packet is - /// received, containing the updated position, rotation, and - /// movement-related vectors. - /// - public event AvatarMovedCallback OnAvatarMoved; - /// - /// This event will be raised when an object is removed from a - /// simulator. - /// - public event KillObjectCallback OnObjectKilled; - - private SecondLife Client; - - /// - /// - /// - /// - public ObjectManager(SecondLife client) - { - Client = client; - - Client.Network.RegisterCallback(PacketType.ObjectUpdate, new PacketCallback(UpdateHandler)); - Client.Network.RegisterCallback(PacketType.ImprovedTerseObjectUpdate, new PacketCallback(TerseUpdateHandler)); - Client.Network.RegisterCallback(PacketType.ObjectUpdateCompressed, new PacketCallback(CompressedUpdateHandler)); - Client.Network.RegisterCallback(PacketType.ObjectUpdateCached, new PacketCallback(CachedUpdateHandler)); - Client.Network.RegisterCallback(PacketType.KillObject, new PacketCallback(KillObjectHandler)); - } - - public void RequestObject(Simulator simulator, uint localID) - { - RequestMultipleObjectsPacket request = new RequestMultipleObjectsPacket(); - request.AgentData.AgentID = Client.Network.AgentID; - request.AgentData.SessionID = Client.Network.SessionID; - request.ObjectData = new RequestMultipleObjectsPacket.ObjectDataBlock[1]; - request.ObjectData[0].ID = localID; - request.ObjectData[0].CacheMissType = 0; - - Client.Network.SendPacket(request, simulator); - } - - private void ParseAvName(string name, ref string firstName, ref string lastName, ref string groupName) - { - string[] lines = name.Split('\n'); - - foreach (string line in lines) - { - if (line.Substring(0, 19) == "Title STRING RW SV ") - { - groupName = line.Substring(19); - } - else if (line.Substring(0, 23) == "FirstName STRING RW SV ") - { - firstName = line.Substring(23); - } - else if (line.Substring(0, 22) == "LastName STRING RW SV ") - { - lastName = line.Substring(22); - } - else - { - Client.Log("Unhandled line in an avatar name: " + line, Helpers.LogLevel.Warning); - } - } - } - - private void UpdateHandler(Packet packet, Simulator simulator) - { - ObjectUpdatePacket update = (ObjectUpdatePacket)packet; - - foreach (ObjectUpdatePacket.ObjectDataBlock block in update.ObjectData) - { - if (block.ObjectData.Length == 60) - { - // New prim spotted - PrimObject prim = new PrimObject(); - - prim.Position = new LLVector3(block.ObjectData, 0); - prim.Rotation = new LLQuaternion(block.ObjectData, 36, true); - - // TODO: Parse the rest of the ObjectData byte array fields - - prim.LocalID = block.ID; - prim.State = block.State; - prim.ID = block.FullID; - prim.ParentID = block.ParentID; - //block.OwnerID Sound-related - prim.Material = block.Material; - prim.PathCurve = block.PathCurve; - prim.ProfileCurve = block.ProfileCurve; - prim.PathBegin = PrimObject.PathBeginFloat(block.PathBegin); - prim.PathEnd = PrimObject.PathEndFloat(block.PathEnd); - prim.PathScaleX = PrimObject.PathScaleFloat(block.PathScaleX); - prim.PathScaleY = PrimObject.PathScaleFloat(block.PathScaleY); - prim.PathShearX = PrimObject.PathShearFloat(block.PathShearX); - prim.PathShearY = PrimObject.PathShearFloat(block.PathShearY); - prim.PathTwist = block.PathTwist; //PrimObject.PathTwistFloat(block.PathTwist); - prim.PathTwistBegin = block.PathTwistBegin; //PrimObject.PathTwistFloat(block.PathTwistBegin); - prim.PathRadiusOffset = PrimObject.PathRadiusOffsetFloat(block.PathRadiusOffset); - prim.PathTaperX = PrimObject.PathTaperFloat((byte)block.PathTaperX); - prim.PathTaperY = PrimObject.PathTaperFloat((byte)block.PathTaperY); - prim.PathRevolutions = PrimObject.PathRevolutionsFloat(block.PathRevolutions); - prim.PathSkew = PrimObject.PathSkewFloat((byte)block.PathSkew); - prim.ProfileBegin = PrimObject.ProfileBeginFloat(block.ProfileBegin); - prim.ProfileEnd = PrimObject.ProfileEndFloat(block.ProfileEnd); - prim.ProfileHollow = block.ProfileHollow; - prim.Name = Helpers.FieldToString(block.NameValue); - //block.Data ? - //block.Text Hovering text - //block.TextColor LLColor4U of the hovering text - //block.MediaURL Quicktime stream - // TODO: Multi-texture support - if (block.TextureEntry.Length >= 16) - { - prim.Texture = new LLUUID(block.TextureEntry, 0); - } - else - { - prim.Texture = new LLUUID(); - } - //block.TextureAnim ? - //block.JointType ? - //block.JointPivot ? - //block.JointAxisOrAnchor ? - //block.PCode ? - //block.PSBlock Particle system related - //block.ExtraParams ? - prim.Scale = block.Scale; - //block.Flags ? - //block.UpdateFlags ? - //block.ClickAction ? - //block.Gain Sound-related - //block.Sound Sound-related - //block.Radius Sound-related - - if (OnNewPrim != null) - { - OnNewPrim(simulator, prim, update.RegionData.RegionHandle, update.RegionData.TimeDilation); - } - } - else if (block.ObjectData.Length == 76) - { - // New avatar spotted - Avatar avatar = new Avatar(); - string FirstName = ""; - string LastName = ""; - string GroupName = ""; - - //avatar.CollisionPlane = new LLQuaternion(block.ObjectData, 0); - avatar.Position = new LLVector3(block.ObjectData, 16); - avatar.Rotation = new LLQuaternion(block.ObjectData, 52, true); - - // TODO: Parse the rest of the ObjectData byte array fields - - ParseAvName(Helpers.FieldToString(block.NameValue), ref FirstName, ref LastName, ref GroupName); - - avatar.ID = block.FullID; - avatar.LocalID = block.ID; - avatar.Name = FirstName + " " + LastName; - avatar.GroupName = GroupName; - avatar.Online = true; - avatar.CurrentRegion = simulator.Region; - - if (FirstName == Client.Avatar.FirstName && LastName == Client.Avatar.LastName) - { - // Update our avatar - Client.Avatar.LocalID = avatar.LocalID; - Client.Avatar.Position = avatar.Position; - Client.Avatar.Rotation = avatar.Rotation; - } - else - { - Client.AddAvatar(avatar); - - if (OnNewAvatar != null) - { - OnNewAvatar(simulator, avatar, update.RegionData.RegionHandle, update.RegionData.TimeDilation); - } - } - } - else - { - // Unknown - Client.Log("Unhandled ObjectData.ObjectData length:\n" + block.ObjectData.Length, - Helpers.LogLevel.Warning); - } - } - } - - private void TerseUpdateHandler(Packet packet, Simulator simulator) - { - float x, y, z, w; - uint localid; - LLVector4 CollisionPlane = null; - LLVector3 Position; - LLVector3 Velocity; - LLVector3 Acceleration; - LLQuaternion Rotation; - LLVector3 RotationVelocity; - - ImprovedTerseObjectUpdatePacket update = (ImprovedTerseObjectUpdatePacket)packet; - - foreach (ImprovedTerseObjectUpdatePacket.ObjectDataBlock block in update.ObjectData) - { - int i = 0; - bool avatar; - - localid = (uint)(block.Data[i++] + (block.Data[i++] << 8) + - (block.Data[i++] << 16) + (block.Data[i++] << 24)); - - byte state = block.Data[i++]; - - avatar = Convert.ToBoolean(block.Data[i++]); - - if (avatar) - { - CollisionPlane = new LLVector4(block.Data, i); - i += 16; - } - - // Position - Position = new LLVector3(block.Data, i); - i += 12; - // Velocity - x = Dequantize(block.Data, i, -128.0F, 128.0F); - i += 2; - y = Dequantize(block.Data, i, -128.0F, 128.0F); - i += 2; - z = Dequantize(block.Data, i, -128.0F, 128.0F); - i += 2; - Velocity = new LLVector3(x, y, z); - // Acceleration - x = Dequantize(block.Data, i, -64.0F, 64.0F); - i += 2; - y = Dequantize(block.Data, i, -64.0F, 64.0F); - i += 2; - z = Dequantize(block.Data, i, -64.0F, 64.0F); - i += 2; - Acceleration = new LLVector3(x, y, z); - // Rotation - x = Dequantize(block.Data, i, -1.0F, 1.0F); - i += 2; - y = Dequantize(block.Data, i, -1.0F, 1.0F); - i += 2; - z = Dequantize(block.Data, i, -1.0F, 1.0F); - i += 2; - w = Dequantize(block.Data, i, -1.0F, 1.0F); - i += 2; - Rotation = new LLQuaternion(x, y, z, w); - // Rotation velocity - x = Dequantize(block.Data, i, -64.0F, 64.0F); - i += 2; - y = Dequantize(block.Data, i, -64.0F, 64.0F); - i += 2; - z = Dequantize(block.Data, i, -64.0F, 64.0F); - i += 2; - RotationVelocity = new LLVector3(x, y, z); - - if (avatar) - { - if (localid == Client.Avatar.LocalID) - { - Client.Avatar.Position = Position; - Client.Avatar.Rotation = Rotation; - } - - AvatarUpdate avupdate = new AvatarUpdate(); - avupdate.LocalID = localid; - avupdate.State = state; - avupdate.Position = Position; - avupdate.CollisionPlane = CollisionPlane; - avupdate.Velocity = Velocity; - avupdate.Acceleration = Acceleration; - avupdate.Rotation = Rotation; - avupdate.RotationVelocity = RotationVelocity; - - if (OnAvatarMoved != null) - { - OnAvatarMoved(simulator, avupdate, update.RegionData.RegionHandle, update.RegionData.TimeDilation); - } - } - else - { - PrimUpdate primupdate = new PrimUpdate(); - primupdate.LocalID = localid; - primupdate.State = state; - primupdate.Position = Position; - primupdate.Velocity = Velocity; - primupdate.Acceleration = Acceleration; - primupdate.Rotation = Rotation; - primupdate.RotationVelocity = RotationVelocity; - - if (OnPrimMoved != null) - { - OnPrimMoved(simulator, primupdate, update.RegionData.RegionHandle, update.RegionData.TimeDilation); - } - } - } - } - - private void CompressedUpdateHandler(Packet packet, Simulator simulator) - { - ObjectUpdateCompressedPacket update = (ObjectUpdateCompressedPacket)packet; - PrimObject prim; - - foreach (ObjectUpdateCompressedPacket.ObjectDataBlock block in update.ObjectData) - { - int i = 0; - prim = new PrimObject(); - - prim.ID = new LLUUID(block.Data, 0); - i += 16; - prim.LocalID = (uint)(block.Data[i++] + (block.Data[i++] << 8) + - (block.Data[i++] << 16) + (block.Data[i++] << 24)); - prim.Scale = new LLVector3(block.Data, i); - i += 12; - prim.Position = new LLVector3(block.Data, i); - i += 12; - prim.Rotation = new LLQuaternion(block.Data, i, true); - i += 12; - - // FIXME: Fill in the rest of these fields - prim.PathCurve = (uint)block.Data[69]; - prim.ProfileCurve = (uint)block.Data[83]; - - if (OnNewPrim != null) - { - OnNewPrim(simulator, prim, update.RegionData.RegionHandle, update.RegionData.TimeDilation); - } - } - } - - private void CachedUpdateHandler(Packet packet, Simulator simulator) - { - int i = 0; - - ObjectUpdateCachedPacket update = (ObjectUpdateCachedPacket)packet; - - // Assume clients aren't caching objects for now, so request updates for all of these objects - RequestMultipleObjectsPacket request = new RequestMultipleObjectsPacket(); - request.AgentData.AgentID = Client.Network.AgentID; - request.AgentData.SessionID = Client.Network.AgentID; - request.ObjectData = new RequestMultipleObjectsPacket.ObjectDataBlock[update.ObjectData.Length]; - - foreach (ObjectUpdateCachedPacket.ObjectDataBlock block in update.ObjectData) - { - request.ObjectData[i] = new RequestMultipleObjectsPacket.ObjectDataBlock(); - request.ObjectData[i].ID = block.ID; - i++; - - //Client.Log("CachedData ID=" + block.ID + ", CRC=" + block.CRC + ", UpdateFlags=" + block.UpdateFlags, - //Helpers.LogLevel.Info); - } - - Client.Network.SendPacket(request); - } - - private void KillObjectHandler(Packet packet, Simulator simulator) - { - if (OnObjectKilled != null) - { - foreach (KillObjectPacket.ObjectDataBlock block in ((KillObjectPacket)packet).ObjectData) - { - OnObjectKilled(simulator, block.ID); - } - } - } - - /// - /// Takes a quantized 16-bit value from a byte array and its range and returns - /// a float representation of the continuous value. For example, a value of - /// 32767 and a range of -128.0 to 128.0 would return 0.0. The endian conversion - /// from the 16-bit little endian to the native platform will also be handled. - /// - /// The byte array containing the short value - /// The beginning position of the short (quantized) value - /// The lower quantization range - /// The upper quantization range - /// A 32-bit floating point representation of the dequantized value - private float Dequantize(byte[] byteArray, int pos, float lower, float upper) - { - ushort value = (ushort)(byteArray[pos] + (byteArray[pos + 1] << 8)); - float QV = (float)value; - float range = upper - lower; - float QF = range / 65536.0F; - return (float)((QV * QF - (0.5F * range)) + QF); - } - } -} +/* + * Copyright (c) 2006, Second Life Reverse Engineering Team + * All rights reserved. + * + * - Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Neither the name of the Second Life Reverse Engineering Team nor the names + * of its contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using libsecondlife.Packets; + +namespace libsecondlife +{ + /// + /// + /// + /// + /// + /// + /// + public delegate void NewPrimCallback(Simulator simulator, PrimObject prim, ulong regionHandle, ushort timeDilation); + /// + /// + /// + /// + /// + /// + /// + public delegate void NewAvatarCallback(Simulator simulator, Avatar avatar, ulong regionHandle, ushort timeDilation); + /// + /// + /// + /// + /// + /// + /// + public delegate void PrimMovedCallback(Simulator simulator, PrimUpdate prim, ulong regionHandle, ushort timeDilation); + /// + /// + /// + /// + /// + /// + /// + public delegate void AvatarMovedCallback(Simulator simulator, AvatarUpdate avatar, ulong regionHandle, ushort timeDilation); + /// + /// + /// + /// + /// + public delegate void KillObjectCallback(Simulator simulator, uint objectID); + + /// + /// Contains all of the variables sent in an object update packet for a + /// prim object. Used to track position and movement of prims. + /// + public struct PrimUpdate + { + /// + public uint LocalID; + /// + public byte State; + /// + public LLVector3 Position; + /// + public LLVector3 Velocity; + /// + public LLVector3 Acceleration; + /// + public LLQuaternion Rotation; + /// + public LLVector3 RotationVelocity; + } + + /// + /// Contains all of the variables sent in an object update packet for an + /// avatar. Used to track position and movement of avatars. + /// + public struct AvatarUpdate + { + /// + public uint LocalID; + /// + public byte State; + /// + public LLVector4 CollisionPlane; + /// + public LLVector3 Position; + /// + public LLVector3 Velocity; + /// + public LLVector3 Acceleration; + /// + public LLQuaternion Rotation; + /// + public LLVector3 RotationVelocity; + } + + /// + /// Handles all network traffic related to prims and avatar positions and + /// movement. + /// + public class ObjectManager + { + /// + /// This event will be raised for every ObjectUpdate block that + /// contains a new prim. + /// Depending on the circumstances a client could + /// receive two or more of these events for the same object, if you + /// or the object left the current sim and returned for example. Client + /// applications are responsible for tracking and storing objects. + /// + /// + public event NewPrimCallback OnNewPrim; + /// + /// This event will be raised for every ObjectUpdate block that + /// contains a new avatar. + /// Depending on the circumstances a client + /// could receive two or more of these events for the same avatar, if + /// you or the other avatar left the current sim and returned for + /// example. Client applications are responsible for tracking and + /// storing objects. + /// + public event NewAvatarCallback OnNewAvatar; + /// + /// This event will be raised when a prim movement packet is received, + /// containing the updated position, rotation, and movement-related + /// vectors. + /// + public event PrimMovedCallback OnPrimMoved; + /// + /// This event will be raised when an avatar movement packet is + /// received, containing the updated position, rotation, and + /// movement-related vectors. + /// + public event AvatarMovedCallback OnAvatarMoved; + /// + /// This event will be raised when an object is removed from a + /// simulator. + /// + public event KillObjectCallback OnObjectKilled; + + private SecondLife Client; + + /// + /// + /// + /// + public ObjectManager(SecondLife client) + { + Client = client; + + Client.Network.RegisterCallback(PacketType.ObjectUpdate, new PacketCallback(UpdateHandler)); + Client.Network.RegisterCallback(PacketType.ImprovedTerseObjectUpdate, new PacketCallback(TerseUpdateHandler)); + Client.Network.RegisterCallback(PacketType.ObjectUpdateCompressed, new PacketCallback(CompressedUpdateHandler)); + Client.Network.RegisterCallback(PacketType.ObjectUpdateCached, new PacketCallback(CachedUpdateHandler)); + Client.Network.RegisterCallback(PacketType.KillObject, new PacketCallback(KillObjectHandler)); + } + + public void RequestObject(Simulator simulator, uint localID) + { + RequestMultipleObjectsPacket request = new RequestMultipleObjectsPacket(); + request.AgentData.AgentID = Client.Network.AgentID; + request.AgentData.SessionID = Client.Network.SessionID; + request.ObjectData = new RequestMultipleObjectsPacket.ObjectDataBlock[1]; + request.ObjectData[0].ID = localID; + request.ObjectData[0].CacheMissType = 0; + + Client.Network.SendPacket(request, simulator); + } + + private void ParseAvName(string name, ref string firstName, ref string lastName, ref string groupName) + { + string[] lines = name.Split('\n'); + + foreach (string line in lines) + { + if (line.Substring(0, 19) == "Title STRING RW SV ") + { + groupName = line.Substring(19); + } + else if (line.Substring(0, 23) == "FirstName STRING RW SV ") + { + firstName = line.Substring(23); + } + else if (line.Substring(0, 22) == "LastName STRING RW SV ") + { + lastName = line.Substring(22); + } + else + { + Client.Log("Unhandled line in an avatar name: " + line, Helpers.LogLevel.Warning); + } + } + } + + private void UpdateHandler(Packet packet, Simulator simulator) + { + ObjectUpdatePacket update = (ObjectUpdatePacket)packet; + + foreach (ObjectUpdatePacket.ObjectDataBlock block in update.ObjectData) + { + if (block.ObjectData.Length == 60) + { + // New prim spotted + PrimObject prim = new PrimObject(); + + prim.Position = new LLVector3(block.ObjectData, 0); + prim.Rotation = new LLQuaternion(block.ObjectData, 36, true); + + // TODO: Parse the rest of the ObjectData byte array fields + + prim.LocalID = block.ID; + prim.State = block.State; + prim.ID = block.FullID; + prim.ParentID = block.ParentID; + //block.OwnerID Sound-related + prim.Material = block.Material; + prim.PathCurve = block.PathCurve; + prim.ProfileCurve = block.ProfileCurve; + prim.PathBegin = PrimObject.PathBeginFloat(block.PathBegin); + prim.PathEnd = PrimObject.PathEndFloat(block.PathEnd); + prim.PathScaleX = PrimObject.PathScaleFloat(block.PathScaleX); + prim.PathScaleY = PrimObject.PathScaleFloat(block.PathScaleY); + prim.PathShearX = PrimObject.PathShearFloat(block.PathShearX); + prim.PathShearY = PrimObject.PathShearFloat(block.PathShearY); + prim.PathTwist = block.PathTwist; //PrimObject.PathTwistFloat(block.PathTwist); + prim.PathTwistBegin = block.PathTwistBegin; //PrimObject.PathTwistFloat(block.PathTwistBegin); + prim.PathRadiusOffset = PrimObject.PathRadiusOffsetFloat(block.PathRadiusOffset); + prim.PathTaperX = PrimObject.PathTaperFloat((byte)block.PathTaperX); + prim.PathTaperY = PrimObject.PathTaperFloat((byte)block.PathTaperY); + prim.PathRevolutions = PrimObject.PathRevolutionsFloat(block.PathRevolutions); + prim.PathSkew = PrimObject.PathSkewFloat((byte)block.PathSkew); + prim.ProfileBegin = PrimObject.ProfileBeginFloat(block.ProfileBegin); + prim.ProfileEnd = PrimObject.ProfileEndFloat(block.ProfileEnd); + prim.ProfileHollow = block.ProfileHollow; + prim.Name = Helpers.FieldToString(block.NameValue); + //block.Data ? + //block.Text Hovering text + //block.TextColor LLColor4U of the hovering text + //block.MediaURL Quicktime stream + // TODO: Multi-texture support + if (block.TextureEntry.Length >= 16) + { + prim.Texture = new LLUUID(block.TextureEntry, 0); + } + else + { + prim.Texture = new LLUUID(); + } + //block.TextureAnim ? + //block.JointType ? + //block.JointPivot ? + //block.JointAxisOrAnchor ? + //block.PCode ? + //block.PSBlock Particle system related + //block.ExtraParams ? + prim.Scale = block.Scale; + //block.Flags ? + //block.UpdateFlags ? + //block.ClickAction ? + //block.Gain Sound-related + //block.Sound Sound-related + //block.Radius Sound-related + + if (OnNewPrim != null) + { + OnNewPrim(simulator, prim, update.RegionData.RegionHandle, update.RegionData.TimeDilation); + } + } + else if (block.ObjectData.Length == 76) + { + // New avatar spotted + Avatar avatar = new Avatar(); + string FirstName = ""; + string LastName = ""; + string GroupName = ""; + + //avatar.CollisionPlane = new LLQuaternion(block.ObjectData, 0); + avatar.Position = new LLVector3(block.ObjectData, 16); + avatar.Rotation = new LLQuaternion(block.ObjectData, 52, true); + + // TODO: Parse the rest of the ObjectData byte array fields + + ParseAvName(Helpers.FieldToString(block.NameValue), ref FirstName, ref LastName, ref GroupName); + + avatar.ID = block.FullID; + avatar.LocalID = block.ID; + avatar.Name = FirstName + " " + LastName; + avatar.GroupName = GroupName; + avatar.Online = true; + avatar.CurrentRegion = simulator.Region; + + if (FirstName == Client.Avatar.FirstName && LastName == Client.Avatar.LastName) + { + // Update our avatar + Client.Avatar.LocalID = avatar.LocalID; + Client.Avatar.Position = avatar.Position; + Client.Avatar.Rotation = avatar.Rotation; + } + else + { + Client.AddAvatar(avatar); + + if (OnNewAvatar != null) + { + OnNewAvatar(simulator, avatar, update.RegionData.RegionHandle, update.RegionData.TimeDilation); + } + } + } + else + { + // Unknown + Client.Log("Unhandled ObjectData.ObjectData length:\n" + block.ObjectData.Length, + Helpers.LogLevel.Warning); + } + } + } + + private void TerseUpdateHandler(Packet packet, Simulator simulator) + { + float x, y, z, w; + uint localid; + LLVector4 CollisionPlane = null; + LLVector3 Position; + LLVector3 Velocity; + LLVector3 Acceleration; + LLQuaternion Rotation; + LLVector3 RotationVelocity; + + ImprovedTerseObjectUpdatePacket update = (ImprovedTerseObjectUpdatePacket)packet; + + foreach (ImprovedTerseObjectUpdatePacket.ObjectDataBlock block in update.ObjectData) + { + int i = 0; + bool avatar; + + localid = (uint)(block.Data[i++] + (block.Data[i++] << 8) + + (block.Data[i++] << 16) + (block.Data[i++] << 24)); + + byte state = block.Data[i++]; + + avatar = Convert.ToBoolean(block.Data[i++]); + + if (avatar) + { + CollisionPlane = new LLVector4(block.Data, i); + i += 16; + } + + // Position + Position = new LLVector3(block.Data, i); + i += 12; + // Velocity + x = Dequantize(block.Data, i, -128.0F, 128.0F); + i += 2; + y = Dequantize(block.Data, i, -128.0F, 128.0F); + i += 2; + z = Dequantize(block.Data, i, -128.0F, 128.0F); + i += 2; + Velocity = new LLVector3(x, y, z); + // Acceleration + x = Dequantize(block.Data, i, -64.0F, 64.0F); + i += 2; + y = Dequantize(block.Data, i, -64.0F, 64.0F); + i += 2; + z = Dequantize(block.Data, i, -64.0F, 64.0F); + i += 2; + Acceleration = new LLVector3(x, y, z); + // Rotation + x = Dequantize(block.Data, i, -1.0F, 1.0F); + i += 2; + y = Dequantize(block.Data, i, -1.0F, 1.0F); + i += 2; + z = Dequantize(block.Data, i, -1.0F, 1.0F); + i += 2; + w = Dequantize(block.Data, i, -1.0F, 1.0F); + i += 2; + Rotation = new LLQuaternion(x, y, z, w); + // Rotation velocity + x = Dequantize(block.Data, i, -64.0F, 64.0F); + i += 2; + y = Dequantize(block.Data, i, -64.0F, 64.0F); + i += 2; + z = Dequantize(block.Data, i, -64.0F, 64.0F); + i += 2; + RotationVelocity = new LLVector3(x, y, z); + + if (avatar) + { + if (localid == Client.Avatar.LocalID) + { + Client.Avatar.Position = Position; + Client.Avatar.Rotation = Rotation; + } + + AvatarUpdate avupdate = new AvatarUpdate(); + avupdate.LocalID = localid; + avupdate.State = state; + avupdate.Position = Position; + avupdate.CollisionPlane = CollisionPlane; + avupdate.Velocity = Velocity; + avupdate.Acceleration = Acceleration; + avupdate.Rotation = Rotation; + avupdate.RotationVelocity = RotationVelocity; + + if (OnAvatarMoved != null) + { + OnAvatarMoved(simulator, avupdate, update.RegionData.RegionHandle, update.RegionData.TimeDilation); + } + } + else + { + PrimUpdate primupdate = new PrimUpdate(); + primupdate.LocalID = localid; + primupdate.State = state; + primupdate.Position = Position; + primupdate.Velocity = Velocity; + primupdate.Acceleration = Acceleration; + primupdate.Rotation = Rotation; + primupdate.RotationVelocity = RotationVelocity; + + if (OnPrimMoved != null) + { + OnPrimMoved(simulator, primupdate, update.RegionData.RegionHandle, update.RegionData.TimeDilation); + } + } + } + } + + private void CompressedUpdateHandler(Packet packet, Simulator simulator) + { + ObjectUpdateCompressedPacket update = (ObjectUpdateCompressedPacket)packet; + PrimObject prim; + + foreach (ObjectUpdateCompressedPacket.ObjectDataBlock block in update.ObjectData) + { + int i = 0; + prim = new PrimObject(); + + prim.ID = new LLUUID(block.Data, 0); + i += 16; + prim.LocalID = (uint)(block.Data[i++] + (block.Data[i++] << 8) + + (block.Data[i++] << 16) + (block.Data[i++] << 24)); + prim.Scale = new LLVector3(block.Data, i); + i += 12; + prim.Position = new LLVector3(block.Data, i); + i += 12; + prim.Rotation = new LLQuaternion(block.Data, i, true); + i += 12; + + // FIXME: Fill in the rest of these fields + prim.PathCurve = (uint)block.Data[69]; + prim.ProfileCurve = (uint)block.Data[83]; + + if (OnNewPrim != null) + { + OnNewPrim(simulator, prim, update.RegionData.RegionHandle, update.RegionData.TimeDilation); + } + } + } + + private void CachedUpdateHandler(Packet packet, Simulator simulator) + { + int i = 0; + + ObjectUpdateCachedPacket update = (ObjectUpdateCachedPacket)packet; + + // Assume clients aren't caching objects for now, so request updates for all of these objects + RequestMultipleObjectsPacket request = new RequestMultipleObjectsPacket(); + request.AgentData.AgentID = Client.Network.AgentID; + request.AgentData.SessionID = Client.Network.AgentID; + request.ObjectData = new RequestMultipleObjectsPacket.ObjectDataBlock[update.ObjectData.Length]; + + foreach (ObjectUpdateCachedPacket.ObjectDataBlock block in update.ObjectData) + { + request.ObjectData[i] = new RequestMultipleObjectsPacket.ObjectDataBlock(); + request.ObjectData[i].ID = block.ID; + i++; + + //Client.Log("CachedData ID=" + block.ID + ", CRC=" + block.CRC + ", UpdateFlags=" + block.UpdateFlags, + //Helpers.LogLevel.Info); + } + + Client.Network.SendPacket(request); + } + + private void KillObjectHandler(Packet packet, Simulator simulator) + { + if (OnObjectKilled != null) + { + foreach (KillObjectPacket.ObjectDataBlock block in ((KillObjectPacket)packet).ObjectData) + { + OnObjectKilled(simulator, block.ID); + } + } + } + + /// + /// Takes a quantized 16-bit value from a byte array and its range and returns + /// a float representation of the continuous value. For example, a value of + /// 32767 and a range of -128.0 to 128.0 would return 0.0. The endian conversion + /// from the 16-bit little endian to the native platform will also be handled. + /// + /// The byte array containing the short value + /// The beginning position of the short (quantized) value + /// The lower quantization range + /// The upper quantization range + /// A 32-bit floating point representation of the dequantized value + private float Dequantize(byte[] byteArray, int pos, float lower, float upper) + { + ushort value = (ushort)(byteArray[pos] + (byteArray[pos + 1] << 8)); + float QV = (float)value; + float range = upper - lower; + float QF = range / 65536.0F; + return (float)((QV * QF - (0.5F * range)) + QF); + } + } +} diff --git a/libsecondlife-cs/Parcel.cs b/libsecondlife-cs/Parcel.cs index d22c9488..521a27ca 100644 --- a/libsecondlife-cs/Parcel.cs +++ b/libsecondlife-cs/Parcel.cs @@ -1,700 +1,700 @@ -/* - * Copyright (c) 2006, Second Life Reverse Engineering Team - * All rights reserved. - * - * - Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - Neither the name of the Second Life Reverse Engineering Team nor the names - * of its contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Timers; -using System.Collections; -using libsecondlife.Packets; - -namespace libsecondlife -{ - /// - /// A parcel retrieved from the dataserver such as results from the - /// "For-Sale" listings - /// - public class DirectoryParcel - { - /// - public LLUUID ID; - /// - public LLUUID OwnerID; - /// - public LLUUID SnapshotID; - /// - public ulong RegionHandle; - /// - public string Name; - /// - public string SimName; - /// - public string Desc; - /// - public int SalePrice; - /// - public int ActualArea; - /// - public LLVector3 GlobalPosition; - /// - public LLVector3 SimPosition; - /// - public float Dwell; - - /// - /// - /// - public DirectoryParcel() - { - GlobalPosition = new LLVector3(); - SimPosition = new LLVector3(); - } - } - - /// - /// Parcel information retrieved from a simulator - /// - public class Parcel - { - /// - public int RequestResult; - /// - public int SequenceID; - /// - public bool SnapSelection; - /// - public int SelfCount; - /// - public int OtherCount; - /// - public int PublicCount; - /// - public int LocalID; - /// - public LLUUID OwnerID; - /// - public bool IsGroupOwned; - /// - public uint AuctionID; - /// - public bool ReservedNewbie; - /// - public int ClaimDate; - /// - public int ClaimPrice; - /// - public int RentPrice; - /// - public LLVector3 AABBMin; - /// - public LLVector3 AABBMax; - /// - public byte[] Bitmap; - /// - public int Area; - /// - public byte Status; - /// - public int SimWideMaxObjects; - /// - public int SimWideTotalObjects; - /// - public int MaxObjects; - /// - public int TotalObjects; - /// - public int OwnerObjects; - /// - public int GroupObjects; - /// - public int OtherObjects; - /// - public float ParcelObjectBonus; - /// - public int OtherCleanTime; - /// - public uint ParcelFlags; - /// - public int SalePrice; - /// - public string Name; - /// - public string Desc; - /// - public string MusicURL; - /// - public string MediaURL; - /// - public LLUUID MediaID; - /// - public byte MediaAutoScale; - /// - public LLUUID GroupID; - /// - public int PassPrice; - /// - public float PassHours; - /// - public byte Category; - /// - public LLUUID AuthBuyerID; - /// - public LLUUID SnapshotID; - /// - public LLVector3 UserLocation; - /// - public LLVector3 UserLookAt; - /// - public byte LandingType; - /// - public float Dwell; - - // Using Sim instead of Region since it references both - private Simulator Sim; - - private void init() - { - OwnerID = new LLUUID(); - AABBMin = new LLVector3(); - AABBMax = new LLVector3(); - Bitmap = new byte[512]; - MediaID = new LLUUID(); - GroupID = new LLUUID(); - AuthBuyerID = new LLUUID(); - SnapshotID = new LLUUID(); - UserLocation = new LLVector3(); - UserLookAt = new LLVector3(); - } - - /// - /// - /// - public Parcel() - { - init(); - } - - /// - /// - /// - /// - public Parcel(Simulator simulator) - { - Sim = simulator; - init(); - } - - /// - /// - /// - /// - public void GetDwell(SecondLife client) - { - ParcelDwellRequestPacket request = new ParcelDwellRequestPacket(); - request.AgentData.AgentID = client.Network.AgentID; - request.AgentData.SessionID = client.Network.SessionID; - request.Data.LocalID = LocalID; - request.Data.ParcelID = new LLUUID(); - - client.Network.SendPacket((Packet)request, Sim); - } - - /// - /// - /// - /// - /// - /// - /// - public bool Buy(SecondLife client, bool forGroup, LLUUID groupID, bool removeContribution) - { - ParcelBuyPacket request = new ParcelBuyPacket(); - - request.AgentData.AgentID = client.Avatar.ID; - request.AgentData.SessionID = client.Network.SessionID; - - request.Data.Final = true; - request.Data.GroupID = groupID; - request.Data.LocalID = this.LocalID; - request.Data.IsGroupOwned = forGroup; - request.Data.RemoveContribution = removeContribution; - - client.Network.SendPacket((Packet)request, Sim); - return true; - } - - /// - /// - /// - /// - /// - public bool Reclaim(SecondLife client) - { - ParcelReclaimPacket request = new ParcelReclaimPacket(); - request.AgentData.AgentID = client.Avatar.ID; - request.AgentData.SessionID = client.Network.SessionID; - - request.Data.LocalID = this.LocalID; - - client.Network.SendPacket((Packet)request, Sim); - return true; - } - - /// - /// - /// - /// - /// - /// - public bool Deed(SecondLife client, LLUUID groupID) - { - ParcelDeedToGroupPacket request = new ParcelDeedToGroupPacket(); - request.AgentData.AgentID = client.Avatar.ID; - request.AgentData.SessionID = client.Network.SessionID; - - request.Data.LocalID = this.LocalID; - request.Data.GroupID = groupID; - - client.Network.SendPacket((Packet)request, Sim); - return true; - } - - /// - /// - /// - /// - public void Update(SecondLife client) - { - ParcelPropertiesUpdatePacket request = new ParcelPropertiesUpdatePacket(); - - request.AgentData.AgentID = client.Avatar.ID; - request.AgentData.SessionID = client.Network.SessionID; - - request.ParcelData.Flags = 0xFFFFFFFF; // TODO: Probably very important - request.ParcelData.LocalID = this.LocalID; - - request.ParcelData.AuthBuyerID = this.AuthBuyerID; - request.ParcelData.Category = this.Category; - request.ParcelData.Desc = Helpers.StringToField(this.Desc); - request.ParcelData.GroupID = this.GroupID; - request.ParcelData.LandingType = this.LandingType; - request.ParcelData.MediaAutoScale = this.MediaAutoScale; - request.ParcelData.MediaID = this.MediaID; - request.ParcelData.MediaURL = Helpers.StringToField(this.MediaURL); - request.ParcelData.MusicURL = Helpers.StringToField(this.MusicURL); - request.ParcelData.Name = Helpers.StringToField(this.Name); - request.ParcelData.ParcelFlags = this.ParcelFlags; - request.ParcelData.PassHours = this.PassHours; - request.ParcelData.PassPrice = this.PassPrice; - request.ParcelData.SalePrice = this.SalePrice; - request.ParcelData.SnapshotID = this.SnapshotID; - request.ParcelData.UserLocation = this.UserLocation; - request.ParcelData.UserLookAt = this.UserLookAt; - - client.Network.SendPacket((Packet)request, Sim); - //Packet updatePacket = Packets.Parcel.ParcelPropertiesUpdate(client.Protocol, client.Avatar.ID, client.Network.SessionID, this); - //Sim.SendPacket(updatePacket, true); - } - - /// - /// - /// - /// - /// - public void ReturnObjects(SecondLife client, uint returnType) - { - // TODO: ENUM for returnType - - ParcelReturnObjectsPacket request = new ParcelReturnObjectsPacket(); - request.AgentData.AgentID = client.Avatar.ID; - request.AgentData.SessionID = client.Network.SessionID; - - request.ParcelData.LocalID = this.LocalID; - request.ParcelData.ReturnType = returnType; - - // TODO: Handling of TaskIDs and OwnerIDs - request.OwnerIDs = new ParcelReturnObjectsPacket.OwnerIDsBlock[0]; - request.TaskIDs = new ParcelReturnObjectsPacket.TaskIDsBlock[1]; - - client.Network.SendPacket((Packet)request, Sim); - } - } - - /// - /// - /// - public class ParcelManager - { - /// - public ArrayList ParcelsForSale; - - private SecondLife Client; - private bool ReservedNewbie; - private bool ForSale; - private bool Auction; - private bool Finished; - private Timer DirLandTimer; - private bool DirLandTimeout; - private bool ParcelInfoTimeout; - private DirectoryParcel ParcelInfoParcel; - - /// - /// - /// - /// - public ParcelManager(SecondLife client) - { - Client = client; - ParcelsForSale = new ArrayList(); - - // Setup the callbacks - Client.Network.RegisterCallback(PacketType.DirLandReply, new PacketCallback(DirLandReplyHandler)); - Client.Network.RegisterCallback(PacketType.ParcelInfoReply, new PacketCallback(ParcelInfoReplyHandler)); - Client.Network.RegisterCallback(PacketType.ParcelProperties, new PacketCallback(ParcelPropertiesHandler)); - Client.Network.RegisterCallback(PacketType.ParcelDwellReply, new PacketCallback(ParcelDwellReplyHandler)); - - ParcelInfoParcel = new DirectoryParcel(); - } - - /// - /// - /// - /// - /// - public void ParcelDwellReplyHandler(Packet packet, Simulator simulator) - { - ParcelDwellReplyPacket dwell = (ParcelDwellReplyPacket)packet; - - if (dwell.Data.Dwell != 0.0F && simulator.Region.Parcels.ContainsKey(dwell.Data.LocalID)) - { - ((Parcel)simulator.Region.Parcels[dwell.Data.LocalID]).Dwell = dwell.Data.Dwell; - } - } - - /// - /// - /// - /// - /// - public bool RequestParcelInfo(DirectoryParcel parcel) - { - int attempts = 0; - - Beginning: - if (attempts++ > 3) { return false; } - - Finished = false; - ParcelInfoTimeout = false; - ParcelInfoParcel = parcel; - - // // Setup the timer - // Timer ParcelInfoTimer = new Timer(5000); - // ParcelInfoTimer.Elapsed += new ElapsedEventHandler(ParcelInfoTimerEvent); - // ParcelInfoTimeout = false; - - // // Build the ParcelInfoRequest packet - // ParcelInfoRequestPacket request = new ParcelInfoRequestPacket(); - // request.AgentData.AgentID = Client.Network.AgentID; - // request.AgentData.SessionID = Client.Network.SessionID; - // request.Data.ParcelID = parcel.ID; - - // // Start the timer - // ParcelInfoTimer.Start(); - - // Client.Network.SendPacket((Packet)request); - - while (!Finished) - { - // FIXME: This can easily cause an infinite loop - if (ParcelInfoTimeout) { goto Beginning; } - - Client.Tick(); - } - - return true; - } - - /// - /// - /// - /// - /// - /// - /// - public int DirLandRequest(bool reservedNewbie, bool forSale, bool auction) - { - // Set the class-wide variables so the callback has them - ReservedNewbie = reservedNewbie; - ForSale = forSale; - Auction = auction; - - // Clear the list - ParcelsForSale.Clear(); - - // Setup the timer - DirLandTimer = new Timer(15000); - DirLandTimer.Elapsed += new ElapsedEventHandler(DirLandTimerEvent); - DirLandTimeout = false; - DirLandTimer.Start(); - - DirLandQueryPacket query = new DirLandQueryPacket(); - query.AgentData.AgentID = Client.Network.AgentID; - query.AgentData.SessionID = Client.Network.SessionID; - query.QueryData.Auction = auction; - query.QueryData.ForSale = forSale; - query.QueryData.QueryFlags = 0; - query.QueryData.QueryID = LLUUID.GenerateUUID(); - query.QueryData.ReservedNewbie = reservedNewbie; - - Client.Network.SendPacket((Packet)query); - - while (!DirLandTimeout) - { - Client.Tick(); - } - - // Make sure the timer is actually stopped - DirLandTimer.Stop(); - - return ParcelsForSale.Count; - } - - private void ParcelPropertiesHandler(Packet packet, Simulator simulator) - { - ParcelPropertiesPacket properties = (ParcelPropertiesPacket)packet; - - byte[] Bitmap = properties.ParcelData.Bitmap; - int LocalID = properties.ParcelData.LocalID; - - // Mark this area as downloaded - int x, y, index, subindex; - byte val; - - for (x = 0; x < 64; x++) - { - for (y = 0; y < 64; y++) - { - if (simulator.Region.ParcelMarked[y, x] == 0) - { - index = ((x * 64) + y); - subindex = index % 8; - index /= 8; - - val = Bitmap[index]; - - simulator.Region.ParcelMarked[y, x] = ((val >> subindex) & 1) == 1 ? LocalID : 0; - } - } - } - - // Fire off the next request, if we are downloading the whole sim - bool hasTriggered = false; - if (simulator.Region.ParcelDownloading == true) - { - for (x = 0; x < 64; x++) - { - for (y = 0; y < 64; y++) - { - if (simulator.Region.ParcelMarked[x, y] == 0) - { - ParcelPropertiesRequestPacket tPacket = new ParcelPropertiesRequestPacket(); - tPacket.AgentData.AgentID = Client.Avatar.ID; - tPacket.AgentData.SessionID = Client.Network.SessionID; - tPacket.ParcelData.SequenceID = -10000; - tPacket.ParcelData.West = (x * 4.0f); - tPacket.ParcelData.South = (y * 4.0f); - tPacket.ParcelData.East = (x * 4.0f) + 4.0f; - tPacket.ParcelData.North = (y * 4.0f) + 4.0f; - - simulator.SendPacket((Packet)tPacket, true); - - hasTriggered = true; - - goto exit; - } - } - } - exit: - ; - } - - // This map is complete, fire callback - if (hasTriggered == false) - { - simulator.Region.FilledParcels(); - } - - // Save this parcels data - // TODO: Lots of values are not being stored, Parcel needs to be expanded to take all the data. - simulator.Region.ParcelsMutex.WaitOne(); - - if (!simulator.Region.Parcels.ContainsKey(LocalID)) - { - simulator.Region.Parcels[LocalID] = new Parcel(simulator); - } - - // August2006: God help me should I have to type this out again... argh. - // October2006: I really shouldnt have typed that. - ((Parcel)simulator.Region.Parcels[LocalID]).RequestResult = properties.ParcelData.RequestResult; - ((Parcel)simulator.Region.Parcels[LocalID]).SequenceID = properties.ParcelData.SequenceID; - ((Parcel)simulator.Region.Parcels[LocalID]).SnapSelection = properties.ParcelData.SnapSelection; - ((Parcel)simulator.Region.Parcels[LocalID]).SelfCount = properties.ParcelData.SelfCount; - ((Parcel)simulator.Region.Parcels[LocalID]).OtherCount = properties.ParcelData.OtherCount; - ((Parcel)simulator.Region.Parcels[LocalID]).PublicCount = properties.ParcelData.PublicCount; - ((Parcel)simulator.Region.Parcels[LocalID]).LocalID = LocalID; - ((Parcel)simulator.Region.Parcels[LocalID]).OwnerID = properties.ParcelData.OwnerID; - ((Parcel)simulator.Region.Parcels[LocalID]).IsGroupOwned = properties.ParcelData.IsGroupOwned; - ((Parcel)simulator.Region.Parcels[LocalID]).AuctionID = properties.ParcelData.AuctionID; - ((Parcel)simulator.Region.Parcels[LocalID]).ReservedNewbie = properties.ParcelData.ReservedNewbie; - ((Parcel)simulator.Region.Parcels[LocalID]).ClaimDate = properties.ParcelData.ClaimDate; - ((Parcel)simulator.Region.Parcels[LocalID]).ClaimPrice = properties.ParcelData.ClaimPrice; - ((Parcel)simulator.Region.Parcels[LocalID]).RentPrice = properties.ParcelData.RentPrice; - ((Parcel)simulator.Region.Parcels[LocalID]).AABBMin = properties.ParcelData.AABBMin; - ((Parcel)simulator.Region.Parcels[LocalID]).AABBMax = properties.ParcelData.AABBMax; - ((Parcel)simulator.Region.Parcels[LocalID]).Bitmap = properties.ParcelData.Bitmap; - ((Parcel)simulator.Region.Parcels[LocalID]).Area = properties.ParcelData.Area; - ((Parcel)simulator.Region.Parcels[LocalID]).Status = properties.ParcelData.Status; - ((Parcel)simulator.Region.Parcels[LocalID]).SimWideMaxObjects = properties.ParcelData.SimWideMaxPrims; - ((Parcel)simulator.Region.Parcels[LocalID]).SimWideTotalObjects = properties.ParcelData.SimWideTotalPrims; - ((Parcel)simulator.Region.Parcels[LocalID]).MaxObjects = properties.ParcelData.MaxPrims; - ((Parcel)simulator.Region.Parcels[LocalID]).TotalObjects = properties.ParcelData.TotalPrims; - ((Parcel)simulator.Region.Parcels[LocalID]).OwnerObjects = properties.ParcelData.OwnerPrims; - ((Parcel)simulator.Region.Parcels[LocalID]).GroupObjects = properties.ParcelData.GroupPrims; - ((Parcel)simulator.Region.Parcels[LocalID]).OtherObjects = properties.ParcelData.OtherPrims; - ((Parcel)simulator.Region.Parcels[LocalID]).ParcelObjectBonus = properties.ParcelData.ParcelPrimBonus; - ((Parcel)simulator.Region.Parcels[LocalID]).OtherCleanTime = properties.ParcelData.OtherCleanTime; - ((Parcel)simulator.Region.Parcels[LocalID]).ParcelFlags = properties.ParcelData.ParcelFlags; - ((Parcel)simulator.Region.Parcels[LocalID]).SalePrice = properties.ParcelData.SalePrice; - ((Parcel)simulator.Region.Parcels[LocalID]).Name = Helpers.FieldToString(properties.ParcelData.Name); - ((Parcel)simulator.Region.Parcels[LocalID]).Desc = Helpers.FieldToString(properties.ParcelData.Desc); - ((Parcel)simulator.Region.Parcels[LocalID]).MusicURL = Helpers.FieldToString(properties.ParcelData.MusicURL); - ((Parcel)simulator.Region.Parcels[LocalID]).MediaURL = Helpers.FieldToString(properties.ParcelData.MediaURL); - ((Parcel)simulator.Region.Parcels[LocalID]).MediaID = properties.ParcelData.MediaID; - ((Parcel)simulator.Region.Parcels[LocalID]).MediaAutoScale = properties.ParcelData.MediaAutoScale; - ((Parcel)simulator.Region.Parcels[LocalID]).GroupID = properties.ParcelData.GroupID; - ((Parcel)simulator.Region.Parcels[LocalID]).PassPrice = properties.ParcelData.PassPrice; - ((Parcel)simulator.Region.Parcels[LocalID]).PassHours = properties.ParcelData.PassHours; - ((Parcel)simulator.Region.Parcels[LocalID]).Category = properties.ParcelData.Category; - ((Parcel)simulator.Region.Parcels[LocalID]).AuthBuyerID = properties.ParcelData.AuthBuyerID; - ((Parcel)simulator.Region.Parcels[LocalID]).SnapshotID = properties.ParcelData.SnapshotID; - ((Parcel)simulator.Region.Parcels[LocalID]).UserLocation = properties.ParcelData.UserLocation; - ((Parcel)simulator.Region.Parcels[LocalID]).UserLookAt = properties.ParcelData.UserLookAt; - ((Parcel)simulator.Region.Parcels[LocalID]).LandingType = properties.ParcelData.LandingType; - - simulator.Region.ParcelsMutex.ReleaseMutex(); - } - - private void ParcelInfoReplyHandler(Packet packet, Simulator simulator) - { - ParcelInfoReplyPacket reply = (ParcelInfoReplyPacket)packet; - - if (!reply.Data.ParcelID.Equals(ParcelInfoParcel.ID)) - { - Client.Log("Received a ParcelInfoReply for " + reply.Data.ParcelID.ToString() + - ", looking for " + ParcelInfoParcel.ID.ToString(), Helpers.LogLevel.Warning); - - // Build and resend the ParcelInfoRequest packet - ParcelInfoRequestPacket request = new ParcelInfoRequestPacket(); - request.AgentData.AgentID = Client.Network.AgentID; - request.AgentData.SessionID = Client.Network.SessionID; - request.Data.ParcelID = ParcelInfoParcel.ID; - - Client.Network.SendPacket(request); - - return; - } - - ParcelInfoParcel.SimName = Helpers.FieldToString(reply.Data.SimName); - ParcelInfoParcel.ActualArea = reply.Data.ActualArea; - ParcelInfoParcel.GlobalPosition.X = reply.Data.GlobalX; - ParcelInfoParcel.GlobalPosition.Y = reply.Data.GlobalY; - ParcelInfoParcel.GlobalPosition.Z = reply.Data.GlobalZ; - ParcelInfoParcel.Name = Helpers.FieldToString(reply.Data.Name); - ParcelInfoParcel.Desc = Helpers.FieldToString(reply.Data.Desc); - ParcelInfoParcel.SalePrice = reply.Data.SalePrice; - ParcelInfoParcel.OwnerID = reply.Data.OwnerID; - ParcelInfoParcel.SnapshotID = reply.Data.SnapshotID; - ParcelInfoParcel.Dwell = reply.Data.Dwell; - - // Get RegionHandle from GlobalX/GlobalY - uint handleX = (uint)Math.Floor(ParcelInfoParcel.GlobalPosition.X / 256.0F); - handleX *= 256; - uint handleY = (uint)Math.Floor(ParcelInfoParcel.GlobalPosition.Y / 256.0F); - handleY *= 256; - // FIXME: Helpers function needed - //ParcelInfoParcel.RegionHandle = new U64(handleX, handleY); - - // Get SimPosition from GlobalX/GlobalY and RegionHandle - ParcelInfoParcel.SimPosition.X = ParcelInfoParcel.GlobalPosition.X - (float)handleX; - ParcelInfoParcel.SimPosition.Y = ParcelInfoParcel.GlobalPosition.Y - (float)handleY; - ParcelInfoParcel.SimPosition.Z = ParcelInfoParcel.GlobalPosition.Z; - - Finished = true; - } - - //private void ParcelInfoTimerEvent(object source, System.Timers.ElapsedEventArgs ea) - //{ - // ParcelInfoTimeout = true; - //} - - private void DirLandReplyHandler(Packet packet, Simulator simulator) - { - if (!DirLandTimeout) - { - // Reset the timer - DirLandTimer.Stop(); - DirLandTimer.Start(); - - DirLandReplyPacket reply = (DirLandReplyPacket)packet; - - foreach (DirLandReplyPacket.QueryRepliesBlock block in reply.QueryReplies) - { - if (block.ReservedNewbie == ReservedNewbie && - block.Auction == Auction && - block.ForSale == ForSale) - { - DirectoryParcel parcel = new DirectoryParcel(); - - parcel.ActualArea = block.ActualArea; - parcel.ID = block.ParcelID; - parcel.Name = Helpers.FieldToString(block.Name); - parcel.SalePrice = block.SalePrice; - - ParcelsForSale.Add(parcel); - } - } - } - else - { - Client.Log("Received a DirLandReply after the timeout, ignoring", Helpers.LogLevel.Warning); - } - } - - private void DirLandTimerEvent(object source, System.Timers.ElapsedEventArgs ea) - { - DirLandTimer.Stop(); - DirLandTimeout = true; - } - } -} +/* + * Copyright (c) 2006, Second Life Reverse Engineering Team + * All rights reserved. + * + * - Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Neither the name of the Second Life Reverse Engineering Team nor the names + * of its contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Timers; +using System.Collections; +using libsecondlife.Packets; + +namespace libsecondlife +{ + /// + /// A parcel retrieved from the dataserver such as results from the + /// "For-Sale" listings + /// + public class DirectoryParcel + { + /// + public LLUUID ID; + /// + public LLUUID OwnerID; + /// + public LLUUID SnapshotID; + /// + public ulong RegionHandle; + /// + public string Name; + /// + public string SimName; + /// + public string Desc; + /// + public int SalePrice; + /// + public int ActualArea; + /// + public LLVector3 GlobalPosition; + /// + public LLVector3 SimPosition; + /// + public float Dwell; + + /// + /// + /// + public DirectoryParcel() + { + GlobalPosition = new LLVector3(); + SimPosition = new LLVector3(); + } + } + + /// + /// Parcel information retrieved from a simulator + /// + public class Parcel + { + /// + public int RequestResult; + /// + public int SequenceID; + /// + public bool SnapSelection; + /// + public int SelfCount; + /// + public int OtherCount; + /// + public int PublicCount; + /// + public int LocalID; + /// + public LLUUID OwnerID; + /// + public bool IsGroupOwned; + /// + public uint AuctionID; + /// + public bool ReservedNewbie; + /// + public int ClaimDate; + /// + public int ClaimPrice; + /// + public int RentPrice; + /// + public LLVector3 AABBMin; + /// + public LLVector3 AABBMax; + /// + public byte[] Bitmap; + /// + public int Area; + /// + public byte Status; + /// + public int SimWideMaxObjects; + /// + public int SimWideTotalObjects; + /// + public int MaxObjects; + /// + public int TotalObjects; + /// + public int OwnerObjects; + /// + public int GroupObjects; + /// + public int OtherObjects; + /// + public float ParcelObjectBonus; + /// + public int OtherCleanTime; + /// + public uint ParcelFlags; + /// + public int SalePrice; + /// + public string Name; + /// + public string Desc; + /// + public string MusicURL; + /// + public string MediaURL; + /// + public LLUUID MediaID; + /// + public byte MediaAutoScale; + /// + public LLUUID GroupID; + /// + public int PassPrice; + /// + public float PassHours; + /// + public byte Category; + /// + public LLUUID AuthBuyerID; + /// + public LLUUID SnapshotID; + /// + public LLVector3 UserLocation; + /// + public LLVector3 UserLookAt; + /// + public byte LandingType; + /// + public float Dwell; + + // Using Sim instead of Region since it references both + private Simulator Sim; + + private void init() + { + OwnerID = new LLUUID(); + AABBMin = new LLVector3(); + AABBMax = new LLVector3(); + Bitmap = new byte[512]; + MediaID = new LLUUID(); + GroupID = new LLUUID(); + AuthBuyerID = new LLUUID(); + SnapshotID = new LLUUID(); + UserLocation = new LLVector3(); + UserLookAt = new LLVector3(); + } + + /// + /// + /// + public Parcel() + { + init(); + } + + /// + /// + /// + /// + public Parcel(Simulator simulator) + { + Sim = simulator; + init(); + } + + /// + /// + /// + /// + public void GetDwell(SecondLife client) + { + ParcelDwellRequestPacket request = new ParcelDwellRequestPacket(); + request.AgentData.AgentID = client.Network.AgentID; + request.AgentData.SessionID = client.Network.SessionID; + request.Data.LocalID = LocalID; + request.Data.ParcelID = new LLUUID(); + + client.Network.SendPacket((Packet)request, Sim); + } + + /// + /// + /// + /// + /// + /// + /// + public bool Buy(SecondLife client, bool forGroup, LLUUID groupID, bool removeContribution) + { + ParcelBuyPacket request = new ParcelBuyPacket(); + + request.AgentData.AgentID = client.Avatar.ID; + request.AgentData.SessionID = client.Network.SessionID; + + request.Data.Final = true; + request.Data.GroupID = groupID; + request.Data.LocalID = this.LocalID; + request.Data.IsGroupOwned = forGroup; + request.Data.RemoveContribution = removeContribution; + + client.Network.SendPacket((Packet)request, Sim); + return true; + } + + /// + /// + /// + /// + /// + public bool Reclaim(SecondLife client) + { + ParcelReclaimPacket request = new ParcelReclaimPacket(); + request.AgentData.AgentID = client.Avatar.ID; + request.AgentData.SessionID = client.Network.SessionID; + + request.Data.LocalID = this.LocalID; + + client.Network.SendPacket((Packet)request, Sim); + return true; + } + + /// + /// + /// + /// + /// + /// + public bool Deed(SecondLife client, LLUUID groupID) + { + ParcelDeedToGroupPacket request = new ParcelDeedToGroupPacket(); + request.AgentData.AgentID = client.Avatar.ID; + request.AgentData.SessionID = client.Network.SessionID; + + request.Data.LocalID = this.LocalID; + request.Data.GroupID = groupID; + + client.Network.SendPacket((Packet)request, Sim); + return true; + } + + /// + /// + /// + /// + public void Update(SecondLife client) + { + ParcelPropertiesUpdatePacket request = new ParcelPropertiesUpdatePacket(); + + request.AgentData.AgentID = client.Avatar.ID; + request.AgentData.SessionID = client.Network.SessionID; + + request.ParcelData.Flags = 0xFFFFFFFF; // TODO: Probably very important + request.ParcelData.LocalID = this.LocalID; + + request.ParcelData.AuthBuyerID = this.AuthBuyerID; + request.ParcelData.Category = this.Category; + request.ParcelData.Desc = Helpers.StringToField(this.Desc); + request.ParcelData.GroupID = this.GroupID; + request.ParcelData.LandingType = this.LandingType; + request.ParcelData.MediaAutoScale = this.MediaAutoScale; + request.ParcelData.MediaID = this.MediaID; + request.ParcelData.MediaURL = Helpers.StringToField(this.MediaURL); + request.ParcelData.MusicURL = Helpers.StringToField(this.MusicURL); + request.ParcelData.Name = Helpers.StringToField(this.Name); + request.ParcelData.ParcelFlags = this.ParcelFlags; + request.ParcelData.PassHours = this.PassHours; + request.ParcelData.PassPrice = this.PassPrice; + request.ParcelData.SalePrice = this.SalePrice; + request.ParcelData.SnapshotID = this.SnapshotID; + request.ParcelData.UserLocation = this.UserLocation; + request.ParcelData.UserLookAt = this.UserLookAt; + + client.Network.SendPacket((Packet)request, Sim); + //Packet updatePacket = Packets.Parcel.ParcelPropertiesUpdate(client.Protocol, client.Avatar.ID, client.Network.SessionID, this); + //Sim.SendPacket(updatePacket, true); + } + + /// + /// + /// + /// + /// + public void ReturnObjects(SecondLife client, uint returnType) + { + // TODO: ENUM for returnType + + ParcelReturnObjectsPacket request = new ParcelReturnObjectsPacket(); + request.AgentData.AgentID = client.Avatar.ID; + request.AgentData.SessionID = client.Network.SessionID; + + request.ParcelData.LocalID = this.LocalID; + request.ParcelData.ReturnType = returnType; + + // TODO: Handling of TaskIDs and OwnerIDs + request.OwnerIDs = new ParcelReturnObjectsPacket.OwnerIDsBlock[0]; + request.TaskIDs = new ParcelReturnObjectsPacket.TaskIDsBlock[1]; + + client.Network.SendPacket((Packet)request, Sim); + } + } + + /// + /// + /// + public class ParcelManager + { + /// + public ArrayList ParcelsForSale; + + private SecondLife Client; + private bool ReservedNewbie; + private bool ForSale; + private bool Auction; + private bool Finished; + private Timer DirLandTimer; + private bool DirLandTimeout; + private bool ParcelInfoTimeout; + private DirectoryParcel ParcelInfoParcel; + + /// + /// + /// + /// + public ParcelManager(SecondLife client) + { + Client = client; + ParcelsForSale = new ArrayList(); + + // Setup the callbacks + Client.Network.RegisterCallback(PacketType.DirLandReply, new PacketCallback(DirLandReplyHandler)); + Client.Network.RegisterCallback(PacketType.ParcelInfoReply, new PacketCallback(ParcelInfoReplyHandler)); + Client.Network.RegisterCallback(PacketType.ParcelProperties, new PacketCallback(ParcelPropertiesHandler)); + Client.Network.RegisterCallback(PacketType.ParcelDwellReply, new PacketCallback(ParcelDwellReplyHandler)); + + ParcelInfoParcel = new DirectoryParcel(); + } + + /// + /// + /// + /// + /// + public void ParcelDwellReplyHandler(Packet packet, Simulator simulator) + { + ParcelDwellReplyPacket dwell = (ParcelDwellReplyPacket)packet; + + if (dwell.Data.Dwell != 0.0F && simulator.Region.Parcels.ContainsKey(dwell.Data.LocalID)) + { + ((Parcel)simulator.Region.Parcels[dwell.Data.LocalID]).Dwell = dwell.Data.Dwell; + } + } + + /// + /// + /// + /// + /// + public bool RequestParcelInfo(DirectoryParcel parcel) + { + int attempts = 0; + + Beginning: + if (attempts++ > 3) { return false; } + + Finished = false; + ParcelInfoTimeout = false; + ParcelInfoParcel = parcel; + + // // Setup the timer + // Timer ParcelInfoTimer = new Timer(5000); + // ParcelInfoTimer.Elapsed += new ElapsedEventHandler(ParcelInfoTimerEvent); + // ParcelInfoTimeout = false; + + // // Build the ParcelInfoRequest packet + // ParcelInfoRequestPacket request = new ParcelInfoRequestPacket(); + // request.AgentData.AgentID = Client.Network.AgentID; + // request.AgentData.SessionID = Client.Network.SessionID; + // request.Data.ParcelID = parcel.ID; + + // // Start the timer + // ParcelInfoTimer.Start(); + + // Client.Network.SendPacket((Packet)request); + + while (!Finished) + { + // FIXME: This can easily cause an infinite loop + if (ParcelInfoTimeout) { goto Beginning; } + + Client.Tick(); + } + + return true; + } + + /// + /// + /// + /// + /// + /// + /// + public int DirLandRequest(bool reservedNewbie, bool forSale, bool auction) + { + // Set the class-wide variables so the callback has them + ReservedNewbie = reservedNewbie; + ForSale = forSale; + Auction = auction; + + // Clear the list + ParcelsForSale.Clear(); + + // Setup the timer + DirLandTimer = new Timer(15000); + DirLandTimer.Elapsed += new ElapsedEventHandler(DirLandTimerEvent); + DirLandTimeout = false; + DirLandTimer.Start(); + + DirLandQueryPacket query = new DirLandQueryPacket(); + query.AgentData.AgentID = Client.Network.AgentID; + query.AgentData.SessionID = Client.Network.SessionID; + query.QueryData.Auction = auction; + query.QueryData.ForSale = forSale; + query.QueryData.QueryFlags = 0; + query.QueryData.QueryID = LLUUID.GenerateUUID(); + query.QueryData.ReservedNewbie = reservedNewbie; + + Client.Network.SendPacket((Packet)query); + + while (!DirLandTimeout) + { + Client.Tick(); + } + + // Make sure the timer is actually stopped + DirLandTimer.Stop(); + + return ParcelsForSale.Count; + } + + private void ParcelPropertiesHandler(Packet packet, Simulator simulator) + { + ParcelPropertiesPacket properties = (ParcelPropertiesPacket)packet; + + byte[] Bitmap = properties.ParcelData.Bitmap; + int LocalID = properties.ParcelData.LocalID; + + // Mark this area as downloaded + int x, y, index, subindex; + byte val; + + for (x = 0; x < 64; x++) + { + for (y = 0; y < 64; y++) + { + if (simulator.Region.ParcelMarked[y, x] == 0) + { + index = ((x * 64) + y); + subindex = index % 8; + index /= 8; + + val = Bitmap[index]; + + simulator.Region.ParcelMarked[y, x] = ((val >> subindex) & 1) == 1 ? LocalID : 0; + } + } + } + + // Fire off the next request, if we are downloading the whole sim + bool hasTriggered = false; + if (simulator.Region.ParcelDownloading == true) + { + for (x = 0; x < 64; x++) + { + for (y = 0; y < 64; y++) + { + if (simulator.Region.ParcelMarked[x, y] == 0) + { + ParcelPropertiesRequestPacket tPacket = new ParcelPropertiesRequestPacket(); + tPacket.AgentData.AgentID = Client.Avatar.ID; + tPacket.AgentData.SessionID = Client.Network.SessionID; + tPacket.ParcelData.SequenceID = -10000; + tPacket.ParcelData.West = (x * 4.0f); + tPacket.ParcelData.South = (y * 4.0f); + tPacket.ParcelData.East = (x * 4.0f) + 4.0f; + tPacket.ParcelData.North = (y * 4.0f) + 4.0f; + + simulator.SendPacket((Packet)tPacket, true); + + hasTriggered = true; + + goto exit; + } + } + } + exit: + ; + } + + // This map is complete, fire callback + if (hasTriggered == false) + { + simulator.Region.FilledParcels(); + } + + // Save this parcels data + // TODO: Lots of values are not being stored, Parcel needs to be expanded to take all the data. + simulator.Region.ParcelsMutex.WaitOne(); + + if (!simulator.Region.Parcels.ContainsKey(LocalID)) + { + simulator.Region.Parcels[LocalID] = new Parcel(simulator); + } + + // August2006: God help me should I have to type this out again... argh. + // October2006: I really shouldnt have typed that. + ((Parcel)simulator.Region.Parcels[LocalID]).RequestResult = properties.ParcelData.RequestResult; + ((Parcel)simulator.Region.Parcels[LocalID]).SequenceID = properties.ParcelData.SequenceID; + ((Parcel)simulator.Region.Parcels[LocalID]).SnapSelection = properties.ParcelData.SnapSelection; + ((Parcel)simulator.Region.Parcels[LocalID]).SelfCount = properties.ParcelData.SelfCount; + ((Parcel)simulator.Region.Parcels[LocalID]).OtherCount = properties.ParcelData.OtherCount; + ((Parcel)simulator.Region.Parcels[LocalID]).PublicCount = properties.ParcelData.PublicCount; + ((Parcel)simulator.Region.Parcels[LocalID]).LocalID = LocalID; + ((Parcel)simulator.Region.Parcels[LocalID]).OwnerID = properties.ParcelData.OwnerID; + ((Parcel)simulator.Region.Parcels[LocalID]).IsGroupOwned = properties.ParcelData.IsGroupOwned; + ((Parcel)simulator.Region.Parcels[LocalID]).AuctionID = properties.ParcelData.AuctionID; + ((Parcel)simulator.Region.Parcels[LocalID]).ReservedNewbie = properties.ParcelData.ReservedNewbie; + ((Parcel)simulator.Region.Parcels[LocalID]).ClaimDate = properties.ParcelData.ClaimDate; + ((Parcel)simulator.Region.Parcels[LocalID]).ClaimPrice = properties.ParcelData.ClaimPrice; + ((Parcel)simulator.Region.Parcels[LocalID]).RentPrice = properties.ParcelData.RentPrice; + ((Parcel)simulator.Region.Parcels[LocalID]).AABBMin = properties.ParcelData.AABBMin; + ((Parcel)simulator.Region.Parcels[LocalID]).AABBMax = properties.ParcelData.AABBMax; + ((Parcel)simulator.Region.Parcels[LocalID]).Bitmap = properties.ParcelData.Bitmap; + ((Parcel)simulator.Region.Parcels[LocalID]).Area = properties.ParcelData.Area; + ((Parcel)simulator.Region.Parcels[LocalID]).Status = properties.ParcelData.Status; + ((Parcel)simulator.Region.Parcels[LocalID]).SimWideMaxObjects = properties.ParcelData.SimWideMaxPrims; + ((Parcel)simulator.Region.Parcels[LocalID]).SimWideTotalObjects = properties.ParcelData.SimWideTotalPrims; + ((Parcel)simulator.Region.Parcels[LocalID]).MaxObjects = properties.ParcelData.MaxPrims; + ((Parcel)simulator.Region.Parcels[LocalID]).TotalObjects = properties.ParcelData.TotalPrims; + ((Parcel)simulator.Region.Parcels[LocalID]).OwnerObjects = properties.ParcelData.OwnerPrims; + ((Parcel)simulator.Region.Parcels[LocalID]).GroupObjects = properties.ParcelData.GroupPrims; + ((Parcel)simulator.Region.Parcels[LocalID]).OtherObjects = properties.ParcelData.OtherPrims; + ((Parcel)simulator.Region.Parcels[LocalID]).ParcelObjectBonus = properties.ParcelData.ParcelPrimBonus; + ((Parcel)simulator.Region.Parcels[LocalID]).OtherCleanTime = properties.ParcelData.OtherCleanTime; + ((Parcel)simulator.Region.Parcels[LocalID]).ParcelFlags = properties.ParcelData.ParcelFlags; + ((Parcel)simulator.Region.Parcels[LocalID]).SalePrice = properties.ParcelData.SalePrice; + ((Parcel)simulator.Region.Parcels[LocalID]).Name = Helpers.FieldToString(properties.ParcelData.Name); + ((Parcel)simulator.Region.Parcels[LocalID]).Desc = Helpers.FieldToString(properties.ParcelData.Desc); + ((Parcel)simulator.Region.Parcels[LocalID]).MusicURL = Helpers.FieldToString(properties.ParcelData.MusicURL); + ((Parcel)simulator.Region.Parcels[LocalID]).MediaURL = Helpers.FieldToString(properties.ParcelData.MediaURL); + ((Parcel)simulator.Region.Parcels[LocalID]).MediaID = properties.ParcelData.MediaID; + ((Parcel)simulator.Region.Parcels[LocalID]).MediaAutoScale = properties.ParcelData.MediaAutoScale; + ((Parcel)simulator.Region.Parcels[LocalID]).GroupID = properties.ParcelData.GroupID; + ((Parcel)simulator.Region.Parcels[LocalID]).PassPrice = properties.ParcelData.PassPrice; + ((Parcel)simulator.Region.Parcels[LocalID]).PassHours = properties.ParcelData.PassHours; + ((Parcel)simulator.Region.Parcels[LocalID]).Category = properties.ParcelData.Category; + ((Parcel)simulator.Region.Parcels[LocalID]).AuthBuyerID = properties.ParcelData.AuthBuyerID; + ((Parcel)simulator.Region.Parcels[LocalID]).SnapshotID = properties.ParcelData.SnapshotID; + ((Parcel)simulator.Region.Parcels[LocalID]).UserLocation = properties.ParcelData.UserLocation; + ((Parcel)simulator.Region.Parcels[LocalID]).UserLookAt = properties.ParcelData.UserLookAt; + ((Parcel)simulator.Region.Parcels[LocalID]).LandingType = properties.ParcelData.LandingType; + + simulator.Region.ParcelsMutex.ReleaseMutex(); + } + + private void ParcelInfoReplyHandler(Packet packet, Simulator simulator) + { + ParcelInfoReplyPacket reply = (ParcelInfoReplyPacket)packet; + + if (!reply.Data.ParcelID.Equals(ParcelInfoParcel.ID)) + { + Client.Log("Received a ParcelInfoReply for " + reply.Data.ParcelID.ToString() + + ", looking for " + ParcelInfoParcel.ID.ToString(), Helpers.LogLevel.Warning); + + // Build and resend the ParcelInfoRequest packet + ParcelInfoRequestPacket request = new ParcelInfoRequestPacket(); + request.AgentData.AgentID = Client.Network.AgentID; + request.AgentData.SessionID = Client.Network.SessionID; + request.Data.ParcelID = ParcelInfoParcel.ID; + + Client.Network.SendPacket(request); + + return; + } + + ParcelInfoParcel.SimName = Helpers.FieldToString(reply.Data.SimName); + ParcelInfoParcel.ActualArea = reply.Data.ActualArea; + ParcelInfoParcel.GlobalPosition.X = reply.Data.GlobalX; + ParcelInfoParcel.GlobalPosition.Y = reply.Data.GlobalY; + ParcelInfoParcel.GlobalPosition.Z = reply.Data.GlobalZ; + ParcelInfoParcel.Name = Helpers.FieldToString(reply.Data.Name); + ParcelInfoParcel.Desc = Helpers.FieldToString(reply.Data.Desc); + ParcelInfoParcel.SalePrice = reply.Data.SalePrice; + ParcelInfoParcel.OwnerID = reply.Data.OwnerID; + ParcelInfoParcel.SnapshotID = reply.Data.SnapshotID; + ParcelInfoParcel.Dwell = reply.Data.Dwell; + + // Get RegionHandle from GlobalX/GlobalY + uint handleX = (uint)Math.Floor(ParcelInfoParcel.GlobalPosition.X / 256.0F); + handleX *= 256; + uint handleY = (uint)Math.Floor(ParcelInfoParcel.GlobalPosition.Y / 256.0F); + handleY *= 256; + // FIXME: Helpers function needed + //ParcelInfoParcel.RegionHandle = new U64(handleX, handleY); + + // Get SimPosition from GlobalX/GlobalY and RegionHandle + ParcelInfoParcel.SimPosition.X = ParcelInfoParcel.GlobalPosition.X - (float)handleX; + ParcelInfoParcel.SimPosition.Y = ParcelInfoParcel.GlobalPosition.Y - (float)handleY; + ParcelInfoParcel.SimPosition.Z = ParcelInfoParcel.GlobalPosition.Z; + + Finished = true; + } + + //private void ParcelInfoTimerEvent(object source, System.Timers.ElapsedEventArgs ea) + //{ + // ParcelInfoTimeout = true; + //} + + private void DirLandReplyHandler(Packet packet, Simulator simulator) + { + if (!DirLandTimeout) + { + // Reset the timer + DirLandTimer.Stop(); + DirLandTimer.Start(); + + DirLandReplyPacket reply = (DirLandReplyPacket)packet; + + foreach (DirLandReplyPacket.QueryRepliesBlock block in reply.QueryReplies) + { + if (block.ReservedNewbie == ReservedNewbie && + block.Auction == Auction && + block.ForSale == ForSale) + { + DirectoryParcel parcel = new DirectoryParcel(); + + parcel.ActualArea = block.ActualArea; + parcel.ID = block.ParcelID; + parcel.Name = Helpers.FieldToString(block.Name); + parcel.SalePrice = block.SalePrice; + + ParcelsForSale.Add(parcel); + } + } + } + else + { + Client.Log("Received a DirLandReply after the timeout, ignoring", Helpers.LogLevel.Warning); + } + } + + private void DirLandTimerEvent(object source, System.Timers.ElapsedEventArgs ea) + { + DirLandTimer.Stop(); + DirLandTimeout = true; + } + } +} diff --git a/libsecondlife-cs/Prims.cs b/libsecondlife-cs/Prims.cs index 5d3bbd6d..74528dea 100644 --- a/libsecondlife-cs/Prims.cs +++ b/libsecondlife-cs/Prims.cs @@ -1,369 +1,369 @@ -/* - * Copyright (c) 2006, Second Life Reverse Engineering Team - * All rights reserved. - * - * - Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - Neither the name of the Second Life Reverse Engineering Team nor the names - * of its contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -using System; - -namespace libsecondlife -{ - /// - /// - /// - public class PrimObject - { - /// - public int PathTwistBegin = 0; - /// - public float PathEnd = 0; - /// - public float ProfileBegin = 0; - /// - public float PathRadiusOffset = 0; - /// - public float PathSkew = 0; - /// - public LLVector3 Position = new LLVector3(); - /// - public uint ProfileCurve = 0; - /// - public float PathScaleX = 0; - /// - public float PathScaleY = 0; - /// - public LLUUID ID = new LLUUID(); - /// - public uint LocalID = 0; - /// - public uint ParentID = 0; - /// - public LLUUID GroupID = new LLUUID(); - /// - public uint Material = 0; - /// - public string Name = ""; - /// - public string Description; - /// - public float PathShearX = 0; - /// - public float PathShearY = 0; - /// - public float PathTaperX = 0; - /// - public float PathTaperY = 0; - /// - public float ProfileEnd = 0; - /// - public float PathBegin = 0; - /// - public uint PathCurve = 0; - /// - public LLVector3 Scale = new LLVector3(); - /// - public int PathTwist = 0; - /// - public LLUUID Texture = new LLUUID(); // TODO: Add multi-texture support - /// - public uint ProfileHollow = 0; - /// - public float PathRevolutions = 0; - /// - public LLQuaternion Rotation = new LLQuaternion(); - /// - public uint State; - - /// - /// - /// - public PrimObject() - { - Texture = new LLUUID(); - } - - /// - /// - /// - /// - public PrimObject(LLUUID texture) - { - Texture = texture; - } - - /// - /// - /// - /// - /// - public static byte PathScaleByte(float pathScale) - { - // Y = 100 + 100X - return (byte)(100 + Convert.ToInt16(100.0F * pathScale)); - } - - /// - /// - /// - /// - /// - public static float PathScaleFloat(byte pathScale) - { - // Y = -1 + 0.01X - return (float)pathScale * 0.01F - 1.0F; - } - - /// - /// - /// - /// - /// - public static byte PathTwistByte(float pathTwist) - { - // Y = 256 + ceil (X / 1.8) - ushort temp = Convert.ToUInt16(256 + Math.Ceiling(pathTwist / 1.8F)); - return (byte)(temp % 256); - } - - /*/// - /// - /// - /// - /// - public static float PathTwistFloat(sbyte pathTwist) - { - // Y = 0.5556X - return (float)pathTwist * 0.5556F; - }*/ - - /// - /// - /// - /// - /// - public static byte PathShearByte(float pathShear) - { - // Y = 256 + 100X - ushort temp = Convert.ToUInt16(100.0F * pathShear); - temp += 256; - return (byte)(temp % 256); - } - - /// - /// - /// - /// - /// - public static float PathShearFloat(byte pathShear) - { - // Y = (X - 256) / 100 - if (pathShear > 150) - { - return ((float)pathShear - 256.0F) / 100.0F; - } - else - { - return (float)pathShear / 100.0F; - } } - - /// - /// - /// - /// - /// - public static byte ProfileBeginByte(float profileBegin) - { - // Y = ceil (200X) - return (byte)Convert.ToInt16(200.0F * profileBegin); - } - - /// - /// - /// - /// - /// - public static float ProfileBeginFloat(byte profileBegin) - { - // Y = 0.005X - return (float)profileBegin * 0.005F; - } - - /// - /// - /// - /// - /// - public static byte ProfileEndByte(float profileEnd) - { - // Y = 200 - ceil (200X) - return (byte)(200 - (200.0F * profileEnd)); - } - - /// - /// - /// - /// - /// - public static float ProfileEndFloat(byte profileEnd) - { - // Y = 1 - 0.005X - return 1.0F - (float)profileEnd * 0.005F; - } - - /// - /// - /// - /// - /// - public static byte PathBeginByte(float pathBegin) - { - // Y = 100X - return (byte)Convert.ToInt16(100.0F * pathBegin); - } - - /// - /// - /// - /// - /// - public static float PathBeginFloat(byte pathBegin) - { - // Y = X / 100 - return (float)pathBegin / 100.0F; - } - - /// - /// - /// - /// - /// - public static byte PathEndByte(float pathEnd) - { - // Y = 100 - 100X - return (byte)(100 - Convert.ToInt16(100.0F * pathEnd)); - } - - /// - /// - /// - /// - /// - public static float PathEndFloat(byte pathEnd) - { - // Y = 1 - X / 100 - return 1.0F - (float)pathEnd / 100; - } - - /// - /// - /// - /// - /// - public static byte PathRadiusOffsetByte(float pathRadiusOffset) - { - // Y = 256 + 100X - return PathShearByte(pathRadiusOffset); - } - - /// - /// - /// - /// - /// - public static float PathRadiusOffsetFloat(sbyte pathRadiusOffset) - { - // Y = X / 100 - return (float)pathRadiusOffset / 100.0F; - } - - /// - /// - /// - /// - /// - public static byte PathRevolutionsByte(float pathRevolutions) - { - // Y = ceil (66X) - 66 - return (byte)(Convert.ToInt16(Math.Ceiling(66.0F * pathRevolutions)) - 66); - } - - /// - /// - /// - /// - /// - public static float PathRevolutionsFloat(byte pathRevolutions) - { - // Y = 1 + 0.015X - return 1.0F + (float)pathRevolutions * 0.015F; - } - - /// - /// - /// - /// - /// - public static byte PathSkewByte(float pathSkew) - { - return PathTaperByte(pathSkew); - } - - /// - /// - /// - /// - /// - public static float PathSkewFloat(byte pathSkew) - { - return PathTaperFloat(pathSkew); - } - - /// - /// - /// - /// - /// - public static byte PathTaperByte(float pathTaper) - { - // Y = 256 + 100X - return PathShearByte(pathTaper); - } - - /// - /// - /// - /// - /// - public static float PathTaperFloat(byte pathTaper) - { - if (pathTaper > 100) - { - return (float)(256 - pathTaper) * 0.01F; - } - else - { - return (float)pathTaper * 0.01F; - } - } - } -} +/* + * Copyright (c) 2006, Second Life Reverse Engineering Team + * All rights reserved. + * + * - Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Neither the name of the Second Life Reverse Engineering Team nor the names + * of its contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +using System; + +namespace libsecondlife +{ + /// + /// + /// + public class PrimObject + { + /// + public int PathTwistBegin = 0; + /// + public float PathEnd = 0; + /// + public float ProfileBegin = 0; + /// + public float PathRadiusOffset = 0; + /// + public float PathSkew = 0; + /// + public LLVector3 Position = new LLVector3(); + /// + public uint ProfileCurve = 0; + /// + public float PathScaleX = 0; + /// + public float PathScaleY = 0; + /// + public LLUUID ID = new LLUUID(); + /// + public uint LocalID = 0; + /// + public uint ParentID = 0; + /// + public LLUUID GroupID = new LLUUID(); + /// + public uint Material = 0; + /// + public string Name = ""; + /// + public string Description; + /// + public float PathShearX = 0; + /// + public float PathShearY = 0; + /// + public float PathTaperX = 0; + /// + public float PathTaperY = 0; + /// + public float ProfileEnd = 0; + /// + public float PathBegin = 0; + /// + public uint PathCurve = 0; + /// + public LLVector3 Scale = new LLVector3(); + /// + public int PathTwist = 0; + /// + public LLUUID Texture = new LLUUID(); // TODO: Add multi-texture support + /// + public uint ProfileHollow = 0; + /// + public float PathRevolutions = 0; + /// + public LLQuaternion Rotation = new LLQuaternion(); + /// + public uint State; + + /// + /// + /// + public PrimObject() + { + Texture = new LLUUID(); + } + + /// + /// + /// + /// + public PrimObject(LLUUID texture) + { + Texture = texture; + } + + /// + /// + /// + /// + /// + public static byte PathScaleByte(float pathScale) + { + // Y = 100 + 100X + return (byte)(100 + Convert.ToInt16(100.0F * pathScale)); + } + + /// + /// + /// + /// + /// + public static float PathScaleFloat(byte pathScale) + { + // Y = -1 + 0.01X + return (float)pathScale * 0.01F - 1.0F; + } + + /// + /// + /// + /// + /// + public static byte PathTwistByte(float pathTwist) + { + // Y = 256 + ceil (X / 1.8) + ushort temp = Convert.ToUInt16(256 + Math.Ceiling(pathTwist / 1.8F)); + return (byte)(temp % 256); + } + + /*/// + /// + /// + /// + /// + public static float PathTwistFloat(sbyte pathTwist) + { + // Y = 0.5556X + return (float)pathTwist * 0.5556F; + }*/ + + /// + /// + /// + /// + /// + public static byte PathShearByte(float pathShear) + { + // Y = 256 + 100X + ushort temp = Convert.ToUInt16(100.0F * pathShear); + temp += 256; + return (byte)(temp % 256); + } + + /// + /// + /// + /// + /// + public static float PathShearFloat(byte pathShear) + { + // Y = (X - 256) / 100 + if (pathShear > 150) + { + return ((float)pathShear - 256.0F) / 100.0F; + } + else + { + return (float)pathShear / 100.0F; + } } + + /// + /// + /// + /// + /// + public static byte ProfileBeginByte(float profileBegin) + { + // Y = ceil (200X) + return (byte)Convert.ToInt16(200.0F * profileBegin); + } + + /// + /// + /// + /// + /// + public static float ProfileBeginFloat(byte profileBegin) + { + // Y = 0.005X + return (float)profileBegin * 0.005F; + } + + /// + /// + /// + /// + /// + public static byte ProfileEndByte(float profileEnd) + { + // Y = 200 - ceil (200X) + return (byte)(200 - (200.0F * profileEnd)); + } + + /// + /// + /// + /// + /// + public static float ProfileEndFloat(byte profileEnd) + { + // Y = 1 - 0.005X + return 1.0F - (float)profileEnd * 0.005F; + } + + /// + /// + /// + /// + /// + public static byte PathBeginByte(float pathBegin) + { + // Y = 100X + return (byte)Convert.ToInt16(100.0F * pathBegin); + } + + /// + /// + /// + /// + /// + public static float PathBeginFloat(byte pathBegin) + { + // Y = X / 100 + return (float)pathBegin / 100.0F; + } + + /// + /// + /// + /// + /// + public static byte PathEndByte(float pathEnd) + { + // Y = 100 - 100X + return (byte)(100 - Convert.ToInt16(100.0F * pathEnd)); + } + + /// + /// + /// + /// + /// + public static float PathEndFloat(byte pathEnd) + { + // Y = 1 - X / 100 + return 1.0F - (float)pathEnd / 100; + } + + /// + /// + /// + /// + /// + public static byte PathRadiusOffsetByte(float pathRadiusOffset) + { + // Y = 256 + 100X + return PathShearByte(pathRadiusOffset); + } + + /// + /// + /// + /// + /// + public static float PathRadiusOffsetFloat(sbyte pathRadiusOffset) + { + // Y = X / 100 + return (float)pathRadiusOffset / 100.0F; + } + + /// + /// + /// + /// + /// + public static byte PathRevolutionsByte(float pathRevolutions) + { + // Y = ceil (66X) - 66 + return (byte)(Convert.ToInt16(Math.Ceiling(66.0F * pathRevolutions)) - 66); + } + + /// + /// + /// + /// + /// + public static float PathRevolutionsFloat(byte pathRevolutions) + { + // Y = 1 + 0.015X + return 1.0F + (float)pathRevolutions * 0.015F; + } + + /// + /// + /// + /// + /// + public static byte PathSkewByte(float pathSkew) + { + return PathTaperByte(pathSkew); + } + + /// + /// + /// + /// + /// + public static float PathSkewFloat(byte pathSkew) + { + return PathTaperFloat(pathSkew); + } + + /// + /// + /// + /// + /// + public static byte PathTaperByte(float pathTaper) + { + // Y = 256 + 100X + return PathShearByte(pathTaper); + } + + /// + /// + /// + /// + /// + public static float PathTaperFloat(byte pathTaper) + { + if (pathTaper > 100) + { + return (float)(256 - pathTaper) * 0.01F; + } + else + { + return (float)pathTaper * 0.01F; + } + } + } +} diff --git a/libsecondlife-cs/ProtocolManager.cs b/libsecondlife-cs/ProtocolManager.cs index 119eafb8..596eda8a 100644 --- a/libsecondlife-cs/ProtocolManager.cs +++ b/libsecondlife-cs/ProtocolManager.cs @@ -1,702 +1,702 @@ -using System; -using System.Collections; -using System.IO; - -namespace libsecondlife -{ - /// - /// - /// - public enum PacketFrequency - { - /// - Low, - /// - Medium, - /// - High - } - - /// - /// - /// - public enum FieldType - { - /// - U8, - /// - U16, - /// - U32, - /// - U64, - /// - S8, - /// - S16, - /// - S32, - /// - F32, - /// - F64, - /// - LLUUID, - /// - BOOL, - /// - LLVector3, - /// - LLVector3d, - /// - LLVector4, - /// - LLQuaternion, - /// - IPADDR, - /// - IPPORT, - /// - Variable, - /// - Fixed, - /// - Single, - /// - Multiple - } - - /// - /// - /// - public class MapField : IComparable - { - /// - public int KeywordPosition; - /// - public string Name; - /// - public FieldType Type; - /// - public int Count; - - /// - /// - /// - /// - /// - public int CompareTo(object obj) - { - MapField temp = (MapField)obj; - - if (this.KeywordPosition > temp.KeywordPosition) - { - return 1; - } - else - { - if(temp.KeywordPosition == this.KeywordPosition) - { - return 0; - } - else - { - return -1; - } - } - } - } - - /// - /// - /// - public class MapBlock : IComparable - { - /// - public int KeywordPosition; - /// - public string Name; - /// - public int Count; - /// - public ArrayList Fields; - - /// - /// - /// - /// - /// - public int CompareTo(object obj) - { - MapBlock temp = (MapBlock)obj; - - if (this.KeywordPosition > temp.KeywordPosition) - { - return 1; - } - else - { - if(temp.KeywordPosition == this.KeywordPosition) - { - return 0; - } - else - { - return -1; - } - } - } - } - - /// - /// - /// - public class MapPacket - { - /// - public ushort ID; - /// - public string Name; - /// - public PacketFrequency Frequency; - /// - public bool Trusted; - /// - public bool Encoded; - /// - public ArrayList Blocks; - } - - /// - /// - /// - public class ProtocolManager - { - /// - public Hashtable TypeSizes; - /// - public Hashtable KeywordPositions; - /// - public MapPacket[] LowMaps; - /// - public MapPacket[] MediumMaps; - /// - public MapPacket[] HighMaps; - - private SecondLife Client; - private int i = 0; - - /// - /// - /// - /// - /// - /// - public ProtocolManager(string keywordFile, string mapFile, SecondLife client) - { - Client = client; - - // Initialize the map arrays - LowMaps = new MapPacket[65536]; - MediumMaps = new MapPacket[256]; - HighMaps = new MapPacket[256]; - - // Build the type size hash table - TypeSizes = new Hashtable(); - TypeSizes.Add(FieldType.U8, 1); - TypeSizes.Add(FieldType.U16, 2); - TypeSizes.Add(FieldType.U32, 4); - TypeSizes.Add(FieldType.U64, 8); - TypeSizes.Add(FieldType.S8, 1); - TypeSizes.Add(FieldType.S16, 2); - TypeSizes.Add(FieldType.S32, 4); - TypeSizes.Add(FieldType.F32, 4); - TypeSizes.Add(FieldType.F64, 8); - TypeSizes.Add(FieldType.LLUUID, 16); - TypeSizes.Add(FieldType.BOOL, 1); - TypeSizes.Add(FieldType.LLVector3, 12); - TypeSizes.Add(FieldType.LLVector3d, 24); - TypeSizes.Add(FieldType.LLVector4, 16); - TypeSizes.Add(FieldType.LLQuaternion, 16); - TypeSizes.Add(FieldType.IPADDR, 4); - TypeSizes.Add(FieldType.IPPORT, 2); - TypeSizes.Add(FieldType.Variable, -1); - TypeSizes.Add(FieldType.Fixed, -2); - - LoadKeywordFile(keywordFile); - LoadMapFile(mapFile); - } - - /// - /// - /// - /// - /// - public MapPacket Command(string command) - { - foreach (MapPacket map in HighMaps) - { - if (map != null) - { - if (command == map.Name) - { - return map; - } - } - } - - foreach (MapPacket map in MediumMaps) - { - if (map != null) - { - if (command == map.Name) - { - return map; - } - } - } - - foreach (MapPacket map in LowMaps) - { - if (map != null) - { - if (command == map.Name) - { - return map; - } - } - } - - throw new Exception("Cannot find map for command \"" + command + "\""); - } - - /// - /// - /// - /// - /// - public MapPacket Command(byte[] data) - { - ushort command; - - if (data.Length < 5) - { - return null; - } - - if (data[4] == 0xFF) - { - if ((byte)data[5] == 0xFF) - { - // Low frequency - command = (ushort)(data[6] * 256 + data[7]); - return Command(command, PacketFrequency.Low); - } - else - { - // Medium frequency - command = (ushort)data[5]; - return Command(command, PacketFrequency.Medium); - } - } - else - { - // High frequency - command = (ushort)data[4]; - return Command(command, PacketFrequency.High); - } - } - - /// - /// - /// - /// - /// - /// - public MapPacket Command(ushort command, PacketFrequency frequency) - { - switch (frequency) - { - case PacketFrequency.High: - return HighMaps[command]; - case PacketFrequency.Medium: - return MediumMaps[command]; - case PacketFrequency.Low: - return LowMaps[command]; - } - - throw new Exception("Cannot find map for command \"" + command + "\" with frequency \"" + frequency + "\""); - } - - /// - /// - /// - public void PrintMap() - { - PrintOneMap(LowMaps, "Low "); - PrintOneMap(MediumMaps, "Medium"); - PrintOneMap(HighMaps, "High "); - } - - /// - /// - /// - /// - /// - private void PrintOneMap(MapPacket[] map, string frequency) { - int i; - - for (i = 0; i < map.Length; ++i) - { - if (map[i] != null) - { - Console.WriteLine("{0} {1,5} - {2} - {3} - {4}", frequency, i, map[i].Name, - map[i].Trusted ? "Trusted" : "Untrusted", - map[i].Encoded ? "Unencoded" : "Zerocoded"); - - foreach (MapBlock block in map[i].Blocks) - { - if (block.Count == -1) - { - Console.WriteLine("\t{0,4} {1} (Variable)", block.KeywordPosition, block.Name); - } - else - { - Console.WriteLine("\t{0,4} {1} ({2})", block.KeywordPosition, block.Name, block.Count); - } - - foreach (MapField field in block.Fields) - { - Console.WriteLine("\t\t{0,4} {1} ({2} / {3})", field.KeywordPosition, field.Name, - field.Type, field.Count); - } - } - } - } - } - - /// - /// - /// - /// - private void LoadKeywordFile(string keywordFile) - { - string line; - StreamReader file; - - KeywordPositions = new Hashtable(); - - // Load the keyword file - try - { - file = File.OpenText(keywordFile); - } - catch(Exception e) - { - Client.Log("Error opening \"" + keywordFile + "\": " + e.Message, Helpers.LogLevel.Error); - throw new Exception("Keyword file error", e); - } - - while((line = file.ReadLine()) != null) - { - KeywordPositions.Add(line.Trim(), i++); - } - - file.Close(); - } - - /// - /// - /// - /// - /// - public static void DecodeMapFile(string mapFile, string outputFile) - { - byte magicKey = 0; - byte[] buffer = new byte[2048]; - int nread; - BinaryReader map; - BinaryWriter output; - - try - { - map = new BinaryReader(new FileStream(mapFile, FileMode.Open)); - } - catch(Exception e) - { - throw new Exception("Map file error", e); - } - - try - { - output = new BinaryWriter(new FileStream(outputFile, FileMode.CreateNew)); - } - catch(Exception e) - { - throw new Exception("Map file error", e); - } - - while ((nread = map.Read(buffer, 0, 2048)) != 0) - { - for (int i = 0; i < nread; ++i) - { - buffer[i] ^= magicKey; - magicKey += 43; - } - - output.Write(buffer, 0, nread); - } - - map.Close(); - output.Close(); - } - - /// - /// - /// - /// - private void LoadMapFile(string mapFile) - { - FileStream map; - ushort low = 1; - ushort medium = 1; - ushort high = 1; - - // Load the protocol map file - try - { - map = new FileStream(mapFile, FileMode.Open, FileAccess.Read); - } - catch(Exception e) - { - throw new Exception("Map file error", e); - } - - try - { - StreamReader r = new StreamReader(map); - r.BaseStream.Seek(0, SeekOrigin.Begin); - string newline; - string trimmedline; - bool inPacket = false; - bool inBlock = false; - MapPacket currentPacket = null; - MapBlock currentBlock = null; - char[] trimArray = new char[] {' ', '\t'}; - - // While not at the end of the file - while (r.Peek() > -1) - { - #region ParseMap - - newline = r.ReadLine(); - trimmedline = System.Text.RegularExpressions.Regex.Replace(newline, @"\s+", " "); - trimmedline = trimmedline.Trim(trimArray); - - if (!inPacket) - { - // Outside of all packet blocks - - if (trimmedline == "{") - { - inPacket = true; - } - } - else - { - // Inside of a packet block - - if (!inBlock) - { - // Inside a packet block, outside of the blocks - - if (trimmedline == "{") - { - inBlock = true; - } - else if (trimmedline == "}") - { - // Reached the end of the packet - currentPacket.Blocks.Sort(); - inPacket = false; - } - else - { - // The packet header - #region ParsePacketHeader - - // Splice the string in to tokens - string[] tokens = trimmedline.Split(new char[] {' ', '\t'}); - - if (tokens.Length > 3) - { - if (tokens[1] == "Fixed") - { - // Remove the leading "0x" - if (tokens[2].Substring(0, 2) == "0x") - { - tokens[2] = tokens[2].Substring(2, tokens[2].Length - 2); - } - - uint fixedID = UInt32.Parse(tokens[2], System.Globalization.NumberStyles.HexNumber); - // Truncate the id to a short - fixedID ^= 0xFFFF0000; - LowMaps[fixedID] = new MapPacket(); - LowMaps[fixedID].ID = (ushort)fixedID; - LowMaps[fixedID].Frequency = PacketFrequency.Low; - LowMaps[fixedID].Name = tokens[0]; - LowMaps[fixedID].Trusted = (tokens[3] == "Trusted"); - LowMaps[fixedID].Encoded = (tokens[4] == "Zerocoded"); - LowMaps[fixedID].Blocks = new ArrayList(); - - currentPacket = LowMaps[fixedID]; - } - else if (tokens[1] == "Low") - { - LowMaps[low] = new MapPacket(); - LowMaps[low].ID = low; - LowMaps[low].Frequency = PacketFrequency.Low; - LowMaps[low].Name = tokens[0]; - LowMaps[low].Trusted = (tokens[2] == "Trusted"); - LowMaps[low].Encoded = (tokens[3] == "Zerocoded"); - LowMaps[low].Blocks = new ArrayList(); - - currentPacket = LowMaps[low]; - - low++; - } - else if (tokens[1] == "Medium") - { - MediumMaps[medium] = new MapPacket(); - MediumMaps[medium].ID = medium; - MediumMaps[medium].Frequency = PacketFrequency.Medium; - MediumMaps[medium].Name = tokens[0]; - MediumMaps[medium].Trusted = (tokens[2] == "Trusted"); - MediumMaps[medium].Encoded = (tokens[3] == "Zerocoded"); - MediumMaps[medium].Blocks = new ArrayList(); - - currentPacket = MediumMaps[medium]; - - medium++; - } - else if (tokens[1] == "High") - { - HighMaps[high] = new MapPacket(); - HighMaps[high].ID = high; - HighMaps[high].Frequency = PacketFrequency.High; - HighMaps[high].Name = tokens[0]; - HighMaps[high].Trusted = (tokens[2] == "Trusted"); - HighMaps[high].Encoded = (tokens[3] == "Zerocoded"); - HighMaps[high].Blocks = new ArrayList(); - - currentPacket = HighMaps[high]; - - high++; - } - else - { - Client.Log("Unknown packet frequency", Helpers.LogLevel.Error); - } - } - - #endregion - } - } - else - { - if (trimmedline.Length > 0 && trimmedline.Substring(0, 1) == "{") - { - // A field - #region ParseField - - MapField field = new MapField(); - - // Splice the string in to tokens - string[] tokens = trimmedline.Split(new char[] {' ', '\t'}); - - field.Name = tokens[1]; - field.KeywordPosition = KeywordPosition(field.Name); - field.Type = (FieldType)Enum.Parse(typeof(FieldType), tokens[2], true); - - if (tokens[3] != "}") - { - field.Count = Int32.Parse(tokens[3]); - } - else - { - field.Count = 1; - } - - // Save this field to the current block - currentBlock.Fields.Add(field); - - #endregion - } - else if (trimmedline == "}") - { - currentBlock.Fields.Sort(); - inBlock = false; - } - else if (trimmedline.Length != 0 && trimmedline.Substring(0, 2) != "//") - { - // The block header - #region ParseBlockHeader - - currentBlock = new MapBlock(); - - // Splice the string in to tokens - string[] tokens = trimmedline.Split(new char[] {' ', '\t'}); - - currentBlock.Name = tokens[0]; - currentBlock.KeywordPosition = KeywordPosition(currentBlock.Name); - currentBlock.Fields = new ArrayList(); - currentPacket.Blocks.Add(currentBlock); - - if (tokens[1] == "Single") - { - currentBlock.Count = 1; - } - else if (tokens[1] == "Multiple") - { - currentBlock.Count = Int32.Parse(tokens[2]); - } - else if (tokens[1] == "Variable") - { - currentBlock.Count = -1; - } - else - { - Client.Log("Unknown block frequency", Helpers.LogLevel.Error); - } - - #endregion - } - } - } - - #endregion - } - - r.Close(); - map.Close(); - } - catch (Exception e) - { - throw e; - } - } - - private int KeywordPosition(string keyword) - { - if (KeywordPositions.ContainsKey(keyword)) - { - return (int)KeywordPositions[keyword]; - } - else - { - Client.Log("Couldn't find keyword: " + keyword, Helpers.LogLevel.Warning); - return -1; - } - } - } -} +using System; +using System.Collections; +using System.IO; + +namespace libsecondlife +{ + /// + /// + /// + public enum PacketFrequency + { + /// + Low, + /// + Medium, + /// + High + } + + /// + /// + /// + public enum FieldType + { + /// + U8, + /// + U16, + /// + U32, + /// + U64, + /// + S8, + /// + S16, + /// + S32, + /// + F32, + /// + F64, + /// + LLUUID, + /// + BOOL, + /// + LLVector3, + /// + LLVector3d, + /// + LLVector4, + /// + LLQuaternion, + /// + IPADDR, + /// + IPPORT, + /// + Variable, + /// + Fixed, + /// + Single, + /// + Multiple + } + + /// + /// + /// + public class MapField : IComparable + { + /// + public int KeywordPosition; + /// + public string Name; + /// + public FieldType Type; + /// + public int Count; + + /// + /// + /// + /// + /// + public int CompareTo(object obj) + { + MapField temp = (MapField)obj; + + if (this.KeywordPosition > temp.KeywordPosition) + { + return 1; + } + else + { + if(temp.KeywordPosition == this.KeywordPosition) + { + return 0; + } + else + { + return -1; + } + } + } + } + + /// + /// + /// + public class MapBlock : IComparable + { + /// + public int KeywordPosition; + /// + public string Name; + /// + public int Count; + /// + public ArrayList Fields; + + /// + /// + /// + /// + /// + public int CompareTo(object obj) + { + MapBlock temp = (MapBlock)obj; + + if (this.KeywordPosition > temp.KeywordPosition) + { + return 1; + } + else + { + if(temp.KeywordPosition == this.KeywordPosition) + { + return 0; + } + else + { + return -1; + } + } + } + } + + /// + /// + /// + public class MapPacket + { + /// + public ushort ID; + /// + public string Name; + /// + public PacketFrequency Frequency; + /// + public bool Trusted; + /// + public bool Encoded; + /// + public ArrayList Blocks; + } + + /// + /// + /// + public class ProtocolManager + { + /// + public Hashtable TypeSizes; + /// + public Hashtable KeywordPositions; + /// + public MapPacket[] LowMaps; + /// + public MapPacket[] MediumMaps; + /// + public MapPacket[] HighMaps; + + private SecondLife Client; + private int i = 0; + + /// + /// + /// + /// + /// + /// + public ProtocolManager(string keywordFile, string mapFile, SecondLife client) + { + Client = client; + + // Initialize the map arrays + LowMaps = new MapPacket[65536]; + MediumMaps = new MapPacket[256]; + HighMaps = new MapPacket[256]; + + // Build the type size hash table + TypeSizes = new Hashtable(); + TypeSizes.Add(FieldType.U8, 1); + TypeSizes.Add(FieldType.U16, 2); + TypeSizes.Add(FieldType.U32, 4); + TypeSizes.Add(FieldType.U64, 8); + TypeSizes.Add(FieldType.S8, 1); + TypeSizes.Add(FieldType.S16, 2); + TypeSizes.Add(FieldType.S32, 4); + TypeSizes.Add(FieldType.F32, 4); + TypeSizes.Add(FieldType.F64, 8); + TypeSizes.Add(FieldType.LLUUID, 16); + TypeSizes.Add(FieldType.BOOL, 1); + TypeSizes.Add(FieldType.LLVector3, 12); + TypeSizes.Add(FieldType.LLVector3d, 24); + TypeSizes.Add(FieldType.LLVector4, 16); + TypeSizes.Add(FieldType.LLQuaternion, 16); + TypeSizes.Add(FieldType.IPADDR, 4); + TypeSizes.Add(FieldType.IPPORT, 2); + TypeSizes.Add(FieldType.Variable, -1); + TypeSizes.Add(FieldType.Fixed, -2); + + LoadKeywordFile(keywordFile); + LoadMapFile(mapFile); + } + + /// + /// + /// + /// + /// + public MapPacket Command(string command) + { + foreach (MapPacket map in HighMaps) + { + if (map != null) + { + if (command == map.Name) + { + return map; + } + } + } + + foreach (MapPacket map in MediumMaps) + { + if (map != null) + { + if (command == map.Name) + { + return map; + } + } + } + + foreach (MapPacket map in LowMaps) + { + if (map != null) + { + if (command == map.Name) + { + return map; + } + } + } + + throw new Exception("Cannot find map for command \"" + command + "\""); + } + + /// + /// + /// + /// + /// + public MapPacket Command(byte[] data) + { + ushort command; + + if (data.Length < 5) + { + return null; + } + + if (data[4] == 0xFF) + { + if ((byte)data[5] == 0xFF) + { + // Low frequency + command = (ushort)(data[6] * 256 + data[7]); + return Command(command, PacketFrequency.Low); + } + else + { + // Medium frequency + command = (ushort)data[5]; + return Command(command, PacketFrequency.Medium); + } + } + else + { + // High frequency + command = (ushort)data[4]; + return Command(command, PacketFrequency.High); + } + } + + /// + /// + /// + /// + /// + /// + public MapPacket Command(ushort command, PacketFrequency frequency) + { + switch (frequency) + { + case PacketFrequency.High: + return HighMaps[command]; + case PacketFrequency.Medium: + return MediumMaps[command]; + case PacketFrequency.Low: + return LowMaps[command]; + } + + throw new Exception("Cannot find map for command \"" + command + "\" with frequency \"" + frequency + "\""); + } + + /// + /// + /// + public void PrintMap() + { + PrintOneMap(LowMaps, "Low "); + PrintOneMap(MediumMaps, "Medium"); + PrintOneMap(HighMaps, "High "); + } + + /// + /// + /// + /// + /// + private void PrintOneMap(MapPacket[] map, string frequency) { + int i; + + for (i = 0; i < map.Length; ++i) + { + if (map[i] != null) + { + Console.WriteLine("{0} {1,5} - {2} - {3} - {4}", frequency, i, map[i].Name, + map[i].Trusted ? "Trusted" : "Untrusted", + map[i].Encoded ? "Unencoded" : "Zerocoded"); + + foreach (MapBlock block in map[i].Blocks) + { + if (block.Count == -1) + { + Console.WriteLine("\t{0,4} {1} (Variable)", block.KeywordPosition, block.Name); + } + else + { + Console.WriteLine("\t{0,4} {1} ({2})", block.KeywordPosition, block.Name, block.Count); + } + + foreach (MapField field in block.Fields) + { + Console.WriteLine("\t\t{0,4} {1} ({2} / {3})", field.KeywordPosition, field.Name, + field.Type, field.Count); + } + } + } + } + } + + /// + /// + /// + /// + private void LoadKeywordFile(string keywordFile) + { + string line; + StreamReader file; + + KeywordPositions = new Hashtable(); + + // Load the keyword file + try + { + file = File.OpenText(keywordFile); + } + catch(Exception e) + { + Client.Log("Error opening \"" + keywordFile + "\": " + e.Message, Helpers.LogLevel.Error); + throw new Exception("Keyword file error", e); + } + + while((line = file.ReadLine()) != null) + { + KeywordPositions.Add(line.Trim(), i++); + } + + file.Close(); + } + + /// + /// + /// + /// + /// + public static void DecodeMapFile(string mapFile, string outputFile) + { + byte magicKey = 0; + byte[] buffer = new byte[2048]; + int nread; + BinaryReader map; + BinaryWriter output; + + try + { + map = new BinaryReader(new FileStream(mapFile, FileMode.Open)); + } + catch(Exception e) + { + throw new Exception("Map file error", e); + } + + try + { + output = new BinaryWriter(new FileStream(outputFile, FileMode.CreateNew)); + } + catch(Exception e) + { + throw new Exception("Map file error", e); + } + + while ((nread = map.Read(buffer, 0, 2048)) != 0) + { + for (int i = 0; i < nread; ++i) + { + buffer[i] ^= magicKey; + magicKey += 43; + } + + output.Write(buffer, 0, nread); + } + + map.Close(); + output.Close(); + } + + /// + /// + /// + /// + private void LoadMapFile(string mapFile) + { + FileStream map; + ushort low = 1; + ushort medium = 1; + ushort high = 1; + + // Load the protocol map file + try + { + map = new FileStream(mapFile, FileMode.Open, FileAccess.Read); + } + catch(Exception e) + { + throw new Exception("Map file error", e); + } + + try + { + StreamReader r = new StreamReader(map); + r.BaseStream.Seek(0, SeekOrigin.Begin); + string newline; + string trimmedline; + bool inPacket = false; + bool inBlock = false; + MapPacket currentPacket = null; + MapBlock currentBlock = null; + char[] trimArray = new char[] {' ', '\t'}; + + // While not at the end of the file + while (r.Peek() > -1) + { + #region ParseMap + + newline = r.ReadLine(); + trimmedline = System.Text.RegularExpressions.Regex.Replace(newline, @"\s+", " "); + trimmedline = trimmedline.Trim(trimArray); + + if (!inPacket) + { + // Outside of all packet blocks + + if (trimmedline == "{") + { + inPacket = true; + } + } + else + { + // Inside of a packet block + + if (!inBlock) + { + // Inside a packet block, outside of the blocks + + if (trimmedline == "{") + { + inBlock = true; + } + else if (trimmedline == "}") + { + // Reached the end of the packet + currentPacket.Blocks.Sort(); + inPacket = false; + } + else + { + // The packet header + #region ParsePacketHeader + + // Splice the string in to tokens + string[] tokens = trimmedline.Split(new char[] {' ', '\t'}); + + if (tokens.Length > 3) + { + if (tokens[1] == "Fixed") + { + // Remove the leading "0x" + if (tokens[2].Substring(0, 2) == "0x") + { + tokens[2] = tokens[2].Substring(2, tokens[2].Length - 2); + } + + uint fixedID = UInt32.Parse(tokens[2], System.Globalization.NumberStyles.HexNumber); + // Truncate the id to a short + fixedID ^= 0xFFFF0000; + LowMaps[fixedID] = new MapPacket(); + LowMaps[fixedID].ID = (ushort)fixedID; + LowMaps[fixedID].Frequency = PacketFrequency.Low; + LowMaps[fixedID].Name = tokens[0]; + LowMaps[fixedID].Trusted = (tokens[3] == "Trusted"); + LowMaps[fixedID].Encoded = (tokens[4] == "Zerocoded"); + LowMaps[fixedID].Blocks = new ArrayList(); + + currentPacket = LowMaps[fixedID]; + } + else if (tokens[1] == "Low") + { + LowMaps[low] = new MapPacket(); + LowMaps[low].ID = low; + LowMaps[low].Frequency = PacketFrequency.Low; + LowMaps[low].Name = tokens[0]; + LowMaps[low].Trusted = (tokens[2] == "Trusted"); + LowMaps[low].Encoded = (tokens[3] == "Zerocoded"); + LowMaps[low].Blocks = new ArrayList(); + + currentPacket = LowMaps[low]; + + low++; + } + else if (tokens[1] == "Medium") + { + MediumMaps[medium] = new MapPacket(); + MediumMaps[medium].ID = medium; + MediumMaps[medium].Frequency = PacketFrequency.Medium; + MediumMaps[medium].Name = tokens[0]; + MediumMaps[medium].Trusted = (tokens[2] == "Trusted"); + MediumMaps[medium].Encoded = (tokens[3] == "Zerocoded"); + MediumMaps[medium].Blocks = new ArrayList(); + + currentPacket = MediumMaps[medium]; + + medium++; + } + else if (tokens[1] == "High") + { + HighMaps[high] = new MapPacket(); + HighMaps[high].ID = high; + HighMaps[high].Frequency = PacketFrequency.High; + HighMaps[high].Name = tokens[0]; + HighMaps[high].Trusted = (tokens[2] == "Trusted"); + HighMaps[high].Encoded = (tokens[3] == "Zerocoded"); + HighMaps[high].Blocks = new ArrayList(); + + currentPacket = HighMaps[high]; + + high++; + } + else + { + Client.Log("Unknown packet frequency", Helpers.LogLevel.Error); + } + } + + #endregion + } + } + else + { + if (trimmedline.Length > 0 && trimmedline.Substring(0, 1) == "{") + { + // A field + #region ParseField + + MapField field = new MapField(); + + // Splice the string in to tokens + string[] tokens = trimmedline.Split(new char[] {' ', '\t'}); + + field.Name = tokens[1]; + field.KeywordPosition = KeywordPosition(field.Name); + field.Type = (FieldType)Enum.Parse(typeof(FieldType), tokens[2], true); + + if (tokens[3] != "}") + { + field.Count = Int32.Parse(tokens[3]); + } + else + { + field.Count = 1; + } + + // Save this field to the current block + currentBlock.Fields.Add(field); + + #endregion + } + else if (trimmedline == "}") + { + currentBlock.Fields.Sort(); + inBlock = false; + } + else if (trimmedline.Length != 0 && trimmedline.Substring(0, 2) != "//") + { + // The block header + #region ParseBlockHeader + + currentBlock = new MapBlock(); + + // Splice the string in to tokens + string[] tokens = trimmedline.Split(new char[] {' ', '\t'}); + + currentBlock.Name = tokens[0]; + currentBlock.KeywordPosition = KeywordPosition(currentBlock.Name); + currentBlock.Fields = new ArrayList(); + currentPacket.Blocks.Add(currentBlock); + + if (tokens[1] == "Single") + { + currentBlock.Count = 1; + } + else if (tokens[1] == "Multiple") + { + currentBlock.Count = Int32.Parse(tokens[2]); + } + else if (tokens[1] == "Variable") + { + currentBlock.Count = -1; + } + else + { + Client.Log("Unknown block frequency", Helpers.LogLevel.Error); + } + + #endregion + } + } + } + + #endregion + } + + r.Close(); + map.Close(); + } + catch (Exception e) + { + throw e; + } + } + + private int KeywordPosition(string keyword) + { + if (KeywordPositions.ContainsKey(keyword)) + { + return (int)KeywordPositions[keyword]; + } + else + { + Client.Log("Couldn't find keyword: " + keyword, Helpers.LogLevel.Warning); + return -1; + } + } + } +} diff --git a/libsecondlife-cs/README.txt b/libsecondlife-cs/README.txt index 98076f32..3f3f8b36 100644 --- a/libsecondlife-cs/README.txt +++ b/libsecondlife-cs/README.txt @@ -1,17 +1,17 @@ -Building libsecondlife ----------------------- - -libsecondlife has two primary build systems, NAnt and Microsoft Visual Studio. - -To use NAnt first download it from http://nant.sourceforge.net/ and then -simply run "nant" in the top directory containing libsecondlife.build, or run -"nant package" to build a zip file containing the executables and libraries. - -To use the Visual Studio project files, you must be running Visual Studio 2005 -or compatible software (including Visual C# Express 2005 and SharpDevelop, -possibly MonoDevelop). Simply open the libsecondlife.sln solution and begin -compiling. The output will be in the bin folder under the root directory. - -If you have any questions, stop by #libsl on EFNet in IRC - -http://www.libsecondlife.org/ +Building libsecondlife +---------------------- + +libsecondlife has two primary build systems, NAnt and Microsoft Visual Studio. + +To use NAnt first download it from http://nant.sourceforge.net/ and then +simply run "nant" in the top directory containing libsecondlife.build, or run +"nant package" to build a zip file containing the executables and libraries. + +To use the Visual Studio project files, you must be running Visual Studio 2005 +or compatible software (including Visual C# Express 2005 and SharpDevelop, +possibly MonoDevelop). Simply open the libsecondlife.sln solution and begin +compiling. The output will be in the bin folder under the root directory. + +If you have any questions, stop by #libsl on EFNet in IRC + +http://www.libsecondlife.org/ diff --git a/libsecondlife-cs/Region.cs b/libsecondlife-cs/Region.cs index 15b20dd0..1e0a14f5 100644 --- a/libsecondlife-cs/Region.cs +++ b/libsecondlife-cs/Region.cs @@ -1,359 +1,359 @@ -/* - * Copyright (c) 2006, Second Life Reverse Engineering Team - * All rights reserved. - * - * - Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - Neither the name of the Second Life Reverse Engineering Team nor the names - * of its contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using libsecondlife.Packets; - -namespace libsecondlife -{ - /// - /// - /// - /// - public delegate void ParcelCompleteCallback(Region region); - - /// - /// Represents a region (also known as a sim) in Second Life. - /// - public class Region - { - /// - public LLUUID ID; - /// - public ulong Handle; - /// - public string Name; - /// - public byte[] ParcelOverlay; - /// - public int ParcelOverlaysReceived; - - /// 64x64 Array of parcels which have been successfully downloaded. - /// (and their LocalID's, 0 = Null) - public int[,] ParcelMarked; - /// Flag to indicate whether we are downloading a sim's parcels. - public bool ParcelDownloading; - /// Flag to indicate whether to get Dwell values automatically (NOT USED YET). Call Parcel.GetDwell() instead. - public bool ParcelDwell; - - /// - public System.Collections.Hashtable Parcels; - /// - public System.Threading.Mutex ParcelsMutex; - - /// - public float TerrainHeightRange00; - /// - public float TerrainHeightRange01; - /// - public float TerrainHeightRange10; - /// - public float TerrainHeightRange11; - /// - public float TerrainStartHeight00; - /// - public float TerrainStartHeight01; - /// - public float TerrainStartHeight10; - /// - public float TerrainStartHeight11; - /// - public float WaterHeight; - - /// - public LLUUID SimOwner; - - /// - public LLUUID TerrainBase0; - /// - public LLUUID TerrainBase1; - /// - public LLUUID TerrainBase2; - /// - public LLUUID TerrainBase3; - /// - public LLUUID TerrainDetail0; - /// - public LLUUID TerrainDetail1; - /// - public LLUUID TerrainDetail2; - /// - public LLUUID TerrainDetail3; - - /// - public bool IsEstateManager; - /// - public EstateTools Estate; - - private SecondLife Client; - - /// - public event ParcelCompleteCallback OnParcelCompletion; - - /// - /// - /// - /// - public Region(SecondLife client) - { - Estate = new EstateTools(client); - Client = client; - ID = new LLUUID(); - ParcelOverlay = new byte[4096]; - ParcelMarked = new int[64, 64]; - - Parcels = new System.Collections.Hashtable(); - ParcelsMutex = new System.Threading.Mutex(false, "ParcelsMutex"); - - SimOwner = new LLUUID(); - TerrainBase0 = new LLUUID(); - TerrainBase1 = new LLUUID(); - TerrainBase2 = new LLUUID(); - TerrainBase3 = new LLUUID(); - TerrainDetail0 = new LLUUID(); - TerrainDetail1 = new LLUUID(); - TerrainDetail2 = new LLUUID(); - TerrainDetail3 = new LLUUID(); - } - - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - public Region(SecondLife client, LLUUID id, ulong handle, string name, float[] heightList, - LLUUID simOwner, LLUUID[] terrainImages, bool isEstateManager) - { - Client = client; - Estate = new EstateTools(client); - ID = id; - Handle = handle; - Name = name; - ParcelOverlay = new byte[4096]; - ParcelMarked = new int[64, 64]; - ParcelDownloading = false; - ParcelDwell = false; - - TerrainHeightRange00 = heightList[0]; - TerrainHeightRange01 = heightList[1]; - TerrainHeightRange10 = heightList[2]; - TerrainHeightRange11 = heightList[3]; - TerrainStartHeight00 = heightList[4]; - TerrainStartHeight01 = heightList[5]; - TerrainStartHeight10 = heightList[6]; - TerrainStartHeight11 = heightList[7]; - WaterHeight = heightList[8]; - - SimOwner = simOwner; - - TerrainBase0 = terrainImages[0]; - TerrainBase1 = terrainImages[1]; - TerrainBase2 = terrainImages[2]; - TerrainBase3 = terrainImages[3]; - TerrainDetail0 = terrainImages[4]; - TerrainDetail1 = terrainImages[5]; - TerrainDetail2 = terrainImages[6]; - TerrainDetail3 = terrainImages[7]; - - IsEstateManager = isEstateManager; - } - - /// - /// - /// - /// - /// - /// - /// - public void ParcelSubdivide(float west, float south, float east, float north) - { - ParcelDividePacket divide = new ParcelDividePacket(); - divide.AgentData.AgentID = Client.Network.AgentID; - divide.AgentData.SessionID = Client.Network.SessionID; - divide.ParcelData.East = east; - divide.ParcelData.North = north; - divide.ParcelData.South = south; - divide.ParcelData.West = west; - - // FIXME: Region needs a reference to it's parent Simulator - //Client.Network.SendPacket((Packet)divide, this.Simulator); - } - - /// - /// - /// - /// - /// - /// - /// - public void ParcelJoin(float west, float south, float east, float north) - { - ParcelJoinPacket join = new ParcelJoinPacket(); - join.AgentData.AgentID = Client.Network.AgentID; - join.AgentData.SessionID = Client.Network.SessionID; - join.ParcelData.East = east; - join.ParcelData.North = north; - join.ParcelData.South = south; - join.ParcelData.West = west; - - // FIXME: Region needs a reference to it's parent Simulator - //Client.Network.SendPacket((Packet)join, this.Simulator); - } - - /// - /// - /// - /// - /// - /// - public void RezObject(PrimObject prim, LLVector3 position, LLVector3 avatarPosition) - { - // FIXME: - //byte[] textureEntry = new byte[40]; - //Array.Copy(prim.Texture.Data, textureEntry, 16); - //textureEntry[35] = 0xe0; // No clue - - //Packet objectAdd = libsecondlife.Packets.Object.ObjectAdd(Client.Protocol, Client.Network.AgentID, - // LLUUID.GenerateUUID(), avatarPosition, - // position, prim, textureEntry); - //Client.Network.SendPacket(objectAdd); - } - - /// - /// - /// - public void FillParcels() - { - // Begins filling parcels - ParcelDownloading = true; - - ParcelPropertiesRequestPacket tPacket = new ParcelPropertiesRequestPacket(); - tPacket.AgentData.AgentID = Client.Avatar.ID; - tPacket.AgentData.SessionID = Client.Network.SessionID; - tPacket.ParcelData.SequenceID = -10000; - tPacket.ParcelData.West = 0.0f; - tPacket.ParcelData.South = 0.0f; - tPacket.ParcelData.East = 0.0f; - tPacket.ParcelData.North = 0.0f; - - Client.Network.SendPacket((Packet)tPacket); - } - - /// - /// - /// - public void ResetParcelDownload() - { - Parcels = new System.Collections.Hashtable(); - ParcelMarked = new int[64, 64]; - } - - /// - /// - /// - public void FilledParcels() - { - if (OnParcelCompletion != null) - { - OnParcelCompletion(this); - } - } - - /// - /// - /// - /// - public override int GetHashCode() - { - return ID.GetHashCode(); - } - - /// - /// - /// - /// - /// - public override bool Equals(object o) - { - if (!(o is Region)) - { - return false; - } - - Region region = (Region)o; - - return (region.ID == ID); - } - - /// - /// - /// - /// - /// - /// - public static bool operator ==(Region lhs, Region rhs) - { - try - { - return (lhs.ID == rhs.ID); - } - catch (NullReferenceException) - { - bool lhsnull = false; - bool rhsnull = false; - - if (lhs == null || lhs.ID == null || lhs.ID.Data == null || lhs.ID.Data.Length == 0) - { - lhsnull = true; - } - - if (rhs == null || rhs.ID == null || rhs.ID.Data == null || rhs.ID.Data.Length == 0) - { - rhsnull = true; - } - - return (lhsnull == rhsnull); - } - } - - /// - /// - /// - /// - /// - /// - public static bool operator !=(Region lhs, Region rhs) - { - return !(lhs == rhs); - } - } -} +/* + * Copyright (c) 2006, Second Life Reverse Engineering Team + * All rights reserved. + * + * - Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Neither the name of the Second Life Reverse Engineering Team nor the names + * of its contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using libsecondlife.Packets; + +namespace libsecondlife +{ + /// + /// + /// + /// + public delegate void ParcelCompleteCallback(Region region); + + /// + /// Represents a region (also known as a sim) in Second Life. + /// + public class Region + { + /// + public LLUUID ID; + /// + public ulong Handle; + /// + public string Name; + /// + public byte[] ParcelOverlay; + /// + public int ParcelOverlaysReceived; + + /// 64x64 Array of parcels which have been successfully downloaded. + /// (and their LocalID's, 0 = Null) + public int[,] ParcelMarked; + /// Flag to indicate whether we are downloading a sim's parcels. + public bool ParcelDownloading; + /// Flag to indicate whether to get Dwell values automatically (NOT USED YET). Call Parcel.GetDwell() instead. + public bool ParcelDwell; + + /// + public System.Collections.Hashtable Parcels; + /// + public System.Threading.Mutex ParcelsMutex; + + /// + public float TerrainHeightRange00; + /// + public float TerrainHeightRange01; + /// + public float TerrainHeightRange10; + /// + public float TerrainHeightRange11; + /// + public float TerrainStartHeight00; + /// + public float TerrainStartHeight01; + /// + public float TerrainStartHeight10; + /// + public float TerrainStartHeight11; + /// + public float WaterHeight; + + /// + public LLUUID SimOwner; + + /// + public LLUUID TerrainBase0; + /// + public LLUUID TerrainBase1; + /// + public LLUUID TerrainBase2; + /// + public LLUUID TerrainBase3; + /// + public LLUUID TerrainDetail0; + /// + public LLUUID TerrainDetail1; + /// + public LLUUID TerrainDetail2; + /// + public LLUUID TerrainDetail3; + + /// + public bool IsEstateManager; + /// + public EstateTools Estate; + + private SecondLife Client; + + /// + public event ParcelCompleteCallback OnParcelCompletion; + + /// + /// + /// + /// + public Region(SecondLife client) + { + Estate = new EstateTools(client); + Client = client; + ID = new LLUUID(); + ParcelOverlay = new byte[4096]; + ParcelMarked = new int[64, 64]; + + Parcels = new System.Collections.Hashtable(); + ParcelsMutex = new System.Threading.Mutex(false, "ParcelsMutex"); + + SimOwner = new LLUUID(); + TerrainBase0 = new LLUUID(); + TerrainBase1 = new LLUUID(); + TerrainBase2 = new LLUUID(); + TerrainBase3 = new LLUUID(); + TerrainDetail0 = new LLUUID(); + TerrainDetail1 = new LLUUID(); + TerrainDetail2 = new LLUUID(); + TerrainDetail3 = new LLUUID(); + } + + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public Region(SecondLife client, LLUUID id, ulong handle, string name, float[] heightList, + LLUUID simOwner, LLUUID[] terrainImages, bool isEstateManager) + { + Client = client; + Estate = new EstateTools(client); + ID = id; + Handle = handle; + Name = name; + ParcelOverlay = new byte[4096]; + ParcelMarked = new int[64, 64]; + ParcelDownloading = false; + ParcelDwell = false; + + TerrainHeightRange00 = heightList[0]; + TerrainHeightRange01 = heightList[1]; + TerrainHeightRange10 = heightList[2]; + TerrainHeightRange11 = heightList[3]; + TerrainStartHeight00 = heightList[4]; + TerrainStartHeight01 = heightList[5]; + TerrainStartHeight10 = heightList[6]; + TerrainStartHeight11 = heightList[7]; + WaterHeight = heightList[8]; + + SimOwner = simOwner; + + TerrainBase0 = terrainImages[0]; + TerrainBase1 = terrainImages[1]; + TerrainBase2 = terrainImages[2]; + TerrainBase3 = terrainImages[3]; + TerrainDetail0 = terrainImages[4]; + TerrainDetail1 = terrainImages[5]; + TerrainDetail2 = terrainImages[6]; + TerrainDetail3 = terrainImages[7]; + + IsEstateManager = isEstateManager; + } + + /// + /// + /// + /// + /// + /// + /// + public void ParcelSubdivide(float west, float south, float east, float north) + { + ParcelDividePacket divide = new ParcelDividePacket(); + divide.AgentData.AgentID = Client.Network.AgentID; + divide.AgentData.SessionID = Client.Network.SessionID; + divide.ParcelData.East = east; + divide.ParcelData.North = north; + divide.ParcelData.South = south; + divide.ParcelData.West = west; + + // FIXME: Region needs a reference to it's parent Simulator + //Client.Network.SendPacket((Packet)divide, this.Simulator); + } + + /// + /// + /// + /// + /// + /// + /// + public void ParcelJoin(float west, float south, float east, float north) + { + ParcelJoinPacket join = new ParcelJoinPacket(); + join.AgentData.AgentID = Client.Network.AgentID; + join.AgentData.SessionID = Client.Network.SessionID; + join.ParcelData.East = east; + join.ParcelData.North = north; + join.ParcelData.South = south; + join.ParcelData.West = west; + + // FIXME: Region needs a reference to it's parent Simulator + //Client.Network.SendPacket((Packet)join, this.Simulator); + } + + /// + /// + /// + /// + /// + /// + public void RezObject(PrimObject prim, LLVector3 position, LLVector3 avatarPosition) + { + // FIXME: + //byte[] textureEntry = new byte[40]; + //Array.Copy(prim.Texture.Data, textureEntry, 16); + //textureEntry[35] = 0xe0; // No clue + + //Packet objectAdd = libsecondlife.Packets.Object.ObjectAdd(Client.Protocol, Client.Network.AgentID, + // LLUUID.GenerateUUID(), avatarPosition, + // position, prim, textureEntry); + //Client.Network.SendPacket(objectAdd); + } + + /// + /// + /// + public void FillParcels() + { + // Begins filling parcels + ParcelDownloading = true; + + ParcelPropertiesRequestPacket tPacket = new ParcelPropertiesRequestPacket(); + tPacket.AgentData.AgentID = Client.Avatar.ID; + tPacket.AgentData.SessionID = Client.Network.SessionID; + tPacket.ParcelData.SequenceID = -10000; + tPacket.ParcelData.West = 0.0f; + tPacket.ParcelData.South = 0.0f; + tPacket.ParcelData.East = 0.0f; + tPacket.ParcelData.North = 0.0f; + + Client.Network.SendPacket((Packet)tPacket); + } + + /// + /// + /// + public void ResetParcelDownload() + { + Parcels = new System.Collections.Hashtable(); + ParcelMarked = new int[64, 64]; + } + + /// + /// + /// + public void FilledParcels() + { + if (OnParcelCompletion != null) + { + OnParcelCompletion(this); + } + } + + /// + /// + /// + /// + public override int GetHashCode() + { + return ID.GetHashCode(); + } + + /// + /// + /// + /// + /// + public override bool Equals(object o) + { + if (!(o is Region)) + { + return false; + } + + Region region = (Region)o; + + return (region.ID == ID); + } + + /// + /// + /// + /// + /// + /// + public static bool operator ==(Region lhs, Region rhs) + { + try + { + return (lhs.ID == rhs.ID); + } + catch (NullReferenceException) + { + bool lhsnull = false; + bool rhsnull = false; + + if (lhs == null || lhs.ID == null || lhs.ID.Data == null || lhs.ID.Data.Length == 0) + { + lhsnull = true; + } + + if (rhs == null || rhs.ID == null || rhs.ID.Data == null || rhs.ID.Data.Length == 0) + { + rhsnull = true; + } + + return (lhsnull == rhsnull); + } + } + + /// + /// + /// + /// + /// + /// + public static bool operator !=(Region lhs, Region rhs) + { + return !(lhs == rhs); + } + } +} diff --git a/libsecondlife-cs/SecondLife.cs b/libsecondlife-cs/SecondLife.cs index 48e510f3..ac9a2d96 100644 --- a/libsecondlife-cs/SecondLife.cs +++ b/libsecondlife-cs/SecondLife.cs @@ -1,592 +1,592 @@ -/* - * Copyright (c) 2006, Second Life Reverse Engineering Team - * All rights reserved. - * - * - Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - Neither the name of the Second Life Reverse Engineering Team nor the names - * of its contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections; -using System.Threading; -using libsecondlife.Packets; - -namespace libsecondlife -{ - /// - /// Callback used for client apps to receive log messages from - /// libsecondlife - /// - /// - /// - public delegate void LogCallback(string message, Helpers.LogLevel level); - - /// - /// Main class to expose Second Life functionality to clients. All of the - /// classes needed for sending and receiving data are accessible through - /// this class. - /// - public class SecondLife - { - public const string LOGIN_SERVER = "https://login.agni.lindenlab.com/cgi-bin/login.cgi"; - - /// - public NetworkManager Network; - /// - public ParcelManager Parcels; - /// - public MainAvatar Avatar; - /// - public Hashtable Avatars; - /// - public Mutex AvatarsMutex; - /// - public GridManager Grid; - /// - public ObjectManager Objects; - /// - public GroupManager Groups; - /// - public LogCallback OnLogMessage; - /// - public bool Debug; - - /// - /// - /// - public SecondLife() - { - Network = new NetworkManager(this); - Parcels = new ParcelManager(this); - Avatar = new MainAvatar(this); - Avatars = new Hashtable(); - AvatarsMutex = new Mutex(false, "AvatarsMutex"); - Grid = new GridManager(this); - Objects = new ObjectManager(this); - Groups = new GroupManager(this); - Debug = true; - - Network.RegisterCallback(PacketType.UUIDNameReply, new PacketCallback(GetAgentNameHandler)); - } - - /// - /// - /// - /// - public override string ToString() - { - return Avatar.FirstName + " " + Avatar.LastName; - } - - /// - /// A simple sleep function that will allow pending threads to run - /// - public void Tick() - { - System.Threading.Thread.Sleep(0); - } - - /// - /// Send a log message to the debugging output system - /// - /// The log message - /// From the LogLevel enum, either Info, Warning, or Error - public void Log(string message, Helpers.LogLevel level) - { - if (OnLogMessage != null) - { - ; - } - else - { - Console.WriteLine(level.ToString().ToUpper() + ": " + message); - } - } - - /// - /// If the library is compiled with DEBUG defined, and SecondLife.Debug - /// is true, either an event will be fired for the debug message or - /// it will be written to the console - /// - /// The debug message - [System.Diagnostics.Conditional("DEBUG")] - public void DebugLog(string message) - { - if (Debug) - { - if (OnLogMessage != null) - { - ; - } - else - { - Console.WriteLine("DEBUG: " + message); - } - } - } - - /// - /// - /// - /// - public void AddAvatar(LLUUID AgentID) - { - // Quick sanity check - if (Avatars.ContainsKey(AgentID)) - { - return; - } - - GetAgentDetails(AgentID); - - AvatarsMutex.WaitOne(); - Avatars[AgentID] = new Avatar(); - AvatarsMutex.ReleaseMutex(); - } - - /// - /// - /// - /// - public void AddAvatar(Avatar avatar) - { - AvatarsMutex.WaitOne(); - Avatars[avatar.ID] = avatar; - AvatarsMutex.ReleaseMutex(); - } - - /// - /// - /// - /// - private void GetAgentDetails(LLUUID AgentID) - { - //FIXME: - //Packet packet = Packets.Communication.UUIDNameRequest(Protocol, AgentID); - //Network.SendPacket(packet); - - //// TODO: Shouldn't this function block? - } - - /// - /// - /// - /// - /// - private void GetAgentNameHandler(Packet packet, Simulator simulator) - { - if (packet.Type == PacketType.UUIDNameReply) - { - UUIDNameReplyPacket reply = (UUIDNameReplyPacket)packet; - - #region AvatarsMutex - AvatarsMutex.WaitOne(); - foreach (UUIDNameReplyPacket.UUIDNameBlockBlock block in reply.UUIDNameBlock) - { - ((Avatar)Avatars[block.ID]).Name = Helpers.FieldToString(block.FirstName) + - " " + Helpers.FieldToString(block.LastName); - } - AvatarsMutex.ReleaseMutex(); - #endregion AvatarsMutex - } - } - } - - /// - /// Static helper functions and global variables - /// - public class Helpers - { - /// - public readonly static string VERSION = "libsecondlife 0.0.9"; - /// This header flag signals that ACKs are appended to the packet - public const byte MSG_APPENDED_ACKS = 0x10; - /// This header flag signals that this packet has been sent before - public const byte MSG_RESENT = 0x20; - /// This header flags signals that an ACK is expected for this packet - public const byte MSG_RELIABLE = 0x40; - /// This header flag signals that the message is compressed using zerocoding - public const byte MSG_ZEROCODED = 0x80; - - /// - /// Passed to SecondLife.Log() to identify the severity of a log entry - /// - public enum LogLevel - { - /// Non-noisy useful information, may be helpful in - /// debugging a problem - Info, - /// A non-critical error occurred. A warning will not - /// prevent the rest of libsecondlife from operating as usual, - /// although it may be indicative of an underlying issue - Warning, - /// A critical error has occurred. Generally this will - /// be followed by the network layer shutting down, although the - /// stability of libsecondlife after an error is uncertain - Error - }; - - /// - /// Packs to 32-bit unsigned integers in to a 64-bit unsigned integer - /// - /// The left-hand (or X) value - /// The right-hand (or Y) value - /// A 64-bit integer containing the two 32-bit input values - public static ulong UIntsToLong(uint a, uint b) - { - return (ulong)(((ulong)a << 32) + (ulong)b); - } - - /// - /// Unpacks two 32-bit unsigned integers from a 64-bit unsigned integer - /// - /// The 64-bit input integer - /// The left-hand (or X) output value - /// The right-hand (or Y) output value - public static void LongToUInts(ulong a, out uint b, out uint c) - { - b = (uint)(a >> 32); - c = (uint)(a & 0x00000000FFFFFFFF); - } - - /// - /// Convert a variable length field (byte array) to a string. - /// - /// If the byte array has unprintable characters in it, a - /// hex dump will be put in the string instead - /// The byte array to convert to a string - /// A UTF8 string, minus the null terminator - public static string FieldToString(byte[] bytes) - { - return FieldToString(bytes, ""); - } - - /// - /// Convert a variable length field (byte array) to a string, with a - /// field name prepended to each line of the output. - /// - /// If the byte array has unprintable characters in it, a - /// hex dump will be put in the string instead - /// The byte array to convert to a string - /// A field name to prepend to each line of output - /// A UTF8 string, minus the null terminator - public static string FieldToString(byte[] bytes, string fieldName) - { - string output = ""; - bool printable = true; - - for (int i = 0; i < bytes.Length; ++i) - { - // Check if there are any unprintable characters in the array - if ((bytes[i] < 0x20 || bytes[i] > 0x7E) && bytes[i] != 0x09 - && bytes[i] != 0x0D && bytes[i] != 0x0A && bytes[i] != 0x00) - { - printable = false; - break; - } - } - - if (printable) - { - if (fieldName.Length > 0) - { - output += fieldName + ": "; - } - - output += System.Text.Encoding.UTF8.GetString(bytes).Replace("\0", ""); - } - else - { - for (int i = 0; i < bytes.Length; i += 16) - { - if (i != 0) { output += "\n"; } - if (fieldName != "") { output += fieldName + ": "; } - - for (int j = 0; j < 16; j++) - { - if ((i + j) < bytes.Length) - { - string s = String.Format("{0:X} ", bytes[i + j]); - if (s.Length == 2) - { - s = "0" + s; - } - - output += s; - } - else - { - output += " "; - } - } - - for (int j = 0; j < 16 && (i + j) < bytes.Length; j++) - { - if (bytes[i + j] >= 0x20 && bytes[i + j] < 0x7E) - { - output += (char)bytes[i + j]; - } - else - { - output += "."; - } - } - } - } - - return output; - } - - /// - /// Convert a UTF8 string to a byte array - /// - /// The string to convert to a byte array - /// A null-terminated byte array - public static byte[] StringToField(string str) - { - if (!str.EndsWith("\0")) { str += "\0"; } - return System.Text.UTF8Encoding.UTF8.GetBytes(str); - } - - public static uint GetUnixTime() - { - TimeSpan ts = (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0)); - return (uint)ts.TotalSeconds; - } - - /// - /// Decode a zerocoded byte array, used to decompress packets marked - /// with the zerocoded flag - /// - /// Any time a zero is encountered, the next byte is a count - /// of how many zeroes to expand. One zero is encoded with 0x00 0x01, - /// two zeroes is 0x00 0x02, three zeroes is 0x00 0x03, etc. The - /// first four bytes are copied directly to the output buffer. - /// - /// The byte array to decode - /// The length of the byte array to decode - /// The output byte array to decode to - /// The length of the output buffer - public static int ZeroDecode(byte[] src, int srclen, byte[] dest) - { - uint zerolen = 0; - - Array.Copy(src, 0, dest, 0, 4); - zerolen += 4; - - //int bodylen; - //if ((src[0] & MSG_APPENDED_ACKS) == 0) - //{ - // bodylen = srclen; - //} - //else - //{ - // bodylen = srclen - src[srclen - 1] * 4 - 1; - //} - int bodylen = srclen; - - uint i; - for (i = zerolen; i < bodylen; i++) - { - if (src[i] == 0x00) - { - for (byte j = 0; j < src[i + 1]; j++) - { - dest[zerolen++] = 0x00; - } - - i++; - } - else - { - dest[zerolen++] = src[i]; - } - } - - // HACK: Fix truncated zerocoded messages - for (uint j = zerolen; j < zerolen + 16; j++) - { - dest[j] = 0; - } - zerolen += 16; - - // copy appended ACKs - for (; i < srclen; i++) - { - dest[zerolen++] = src[i]; - } - - return (int)zerolen; - } - - /// - /// Decode enough of a byte array to get the packet ID. Data before and - /// after the packet ID is undefined. - /// - /// The byte array to decode - /// The output byte array to encode to - public static void ZeroDecodeCommand(byte[] src, byte[] dest) - { - for (int srcPos = 4, destPos = 4; destPos < 8; ++srcPos) - { - if (src[srcPos] == 0x00) - { - for (byte j = 0; j < src[srcPos + 1]; ++j) - { - dest[destPos++] = 0x00; - } - - ++srcPos; - } - else - { - dest[destPos++] = src[srcPos]; - } - } - } - - /// - /// Encode a byte array with zerocoding. Used to compress packets marked - /// with the zerocoded flag. Any zeroes in the array are compressed down - /// to a single zero byte followed by a count of how many zeroes to expand - /// out. A single zero becomes 0x00 0x01, two zeroes becomes 0x00 0x02, - /// three zeroes becomes 0x00 0x03, etc. The first four bytes are copied - /// directly to the output buffer. - /// - /// The byte array to encode - /// The length of the byte array to encode - /// The output byte array to encode to - /// The length of the output buffer - public static int ZeroEncode(byte[] src, int srclen, byte[] dest) - { - uint zerolen = 0; - byte zerocount = 0; - - Array.Copy(src, 0, dest, 0, 4); - zerolen += 4; - - int bodylen; - if ((src[0] & MSG_APPENDED_ACKS) == 0) - { - bodylen = srclen; - } - else - { - bodylen = srclen - src[srclen - 1] * 4 - 1; - } - - uint i; - for (i = zerolen; i < bodylen; i++) - { - if (src[i] == 0x00) - { - zerocount++; - - if (zerocount == 0) - { - dest[zerolen++] = 0x00; - dest[zerolen++] = 0xff; - zerocount++; - } - } - else - { - if (zerocount != 0) - { - dest[zerolen++] = 0x00; - dest[zerolen++] = (byte)zerocount; - zerocount = 0; - } - - dest[zerolen++] = src[i]; - } - } - - if (zerocount != 0) - { - dest[zerolen++] = 0x00; - dest[zerolen++] = (byte)zerocount; - } - - // copy appended ACKs - for (; i < srclen; i++) - { - dest[zerolen++] = src[i]; - } - - return (int)zerolen; - } - - /// - /// Calculates the CRC (cyclic redundancy check) needed to upload inventory. - /// - /// Creation date - /// Sale type - /// Inventory type - /// Type - /// Asset ID - /// Group ID - /// Sale price - /// Owner ID - /// Creator ID - /// Item ID - /// Folder ID - /// Everyone mask (permissions) - /// Flags - /// Next owner mask (permissions) - /// Group mask (permissions) - /// Owner mask (permisions) - /// The calculated CRC - public static uint InventoryCRC(int creationDate, byte saleType, sbyte invType, sbyte type, - LLUUID assetID, LLUUID groupID, int salePrice, LLUUID ownerID, LLUUID creatorID, - LLUUID itemID, LLUUID folderID, uint everyoneMask, uint flags, uint nextOwnerMask, - uint groupMask, uint ownerMask) - { - uint CRC = 0; - - // IDs - CRC += assetID.CRC(); // AssetID - CRC += folderID.CRC(); // FolderID - CRC += itemID.CRC(); // ItemID - - // Permission stuff - CRC += creatorID.CRC(); // CreatorID - CRC += ownerID.CRC(); // OwnerID - CRC += groupID.CRC(); // GroupID - - // CRC += another 4 words which always seem to be zero -- unclear if this is a LLUUID or what - CRC += ownerMask; - CRC += nextOwnerMask; - CRC += everyoneMask; - CRC += groupMask; - - // The rest of the CRC fields - CRC += flags; // Flags - CRC += (uint)invType; // InvType - CRC += (uint)type; // Type - CRC += (uint)creationDate; // CreationDate - CRC += (uint)salePrice; // SalePrice - CRC += (uint)((uint)saleType * 0x07073096); // SaleType - - return CRC; - } - } -} +/* + * Copyright (c) 2006, Second Life Reverse Engineering Team + * All rights reserved. + * + * - Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Neither the name of the Second Life Reverse Engineering Team nor the names + * of its contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using System.Threading; +using libsecondlife.Packets; + +namespace libsecondlife +{ + /// + /// Callback used for client apps to receive log messages from + /// libsecondlife + /// + /// + /// + public delegate void LogCallback(string message, Helpers.LogLevel level); + + /// + /// Main class to expose Second Life functionality to clients. All of the + /// classes needed for sending and receiving data are accessible through + /// this class. + /// + public class SecondLife + { + public const string LOGIN_SERVER = "https://login.agni.lindenlab.com/cgi-bin/login.cgi"; + + /// + public NetworkManager Network; + /// + public ParcelManager Parcels; + /// + public MainAvatar Avatar; + /// + public Hashtable Avatars; + /// + public Mutex AvatarsMutex; + /// + public GridManager Grid; + /// + public ObjectManager Objects; + /// + public GroupManager Groups; + /// + public LogCallback OnLogMessage; + /// + public bool Debug; + + /// + /// + /// + public SecondLife() + { + Network = new NetworkManager(this); + Parcels = new ParcelManager(this); + Avatar = new MainAvatar(this); + Avatars = new Hashtable(); + AvatarsMutex = new Mutex(false, "AvatarsMutex"); + Grid = new GridManager(this); + Objects = new ObjectManager(this); + Groups = new GroupManager(this); + Debug = true; + + Network.RegisterCallback(PacketType.UUIDNameReply, new PacketCallback(GetAgentNameHandler)); + } + + /// + /// + /// + /// + public override string ToString() + { + return Avatar.FirstName + " " + Avatar.LastName; + } + + /// + /// A simple sleep function that will allow pending threads to run + /// + public void Tick() + { + System.Threading.Thread.Sleep(0); + } + + /// + /// Send a log message to the debugging output system + /// + /// The log message + /// From the LogLevel enum, either Info, Warning, or Error + public void Log(string message, Helpers.LogLevel level) + { + if (OnLogMessage != null) + { + ; + } + else + { + Console.WriteLine(level.ToString().ToUpper() + ": " + message); + } + } + + /// + /// If the library is compiled with DEBUG defined, and SecondLife.Debug + /// is true, either an event will be fired for the debug message or + /// it will be written to the console + /// + /// The debug message + [System.Diagnostics.Conditional("DEBUG")] + public void DebugLog(string message) + { + if (Debug) + { + if (OnLogMessage != null) + { + ; + } + else + { + Console.WriteLine("DEBUG: " + message); + } + } + } + + /// + /// + /// + /// + public void AddAvatar(LLUUID AgentID) + { + // Quick sanity check + if (Avatars.ContainsKey(AgentID)) + { + return; + } + + GetAgentDetails(AgentID); + + AvatarsMutex.WaitOne(); + Avatars[AgentID] = new Avatar(); + AvatarsMutex.ReleaseMutex(); + } + + /// + /// + /// + /// + public void AddAvatar(Avatar avatar) + { + AvatarsMutex.WaitOne(); + Avatars[avatar.ID] = avatar; + AvatarsMutex.ReleaseMutex(); + } + + /// + /// + /// + /// + private void GetAgentDetails(LLUUID AgentID) + { + //FIXME: + //Packet packet = Packets.Communication.UUIDNameRequest(Protocol, AgentID); + //Network.SendPacket(packet); + + //// TODO: Shouldn't this function block? + } + + /// + /// + /// + /// + /// + private void GetAgentNameHandler(Packet packet, Simulator simulator) + { + if (packet.Type == PacketType.UUIDNameReply) + { + UUIDNameReplyPacket reply = (UUIDNameReplyPacket)packet; + + #region AvatarsMutex + AvatarsMutex.WaitOne(); + foreach (UUIDNameReplyPacket.UUIDNameBlockBlock block in reply.UUIDNameBlock) + { + ((Avatar)Avatars[block.ID]).Name = Helpers.FieldToString(block.FirstName) + + " " + Helpers.FieldToString(block.LastName); + } + AvatarsMutex.ReleaseMutex(); + #endregion AvatarsMutex + } + } + } + + /// + /// Static helper functions and global variables + /// + public class Helpers + { + /// + public readonly static string VERSION = "libsecondlife 0.0.9"; + /// This header flag signals that ACKs are appended to the packet + public const byte MSG_APPENDED_ACKS = 0x10; + /// This header flag signals that this packet has been sent before + public const byte MSG_RESENT = 0x20; + /// This header flags signals that an ACK is expected for this packet + public const byte MSG_RELIABLE = 0x40; + /// This header flag signals that the message is compressed using zerocoding + public const byte MSG_ZEROCODED = 0x80; + + /// + /// Passed to SecondLife.Log() to identify the severity of a log entry + /// + public enum LogLevel + { + /// Non-noisy useful information, may be helpful in + /// debugging a problem + Info, + /// A non-critical error occurred. A warning will not + /// prevent the rest of libsecondlife from operating as usual, + /// although it may be indicative of an underlying issue + Warning, + /// A critical error has occurred. Generally this will + /// be followed by the network layer shutting down, although the + /// stability of libsecondlife after an error is uncertain + Error + }; + + /// + /// Packs to 32-bit unsigned integers in to a 64-bit unsigned integer + /// + /// The left-hand (or X) value + /// The right-hand (or Y) value + /// A 64-bit integer containing the two 32-bit input values + public static ulong UIntsToLong(uint a, uint b) + { + return (ulong)(((ulong)a << 32) + (ulong)b); + } + + /// + /// Unpacks two 32-bit unsigned integers from a 64-bit unsigned integer + /// + /// The 64-bit input integer + /// The left-hand (or X) output value + /// The right-hand (or Y) output value + public static void LongToUInts(ulong a, out uint b, out uint c) + { + b = (uint)(a >> 32); + c = (uint)(a & 0x00000000FFFFFFFF); + } + + /// + /// Convert a variable length field (byte array) to a string. + /// + /// If the byte array has unprintable characters in it, a + /// hex dump will be put in the string instead + /// The byte array to convert to a string + /// A UTF8 string, minus the null terminator + public static string FieldToString(byte[] bytes) + { + return FieldToString(bytes, ""); + } + + /// + /// Convert a variable length field (byte array) to a string, with a + /// field name prepended to each line of the output. + /// + /// If the byte array has unprintable characters in it, a + /// hex dump will be put in the string instead + /// The byte array to convert to a string + /// A field name to prepend to each line of output + /// A UTF8 string, minus the null terminator + public static string FieldToString(byte[] bytes, string fieldName) + { + string output = ""; + bool printable = true; + + for (int i = 0; i < bytes.Length; ++i) + { + // Check if there are any unprintable characters in the array + if ((bytes[i] < 0x20 || bytes[i] > 0x7E) && bytes[i] != 0x09 + && bytes[i] != 0x0D && bytes[i] != 0x0A && bytes[i] != 0x00) + { + printable = false; + break; + } + } + + if (printable) + { + if (fieldName.Length > 0) + { + output += fieldName + ": "; + } + + output += System.Text.Encoding.UTF8.GetString(bytes).Replace("\0", ""); + } + else + { + for (int i = 0; i < bytes.Length; i += 16) + { + if (i != 0) { output += "\n"; } + if (fieldName != "") { output += fieldName + ": "; } + + for (int j = 0; j < 16; j++) + { + if ((i + j) < bytes.Length) + { + string s = String.Format("{0:X} ", bytes[i + j]); + if (s.Length == 2) + { + s = "0" + s; + } + + output += s; + } + else + { + output += " "; + } + } + + for (int j = 0; j < 16 && (i + j) < bytes.Length; j++) + { + if (bytes[i + j] >= 0x20 && bytes[i + j] < 0x7E) + { + output += (char)bytes[i + j]; + } + else + { + output += "."; + } + } + } + } + + return output; + } + + /// + /// Convert a UTF8 string to a byte array + /// + /// The string to convert to a byte array + /// A null-terminated byte array + public static byte[] StringToField(string str) + { + if (!str.EndsWith("\0")) { str += "\0"; } + return System.Text.UTF8Encoding.UTF8.GetBytes(str); + } + + public static uint GetUnixTime() + { + TimeSpan ts = (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0)); + return (uint)ts.TotalSeconds; + } + + /// + /// Decode a zerocoded byte array, used to decompress packets marked + /// with the zerocoded flag + /// + /// Any time a zero is encountered, the next byte is a count + /// of how many zeroes to expand. One zero is encoded with 0x00 0x01, + /// two zeroes is 0x00 0x02, three zeroes is 0x00 0x03, etc. The + /// first four bytes are copied directly to the output buffer. + /// + /// The byte array to decode + /// The length of the byte array to decode + /// The output byte array to decode to + /// The length of the output buffer + public static int ZeroDecode(byte[] src, int srclen, byte[] dest) + { + uint zerolen = 0; + + Array.Copy(src, 0, dest, 0, 4); + zerolen += 4; + + //int bodylen; + //if ((src[0] & MSG_APPENDED_ACKS) == 0) + //{ + // bodylen = srclen; + //} + //else + //{ + // bodylen = srclen - src[srclen - 1] * 4 - 1; + //} + int bodylen = srclen; + + uint i; + for (i = zerolen; i < bodylen; i++) + { + if (src[i] == 0x00) + { + for (byte j = 0; j < src[i + 1]; j++) + { + dest[zerolen++] = 0x00; + } + + i++; + } + else + { + dest[zerolen++] = src[i]; + } + } + + // HACK: Fix truncated zerocoded messages + for (uint j = zerolen; j < zerolen + 16; j++) + { + dest[j] = 0; + } + zerolen += 16; + + // copy appended ACKs + for (; i < srclen; i++) + { + dest[zerolen++] = src[i]; + } + + return (int)zerolen; + } + + /// + /// Decode enough of a byte array to get the packet ID. Data before and + /// after the packet ID is undefined. + /// + /// The byte array to decode + /// The output byte array to encode to + public static void ZeroDecodeCommand(byte[] src, byte[] dest) + { + for (int srcPos = 4, destPos = 4; destPos < 8; ++srcPos) + { + if (src[srcPos] == 0x00) + { + for (byte j = 0; j < src[srcPos + 1]; ++j) + { + dest[destPos++] = 0x00; + } + + ++srcPos; + } + else + { + dest[destPos++] = src[srcPos]; + } + } + } + + /// + /// Encode a byte array with zerocoding. Used to compress packets marked + /// with the zerocoded flag. Any zeroes in the array are compressed down + /// to a single zero byte followed by a count of how many zeroes to expand + /// out. A single zero becomes 0x00 0x01, two zeroes becomes 0x00 0x02, + /// three zeroes becomes 0x00 0x03, etc. The first four bytes are copied + /// directly to the output buffer. + /// + /// The byte array to encode + /// The length of the byte array to encode + /// The output byte array to encode to + /// The length of the output buffer + public static int ZeroEncode(byte[] src, int srclen, byte[] dest) + { + uint zerolen = 0; + byte zerocount = 0; + + Array.Copy(src, 0, dest, 0, 4); + zerolen += 4; + + int bodylen; + if ((src[0] & MSG_APPENDED_ACKS) == 0) + { + bodylen = srclen; + } + else + { + bodylen = srclen - src[srclen - 1] * 4 - 1; + } + + uint i; + for (i = zerolen; i < bodylen; i++) + { + if (src[i] == 0x00) + { + zerocount++; + + if (zerocount == 0) + { + dest[zerolen++] = 0x00; + dest[zerolen++] = 0xff; + zerocount++; + } + } + else + { + if (zerocount != 0) + { + dest[zerolen++] = 0x00; + dest[zerolen++] = (byte)zerocount; + zerocount = 0; + } + + dest[zerolen++] = src[i]; + } + } + + if (zerocount != 0) + { + dest[zerolen++] = 0x00; + dest[zerolen++] = (byte)zerocount; + } + + // copy appended ACKs + for (; i < srclen; i++) + { + dest[zerolen++] = src[i]; + } + + return (int)zerolen; + } + + /// + /// Calculates the CRC (cyclic redundancy check) needed to upload inventory. + /// + /// Creation date + /// Sale type + /// Inventory type + /// Type + /// Asset ID + /// Group ID + /// Sale price + /// Owner ID + /// Creator ID + /// Item ID + /// Folder ID + /// Everyone mask (permissions) + /// Flags + /// Next owner mask (permissions) + /// Group mask (permissions) + /// Owner mask (permisions) + /// The calculated CRC + public static uint InventoryCRC(int creationDate, byte saleType, sbyte invType, sbyte type, + LLUUID assetID, LLUUID groupID, int salePrice, LLUUID ownerID, LLUUID creatorID, + LLUUID itemID, LLUUID folderID, uint everyoneMask, uint flags, uint nextOwnerMask, + uint groupMask, uint ownerMask) + { + uint CRC = 0; + + // IDs + CRC += assetID.CRC(); // AssetID + CRC += folderID.CRC(); // FolderID + CRC += itemID.CRC(); // ItemID + + // Permission stuff + CRC += creatorID.CRC(); // CreatorID + CRC += ownerID.CRC(); // OwnerID + CRC += groupID.CRC(); // GroupID + + // CRC += another 4 words which always seem to be zero -- unclear if this is a LLUUID or what + CRC += ownerMask; + CRC += nextOwnerMask; + CRC += everyoneMask; + CRC += groupMask; + + // The rest of the CRC fields + CRC += flags; // Flags + CRC += (uint)invType; // InvType + CRC += (uint)type; // Type + CRC += (uint)creationDate; // CreationDate + CRC += (uint)salePrice; // SalePrice + CRC += (uint)((uint)saleType * 0x07073096); // SaleType + + return CRC; + } + } +} diff --git a/libsecondlife-cs/Types.cs b/libsecondlife-cs/Types.cs index cf303e23..d8b589c1 100644 --- a/libsecondlife-cs/Types.cs +++ b/libsecondlife-cs/Types.cs @@ -1,780 +1,780 @@ -/* - * Copyright (c) 2006, Second Life Reverse Engineering Team - * All rights reserved. - * - * - Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - Neither the name of the Second Life Reverse Engineering Team nor the names - * of its contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Net; - -namespace libsecondlife -{ - /*public class U64 - { - public uint[] Data; - - public U64() - { - Data = new uint[2]; - Data[0] = 0; - Data[1] = 1; - } - - public U64(uint left, uint right) - { - Data = new uint[2]; - // "backwards", due to little-endian ordering - Data[0] = right; - Data[1] = left; - } - - public U64(int left, int right) - { - Data = new uint[2]; - // "backwards", due to little-endian ordering - Data[0] = (uint)right; - Data[1] = (uint)left; - } - - public U64(byte[] bA, int pos) - { - Data = new uint[2]; - Data[0] = (uint)(bA[pos] + (bA[pos+1]<<8) + (bA[pos+2]<<16) + (bA[pos+3]<<24)); - Data[1] = (uint)(bA[pos+4] + (bA[pos+5]<<8) + (bA[pos+6]<<16) + (bA[pos+7]<<24)); - } - - public byte[] GetBytes() - { - byte[] bA = new byte[8]; - - bA[0]=(byte)((Data[0]) %256); bA[1]=(byte)((Data[0]>>8) %256); - bA[2]=(byte)((Data[0]>>16)%256); bA[3]=(byte)((Data[0]>>24)%256); - bA[4]=(byte)((Data[1]) %256); bA[5]=(byte)((Data[1]>>8) %256); - bA[6]=(byte)((Data[1]>>16)%256); bA[7]=(byte)((Data[1]>>24)%256); - - return bA; - } - - public override int GetHashCode() - { - return (int)(Data[0] ^ Data[1]); - } - - public override bool Equals(object o) - { - if (!(o is U64)) return false; - - U64 u64 = (U64)o; - - return (u64.Data[0] == Data[0] && u64.Data[1] == Data[1]); - } - - public static bool operator==(U64 lhs, U64 rhs) - { - if(object.ReferenceEquals(lhs, rhs)) return true; - if(object.ReferenceEquals(lhs, null)) return false; - if(object.ReferenceEquals(rhs, null)) return false; - - return (lhs.Data[0] == rhs.Data[0] && lhs.Data[1] == rhs.Data[1]); - } - - public static bool operator!=(U64 lhs, U64 rhs) - { - return !(lhs == rhs); - } - - public static bool operator==(U64 lhs, int rhs) - { - if(object.ReferenceEquals(lhs, null)) return (rhs == 0); - return (lhs.Data[0] == 0 && lhs.Data[1] == rhs); - } - - public static bool operator!=(U64 lhs, int rhs) - { - return !(lhs == rhs); - } - - public override string ToString() - { - ulong u64 = (Data[1] << 32) + Data[0]; - return u64.ToString(); - } - }*/ - - /// - /// - /// - public class LLUUID - { - /// - public byte[] Data - { - get { return data; } - } - - private byte[] data = null; - - /// - /// - /// - public LLUUID() - { - data = new byte[16]; - } - - /// - /// - /// - /// - public LLUUID(string val) - { - data = new byte[16]; - - if (val.Length == 36) val = val.Replace("-", ""); - - if (val.Length != 32) return; - - for(int i = 0; i < 16; ++i) - { - data[i] = Convert.ToByte(val.Substring(i * 2, 2), 16); - } - } - - /// - /// - /// - /// - /// - public LLUUID(byte[] byteArray, int pos) - { - data = new byte[16]; - - Array.Copy(byteArray, pos, data, 0, 16); - } - - /// - /// - /// - /// - public LLUUID(bool randomize) - { - if (randomize) data = Guid.NewGuid().ToByteArray(); - else data = new byte[16]; - } - - /// - /// - /// - /// - public byte[] GetBytes() - { - return Data; - } - - /// - /// Calculate an LLCRC (cyclic redundancy check) for this LLUUID - /// - /// The CRC checksum for this LLUUID - public uint CRC() - { - uint retval = 0; - - retval += (uint)((Data[3] << 24) + (Data[2] << 16) + (Data[1] << 8) + Data[0]); - retval += (uint)((Data[7] << 24) + (Data[6] << 16) + (Data[5] << 8) + Data[4]); - retval += (uint)((Data[11] << 24) + (Data[10] << 16) + (Data[9] << 8) + Data[8]); - retval += (uint)((Data[15] << 24) + (Data[14] << 16) + (Data[13] << 8) + Data[12]); - - return retval; - } - - /// - /// - /// - /// - public static LLUUID GenerateUUID() - { - return new LLUUID(Guid.NewGuid().ToByteArray(), 0); - } - - /// - /// - /// - /// - public override int GetHashCode() - { - return ToString().GetHashCode(); - } - - /// - /// - /// - /// - /// - public override bool Equals(object o) - { - if (!(o is LLUUID)) return false; - - LLUUID uuid = (LLUUID)o; - - for (int i = 0; i < 16; ++i) - { - if (Data[i] != uuid.Data[i]) return false; - } - - return true; - } - - /// - /// - /// - /// - /// - /// - public static bool operator==(LLUUID lhs, LLUUID rhs) - { - if(object.ReferenceEquals(lhs, rhs)) return true; - if(object.ReferenceEquals(lhs, null)) return false; - if(object.ReferenceEquals(rhs, null)) return false; - - for (int i = 0; i < 16; ++i) - { - if (lhs.Data[i] != rhs.Data[i]) return false; - } - - return true; - } - - /// - /// - /// - /// - /// - /// - public static bool operator!=(LLUUID lhs, LLUUID rhs) - { - return !(lhs == rhs); - } - - /// - /// - /// - /// - /// - public static implicit operator LLUUID(string val) - { - return new LLUUID(val); - } - - /// - /// - /// - /// - public override string ToString() - { - string uuid = ""; - - for (int i = 0; i < 16; ++i) - { - uuid += Data[i].ToString("x2"); - } - - return uuid; - } - - /// - /// - /// - /// - public string ToStringHyphenated() - { - string uuid = ""; - - for (int i = 0; i < 16; ++i) - { - uuid += Data[i].ToString("x2"); - - } - uuid = uuid.Insert(20,"-"); - uuid = uuid.Insert(16,"-"); - uuid = uuid.Insert(12,"-"); - uuid = uuid.Insert(8,"-"); - - - return uuid; - } - } - - /// - /// - /// - public class LLVector3 - { - /// - public float X; - /// - public float Y; - /// - public float Z; - - /// - /// - /// - public LLVector3() - { - X = Y = Z = 0.0F; - } - - /// - /// - /// - /// - public LLVector3(LLVector3d vector) - { - X = (float)vector.X; - Y = (float)vector.Y; - Z = (float)vector.Z; - } - - /// - /// - /// - /// - /// - public LLVector3(byte[] byteArray, int pos) - { - if(!BitConverter.IsLittleEndian) - { - Array.Reverse(byteArray, pos, 4); - Array.Reverse(byteArray, pos + 4, 4); - Array.Reverse(byteArray, pos + 8, 4); - } - - X = BitConverter.ToSingle(byteArray, pos); - Y = BitConverter.ToSingle(byteArray, pos + 4); - Z = BitConverter.ToSingle(byteArray, pos + 8); - } - - /// - /// - /// - /// - /// - /// - public LLVector3(float x, float y, float z) - { - X = x; - Y = y; - Z = z; - } - - /// - /// - /// - /// - public byte[] GetBytes() - { - byte[] byteArray = new byte[12]; - - Array.Copy(BitConverter.GetBytes(X), 0, byteArray, 0, 4); - Array.Copy(BitConverter.GetBytes(Y), 0, byteArray, 4, 4); - Array.Copy(BitConverter.GetBytes(Z), 0, byteArray, 8, 4); - - if(!BitConverter.IsLittleEndian) { - Array.Reverse(byteArray, 0, 4); - Array.Reverse(byteArray, 4, 4); - Array.Reverse(byteArray, 8, 4); - } - - return byteArray; - } - - /// - /// - /// - /// - public override string ToString() - { - return X.ToString() + " " + Y.ToString() + " " + Z.ToString(); - } - - /// - /// - /// - /// - public override int GetHashCode() - { - int x = (int)X; - int y = (int)Y; - int z = (int)Z; - - return (x ^ y ^ z); - } - - /// - /// - /// - /// - /// - public override bool Equals(object o) - { - if (!(o is LLVector3)) return false; - - LLVector3 vector = (LLVector3)o; - - return (X == vector.X && Y == vector.Y && Z == vector.Z); - } - - /// - /// - /// - /// - /// - /// - public static bool operator==(LLVector3 lhs, LLVector3 rhs) - { - if(object.ReferenceEquals(lhs, rhs)) return true; - if(object.ReferenceEquals(lhs, null)) return false; - if(object.ReferenceEquals(rhs, null)) return false; - - return (lhs.X == rhs.X && lhs.Y == rhs.Y && lhs.Z == rhs.Z); - } - - /// - /// - /// - /// - /// - /// - public static bool operator!=(LLVector3 lhs, LLVector3 rhs) - { - return !(lhs == rhs); - } - - /// - /// - /// - /// - /// - /// - public static LLVector3 operator -(LLVector3 lhs, LLVector3 rhs) - { - return new LLVector3(lhs.X - rhs.X,lhs.Y - rhs.Y, lhs.Z - rhs.Z); - } - } - - /// - /// - /// - public class LLVector3d - { - /// - public double X; - /// - public double Y; - /// - public double Z; - - /// - /// - /// - public LLVector3d() - { - X = Y = Z = 0.0D; - } - - /// - /// - /// - /// - /// - /// - public LLVector3d(double x, double y, double z) - { - X = x; - Y = y; - Z = z; - } - - /// - /// - /// - /// - /// - public LLVector3d(byte[] byteArray, int pos) - { - if(!BitConverter.IsLittleEndian) { - Array.Reverse(byteArray, pos, 8); - Array.Reverse(byteArray, pos + 8, 8); - Array.Reverse(byteArray, pos + 16, 8); - } - - X = BitConverter.ToDouble(byteArray, pos); - Y = BitConverter.ToDouble(byteArray, pos + 8); - Z = BitConverter.ToDouble(byteArray, pos + 16); - } - - /// - /// - /// - /// - public byte[] GetBytes() - { - byte[] byteArray = new byte[24]; - - Array.Copy(BitConverter.GetBytes(X), 0, byteArray, 0, 8); - Array.Copy(BitConverter.GetBytes(Y), 0, byteArray, 8, 8); - Array.Copy(BitConverter.GetBytes(Z), 0, byteArray, 16, 8); - - if(!BitConverter.IsLittleEndian) { - Array.Reverse(byteArray, 0, 8); - Array.Reverse(byteArray, 8, 8); - Array.Reverse(byteArray, 16, 8); - } - - return byteArray; - } - - /// - /// - /// - /// - public override string ToString() - { - return X.ToString() + " " + Y.ToString() + " " + Z.ToString(); - } - } - - /// - /// - /// - public class LLVector4 - { - /// - public float X; - /// - public float Y; - /// - public float Z; - /// - public float S; - - /// - /// - /// - public LLVector4() - { - X = Y = Z = S = 0.0F; - } - - /// - /// - /// - /// - /// - public LLVector4(byte[] byteArray, int pos) - { - if(!BitConverter.IsLittleEndian) { - Array.Reverse(byteArray, pos, 4); - Array.Reverse(byteArray, pos + 4, 4); - Array.Reverse(byteArray, pos + 8, 4); - Array.Reverse(byteArray, pos + 12, 4); - } - - X = BitConverter.ToSingle(byteArray, pos); - Y = BitConverter.ToSingle(byteArray, pos + 4); - Z = BitConverter.ToSingle(byteArray, pos + 8); - S = BitConverter.ToSingle(byteArray, pos + 12); - } - - /// - /// - /// - /// - public byte[] GetBytes() - { - byte[] byteArray = new byte[16]; - - Array.Copy(BitConverter.GetBytes(X), 0, byteArray, 0, 4); - Array.Copy(BitConverter.GetBytes(Y), 0, byteArray, 4, 4); - Array.Copy(BitConverter.GetBytes(Z), 0, byteArray, 8, 4); - Array.Copy(BitConverter.GetBytes(S), 0, byteArray, 12, 4); - - if(!BitConverter.IsLittleEndian) { - Array.Reverse(byteArray, 0, 4); - Array.Reverse(byteArray, 4, 4); - Array.Reverse(byteArray, 8, 4); - Array.Reverse(byteArray, 12, 4); - } - - return byteArray; - } - - /// - /// - /// - /// - public override string ToString() - { - return X.ToString() + " " + Y.ToString() + " " + Z.ToString() + " " + S.ToString(); - } - } - - /// - /// - /// - public class LLQuaternion - { - /// - public float X; - /// - public float Y; - /// - public float Z; - /// - public float W; - - /// - /// - /// - public LLQuaternion() - { - X = Y = Z = 0.0f; - W = 1.0f; - } - - /// - /// Build a quaternion object from a byte array - /// - /// The source byte array - /// Offset in the byte array to start reading at - /// Whether the source data is normalized or - /// not. If this is true 12 bytes will be read, otherwise 16 bytes will - /// be read. - public LLQuaternion(byte[] byteArray, int pos, bool normalized) - { - if (!normalized) - { - if (!BitConverter.IsLittleEndian) - { - Array.Reverse(byteArray, pos, 4); - Array.Reverse(byteArray, pos + 4, 4); - Array.Reverse(byteArray, pos + 8, 4); - Array.Reverse(byteArray, pos + 12, 4); - } - - X = BitConverter.ToSingle(byteArray, pos); - Y = BitConverter.ToSingle(byteArray, pos + 4); - Z = BitConverter.ToSingle(byteArray, pos + 8); - W = BitConverter.ToSingle(byteArray, pos + 12); - } - else - { - if (!BitConverter.IsLittleEndian) - { - Array.Reverse(byteArray, pos, 4); - Array.Reverse(byteArray, pos + 4, 4); - Array.Reverse(byteArray, pos + 8, 4); - } - - X = BitConverter.ToSingle(byteArray, pos); - Y = BitConverter.ToSingle(byteArray, pos + 4); - Z = BitConverter.ToSingle(byteArray, pos + 8); - - float xyzsum = 1 - X * X - Y * Y - Z * Z; - W = (xyzsum > 0) ? (float)Math.Sqrt(xyzsum) : 0; - } - } - - /// - /// - /// - /// - /// - /// - /// - public LLQuaternion(float x, float y, float z, float w) - { - X = x; - Y = y; - Z = z; - W = w; - } - - /// - /// - /// - /// - public byte[] GetBytes() - { - //byte[] byteArray = new byte[16]; - - //Array.Copy(BitConverter.GetBytes(X), 0, byteArray, 0, 4); - //Array.Copy(BitConverter.GetBytes(Y), 0, byteArray, 4, 4); - //Array.Copy(BitConverter.GetBytes(Z), 0, byteArray, 8, 4); - //Array.Copy(BitConverter.GetBytes(W), 0, byteArray, 12, 4); - - //if(!BitConverter.IsLittleEndian) { - // Array.Reverse(byteArray, 0, 4); - // Array.Reverse(byteArray, 4, 4); - // Array.Reverse(byteArray, 8, 4); - // Array.Reverse(byteArray, 12, 4); - //} - - byte[] bytes = new byte[12]; - float norm; - - norm = (float)Math.Sqrt(X*X + Y*Y + Z*Z + W*W); - - if (norm != 0) - { - norm = 1 / norm; - - Array.Copy(BitConverter.GetBytes(norm * X), 0, bytes, 0, 4); - Array.Copy(BitConverter.GetBytes(norm * Y), 0, bytes, 4, 4); - Array.Copy(BitConverter.GetBytes(norm * Z), 0, bytes, 8, 4); - - if (!BitConverter.IsLittleEndian) - { - Array.Reverse(bytes, 0, 4); - Array.Reverse(bytes, 4, 4); - Array.Reverse(bytes, 8, 4); - } - } - else - { - throw new Exception("Quaternion <" + X + "," + Y + "," + Z + "," + W + "> normalized to zero"); - } - - return bytes; - } - - /// - /// - /// - /// - public override string ToString() - { - return X.ToString() + " " + Y.ToString() + " " + Z.ToString() + " " + W.ToString(); - } - } -} +/* + * Copyright (c) 2006, Second Life Reverse Engineering Team + * All rights reserved. + * + * - Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Neither the name of the Second Life Reverse Engineering Team nor the names + * of its contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Net; + +namespace libsecondlife +{ + /*public class U64 + { + public uint[] Data; + + public U64() + { + Data = new uint[2]; + Data[0] = 0; + Data[1] = 1; + } + + public U64(uint left, uint right) + { + Data = new uint[2]; + // "backwards", due to little-endian ordering + Data[0] = right; + Data[1] = left; + } + + public U64(int left, int right) + { + Data = new uint[2]; + // "backwards", due to little-endian ordering + Data[0] = (uint)right; + Data[1] = (uint)left; + } + + public U64(byte[] bA, int pos) + { + Data = new uint[2]; + Data[0] = (uint)(bA[pos] + (bA[pos+1]<<8) + (bA[pos+2]<<16) + (bA[pos+3]<<24)); + Data[1] = (uint)(bA[pos+4] + (bA[pos+5]<<8) + (bA[pos+6]<<16) + (bA[pos+7]<<24)); + } + + public byte[] GetBytes() + { + byte[] bA = new byte[8]; + + bA[0]=(byte)((Data[0]) %256); bA[1]=(byte)((Data[0]>>8) %256); + bA[2]=(byte)((Data[0]>>16)%256); bA[3]=(byte)((Data[0]>>24)%256); + bA[4]=(byte)((Data[1]) %256); bA[5]=(byte)((Data[1]>>8) %256); + bA[6]=(byte)((Data[1]>>16)%256); bA[7]=(byte)((Data[1]>>24)%256); + + return bA; + } + + public override int GetHashCode() + { + return (int)(Data[0] ^ Data[1]); + } + + public override bool Equals(object o) + { + if (!(o is U64)) return false; + + U64 u64 = (U64)o; + + return (u64.Data[0] == Data[0] && u64.Data[1] == Data[1]); + } + + public static bool operator==(U64 lhs, U64 rhs) + { + if(object.ReferenceEquals(lhs, rhs)) return true; + if(object.ReferenceEquals(lhs, null)) return false; + if(object.ReferenceEquals(rhs, null)) return false; + + return (lhs.Data[0] == rhs.Data[0] && lhs.Data[1] == rhs.Data[1]); + } + + public static bool operator!=(U64 lhs, U64 rhs) + { + return !(lhs == rhs); + } + + public static bool operator==(U64 lhs, int rhs) + { + if(object.ReferenceEquals(lhs, null)) return (rhs == 0); + return (lhs.Data[0] == 0 && lhs.Data[1] == rhs); + } + + public static bool operator!=(U64 lhs, int rhs) + { + return !(lhs == rhs); + } + + public override string ToString() + { + ulong u64 = (Data[1] << 32) + Data[0]; + return u64.ToString(); + } + }*/ + + /// + /// + /// + public class LLUUID + { + /// + public byte[] Data + { + get { return data; } + } + + private byte[] data = null; + + /// + /// + /// + public LLUUID() + { + data = new byte[16]; + } + + /// + /// + /// + /// + public LLUUID(string val) + { + data = new byte[16]; + + if (val.Length == 36) val = val.Replace("-", ""); + + if (val.Length != 32) return; + + for(int i = 0; i < 16; ++i) + { + data[i] = Convert.ToByte(val.Substring(i * 2, 2), 16); + } + } + + /// + /// + /// + /// + /// + public LLUUID(byte[] byteArray, int pos) + { + data = new byte[16]; + + Array.Copy(byteArray, pos, data, 0, 16); + } + + /// + /// + /// + /// + public LLUUID(bool randomize) + { + if (randomize) data = Guid.NewGuid().ToByteArray(); + else data = new byte[16]; + } + + /// + /// + /// + /// + public byte[] GetBytes() + { + return Data; + } + + /// + /// Calculate an LLCRC (cyclic redundancy check) for this LLUUID + /// + /// The CRC checksum for this LLUUID + public uint CRC() + { + uint retval = 0; + + retval += (uint)((Data[3] << 24) + (Data[2] << 16) + (Data[1] << 8) + Data[0]); + retval += (uint)((Data[7] << 24) + (Data[6] << 16) + (Data[5] << 8) + Data[4]); + retval += (uint)((Data[11] << 24) + (Data[10] << 16) + (Data[9] << 8) + Data[8]); + retval += (uint)((Data[15] << 24) + (Data[14] << 16) + (Data[13] << 8) + Data[12]); + + return retval; + } + + /// + /// + /// + /// + public static LLUUID GenerateUUID() + { + return new LLUUID(Guid.NewGuid().ToByteArray(), 0); + } + + /// + /// + /// + /// + public override int GetHashCode() + { + return ToString().GetHashCode(); + } + + /// + /// + /// + /// + /// + public override bool Equals(object o) + { + if (!(o is LLUUID)) return false; + + LLUUID uuid = (LLUUID)o; + + for (int i = 0; i < 16; ++i) + { + if (Data[i] != uuid.Data[i]) return false; + } + + return true; + } + + /// + /// + /// + /// + /// + /// + public static bool operator==(LLUUID lhs, LLUUID rhs) + { + if(object.ReferenceEquals(lhs, rhs)) return true; + if(object.ReferenceEquals(lhs, null)) return false; + if(object.ReferenceEquals(rhs, null)) return false; + + for (int i = 0; i < 16; ++i) + { + if (lhs.Data[i] != rhs.Data[i]) return false; + } + + return true; + } + + /// + /// + /// + /// + /// + /// + public static bool operator!=(LLUUID lhs, LLUUID rhs) + { + return !(lhs == rhs); + } + + /// + /// + /// + /// + /// + public static implicit operator LLUUID(string val) + { + return new LLUUID(val); + } + + /// + /// + /// + /// + public override string ToString() + { + string uuid = ""; + + for (int i = 0; i < 16; ++i) + { + uuid += Data[i].ToString("x2"); + } + + return uuid; + } + + /// + /// + /// + /// + public string ToStringHyphenated() + { + string uuid = ""; + + for (int i = 0; i < 16; ++i) + { + uuid += Data[i].ToString("x2"); + + } + uuid = uuid.Insert(20,"-"); + uuid = uuid.Insert(16,"-"); + uuid = uuid.Insert(12,"-"); + uuid = uuid.Insert(8,"-"); + + + return uuid; + } + } + + /// + /// + /// + public class LLVector3 + { + /// + public float X; + /// + public float Y; + /// + public float Z; + + /// + /// + /// + public LLVector3() + { + X = Y = Z = 0.0F; + } + + /// + /// + /// + /// + public LLVector3(LLVector3d vector) + { + X = (float)vector.X; + Y = (float)vector.Y; + Z = (float)vector.Z; + } + + /// + /// + /// + /// + /// + public LLVector3(byte[] byteArray, int pos) + { + if(!BitConverter.IsLittleEndian) + { + Array.Reverse(byteArray, pos, 4); + Array.Reverse(byteArray, pos + 4, 4); + Array.Reverse(byteArray, pos + 8, 4); + } + + X = BitConverter.ToSingle(byteArray, pos); + Y = BitConverter.ToSingle(byteArray, pos + 4); + Z = BitConverter.ToSingle(byteArray, pos + 8); + } + + /// + /// + /// + /// + /// + /// + public LLVector3(float x, float y, float z) + { + X = x; + Y = y; + Z = z; + } + + /// + /// + /// + /// + public byte[] GetBytes() + { + byte[] byteArray = new byte[12]; + + Array.Copy(BitConverter.GetBytes(X), 0, byteArray, 0, 4); + Array.Copy(BitConverter.GetBytes(Y), 0, byteArray, 4, 4); + Array.Copy(BitConverter.GetBytes(Z), 0, byteArray, 8, 4); + + if(!BitConverter.IsLittleEndian) { + Array.Reverse(byteArray, 0, 4); + Array.Reverse(byteArray, 4, 4); + Array.Reverse(byteArray, 8, 4); + } + + return byteArray; + } + + /// + /// + /// + /// + public override string ToString() + { + return X.ToString() + " " + Y.ToString() + " " + Z.ToString(); + } + + /// + /// + /// + /// + public override int GetHashCode() + { + int x = (int)X; + int y = (int)Y; + int z = (int)Z; + + return (x ^ y ^ z); + } + + /// + /// + /// + /// + /// + public override bool Equals(object o) + { + if (!(o is LLVector3)) return false; + + LLVector3 vector = (LLVector3)o; + + return (X == vector.X && Y == vector.Y && Z == vector.Z); + } + + /// + /// + /// + /// + /// + /// + public static bool operator==(LLVector3 lhs, LLVector3 rhs) + { + if(object.ReferenceEquals(lhs, rhs)) return true; + if(object.ReferenceEquals(lhs, null)) return false; + if(object.ReferenceEquals(rhs, null)) return false; + + return (lhs.X == rhs.X && lhs.Y == rhs.Y && lhs.Z == rhs.Z); + } + + /// + /// + /// + /// + /// + /// + public static bool operator!=(LLVector3 lhs, LLVector3 rhs) + { + return !(lhs == rhs); + } + + /// + /// + /// + /// + /// + /// + public static LLVector3 operator -(LLVector3 lhs, LLVector3 rhs) + { + return new LLVector3(lhs.X - rhs.X,lhs.Y - rhs.Y, lhs.Z - rhs.Z); + } + } + + /// + /// + /// + public class LLVector3d + { + /// + public double X; + /// + public double Y; + /// + public double Z; + + /// + /// + /// + public LLVector3d() + { + X = Y = Z = 0.0D; + } + + /// + /// + /// + /// + /// + /// + public LLVector3d(double x, double y, double z) + { + X = x; + Y = y; + Z = z; + } + + /// + /// + /// + /// + /// + public LLVector3d(byte[] byteArray, int pos) + { + if(!BitConverter.IsLittleEndian) { + Array.Reverse(byteArray, pos, 8); + Array.Reverse(byteArray, pos + 8, 8); + Array.Reverse(byteArray, pos + 16, 8); + } + + X = BitConverter.ToDouble(byteArray, pos); + Y = BitConverter.ToDouble(byteArray, pos + 8); + Z = BitConverter.ToDouble(byteArray, pos + 16); + } + + /// + /// + /// + /// + public byte[] GetBytes() + { + byte[] byteArray = new byte[24]; + + Array.Copy(BitConverter.GetBytes(X), 0, byteArray, 0, 8); + Array.Copy(BitConverter.GetBytes(Y), 0, byteArray, 8, 8); + Array.Copy(BitConverter.GetBytes(Z), 0, byteArray, 16, 8); + + if(!BitConverter.IsLittleEndian) { + Array.Reverse(byteArray, 0, 8); + Array.Reverse(byteArray, 8, 8); + Array.Reverse(byteArray, 16, 8); + } + + return byteArray; + } + + /// + /// + /// + /// + public override string ToString() + { + return X.ToString() + " " + Y.ToString() + " " + Z.ToString(); + } + } + + /// + /// + /// + public class LLVector4 + { + /// + public float X; + /// + public float Y; + /// + public float Z; + /// + public float S; + + /// + /// + /// + public LLVector4() + { + X = Y = Z = S = 0.0F; + } + + /// + /// + /// + /// + /// + public LLVector4(byte[] byteArray, int pos) + { + if(!BitConverter.IsLittleEndian) { + Array.Reverse(byteArray, pos, 4); + Array.Reverse(byteArray, pos + 4, 4); + Array.Reverse(byteArray, pos + 8, 4); + Array.Reverse(byteArray, pos + 12, 4); + } + + X = BitConverter.ToSingle(byteArray, pos); + Y = BitConverter.ToSingle(byteArray, pos + 4); + Z = BitConverter.ToSingle(byteArray, pos + 8); + S = BitConverter.ToSingle(byteArray, pos + 12); + } + + /// + /// + /// + /// + public byte[] GetBytes() + { + byte[] byteArray = new byte[16]; + + Array.Copy(BitConverter.GetBytes(X), 0, byteArray, 0, 4); + Array.Copy(BitConverter.GetBytes(Y), 0, byteArray, 4, 4); + Array.Copy(BitConverter.GetBytes(Z), 0, byteArray, 8, 4); + Array.Copy(BitConverter.GetBytes(S), 0, byteArray, 12, 4); + + if(!BitConverter.IsLittleEndian) { + Array.Reverse(byteArray, 0, 4); + Array.Reverse(byteArray, 4, 4); + Array.Reverse(byteArray, 8, 4); + Array.Reverse(byteArray, 12, 4); + } + + return byteArray; + } + + /// + /// + /// + /// + public override string ToString() + { + return X.ToString() + " " + Y.ToString() + " " + Z.ToString() + " " + S.ToString(); + } + } + + /// + /// + /// + public class LLQuaternion + { + /// + public float X; + /// + public float Y; + /// + public float Z; + /// + public float W; + + /// + /// + /// + public LLQuaternion() + { + X = Y = Z = 0.0f; + W = 1.0f; + } + + /// + /// Build a quaternion object from a byte array + /// + /// The source byte array + /// Offset in the byte array to start reading at + /// Whether the source data is normalized or + /// not. If this is true 12 bytes will be read, otherwise 16 bytes will + /// be read. + public LLQuaternion(byte[] byteArray, int pos, bool normalized) + { + if (!normalized) + { + if (!BitConverter.IsLittleEndian) + { + Array.Reverse(byteArray, pos, 4); + Array.Reverse(byteArray, pos + 4, 4); + Array.Reverse(byteArray, pos + 8, 4); + Array.Reverse(byteArray, pos + 12, 4); + } + + X = BitConverter.ToSingle(byteArray, pos); + Y = BitConverter.ToSingle(byteArray, pos + 4); + Z = BitConverter.ToSingle(byteArray, pos + 8); + W = BitConverter.ToSingle(byteArray, pos + 12); + } + else + { + if (!BitConverter.IsLittleEndian) + { + Array.Reverse(byteArray, pos, 4); + Array.Reverse(byteArray, pos + 4, 4); + Array.Reverse(byteArray, pos + 8, 4); + } + + X = BitConverter.ToSingle(byteArray, pos); + Y = BitConverter.ToSingle(byteArray, pos + 4); + Z = BitConverter.ToSingle(byteArray, pos + 8); + + float xyzsum = 1 - X * X - Y * Y - Z * Z; + W = (xyzsum > 0) ? (float)Math.Sqrt(xyzsum) : 0; + } + } + + /// + /// + /// + /// + /// + /// + /// + public LLQuaternion(float x, float y, float z, float w) + { + X = x; + Y = y; + Z = z; + W = w; + } + + /// + /// + /// + /// + public byte[] GetBytes() + { + //byte[] byteArray = new byte[16]; + + //Array.Copy(BitConverter.GetBytes(X), 0, byteArray, 0, 4); + //Array.Copy(BitConverter.GetBytes(Y), 0, byteArray, 4, 4); + //Array.Copy(BitConverter.GetBytes(Z), 0, byteArray, 8, 4); + //Array.Copy(BitConverter.GetBytes(W), 0, byteArray, 12, 4); + + //if(!BitConverter.IsLittleEndian) { + // Array.Reverse(byteArray, 0, 4); + // Array.Reverse(byteArray, 4, 4); + // Array.Reverse(byteArray, 8, 4); + // Array.Reverse(byteArray, 12, 4); + //} + + byte[] bytes = new byte[12]; + float norm; + + norm = (float)Math.Sqrt(X*X + Y*Y + Z*Z + W*W); + + if (norm != 0) + { + norm = 1 / norm; + + Array.Copy(BitConverter.GetBytes(norm * X), 0, bytes, 0, 4); + Array.Copy(BitConverter.GetBytes(norm * Y), 0, bytes, 4, 4); + Array.Copy(BitConverter.GetBytes(norm * Z), 0, bytes, 8, 4); + + if (!BitConverter.IsLittleEndian) + { + Array.Reverse(bytes, 0, 4); + Array.Reverse(bytes, 4, 4); + Array.Reverse(bytes, 8, 4); + } + } + else + { + throw new Exception("Quaternion <" + X + "," + Y + "," + Z + "," + W + "> normalized to zero"); + } + + return bytes; + } + + /// + /// + /// + /// + public override string ToString() + { + return X.ToString() + " " + Y.ToString() + " " + Z.ToString() + " " + W.ToString(); + } + } +} diff --git a/libsecondlife-cs/XmlRpcCS/Logger.cs b/libsecondlife-cs/XmlRpcCS/Logger.cs index 2c4379d3..cb4b157f 100644 --- a/libsecondlife-cs/XmlRpcCS/Logger.cs +++ b/libsecondlife-cs/XmlRpcCS/Logger.cs @@ -1,46 +1,46 @@ -namespace Nwc.XmlRpc -{ - using System; - - /// Define levels of logging. This duplicates - /// similar enumerations in System.Diagnostics.EventLogEntryType. The - /// duplication was merited because .NET Compact Framework lacked the EventLogEntryType enum. - public enum LogLevel - { - /// Information level, log entry for informational reasons only. - Information, - /// Warning level, indicates a possible problem. - Warning, - /// Error level, implies a significant problem. - Error - } - - /// - ///Logging singleton with swappable output delegate. - /// - /// - ///This singleton provides a centralized log. The actual WriteEntry calls are passed - ///off to a delegate however. Having a delegate do the actual logginh allows you to - ///implement different logging mechanism and have them take effect throughout the system. - /// - public class Logger - { - ///Delegate definition for logging. - ///The message String to log. - ///The LogLevel of your message. - public delegate void LoggerDelegate(String message, LogLevel level); - ///The LoggerDelegate that will recieve WriteEntry requests. - static public LoggerDelegate Delegate = null; - - /// - ///Method logging events are sent to. - /// - ///The message String to log. - ///The LogLevel of your message. - static public void WriteEntry(String message, LogLevel level) - { - if (Delegate != null) - Delegate(message, level); - } - } -} +namespace Nwc.XmlRpc +{ + using System; + + /// Define levels of logging. This duplicates + /// similar enumerations in System.Diagnostics.EventLogEntryType. The + /// duplication was merited because .NET Compact Framework lacked the EventLogEntryType enum. + public enum LogLevel + { + /// Information level, log entry for informational reasons only. + Information, + /// Warning level, indicates a possible problem. + Warning, + /// Error level, implies a significant problem. + Error + } + + /// + ///Logging singleton with swappable output delegate. + /// + /// + ///This singleton provides a centralized log. The actual WriteEntry calls are passed + ///off to a delegate however. Having a delegate do the actual logginh allows you to + ///implement different logging mechanism and have them take effect throughout the system. + /// + public class Logger + { + ///Delegate definition for logging. + ///The message String to log. + ///The LogLevel of your message. + public delegate void LoggerDelegate(String message, LogLevel level); + ///The LoggerDelegate that will recieve WriteEntry requests. + static public LoggerDelegate Delegate = null; + + /// + ///Method logging events are sent to. + /// + ///The message String to log. + ///The LogLevel of your message. + static public void WriteEntry(String message, LogLevel level) + { + if (Delegate != null) + Delegate(message, level); + } + } +} diff --git a/libsecondlife-cs/XmlRpcCS/XmlRpcDeserializer.cs b/libsecondlife-cs/XmlRpcCS/XmlRpcDeserializer.cs index 7af124f3..cb9b7b1c 100644 --- a/libsecondlife-cs/XmlRpcCS/XmlRpcDeserializer.cs +++ b/libsecondlife-cs/XmlRpcCS/XmlRpcDeserializer.cs @@ -1,180 +1,180 @@ -namespace Nwc.XmlRpc -{ - using System; - using System.Collections; - using System.IO; - using System.Xml; - using System.Globalization; - - /// Parser context, we maintain contexts in a stack to avoiding recursion. - struct Context - { - public String Name; - public Object Container; - } - - /// Basic XML-RPC data deserializer. - /// Uses XmlTextReader to parse the XML data. This level of the class - /// only handles the tokens common to both Requests and Responses. This class is not useful in and of itself - /// but is designed to be subclassed. - public class XmlRpcDeserializer : XmlRpcXmlTokens - { - private static DateTimeFormatInfo _dateFormat = new DateTimeFormatInfo(); - - private Object _container; - private Stack _containerStack; - - /// Protected reference to last text. - protected String _text; - /// Protected reference to last deserialized value. - protected Object _value; - /// Protected reference to last name field. - protected String _name; - - /// Basic constructor. - public XmlRpcDeserializer() - { - Reset(); - _dateFormat.FullDateTimePattern = ISO_DATETIME; - } - - /// Static method that parses XML data into a response using the Singleton. - /// StreamReader containing an XML-RPC response. - /// Object object resulting from the deserialization. - virtual public Object Deserialize(TextReader xmlData) - { - return null; - } - - /// Protected method to parse a node in an XML-RPC XML stream. - /// Method deals with elements common to all XML-RPC data, subclasses of - /// this object deal with request/response spefic elements. - /// XmlTextReader of the in progress parsing data stream. - protected void DeserializeNode(XmlTextReader reader) - { - switch (reader.NodeType) - { - case XmlNodeType.Element: - if (Logger.Delegate != null) - Logger.WriteEntry("START " + reader.Name, LogLevel.Information); - switch (reader.Name) - { - case VALUE: - _value = null; - _text = null; - break; - case STRUCT: - PushContext(); - _container = new Hashtable(); - break; - case ARRAY: - PushContext(); - _container = new ArrayList(); - break; - } - break; - case XmlNodeType.EndElement: - if (Logger.Delegate != null) - Logger.WriteEntry("END " + reader.Name, LogLevel.Information); - switch (reader.Name) - { - case BASE64: - _value = Convert.FromBase64String(_text); - break; - case BOOLEAN: - int val = Int16.Parse(_text); - if (val == 0) - _value = false; - else if (val == 1) - _value = true; - break; - case STRING: - _value = _text; - break; - case DOUBLE: - _value = Double.Parse(_text); - break; - case INT: - case ALT_INT: - _value = Int32.Parse(_text); - break; - case DATETIME: -#if __MONO__ - _value = DateParse(_text); -#else - _value = DateTime.ParseExact(_text, "F", _dateFormat); -#endif - break; - case NAME: - _name = _text; - break; - case VALUE: - if (_value == null) - _value = _text; // some kits don't use tag, they just do - - if ((_container != null) && (_container is IList)) // in an array? If so add value to it. - ((IList)_container).Add(_value); - break; - case MEMBER: - if ((_container != null) && (_container is IDictionary)) // in an struct? If so add value to it. - ((IDictionary)_container).Add(_name, _value); - break; - case ARRAY: - case STRUCT: - _value = _container; - PopContext(); - break; - } - break; - case XmlNodeType.Text: - if (Logger.Delegate != null) - Logger.WriteEntry("Text " + reader.Value, LogLevel.Information); - _text = reader.Value; - break; - default: - break; - } - } - - /// Static method that parses XML in a String into a - /// request using the Singleton. - /// String containing an XML-RPC request. - /// XmlRpcRequest object resulting from the parse. - public Object Deserialize(String xmlData) - { - StringReader sr = new StringReader(xmlData); - return Deserialize(sr); - } - - /// Pop a Context of the stack, an Array or Struct has closed. - private void PopContext() - { - Context c = (Context)_containerStack.Pop(); - _container = c.Container; - _name = c.Name; - } - - /// Push a Context on the stack, an Array or Struct has opened. - private void PushContext() - { - Context context; - - context.Container = _container; - context.Name = _name; - - _containerStack.Push(context); - } - - /// Reset the internal state of the deserializer. - protected void Reset() - { - _text = null; - _value = null; - _name = null; - _container = null; - _containerStack = new Stack(); - } - } -} - - +namespace Nwc.XmlRpc +{ + using System; + using System.Collections; + using System.IO; + using System.Xml; + using System.Globalization; + + /// Parser context, we maintain contexts in a stack to avoiding recursion. + struct Context + { + public String Name; + public Object Container; + } + + /// Basic XML-RPC data deserializer. + /// Uses XmlTextReader to parse the XML data. This level of the class + /// only handles the tokens common to both Requests and Responses. This class is not useful in and of itself + /// but is designed to be subclassed. + public class XmlRpcDeserializer : XmlRpcXmlTokens + { + private static DateTimeFormatInfo _dateFormat = new DateTimeFormatInfo(); + + private Object _container; + private Stack _containerStack; + + /// Protected reference to last text. + protected String _text; + /// Protected reference to last deserialized value. + protected Object _value; + /// Protected reference to last name field. + protected String _name; + + /// Basic constructor. + public XmlRpcDeserializer() + { + Reset(); + _dateFormat.FullDateTimePattern = ISO_DATETIME; + } + + /// Static method that parses XML data into a response using the Singleton. + /// StreamReader containing an XML-RPC response. + /// Object object resulting from the deserialization. + virtual public Object Deserialize(TextReader xmlData) + { + return null; + } + + /// Protected method to parse a node in an XML-RPC XML stream. + /// Method deals with elements common to all XML-RPC data, subclasses of + /// this object deal with request/response spefic elements. + /// XmlTextReader of the in progress parsing data stream. + protected void DeserializeNode(XmlTextReader reader) + { + switch (reader.NodeType) + { + case XmlNodeType.Element: + if (Logger.Delegate != null) + Logger.WriteEntry("START " + reader.Name, LogLevel.Information); + switch (reader.Name) + { + case VALUE: + _value = null; + _text = null; + break; + case STRUCT: + PushContext(); + _container = new Hashtable(); + break; + case ARRAY: + PushContext(); + _container = new ArrayList(); + break; + } + break; + case XmlNodeType.EndElement: + if (Logger.Delegate != null) + Logger.WriteEntry("END " + reader.Name, LogLevel.Information); + switch (reader.Name) + { + case BASE64: + _value = Convert.FromBase64String(_text); + break; + case BOOLEAN: + int val = Int16.Parse(_text); + if (val == 0) + _value = false; + else if (val == 1) + _value = true; + break; + case STRING: + _value = _text; + break; + case DOUBLE: + _value = Double.Parse(_text); + break; + case INT: + case ALT_INT: + _value = Int32.Parse(_text); + break; + case DATETIME: +#if __MONO__ + _value = DateParse(_text); +#else + _value = DateTime.ParseExact(_text, "F", _dateFormat); +#endif + break; + case NAME: + _name = _text; + break; + case VALUE: + if (_value == null) + _value = _text; // some kits don't use tag, they just do + + if ((_container != null) && (_container is IList)) // in an array? If so add value to it. + ((IList)_container).Add(_value); + break; + case MEMBER: + if ((_container != null) && (_container is IDictionary)) // in an struct? If so add value to it. + ((IDictionary)_container).Add(_name, _value); + break; + case ARRAY: + case STRUCT: + _value = _container; + PopContext(); + break; + } + break; + case XmlNodeType.Text: + if (Logger.Delegate != null) + Logger.WriteEntry("Text " + reader.Value, LogLevel.Information); + _text = reader.Value; + break; + default: + break; + } + } + + /// Static method that parses XML in a String into a + /// request using the Singleton. + /// String containing an XML-RPC request. + /// XmlRpcRequest object resulting from the parse. + public Object Deserialize(String xmlData) + { + StringReader sr = new StringReader(xmlData); + return Deserialize(sr); + } + + /// Pop a Context of the stack, an Array or Struct has closed. + private void PopContext() + { + Context c = (Context)_containerStack.Pop(); + _container = c.Container; + _name = c.Name; + } + + /// Push a Context on the stack, an Array or Struct has opened. + private void PushContext() + { + Context context; + + context.Container = _container; + context.Name = _name; + + _containerStack.Push(context); + } + + /// Reset the internal state of the deserializer. + protected void Reset() + { + _text = null; + _value = null; + _name = null; + _container = null; + _containerStack = new Stack(); + } + } +} + + diff --git a/libsecondlife-cs/XmlRpcCS/XmlRpcErrorCodes.cs b/libsecondlife-cs/XmlRpcCS/XmlRpcErrorCodes.cs index 137709a4..db924b25 100644 --- a/libsecondlife-cs/XmlRpcCS/XmlRpcErrorCodes.cs +++ b/libsecondlife-cs/XmlRpcCS/XmlRpcErrorCodes.cs @@ -1,15 +1,15 @@ -namespace Nwc.XmlRpc -{ - using System; - - /// Standard XML-RPC error codes. - public class XmlRpcErrorCodes - { - // -32400 ---> system error - - /// - public const int TRANSPORT_ERROR = -32300; - /// - public const String TRANSPORT_ERROR_MSG = "Transport Layer Error"; - } -} +namespace Nwc.XmlRpc +{ + using System; + + /// Standard XML-RPC error codes. + public class XmlRpcErrorCodes + { + // -32400 ---> system error + + /// + public const int TRANSPORT_ERROR = -32300; + /// + public const String TRANSPORT_ERROR_MSG = "Transport Layer Error"; + } +} diff --git a/libsecondlife-cs/XmlRpcCS/XmlRpcException.cs b/libsecondlife-cs/XmlRpcCS/XmlRpcException.cs index 96bff8d1..333cfc0b 100644 --- a/libsecondlife-cs/XmlRpcCS/XmlRpcException.cs +++ b/libsecondlife-cs/XmlRpcCS/XmlRpcException.cs @@ -1,38 +1,38 @@ -namespace Nwc.XmlRpc -{ - using System; - - /// An XML-RPC Exception. - /// Maps a C# exception to an XML-RPC fault. Normal exceptions - /// include a message so this adds the code needed by XML-RPC. - public class XmlRpcException : Exception - { - private int _code; - - /// Instantiate an XmlRpcException with a code and message. - /// Int faultCode associated with this exception. - /// String faultMessage associated with this exception. - public XmlRpcException(int code, String message) : base(message) - { - _code = code; - } - - /// The value of the faults message, i.e. the faultString. - public String FaultString - { - get { return Message; } - } - - /// The value of the faults code, i.e. the faultCode. - public int FaultCode - { - get { return _code; } - } - - /// Format the message to include the code. - override public String ToString() - { - return "Code: " + FaultCode + " Message: " + base.ToString(); - } - } -} +namespace Nwc.XmlRpc +{ + using System; + + /// An XML-RPC Exception. + /// Maps a C# exception to an XML-RPC fault. Normal exceptions + /// include a message so this adds the code needed by XML-RPC. + public class XmlRpcException : Exception + { + private int _code; + + /// Instantiate an XmlRpcException with a code and message. + /// Int faultCode associated with this exception. + /// String faultMessage associated with this exception. + public XmlRpcException(int code, String message) : base(message) + { + _code = code; + } + + /// The value of the faults message, i.e. the faultString. + public String FaultString + { + get { return Message; } + } + + /// The value of the faults code, i.e. the faultCode. + public int FaultCode + { + get { return _code; } + } + + /// Format the message to include the code. + override public String ToString() + { + return "Code: " + FaultCode + " Message: " + base.ToString(); + } + } +} diff --git a/libsecondlife-cs/XmlRpcCS/XmlRpcRequest.cs b/libsecondlife-cs/XmlRpcCS/XmlRpcRequest.cs index 9d306bd4..2ae5c67c 100644 --- a/libsecondlife-cs/XmlRpcCS/XmlRpcRequest.cs +++ b/libsecondlife-cs/XmlRpcCS/XmlRpcRequest.cs @@ -1,96 +1,96 @@ -namespace Nwc.XmlRpc -{ - using System; - using System.Collections; - using System.IO; - using System.Xml; - using System.Net; - using System.Text; - using System.Reflection; - - internal class AcceptAllCertificatePolicy : ICertificatePolicy - { - public AcceptAllCertificatePolicy() - { - } - - public bool CheckValidationResult(ServicePoint sPoint, - System.Security.Cryptography.X509Certificates.X509Certificate cert, - WebRequest wRequest,int certProb) - { - // Always accept - return true; - } - } - - /// Class supporting the request side of an XML-RPC transaction. - public class XmlRpcRequest - { - private String _methodName = null; - private Encoding _encoding = new ASCIIEncoding(); - private XmlRpcRequestSerializer _serializer = new XmlRpcRequestSerializer(); - private XmlRpcResponseDeserializer _deserializer = new XmlRpcResponseDeserializer(); - - /// ArrayList containing the parameters. - protected IList _params = null; - - /// Instantiate an XmlRpcRequest - public XmlRpcRequest() - { - _params = new ArrayList(); - } - - /// ArrayList conntaining the parameters for the request. - public virtual IList Params - { - get { return _params; } - } - - /// String conntaining the method name, both object and method, that the request will be sent to. - public virtual String MethodName - { - get { return _methodName; } - set { _methodName = value; } - } - - /// Send the request to the server. - /// String The url of the XML-RPC server. - /// XmlRpcResponse The response generated. - public XmlRpcResponse Send(String url) - { - // Override SSL authentication mechanisms - ServicePointManager.CertificatePolicy = new AcceptAllCertificatePolicy(); - - HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); - if (request == null) - throw new XmlRpcException(XmlRpcErrorCodes.TRANSPORT_ERROR, - XmlRpcErrorCodes.TRANSPORT_ERROR_MSG +": Could not create request with " + url); - request.Method = "POST"; - request.ContentType = "text/xml"; - request.AllowWriteStreamBuffering = true; - request.KeepAlive = false; - request.Timeout = 15000; // miliseconds adjust as you see fit - - Stream stream = request.GetRequestStream(); - XmlTextWriter xml = new XmlTextWriter(stream, _encoding); - _serializer.Serialize(xml, this); - xml.Flush(); - xml.Close(); - - HttpWebResponse response = (HttpWebResponse)request.GetResponse(); - StreamReader input = new StreamReader(response.GetResponseStream()); - - XmlRpcResponse resp = (XmlRpcResponse)_deserializer.Deserialize(input); - input.Close(); - response.Close(); - return resp; - } - - /// Produce String representation of the object. - /// String representation of the object. - override public String ToString() - { - return _serializer.Serialize(this); - } - } -} +namespace Nwc.XmlRpc +{ + using System; + using System.Collections; + using System.IO; + using System.Xml; + using System.Net; + using System.Text; + using System.Reflection; + + internal class AcceptAllCertificatePolicy : ICertificatePolicy + { + public AcceptAllCertificatePolicy() + { + } + + public bool CheckValidationResult(ServicePoint sPoint, + System.Security.Cryptography.X509Certificates.X509Certificate cert, + WebRequest wRequest,int certProb) + { + // Always accept + return true; + } + } + + /// Class supporting the request side of an XML-RPC transaction. + public class XmlRpcRequest + { + private String _methodName = null; + private Encoding _encoding = new ASCIIEncoding(); + private XmlRpcRequestSerializer _serializer = new XmlRpcRequestSerializer(); + private XmlRpcResponseDeserializer _deserializer = new XmlRpcResponseDeserializer(); + + /// ArrayList containing the parameters. + protected IList _params = null; + + /// Instantiate an XmlRpcRequest + public XmlRpcRequest() + { + _params = new ArrayList(); + } + + /// ArrayList conntaining the parameters for the request. + public virtual IList Params + { + get { return _params; } + } + + /// String conntaining the method name, both object and method, that the request will be sent to. + public virtual String MethodName + { + get { return _methodName; } + set { _methodName = value; } + } + + /// Send the request to the server. + /// String The url of the XML-RPC server. + /// XmlRpcResponse The response generated. + public XmlRpcResponse Send(String url) + { + // Override SSL authentication mechanisms + ServicePointManager.CertificatePolicy = new AcceptAllCertificatePolicy(); + + HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); + if (request == null) + throw new XmlRpcException(XmlRpcErrorCodes.TRANSPORT_ERROR, + XmlRpcErrorCodes.TRANSPORT_ERROR_MSG +": Could not create request with " + url); + request.Method = "POST"; + request.ContentType = "text/xml"; + request.AllowWriteStreamBuffering = true; + request.KeepAlive = false; + request.Timeout = 15000; // miliseconds adjust as you see fit + + Stream stream = request.GetRequestStream(); + XmlTextWriter xml = new XmlTextWriter(stream, _encoding); + _serializer.Serialize(xml, this); + xml.Flush(); + xml.Close(); + + HttpWebResponse response = (HttpWebResponse)request.GetResponse(); + StreamReader input = new StreamReader(response.GetResponseStream()); + + XmlRpcResponse resp = (XmlRpcResponse)_deserializer.Deserialize(input); + input.Close(); + response.Close(); + return resp; + } + + /// Produce String representation of the object. + /// String representation of the object. + override public String ToString() + { + return _serializer.Serialize(this); + } + } +} diff --git a/libsecondlife-cs/XmlRpcCS/XmlRpcRequestDeserializer.cs b/libsecondlife-cs/XmlRpcCS/XmlRpcRequestDeserializer.cs index 5975a152..75e3e179 100644 --- a/libsecondlife-cs/XmlRpcCS/XmlRpcRequestDeserializer.cs +++ b/libsecondlife-cs/XmlRpcCS/XmlRpcRequestDeserializer.cs @@ -1,64 +1,64 @@ -namespace Nwc.XmlRpc -{ - using System; - using System.Collections; - using System.Diagnostics; - using System.IO; - using System.Xml; - - /// Class to deserialize XML data representing a request. - public class XmlRpcRequestDeserializer : XmlRpcDeserializer - { - static private XmlRpcRequestDeserializer _singleton; - /// A static singleton instance of this deserializer. - [Obsolete("This object is now thread safe, just use an instance.",false)] - static public XmlRpcRequestDeserializer Singleton - { - get - { - if (_singleton == null) - _singleton = new XmlRpcRequestDeserializer(); - - return _singleton; - } - } - - /// Static method that parses XML data into a request using the Singleton. - /// StreamReader containing an XML-RPC request. - /// XmlRpcRequest object resulting from the parse. - override public Object Deserialize(TextReader xmlData) - { - XmlTextReader reader = new XmlTextReader(xmlData); - XmlRpcRequest request = new XmlRpcRequest(); - bool done = false; - - lock(this) - { - Reset(); - while (!done && reader.Read()) - { - DeserializeNode(reader); // Parent parse... - switch (reader.NodeType) - { - case XmlNodeType.EndElement: - switch (reader.Name) - { - case METHOD_NAME: - request.MethodName = _text; - break; - case METHOD_CALL: - done = true; - break; - case PARAM: - request.Params.Add(_value); - _text = null; - break; - } - break; - } - } - } - return request; - } - } -} +namespace Nwc.XmlRpc +{ + using System; + using System.Collections; + using System.Diagnostics; + using System.IO; + using System.Xml; + + /// Class to deserialize XML data representing a request. + public class XmlRpcRequestDeserializer : XmlRpcDeserializer + { + static private XmlRpcRequestDeserializer _singleton; + /// A static singleton instance of this deserializer. + [Obsolete("This object is now thread safe, just use an instance.",false)] + static public XmlRpcRequestDeserializer Singleton + { + get + { + if (_singleton == null) + _singleton = new XmlRpcRequestDeserializer(); + + return _singleton; + } + } + + /// Static method that parses XML data into a request using the Singleton. + /// StreamReader containing an XML-RPC request. + /// XmlRpcRequest object resulting from the parse. + override public Object Deserialize(TextReader xmlData) + { + XmlTextReader reader = new XmlTextReader(xmlData); + XmlRpcRequest request = new XmlRpcRequest(); + bool done = false; + + lock(this) + { + Reset(); + while (!done && reader.Read()) + { + DeserializeNode(reader); // Parent parse... + switch (reader.NodeType) + { + case XmlNodeType.EndElement: + switch (reader.Name) + { + case METHOD_NAME: + request.MethodName = _text; + break; + case METHOD_CALL: + done = true; + break; + case PARAM: + request.Params.Add(_value); + _text = null; + break; + } + break; + } + } + } + return request; + } + } +} diff --git a/libsecondlife-cs/XmlRpcCS/XmlRpcRequestSerializer.cs b/libsecondlife-cs/XmlRpcCS/XmlRpcRequestSerializer.cs index c232caf1..ab4834d7 100644 --- a/libsecondlife-cs/XmlRpcCS/XmlRpcRequestSerializer.cs +++ b/libsecondlife-cs/XmlRpcCS/XmlRpcRequestSerializer.cs @@ -1,38 +1,38 @@ -namespace Nwc.XmlRpc -{ - using System; - using System.Collections; - using System.Xml; - using System.IO; - - /// Class responsible for serializing an XML-RPC request. - /// This class handles the request envelope, depending on XmlRpcSerializer - /// to serialize the payload. - /// - public class XmlRpcRequestSerializer : XmlRpcSerializer - { - /// Serialize the XmlRpcRequest to the output stream. - /// An XmlTextWriter stream to write data to. - /// An XmlRpcRequest to serialize. - /// - override public void Serialize(XmlTextWriter output, Object obj) - { - XmlRpcRequest request = (XmlRpcRequest)obj; - output.WriteStartDocument(); - output.WriteStartElement(METHOD_CALL); - output.WriteElementString(METHOD_NAME,request.MethodName); - output.WriteStartElement(PARAMS); - foreach (Object param in request.Params) - { - output.WriteStartElement(PARAM); - output.WriteStartElement(VALUE); - SerializeObject(output, param); - output.WriteEndElement(); - output.WriteEndElement(); - } - - output.WriteEndElement(); - output.WriteEndElement(); - } - } -} +namespace Nwc.XmlRpc +{ + using System; + using System.Collections; + using System.Xml; + using System.IO; + + /// Class responsible for serializing an XML-RPC request. + /// This class handles the request envelope, depending on XmlRpcSerializer + /// to serialize the payload. + /// + public class XmlRpcRequestSerializer : XmlRpcSerializer + { + /// Serialize the XmlRpcRequest to the output stream. + /// An XmlTextWriter stream to write data to. + /// An XmlRpcRequest to serialize. + /// + override public void Serialize(XmlTextWriter output, Object obj) + { + XmlRpcRequest request = (XmlRpcRequest)obj; + output.WriteStartDocument(); + output.WriteStartElement(METHOD_CALL); + output.WriteElementString(METHOD_NAME,request.MethodName); + output.WriteStartElement(PARAMS); + foreach (Object param in request.Params) + { + output.WriteStartElement(PARAM); + output.WriteStartElement(VALUE); + SerializeObject(output, param); + output.WriteEndElement(); + output.WriteEndElement(); + } + + output.WriteEndElement(); + output.WriteEndElement(); + } + } +} diff --git a/libsecondlife-cs/XmlRpcCS/XmlRpcResponse.cs b/libsecondlife-cs/XmlRpcCS/XmlRpcResponse.cs index 6484268d..eaa40875 100644 --- a/libsecondlife-cs/XmlRpcCS/XmlRpcResponse.cs +++ b/libsecondlife-cs/XmlRpcCS/XmlRpcResponse.cs @@ -1,73 +1,73 @@ -namespace Nwc.XmlRpc -{ - using System; - using System.Collections; - using System.IO; - using System.Xml; - - /// Class designed to represent an XML-RPC response. - public class XmlRpcResponse - { - private Object _value; - /// bool indicating if this response represents a fault. - public bool IsFault; - - /// Basic constructor - public XmlRpcResponse() - { - Value = null; - IsFault = false; - } - - /// The data value of the response, may be fault data. - public Object Value - { - get { return _value; } - set { - IsFault = false; - _value = value; - } - } - - /// The faultCode if this is a fault. - public int FaultCode - { - get { - if (!IsFault) - return 0; - else - return (int)((Hashtable)_value)[XmlRpcXmlTokens.FAULT_CODE]; - } - } - - /// The faultString if this is a fault. - public String FaultString - { - get { - if (!IsFault) - return ""; - else - return (String)((Hashtable)_value)[XmlRpcXmlTokens.FAULT_STRING]; - } - } - - /// Set this response to be a fault. - /// int the numeric faultCode value. - /// String the faultString value. - public void SetFault(int code, String message) - { - Hashtable fault = new Hashtable(); - fault.Add("faultCode", code); - fault.Add("faultString", message); - Value = fault; - IsFault = true; - } - - /// Form a useful string representation of the object, in this case the XML response. - /// String The XML serialized XML-RPC response. - override public String ToString() - { - return XmlRpcResponseSerializer.Singleton.Serialize(this); - } - } -} +namespace Nwc.XmlRpc +{ + using System; + using System.Collections; + using System.IO; + using System.Xml; + + /// Class designed to represent an XML-RPC response. + public class XmlRpcResponse + { + private Object _value; + /// bool indicating if this response represents a fault. + public bool IsFault; + + /// Basic constructor + public XmlRpcResponse() + { + Value = null; + IsFault = false; + } + + /// The data value of the response, may be fault data. + public Object Value + { + get { return _value; } + set { + IsFault = false; + _value = value; + } + } + + /// The faultCode if this is a fault. + public int FaultCode + { + get { + if (!IsFault) + return 0; + else + return (int)((Hashtable)_value)[XmlRpcXmlTokens.FAULT_CODE]; + } + } + + /// The faultString if this is a fault. + public String FaultString + { + get { + if (!IsFault) + return ""; + else + return (String)((Hashtable)_value)[XmlRpcXmlTokens.FAULT_STRING]; + } + } + + /// Set this response to be a fault. + /// int the numeric faultCode value. + /// String the faultString value. + public void SetFault(int code, String message) + { + Hashtable fault = new Hashtable(); + fault.Add("faultCode", code); + fault.Add("faultString", message); + Value = fault; + IsFault = true; + } + + /// Form a useful string representation of the object, in this case the XML response. + /// String The XML serialized XML-RPC response. + override public String ToString() + { + return XmlRpcResponseSerializer.Singleton.Serialize(this); + } + } +} diff --git a/libsecondlife-cs/XmlRpcCS/XmlRpcResponseDeserializer.cs b/libsecondlife-cs/XmlRpcCS/XmlRpcResponseDeserializer.cs index a94388a4..980d1bb6 100644 --- a/libsecondlife-cs/XmlRpcCS/XmlRpcResponseDeserializer.cs +++ b/libsecondlife-cs/XmlRpcCS/XmlRpcResponseDeserializer.cs @@ -1,51 +1,51 @@ -namespace Nwc.XmlRpc -{ - using System; - using System.Collections; - using System.IO; - using System.Xml; - - /// Class to deserialize XML data representing a response. - public class XmlRpcResponseDeserializer : XmlRpcDeserializer - { - /// Static method that parses XML data into a response using the Singleton. - /// StreamReader containing an XML-RPC response. - /// XmlRpcResponse object resulting from the parse. - override public Object Deserialize(TextReader xmlData) - { - XmlTextReader reader = new XmlTextReader(xmlData); - XmlRpcResponse response = new XmlRpcResponse(); - bool done = false; - - lock(this) - { - Reset(); - - while (!done && reader.Read()) - { - DeserializeNode(reader); // Parent parse... - switch (reader.NodeType) - { - case XmlNodeType.EndElement: - switch (reader.Name) - { - case FAULT: - response.Value = _value; - response.IsFault = true; - break; - case PARAM: - response.Value = _value; - _value = null; - _text = null; - break; - } - break; - default: - break; - } - } - } - return response; - } - } -} +namespace Nwc.XmlRpc +{ + using System; + using System.Collections; + using System.IO; + using System.Xml; + + /// Class to deserialize XML data representing a response. + public class XmlRpcResponseDeserializer : XmlRpcDeserializer + { + /// Static method that parses XML data into a response using the Singleton. + /// StreamReader containing an XML-RPC response. + /// XmlRpcResponse object resulting from the parse. + override public Object Deserialize(TextReader xmlData) + { + XmlTextReader reader = new XmlTextReader(xmlData); + XmlRpcResponse response = new XmlRpcResponse(); + bool done = false; + + lock(this) + { + Reset(); + + while (!done && reader.Read()) + { + DeserializeNode(reader); // Parent parse... + switch (reader.NodeType) + { + case XmlNodeType.EndElement: + switch (reader.Name) + { + case FAULT: + response.Value = _value; + response.IsFault = true; + break; + case PARAM: + response.Value = _value; + _value = null; + _text = null; + break; + } + break; + default: + break; + } + } + } + return response; + } + } +} diff --git a/libsecondlife-cs/XmlRpcCS/XmlRpcResponseSerializer.cs b/libsecondlife-cs/XmlRpcCS/XmlRpcResponseSerializer.cs index b2df7cc0..65dc60f8 100644 --- a/libsecondlife-cs/XmlRpcCS/XmlRpcResponseSerializer.cs +++ b/libsecondlife-cs/XmlRpcCS/XmlRpcResponseSerializer.cs @@ -1,57 +1,57 @@ -namespace Nwc.XmlRpc -{ - using System; - using System.Collections; - using System.Xml; - - /// Class responsible for serializing an XML-RPC response. - /// This class handles the response envelope, depending on XmlRpcSerializer - /// to serialize the payload. - /// - public class XmlRpcResponseSerializer : XmlRpcSerializer - { - static private XmlRpcResponseSerializer _singleton; - /// A static singleton instance of this deserializer. - static public XmlRpcResponseSerializer Singleton - { - get - { - if (_singleton == null) - _singleton = new XmlRpcResponseSerializer(); - - return _singleton; - } - } - - /// Serialize the XmlRpcResponse to the output stream. - /// An XmlTextWriter stream to write data to. - /// An Object to serialize. - /// - override public void Serialize(XmlTextWriter output, Object obj) - { - XmlRpcResponse response = (XmlRpcResponse) obj; - - output.WriteStartDocument(); - output.WriteStartElement(METHOD_RESPONSE); - - if (response.IsFault) - output.WriteStartElement(FAULT); - else - { - output.WriteStartElement(PARAMS); - output.WriteStartElement(PARAM); - } - - output.WriteStartElement(VALUE); - - SerializeObject(output,response.Value); - - output.WriteEndElement(); - - output.WriteEndElement(); - if (!response.IsFault) - output.WriteEndElement(); - output.WriteEndElement(); - } - } -} +namespace Nwc.XmlRpc +{ + using System; + using System.Collections; + using System.Xml; + + /// Class responsible for serializing an XML-RPC response. + /// This class handles the response envelope, depending on XmlRpcSerializer + /// to serialize the payload. + /// + public class XmlRpcResponseSerializer : XmlRpcSerializer + { + static private XmlRpcResponseSerializer _singleton; + /// A static singleton instance of this deserializer. + static public XmlRpcResponseSerializer Singleton + { + get + { + if (_singleton == null) + _singleton = new XmlRpcResponseSerializer(); + + return _singleton; + } + } + + /// Serialize the XmlRpcResponse to the output stream. + /// An XmlTextWriter stream to write data to. + /// An Object to serialize. + /// + override public void Serialize(XmlTextWriter output, Object obj) + { + XmlRpcResponse response = (XmlRpcResponse) obj; + + output.WriteStartDocument(); + output.WriteStartElement(METHOD_RESPONSE); + + if (response.IsFault) + output.WriteStartElement(FAULT); + else + { + output.WriteStartElement(PARAMS); + output.WriteStartElement(PARAM); + } + + output.WriteStartElement(VALUE); + + SerializeObject(output,response.Value); + + output.WriteEndElement(); + + output.WriteEndElement(); + if (!response.IsFault) + output.WriteEndElement(); + output.WriteEndElement(); + } + } +} diff --git a/libsecondlife-cs/XmlRpcCS/XmlRpcSerializer.cs b/libsecondlife-cs/XmlRpcCS/XmlRpcSerializer.cs index 459bce15..58c98177 100644 --- a/libsecondlife-cs/XmlRpcCS/XmlRpcSerializer.cs +++ b/libsecondlife-cs/XmlRpcCS/XmlRpcSerializer.cs @@ -1,109 +1,109 @@ -namespace Nwc.XmlRpc -{ - using System; - using System.Collections; - using System.IO; - using System.Xml; - - /// Base class of classes serializing data to XML-RPC's XML format. - /// This class handles the basic type conversions like Integer to <i4>. - /// - public class XmlRpcSerializer : XmlRpcXmlTokens - { - - /// Serialize the XmlRpcRequest to the output stream. - /// An XmlTextWriter stream to write data to. - /// An Object to serialize. - /// - virtual public void Serialize(XmlTextWriter output, Object obj) - { - } - - /// Serialize the XmlRpcRequest to a String. - /// Note this may represent a real memory hog for a large request. - /// An Object to serialize. - /// String containing XML-RPC representation of the request. - /// - public String Serialize(Object obj) - { - StringWriter strBuf = new StringWriter(); - XmlTextWriter xml = new XmlTextWriter(strBuf); - xml.Formatting = Formatting.Indented; - xml.Indentation = 4; - Serialize(xml, obj); - xml.Flush(); - String returns = strBuf.ToString(); - xml.Close(); - return returns; - } - - /// Serialize the object to the output stream. - /// An XmlTextWriter stream to write data to. - /// An Object to serialize. - public void SerializeObject(XmlTextWriter output, Object obj) - { - if (obj == null) - return; - - if (obj is byte[]) - { - byte[] ba = (byte[])obj; - output.WriteStartElement(BASE64); - output.WriteBase64(ba,0,ba.Length); - output.WriteEndElement(); - } - else if (obj is String) - { - output.WriteElementString(STRING,obj.ToString()); - } - else if (obj is Int32) - { - output.WriteElementString(INT,obj.ToString()); - } - else if (obj is DateTime) - { - output.WriteElementString(DATETIME,((DateTime)obj).ToString(ISO_DATETIME)); - } - else if (obj is Double) - { - output.WriteElementString(DOUBLE,obj.ToString()); - } - else if (obj is Boolean) - { - output.WriteElementString(BOOLEAN, ((((Boolean)obj) == true)?"1":"0")); - } - else if (obj is IList) - { - output.WriteStartElement(ARRAY); - output.WriteStartElement(DATA); - if (((ArrayList)obj).Count > 0) - { - foreach (Object member in ((IList)obj)) - { - output.WriteStartElement(VALUE); - SerializeObject(output,member); - output.WriteEndElement(); - } - } - output.WriteEndElement(); - output.WriteEndElement(); - } - else if (obj is IDictionary) - { - IDictionary h = (IDictionary)obj; - output.WriteStartElement(STRUCT); - foreach (String key in h.Keys) - { - output.WriteStartElement(MEMBER); - output.WriteElementString(NAME,key); - output.WriteStartElement(VALUE); - SerializeObject(output,h[key]); - output.WriteEndElement(); - output.WriteEndElement(); - } - output.WriteEndElement(); - } - - } - } -} +namespace Nwc.XmlRpc +{ + using System; + using System.Collections; + using System.IO; + using System.Xml; + + /// Base class of classes serializing data to XML-RPC's XML format. + /// This class handles the basic type conversions like Integer to <i4>. + /// + public class XmlRpcSerializer : XmlRpcXmlTokens + { + + /// Serialize the XmlRpcRequest to the output stream. + /// An XmlTextWriter stream to write data to. + /// An Object to serialize. + /// + virtual public void Serialize(XmlTextWriter output, Object obj) + { + } + + /// Serialize the XmlRpcRequest to a String. + /// Note this may represent a real memory hog for a large request. + /// An Object to serialize. + /// String containing XML-RPC representation of the request. + /// + public String Serialize(Object obj) + { + StringWriter strBuf = new StringWriter(); + XmlTextWriter xml = new XmlTextWriter(strBuf); + xml.Formatting = Formatting.Indented; + xml.Indentation = 4; + Serialize(xml, obj); + xml.Flush(); + String returns = strBuf.ToString(); + xml.Close(); + return returns; + } + + /// Serialize the object to the output stream. + /// An XmlTextWriter stream to write data to. + /// An Object to serialize. + public void SerializeObject(XmlTextWriter output, Object obj) + { + if (obj == null) + return; + + if (obj is byte[]) + { + byte[] ba = (byte[])obj; + output.WriteStartElement(BASE64); + output.WriteBase64(ba,0,ba.Length); + output.WriteEndElement(); + } + else if (obj is String) + { + output.WriteElementString(STRING,obj.ToString()); + } + else if (obj is Int32) + { + output.WriteElementString(INT,obj.ToString()); + } + else if (obj is DateTime) + { + output.WriteElementString(DATETIME,((DateTime)obj).ToString(ISO_DATETIME)); + } + else if (obj is Double) + { + output.WriteElementString(DOUBLE,obj.ToString()); + } + else if (obj is Boolean) + { + output.WriteElementString(BOOLEAN, ((((Boolean)obj) == true)?"1":"0")); + } + else if (obj is IList) + { + output.WriteStartElement(ARRAY); + output.WriteStartElement(DATA); + if (((ArrayList)obj).Count > 0) + { + foreach (Object member in ((IList)obj)) + { + output.WriteStartElement(VALUE); + SerializeObject(output,member); + output.WriteEndElement(); + } + } + output.WriteEndElement(); + output.WriteEndElement(); + } + else if (obj is IDictionary) + { + IDictionary h = (IDictionary)obj; + output.WriteStartElement(STRUCT); + foreach (String key in h.Keys) + { + output.WriteStartElement(MEMBER); + output.WriteElementString(NAME,key); + output.WriteStartElement(VALUE); + SerializeObject(output,h[key]); + output.WriteEndElement(); + output.WriteEndElement(); + } + output.WriteEndElement(); + } + + } + } +} diff --git a/libsecondlife-cs/XmlRpcCS/XmlRpcXmlTokens.cs b/libsecondlife-cs/XmlRpcCS/XmlRpcXmlTokens.cs index 5203bca2..05ea0eb8 100644 --- a/libsecondlife-cs/XmlRpcCS/XmlRpcXmlTokens.cs +++ b/libsecondlife-cs/XmlRpcCS/XmlRpcXmlTokens.cs @@ -1,76 +1,76 @@ -namespace Nwc.XmlRpc -{ - using System; - - /// Class collecting String tokens that are part of XML-RPC files. - public class XmlRpcXmlTokens - { - /// C# formatting string to describe an ISO 8601 date. - public const String ISO_DATETIME = "yyyyMMdd\\THH\\:mm\\:ss"; - /// Base64 field indicator. - /// Corresponds to the <base64> tag. - public const String BASE64 = "base64"; - /// String field indicator. - /// Corresponds to the <string> tag. - public const String STRING = "string"; - /// Integer field integer. - /// Corresponds to the <i4> tag. - public const String INT = "i4"; - /// Alternate integer field indicator. - /// Corresponds to the <int> tag. - public const String ALT_INT = "int"; - /// Date field indicator. - /// Corresponds to the <dateTime.iso8601> tag. - public const String DATETIME = "dateTime.iso8601"; - /// Boolean field indicator. - /// Corresponds to the <boolean> tag. - public const String BOOLEAN = "boolean"; - /// Value token. - /// Corresponds to the <value> tag. - public const String VALUE = "value"; - /// Name token. - /// Corresponds to the <name> tag. - public const String NAME = "name"; - /// Array field indicator.. - /// Corresponds to the <array> tag. - public const String ARRAY = "array"; - /// Data token. - /// Corresponds to the <data> tag. - public const String DATA = "data"; - /// Member token. - /// Corresponds to the <member> tag. - public const String MEMBER = "member"; - /// Stuct field indicator. - /// Corresponds to the <struct> tag. - public const String STRUCT = "struct"; - /// Double field indicator. - /// Corresponds to the <double> tag. - public const String DOUBLE = "double"; - /// Param token. - /// Corresponds to the <param> tag. - public const String PARAM = "param"; - /// Params token. - /// Corresponds to the <params> tag. - public const String PARAMS = "params"; - /// MethodCall token. - /// Corresponds to the <methodCall> tag. - public const String METHOD_CALL = "methodCall"; - /// MethodName token. - /// Corresponds to the <methodName> tag. - public const String METHOD_NAME = "methodName"; - /// MethodResponse token - /// Corresponds to the <methodResponse> tag. - public const String METHOD_RESPONSE = "methodResponse"; - /// Fault response token. - /// Corresponds to the <fault> tag. - public const String FAULT = "fault"; - /// FaultCode token. - /// Corresponds to the <faultCode> tag. - public const String FAULT_CODE = "faultCode"; - /// FaultString token. - /// Corresponds to the <faultString> tag. - public const String FAULT_STRING = "faultString"; - } -} - - +namespace Nwc.XmlRpc +{ + using System; + + /// Class collecting String tokens that are part of XML-RPC files. + public class XmlRpcXmlTokens + { + /// C# formatting string to describe an ISO 8601 date. + public const String ISO_DATETIME = "yyyyMMdd\\THH\\:mm\\:ss"; + /// Base64 field indicator. + /// Corresponds to the <base64> tag. + public const String BASE64 = "base64"; + /// String field indicator. + /// Corresponds to the <string> tag. + public const String STRING = "string"; + /// Integer field integer. + /// Corresponds to the <i4> tag. + public const String INT = "i4"; + /// Alternate integer field indicator. + /// Corresponds to the <int> tag. + public const String ALT_INT = "int"; + /// Date field indicator. + /// Corresponds to the <dateTime.iso8601> tag. + public const String DATETIME = "dateTime.iso8601"; + /// Boolean field indicator. + /// Corresponds to the <boolean> tag. + public const String BOOLEAN = "boolean"; + /// Value token. + /// Corresponds to the <value> tag. + public const String VALUE = "value"; + /// Name token. + /// Corresponds to the <name> tag. + public const String NAME = "name"; + /// Array field indicator.. + /// Corresponds to the <array> tag. + public const String ARRAY = "array"; + /// Data token. + /// Corresponds to the <data> tag. + public const String DATA = "data"; + /// Member token. + /// Corresponds to the <member> tag. + public const String MEMBER = "member"; + /// Stuct field indicator. + /// Corresponds to the <struct> tag. + public const String STRUCT = "struct"; + /// Double field indicator. + /// Corresponds to the <double> tag. + public const String DOUBLE = "double"; + /// Param token. + /// Corresponds to the <param> tag. + public const String PARAM = "param"; + /// Params token. + /// Corresponds to the <params> tag. + public const String PARAMS = "params"; + /// MethodCall token. + /// Corresponds to the <methodCall> tag. + public const String METHOD_CALL = "methodCall"; + /// MethodName token. + /// Corresponds to the <methodName> tag. + public const String METHOD_NAME = "methodName"; + /// MethodResponse token + /// Corresponds to the <methodResponse> tag. + public const String METHOD_RESPONSE = "methodResponse"; + /// Fault response token. + /// Corresponds to the <fault> tag. + public const String FAULT = "fault"; + /// FaultCode token. + /// Corresponds to the <faultCode> tag. + public const String FAULT_CODE = "faultCode"; + /// FaultString token. + /// Corresponds to the <faultString> tag. + public const String FAULT_STRING = "faultString"; + } +} + + diff --git a/libsecondlife-cs/_Packets_.cs b/libsecondlife-cs/_Packets_.cs index 206cb7f1..cbb686fd 100644 --- a/libsecondlife-cs/_Packets_.cs +++ b/libsecondlife-cs/_Packets_.cs @@ -1,1486 +1,1486 @@ -/* - * Copyright (c) 2006, the libsecondlife development team - * All rights reserved. - * - * - Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - Neither the name of the Second Life Reverse Engineering Team nor the names - * of its contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using libsecondlife; - -namespace libsecondlife.Packets -{ - /// - /// - /// - public class MalformedDataException : ApplicationException - { - /// - /// - /// - public MalformedDataException() { } - - /// - /// - /// - /// - public MalformedDataException(string Message) - : base(Message) - { - this.Source = "Packet decoding"; - } - } - - /// - /// - /// - public abstract class Header - { - /// - public byte[] Data; - /// - public byte Flags - { - get { return Data[0]; } - set { Data[0] = value; } - } - /// - public bool Reliable - { - get { return (Data[0] & Helpers.MSG_RELIABLE) != 0; } - set { if (value) { Data[0] |= (byte)Helpers.MSG_RELIABLE; } else { Data[0] -= (byte)Helpers.MSG_RELIABLE; } } - } - /// - public bool Resent - { - get { return (Data[0] & Helpers.MSG_RESENT) != 0; } - set { if (value) { Data[0] |= (byte)Helpers.MSG_RESENT; } else { Data[0] -= (byte)Helpers.MSG_RESENT; } } - } - /// - public bool Zerocoded - { - get { return (Data[0] & Helpers.MSG_ZEROCODED) != 0; } - set { if (value) { Data[0] |= (byte)Helpers.MSG_ZEROCODED; } else { Data[0] -= (byte)Helpers.MSG_ZEROCODED; } } - } - /// - public bool AppendedAcks - { - get { return (Data[0] & Helpers.MSG_APPENDED_ACKS) != 0; } - set { if (value) { Data[0] |= (byte)Helpers.MSG_APPENDED_ACKS; } else { Data[0] -= (byte)Helpers.MSG_APPENDED_ACKS; } } - } - /// - public ushort Sequence - { - get { return (ushort)((Data[2] << 8) + Data[3]); } - set { Data[2] = (byte)(value >> 8); Data[3] = (byte)(value % 256); } - } - /// - public abstract ushort ID { get; set; } - /// - public abstract PacketFrequency Frequency { get; } - /// - public abstract void ToBytes(byte[] bytes, ref int i); - /// - public uint[] AckList; - - /// - /// - /// - /// - /// - public void AcksToBytes(byte[] bytes, ref int i) - { - foreach (uint ack in AckList) - { - bytes[i++] = (byte)((ack >> 24) % 256); - bytes[i++] = (byte)((ack >> 16) % 256); - bytes[i++] = (byte)((ack >> 8) % 256); - bytes[i++] = (byte)(ack % 256); - } - if (AckList.Length > 0) { bytes[i++] = (byte)AckList.Length; } - } - - /// - /// - /// - /// - /// - /// - /// - public static Header BuildHeader(byte[] bytes, ref int pos, ref int packetEnd) - { - if (bytes[4] == 0xFF) - { - if (bytes[5] == 0xFF) - { - return new LowHeader(bytes, ref pos, ref packetEnd); - } - else - { - return new MediumHeader(bytes, ref pos, ref packetEnd); - } - } - else - { - return new HighHeader(bytes, ref pos, ref packetEnd); - } - } - - /// - /// - /// - /// - /// - protected void CreateAckList(byte[] bytes, ref int packetEnd) - { - if (AppendedAcks) - { - try - { - int count = bytes[packetEnd--]; - AckList = new uint[count]; - - for (int i = 0; i < count; i++) - { - AckList[i] = (ushort)((bytes[(packetEnd - i * 4) - 1] << 8) | (bytes[packetEnd - i * 4])); - } - - packetEnd -= (count * 4); - } - catch (Exception) - { - AckList = new uint[0]; - throw new MalformedDataException(); - } - } - else - { - AckList = new uint[0]; - } - } - } - - /// - /// - /// - public class LowHeader : Header - { - /// - public override ushort ID - { - get { return (ushort)((Data[6] << 8) + Data[7]); } - set { Data[6] = (byte)(value >> 8); Data[7] = (byte)(value % 256); } - } - /// - public override PacketFrequency Frequency { get { return PacketFrequency.Low; } } - - /// - /// - /// - public LowHeader() - { - Data = new byte[8]; - Data[4] = Data[5] = 0xFF; - AckList = new uint[0]; - } - - /// - /// - /// - /// - /// - /// - public LowHeader(byte[] bytes, ref int pos, ref int packetEnd) - { - if (bytes.Length < 8) { throw new MalformedDataException(); } - Data = new byte[8]; - Array.Copy(bytes, Data, 8); - - if ((bytes[0] & Helpers.MSG_ZEROCODED) != 0 && bytes[6] == 0) - { - if (bytes[7] == 1) - { - Data[7] = bytes[8]; - } - else - { - throw new MalformedDataException(); - } - } - - pos = 8; - CreateAckList(bytes, ref packetEnd); - } - - /// - /// - /// - /// - /// - public override void ToBytes(byte[] bytes, ref int i) - { - Array.Copy(Data, 0, bytes, i, 8); - i += 8; - } - } - - /// - /// - /// - public class MediumHeader : Header - { - /// - public override ushort ID - { - get { return (ushort)Data[5]; } - set { Data[5] = (byte)value; } - } - /// - public override PacketFrequency Frequency { get { return PacketFrequency.Medium; } } - - /// - /// - /// - public MediumHeader() - { - Data = new byte[6]; - Data[4] = 0xFF; - AckList = new uint[0]; - } - - /// - /// - /// - /// - /// - /// - public MediumHeader(byte[] bytes, ref int pos, ref int packetEnd) - { - if (bytes.Length < 6) { throw new MalformedDataException(); } - Data = new byte[6]; - Array.Copy(bytes, Data, 6); - pos = 6; - CreateAckList(bytes, ref packetEnd); - } - - /// - /// - /// - /// - /// - public override void ToBytes(byte[] bytes, ref int i) - { - Array.Copy(Data, 0, bytes, i, 6); - i += 6; - } - } - - /// - /// - /// - public class HighHeader : Header - { - /// - public override ushort ID - { - get { return (ushort)Data[4]; } - set { Data[4] = (byte)value; } - } - /// - public override PacketFrequency Frequency { get { return PacketFrequency.High; } } - - /// - /// - /// - public HighHeader() - { - Data = new byte[5]; - AckList = new uint[0]; - } - - /// - /// - /// - /// - /// - /// - public HighHeader(byte[] bytes, ref int pos, ref int packetEnd) - { - if (bytes.Length < 5) { throw new MalformedDataException(); } - Data = new byte[5]; - Array.Copy(bytes, Data, 5); - pos = 5; - CreateAckList(bytes, ref packetEnd); - } - - /// - /// - /// - /// - /// - public override void ToBytes(byte[] bytes, ref int i) - { - Array.Copy(Data, 0, bytes, i, 5); - i += 5; - } - } - - /// Used to identify the type of a packet +/* + * Copyright (c) 2006, the libsecondlife development team + * All rights reserved. + * + * - Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Neither the name of the Second Life Reverse Engineering Team nor the names + * of its contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using libsecondlife; + +namespace libsecondlife.Packets +{ + /// + /// + /// + public class MalformedDataException : ApplicationException + { + /// + /// + /// + public MalformedDataException() { } + + /// + /// + /// + /// + public MalformedDataException(string Message) + : base(Message) + { + this.Source = "Packet decoding"; + } + } + + /// + /// + /// + public abstract class Header + { + /// + public byte[] Data; + /// + public byte Flags + { + get { return Data[0]; } + set { Data[0] = value; } + } + /// + public bool Reliable + { + get { return (Data[0] & Helpers.MSG_RELIABLE) != 0; } + set { if (value) { Data[0] |= (byte)Helpers.MSG_RELIABLE; } else { Data[0] -= (byte)Helpers.MSG_RELIABLE; } } + } + /// + public bool Resent + { + get { return (Data[0] & Helpers.MSG_RESENT) != 0; } + set { if (value) { Data[0] |= (byte)Helpers.MSG_RESENT; } else { Data[0] -= (byte)Helpers.MSG_RESENT; } } + } + /// + public bool Zerocoded + { + get { return (Data[0] & Helpers.MSG_ZEROCODED) != 0; } + set { if (value) { Data[0] |= (byte)Helpers.MSG_ZEROCODED; } else { Data[0] -= (byte)Helpers.MSG_ZEROCODED; } } + } + /// + public bool AppendedAcks + { + get { return (Data[0] & Helpers.MSG_APPENDED_ACKS) != 0; } + set { if (value) { Data[0] |= (byte)Helpers.MSG_APPENDED_ACKS; } else { Data[0] -= (byte)Helpers.MSG_APPENDED_ACKS; } } + } + /// + public ushort Sequence + { + get { return (ushort)((Data[2] << 8) + Data[3]); } + set { Data[2] = (byte)(value >> 8); Data[3] = (byte)(value % 256); } + } + /// + public abstract ushort ID { get; set; } + /// + public abstract PacketFrequency Frequency { get; } + /// + public abstract void ToBytes(byte[] bytes, ref int i); + /// + public uint[] AckList; + + /// + /// + /// + /// + /// + public void AcksToBytes(byte[] bytes, ref int i) + { + foreach (uint ack in AckList) + { + bytes[i++] = (byte)((ack >> 24) % 256); + bytes[i++] = (byte)((ack >> 16) % 256); + bytes[i++] = (byte)((ack >> 8) % 256); + bytes[i++] = (byte)(ack % 256); + } + if (AckList.Length > 0) { bytes[i++] = (byte)AckList.Length; } + } + + /// + /// + /// + /// + /// + /// + /// + public static Header BuildHeader(byte[] bytes, ref int pos, ref int packetEnd) + { + if (bytes[4] == 0xFF) + { + if (bytes[5] == 0xFF) + { + return new LowHeader(bytes, ref pos, ref packetEnd); + } + else + { + return new MediumHeader(bytes, ref pos, ref packetEnd); + } + } + else + { + return new HighHeader(bytes, ref pos, ref packetEnd); + } + } + + /// + /// + /// + /// + /// + protected void CreateAckList(byte[] bytes, ref int packetEnd) + { + if (AppendedAcks) + { + try + { + int count = bytes[packetEnd--]; + AckList = new uint[count]; + + for (int i = 0; i < count; i++) + { + AckList[i] = (ushort)((bytes[(packetEnd - i * 4) - 1] << 8) | (bytes[packetEnd - i * 4])); + } + + packetEnd -= (count * 4); + } + catch (Exception) + { + AckList = new uint[0]; + throw new MalformedDataException(); + } + } + else + { + AckList = new uint[0]; + } + } + } + + /// + /// + /// + public class LowHeader : Header + { + /// + public override ushort ID + { + get { return (ushort)((Data[6] << 8) + Data[7]); } + set { Data[6] = (byte)(value >> 8); Data[7] = (byte)(value % 256); } + } + /// + public override PacketFrequency Frequency { get { return PacketFrequency.Low; } } + + /// + /// + /// + public LowHeader() + { + Data = new byte[8]; + Data[4] = Data[5] = 0xFF; + AckList = new uint[0]; + } + + /// + /// + /// + /// + /// + /// + public LowHeader(byte[] bytes, ref int pos, ref int packetEnd) + { + if (bytes.Length < 8) { throw new MalformedDataException(); } + Data = new byte[8]; + Array.Copy(bytes, Data, 8); + + if ((bytes[0] & Helpers.MSG_ZEROCODED) != 0 && bytes[6] == 0) + { + if (bytes[7] == 1) + { + Data[7] = bytes[8]; + } + else + { + throw new MalformedDataException(); + } + } + + pos = 8; + CreateAckList(bytes, ref packetEnd); + } + + /// + /// + /// + /// + /// + public override void ToBytes(byte[] bytes, ref int i) + { + Array.Copy(Data, 0, bytes, i, 8); + i += 8; + } + } + + /// + /// + /// + public class MediumHeader : Header + { + /// + public override ushort ID + { + get { return (ushort)Data[5]; } + set { Data[5] = (byte)value; } + } + /// + public override PacketFrequency Frequency { get { return PacketFrequency.Medium; } } + + /// + /// + /// + public MediumHeader() + { + Data = new byte[6]; + Data[4] = 0xFF; + AckList = new uint[0]; + } + + /// + /// + /// + /// + /// + /// + public MediumHeader(byte[] bytes, ref int pos, ref int packetEnd) + { + if (bytes.Length < 6) { throw new MalformedDataException(); } + Data = new byte[6]; + Array.Copy(bytes, Data, 6); + pos = 6; + CreateAckList(bytes, ref packetEnd); + } + + /// + /// + /// + /// + /// + public override void ToBytes(byte[] bytes, ref int i) + { + Array.Copy(Data, 0, bytes, i, 6); + i += 6; + } + } + + /// + /// + /// + public class HighHeader : Header + { + /// + public override ushort ID + { + get { return (ushort)Data[4]; } + set { Data[4] = (byte)value; } + } + /// + public override PacketFrequency Frequency { get { return PacketFrequency.High; } } + + /// + /// + /// + public HighHeader() + { + Data = new byte[5]; + AckList = new uint[0]; + } + + /// + /// + /// + /// + /// + /// + public HighHeader(byte[] bytes, ref int pos, ref int packetEnd) + { + if (bytes.Length < 5) { throw new MalformedDataException(); } + Data = new byte[5]; + Array.Copy(bytes, Data, 5); + pos = 5; + CreateAckList(bytes, ref packetEnd); + } + + /// + /// + /// + /// + /// + public override void ToBytes(byte[] bytes, ref int i) + { + Array.Copy(Data, 0, bytes, i, 5); + i += 5; + } + } + + /// Used to identify the type of a packet public enum PacketType { /// A generic value, not an actual packet type - Default, - /// TestMessage - TestMessage, - /// AddCircuitCode - AddCircuitCode, - /// UseCircuitCode - UseCircuitCode, - /// LogControl - LogControl, - /// RelayLogControl - RelayLogControl, - /// LogMessages - LogMessages, - /// SimulatorAssign - SimulatorAssign, - /// SpaceServerSimulatorTimeMessage - SpaceServerSimulatorTimeMessage, - /// AvatarTextureUpdate - AvatarTextureUpdate, - /// SimulatorMapUpdate - SimulatorMapUpdate, - /// SimulatorSetMap - SimulatorSetMap, - /// SubscribeLoad - SubscribeLoad, - /// UnsubscribeLoad - UnsubscribeLoad, - /// SimulatorStart - SimulatorStart, - /// SimulatorReady - SimulatorReady, - /// TelehubInfo - TelehubInfo, - /// SimulatorPresentAtLocation - SimulatorPresentAtLocation, - /// SimulatorLoad - SimulatorLoad, - /// SimulatorShutdownRequest - SimulatorShutdownRequest, - /// RegionPresenceRequestByRegionID - RegionPresenceRequestByRegionID, - /// RegionPresenceRequestByHandle - RegionPresenceRequestByHandle, - /// RegionPresenceResponse - RegionPresenceResponse, - /// RecordAgentPresence - RecordAgentPresence, - /// EraseAgentPresence - EraseAgentPresence, - /// AgentPresenceRequest - AgentPresenceRequest, - /// AgentPresenceResponse - AgentPresenceResponse, - /// UpdateSimulator - UpdateSimulator, - /// TrackAgentSession - TrackAgentSession, - /// ClearAgentSessions - ClearAgentSessions, - /// LogDwellTime - LogDwellTime, - /// FeatureDisabled - FeatureDisabled, - /// LogFailedMoneyTransaction - LogFailedMoneyTransaction, - /// UserReportInternal - UserReportInternal, - /// SetSimStatusInDatabase - SetSimStatusInDatabase, - /// SetSimPresenceInDatabase - SetSimPresenceInDatabase, - /// EconomyDataRequest - EconomyDataRequest, - /// EconomyData - EconomyData, - /// AvatarPickerRequest - AvatarPickerRequest, - /// AvatarPickerRequestBackend - AvatarPickerRequestBackend, - /// AvatarPickerReply - AvatarPickerReply, - /// PlacesQuery - PlacesQuery, - /// PlacesReply - PlacesReply, - /// DirFindQuery - DirFindQuery, - /// DirFindQueryBackend - DirFindQueryBackend, - /// DirPlacesQuery - DirPlacesQuery, - /// DirPlacesQueryBackend - DirPlacesQueryBackend, - /// DirPlacesReply - DirPlacesReply, - /// DirPeopleQuery - DirPeopleQuery, - /// DirPeopleQueryBackend - DirPeopleQueryBackend, - /// DirPeopleReply - DirPeopleReply, - /// DirEventsReply - DirEventsReply, - /// DirGroupsQuery - DirGroupsQuery, - /// DirGroupsQueryBackend - DirGroupsQueryBackend, - /// DirGroupsReply - DirGroupsReply, - /// DirClassifiedQuery - DirClassifiedQuery, - /// DirClassifiedQueryBackend - DirClassifiedQueryBackend, - /// DirClassifiedReply - DirClassifiedReply, - /// AvatarClassifiedReply - AvatarClassifiedReply, - /// ClassifiedInfoRequest - ClassifiedInfoRequest, - /// ClassifiedInfoReply - ClassifiedInfoReply, - /// ClassifiedInfoUpdate - ClassifiedInfoUpdate, - /// ClassifiedDelete - ClassifiedDelete, - /// ClassifiedGodDelete - ClassifiedGodDelete, - /// DirPicksQuery - DirPicksQuery, - /// DirPicksQueryBackend - DirPicksQueryBackend, - /// DirPicksReply - DirPicksReply, - /// DirLandQuery - DirLandQuery, - /// DirLandQueryBackend - DirLandQueryBackend, - /// DirLandReply - DirLandReply, - /// DirPopularQuery - DirPopularQuery, - /// DirPopularQueryBackend - DirPopularQueryBackend, - /// DirPopularReply - DirPopularReply, - /// ParcelInfoRequest - ParcelInfoRequest, - /// ParcelInfoReply - ParcelInfoReply, - /// ParcelObjectOwnersRequest - ParcelObjectOwnersRequest, - /// OnlineStatusRequest - OnlineStatusRequest, - /// OnlineStatusReply - OnlineStatusReply, - /// ParcelObjectOwnersReply - ParcelObjectOwnersReply, - /// GroupNoticesListRequest - GroupNoticesListRequest, - /// GroupNoticesListReply - GroupNoticesListReply, - /// GroupNoticeRequest - GroupNoticeRequest, - /// GroupNoticeAdd - GroupNoticeAdd, - /// GroupNoticeDelete - GroupNoticeDelete, - /// TeleportRequest - TeleportRequest, - /// TeleportLocationRequest - TeleportLocationRequest, - /// TeleportLocal - TeleportLocal, - /// TeleportLandmarkRequest - TeleportLandmarkRequest, - /// TeleportProgress - TeleportProgress, - /// DataAgentAccessRequest - DataAgentAccessRequest, - /// DataAgentAccessReply - DataAgentAccessReply, - /// DataHomeLocationRequest - DataHomeLocationRequest, - /// DataHomeLocationReply - DataHomeLocationReply, - /// SpaceLocationTeleportRequest - SpaceLocationTeleportRequest, - /// SpaceLocationTeleportReply - SpaceLocationTeleportReply, - /// TeleportFinish - TeleportFinish, - /// StartLure - StartLure, - /// TeleportLureRequest - TeleportLureRequest, - /// TeleportCancel - TeleportCancel, - /// CompleteLure - CompleteLure, - /// TeleportStart - TeleportStart, - /// TeleportFailed - TeleportFailed, - /// LeaderBoardRequest - LeaderBoardRequest, - /// LeaderBoardData - LeaderBoardData, - /// RegisterNewAgent - RegisterNewAgent, - /// Undo - Undo, - /// Redo - Redo, - /// UndoLand - UndoLand, - /// RedoLand - RedoLand, - /// AgentPause - AgentPause, - /// AgentResume - AgentResume, - /// ChatFromViewer - ChatFromViewer, - /// AgentThrottle - AgentThrottle, - /// AgentFOV - AgentFOV, - /// AgentHeightWidth - AgentHeightWidth, - /// AgentSetAppearance - AgentSetAppearance, - /// AgentQuit - AgentQuit, - /// AgentQuitCopy - AgentQuitCopy, - /// ImageNotInDatabase - ImageNotInDatabase, - /// RebakeAvatarTextures - RebakeAvatarTextures, - /// SetAlwaysRun - SetAlwaysRun, - /// ObjectDelete - ObjectDelete, - /// ObjectDuplicate - ObjectDuplicate, - /// ObjectDuplicateOnRay - ObjectDuplicateOnRay, - /// ObjectScale - ObjectScale, - /// ObjectRotation - ObjectRotation, - /// ObjectFlagUpdate - ObjectFlagUpdate, - /// ObjectClickAction - ObjectClickAction, - /// ObjectImage - ObjectImage, - /// ObjectMaterial - ObjectMaterial, - /// ObjectShape - ObjectShape, - /// ObjectExtraParams - ObjectExtraParams, - /// ObjectOwner - ObjectOwner, - /// ObjectGroup - ObjectGroup, - /// ObjectBuy - ObjectBuy, - /// BuyObjectInventory - BuyObjectInventory, - /// DerezContainer - DerezContainer, - /// ObjectPermissions - ObjectPermissions, - /// ObjectSaleInfo - ObjectSaleInfo, - /// ObjectName - ObjectName, - /// ObjectDescription - ObjectDescription, - /// ObjectCategory - ObjectCategory, - /// ObjectSelect - ObjectSelect, - /// ObjectDeselect - ObjectDeselect, - /// ObjectAttach - ObjectAttach, - /// ObjectDetach - ObjectDetach, - /// ObjectDrop - ObjectDrop, - /// ObjectLink - ObjectLink, - /// ObjectDelink - ObjectDelink, - /// ObjectHinge - ObjectHinge, - /// ObjectDehinge - ObjectDehinge, - /// ObjectGrab - ObjectGrab, - /// ObjectGrabUpdate - ObjectGrabUpdate, - /// ObjectDeGrab - ObjectDeGrab, - /// ObjectSpinStart - ObjectSpinStart, - /// ObjectSpinUpdate - ObjectSpinUpdate, - /// ObjectSpinStop - ObjectSpinStop, - /// ObjectExportSelected - ObjectExportSelected, - /// ObjectImport - ObjectImport, - /// ModifyLand - ModifyLand, - /// VelocityInterpolateOn - VelocityInterpolateOn, - /// VelocityInterpolateOff - VelocityInterpolateOff, - /// StateSave - StateSave, - /// ReportAutosaveCrash - ReportAutosaveCrash, - /// SimWideDeletes - SimWideDeletes, - /// TrackAgent - TrackAgent, - /// GrantModification - GrantModification, - /// RevokeModification - RevokeModification, - /// RequestGrantedProxies - RequestGrantedProxies, - /// GrantedProxies - GrantedProxies, - /// AddModifyAbility - AddModifyAbility, - /// RemoveModifyAbility - RemoveModifyAbility, - /// ViewerStats - ViewerStats, - /// ScriptAnswerYes - ScriptAnswerYes, - /// UserReport - UserReport, - /// AlertMessage - AlertMessage, - /// AgentAlertMessage - AgentAlertMessage, - /// MeanCollisionAlert - MeanCollisionAlert, - /// ViewerFrozenMessage - ViewerFrozenMessage, - /// HealthMessage - HealthMessage, - /// ChatFromSimulator - ChatFromSimulator, - /// SimStats - SimStats, - /// RequestRegionInfo - RequestRegionInfo, - /// RegionInfo - RegionInfo, - /// GodUpdateRegionInfo - GodUpdateRegionInfo, - /// NearestLandingRegionRequest - NearestLandingRegionRequest, - /// NearestLandingRegionReply - NearestLandingRegionReply, - /// NearestLandingRegionUpdated - NearestLandingRegionUpdated, - /// TeleportLandingStatusChanged - TeleportLandingStatusChanged, - /// RegionHandshake - RegionHandshake, - /// RegionHandshakeReply - RegionHandshakeReply, - /// SimulatorViewerTimeMessage - SimulatorViewerTimeMessage, - /// EnableSimulator - EnableSimulator, - /// DisableSimulator - DisableSimulator, - /// TransferRequest - TransferRequest, - /// TransferInfo - TransferInfo, - /// TransferAbort - TransferAbort, - /// TransferPriority - TransferPriority, - /// RequestXfer - RequestXfer, - /// AbortXfer - AbortXfer, - /// RequestAvatarInfo - RequestAvatarInfo, - /// AvatarAppearance - AvatarAppearance, - /// SetFollowCamProperties - SetFollowCamProperties, - /// ClearFollowCamProperties - ClearFollowCamProperties, - /// RequestPayPrice - RequestPayPrice, - /// PayPriceReply - PayPriceReply, - /// KickUser - KickUser, - /// KickUserAck - KickUserAck, - /// GodKickUser - GodKickUser, - /// SystemKickUser - SystemKickUser, - /// EjectUser - EjectUser, - /// FreezeUser - FreezeUser, - /// AvatarPropertiesRequest - AvatarPropertiesRequest, - /// AvatarPropertiesRequestBackend - AvatarPropertiesRequestBackend, - /// AvatarPropertiesReply - AvatarPropertiesReply, - /// AvatarGroupsReply - AvatarGroupsReply, - /// AvatarPropertiesUpdate - AvatarPropertiesUpdate, - /// AvatarStatisticsReply - AvatarStatisticsReply, - /// AvatarNotesReply - AvatarNotesReply, - /// AvatarNotesUpdate - AvatarNotesUpdate, - /// AvatarPicksReply - AvatarPicksReply, - /// EventInfoRequest - EventInfoRequest, - /// EventInfoReply - EventInfoReply, - /// EventNotificationAddRequest - EventNotificationAddRequest, - /// EventNotificationRemoveRequest - EventNotificationRemoveRequest, - /// EventGodDelete - EventGodDelete, - /// PickInfoRequest - PickInfoRequest, - /// PickInfoReply - PickInfoReply, - /// PickInfoUpdate - PickInfoUpdate, - /// PickDelete - PickDelete, - /// PickGodDelete - PickGodDelete, - /// ScriptQuestion - ScriptQuestion, - /// ScriptControlChange - ScriptControlChange, - /// ScriptDialog - ScriptDialog, - /// ScriptDialogReply - ScriptDialogReply, - /// ForceScriptControlRelease - ForceScriptControlRelease, - /// RevokePermissions - RevokePermissions, - /// LoadURL - LoadURL, - /// ScriptTeleportRequest - ScriptTeleportRequest, - /// ParcelOverlay - ParcelOverlay, - /// ParcelPropertiesRequestByID - ParcelPropertiesRequestByID, - /// ParcelPropertiesUpdate - ParcelPropertiesUpdate, - /// ParcelReturnObjects - ParcelReturnObjects, - /// ParcelSetOtherCleanTime - ParcelSetOtherCleanTime, - /// ParcelDisableObjects - ParcelDisableObjects, - /// ParcelSelectObjects - ParcelSelectObjects, - /// EstateCovenantRequest - EstateCovenantRequest, - /// EstateCovenantReply - EstateCovenantReply, - /// ForceObjectSelect - ForceObjectSelect, - /// ParcelBuyPass - ParcelBuyPass, - /// ParcelDeedToGroup - ParcelDeedToGroup, - /// ParcelReclaim - ParcelReclaim, - /// ParcelClaim - ParcelClaim, - /// ParcelJoin - ParcelJoin, - /// ParcelDivide - ParcelDivide, - /// ParcelRelease - ParcelRelease, - /// ParcelBuy - ParcelBuy, - /// ParcelGodForceOwner - ParcelGodForceOwner, - /// ParcelAccessListRequest - ParcelAccessListRequest, - /// ParcelAccessListReply - ParcelAccessListReply, - /// ParcelAccessListUpdate - ParcelAccessListUpdate, - /// ParcelDwellRequest - ParcelDwellRequest, - /// ParcelDwellReply - ParcelDwellReply, - /// RequestParcelTransfer - RequestParcelTransfer, - /// UpdateParcel - UpdateParcel, - /// RemoveParcel - RemoveParcel, - /// MergeParcel - MergeParcel, - /// LogParcelChanges - LogParcelChanges, - /// CheckParcelSales - CheckParcelSales, - /// ParcelSales - ParcelSales, - /// ParcelGodMarkAsContent - ParcelGodMarkAsContent, - /// ParcelGodReserveForNewbie - ParcelGodReserveForNewbie, - /// ViewerStartAuction - ViewerStartAuction, - /// StartAuction - StartAuction, - /// ConfirmAuctionStart - ConfirmAuctionStart, - /// CompleteAuction - CompleteAuction, - /// CancelAuction - CancelAuction, - /// CheckParcelAuctions - CheckParcelAuctions, - /// ParcelAuctions - ParcelAuctions, - /// UUIDNameRequest - UUIDNameRequest, - /// UUIDNameReply - UUIDNameReply, - /// UUIDGroupNameRequest - UUIDGroupNameRequest, - /// UUIDGroupNameReply - UUIDGroupNameReply, - /// ChatPass - ChatPass, - /// ChildAgentDying - ChildAgentDying, - /// ChildAgentUnknown - ChildAgentUnknown, - /// KillChildAgents - KillChildAgents, - /// GetScriptRunning - GetScriptRunning, - /// ScriptRunningReply - ScriptRunningReply, - /// SetScriptRunning - SetScriptRunning, - /// ScriptReset - ScriptReset, - /// ScriptSensorRequest - ScriptSensorRequest, - /// ScriptSensorReply - ScriptSensorReply, - /// CompleteAgentMovement - CompleteAgentMovement, - /// AgentMovementComplete - AgentMovementComplete, - /// LogLogin - LogLogin, - /// ConnectAgentToUserserver - ConnectAgentToUserserver, - /// ConnectToUserserver - ConnectToUserserver, - /// DataServerLogout - DataServerLogout, - /// LogoutRequest - LogoutRequest, - /// FinalizeLogout - FinalizeLogout, - /// LogoutReply - LogoutReply, - /// LogoutDemand - LogoutDemand, - /// ImprovedInstantMessage - ImprovedInstantMessage, - /// RetrieveInstantMessages - RetrieveInstantMessages, - /// DequeueInstantMessages - DequeueInstantMessages, - /// FindAgent - FindAgent, - /// RequestGodlikePowers - RequestGodlikePowers, - /// GrantGodlikePowers - GrantGodlikePowers, - /// GodlikeMessage - GodlikeMessage, - /// EstateOwnerMessage - EstateOwnerMessage, - /// GenericMessage - GenericMessage, - /// MuteListRequest - MuteListRequest, - /// UpdateMuteListEntry - UpdateMuteListEntry, - /// RemoveMuteListEntry - RemoveMuteListEntry, - /// CopyInventoryFromNotecard - CopyInventoryFromNotecard, - /// UpdateInventoryItem - UpdateInventoryItem, - /// UpdateCreateInventoryItem - UpdateCreateInventoryItem, - /// MoveInventoryItem - MoveInventoryItem, - /// CopyInventoryItem - CopyInventoryItem, - /// RemoveInventoryItem - RemoveInventoryItem, - /// ChangeInventoryItemFlags - ChangeInventoryItemFlags, - /// SaveAssetIntoInventory - SaveAssetIntoInventory, - /// CreateInventoryFolder - CreateInventoryFolder, - /// UpdateInventoryFolder - UpdateInventoryFolder, - /// MoveInventoryFolder - MoveInventoryFolder, - /// RemoveInventoryFolder - RemoveInventoryFolder, - /// FetchInventoryDescendents - FetchInventoryDescendents, - /// InventoryDescendents - InventoryDescendents, - /// FetchInventory - FetchInventory, - /// FetchInventoryReply - FetchInventoryReply, - /// BulkUpdateInventory - BulkUpdateInventory, - /// RequestInventoryAsset - RequestInventoryAsset, - /// InventoryAssetResponse - InventoryAssetResponse, - /// RemoveInventoryObjects - RemoveInventoryObjects, - /// PurgeInventoryDescendents - PurgeInventoryDescendents, - /// UpdateTaskInventory - UpdateTaskInventory, - /// RemoveTaskInventory - RemoveTaskInventory, - /// MoveTaskInventory - MoveTaskInventory, - /// RequestTaskInventory - RequestTaskInventory, - /// ReplyTaskInventory - ReplyTaskInventory, - /// DeRezObject - DeRezObject, - /// DeRezAck - DeRezAck, - /// RezObject - RezObject, - /// RezObjectFromNotecard - RezObjectFromNotecard, - /// DeclineInventory - DeclineInventory, - /// TransferInventory - TransferInventory, - /// TransferInventoryAck - TransferInventoryAck, - /// RequestFriendship - RequestFriendship, - /// AcceptFriendship - AcceptFriendship, - /// DeclineFriendship - DeclineFriendship, - /// FormFriendship - FormFriendship, - /// TerminateFriendship - TerminateFriendship, - /// OfferCallingCard - OfferCallingCard, - /// AcceptCallingCard - AcceptCallingCard, - /// DeclineCallingCard - DeclineCallingCard, - /// RezScript - RezScript, - /// CreateInventoryItem - CreateInventoryItem, - /// CreateLandmarkForEvent - CreateLandmarkForEvent, - /// EventLocationRequest - EventLocationRequest, - /// EventLocationReply - EventLocationReply, - /// RegionHandleRequest - RegionHandleRequest, - /// RegionIDAndHandleReply - RegionIDAndHandleReply, - /// MoneyTransferRequest - MoneyTransferRequest, - /// MoneyTransferBackend - MoneyTransferBackend, - /// BulkMoneyTransfer - BulkMoneyTransfer, - /// AdjustBalance - AdjustBalance, - /// MoneyBalanceRequest - MoneyBalanceRequest, - /// MoneyBalanceReply - MoneyBalanceReply, - /// RoutedMoneyBalanceReply - RoutedMoneyBalanceReply, - /// MoneyHistoryRequest - MoneyHistoryRequest, - /// MoneyHistoryReply - MoneyHistoryReply, - /// MoneySummaryRequest - MoneySummaryRequest, - /// MoneySummaryReply - MoneySummaryReply, - /// MoneyDetailsRequest - MoneyDetailsRequest, - /// MoneyDetailsReply - MoneyDetailsReply, - /// MoneyTransactionsRequest - MoneyTransactionsRequest, - /// MoneyTransactionsReply - MoneyTransactionsReply, - /// GestureRequest - GestureRequest, - /// ActivateGestures - ActivateGestures, - /// DeactivateGestures - DeactivateGestures, - /// InventoryUpdate - InventoryUpdate, - /// MuteListUpdate - MuteListUpdate, - /// UseCachedMuteList - UseCachedMuteList, - /// UserLoginLocationReply - UserLoginLocationReply, - /// UserSimLocationReply - UserSimLocationReply, - /// UserListReply - UserListReply, - /// OnlineNotification - OnlineNotification, - /// OfflineNotification - OfflineNotification, - /// SetStartLocationRequest - SetStartLocationRequest, - /// SetStartLocation - SetStartLocation, - /// UserLoginLocationRequest - UserLoginLocationRequest, - /// SpaceLoginLocationReply - SpaceLoginLocationReply, - /// NetTest - NetTest, - /// SetCPURatio - SetCPURatio, - /// SimCrashed - SimCrashed, - /// SimulatorPauseState - SimulatorPauseState, - /// SimulatorThrottleSettings - SimulatorThrottleSettings, - /// NameValuePair - NameValuePair, - /// RemoveNameValuePair - RemoveNameValuePair, - /// GetNameValuePair - GetNameValuePair, - /// UpdateAttachment - UpdateAttachment, - /// RemoveAttachment - RemoveAttachment, - /// AssetUploadRequest - AssetUploadRequest, - /// AssetUploadComplete - AssetUploadComplete, - /// ReputationAgentAssign - ReputationAgentAssign, - /// ReputationIndividualRequest - ReputationIndividualRequest, - /// ReputationIndividualReply - ReputationIndividualReply, - /// EmailMessageRequest - EmailMessageRequest, - /// EmailMessageReply - EmailMessageReply, - /// ScriptDataRequest - ScriptDataRequest, - /// ScriptDataReply - ScriptDataReply, - /// CreateGroupRequest - CreateGroupRequest, - /// CreateGroupReply - CreateGroupReply, - /// UpdateGroupInfo - UpdateGroupInfo, - /// GroupRoleChanges - GroupRoleChanges, - /// JoinGroupRequest - JoinGroupRequest, - /// JoinGroupReply - JoinGroupReply, - /// EjectGroupMemberRequest - EjectGroupMemberRequest, - /// EjectGroupMemberReply - EjectGroupMemberReply, - /// LeaveGroupRequest - LeaveGroupRequest, - /// LeaveGroupReply - LeaveGroupReply, - /// InviteGroupRequest - InviteGroupRequest, - /// InviteGroupResponse - InviteGroupResponse, - /// GroupProfileRequest - GroupProfileRequest, - /// GroupProfileReply - GroupProfileReply, - /// GroupAccountSummaryRequest - GroupAccountSummaryRequest, - /// GroupAccountSummaryReply - GroupAccountSummaryReply, - /// GroupAccountDetailsRequest - GroupAccountDetailsRequest, - /// GroupAccountDetailsReply - GroupAccountDetailsReply, - /// GroupAccountTransactionsRequest - GroupAccountTransactionsRequest, - /// GroupAccountTransactionsReply - GroupAccountTransactionsReply, - /// GroupActiveProposalsRequest - GroupActiveProposalsRequest, - /// GroupActiveProposalItemReply - GroupActiveProposalItemReply, - /// GroupVoteHistoryRequest - GroupVoteHistoryRequest, - /// GroupVoteHistoryItemReply - GroupVoteHistoryItemReply, - /// StartGroupProposal - StartGroupProposal, - /// GroupProposalBallot - GroupProposalBallot, - /// TallyVotes - TallyVotes, - /// GroupMembersRequest - GroupMembersRequest, - /// GroupMembersReply - GroupMembersReply, - /// ActivateGroup - ActivateGroup, - /// SetGroupContribution - SetGroupContribution, - /// SetGroupAcceptNotices - SetGroupAcceptNotices, - /// GroupRoleDataRequest - GroupRoleDataRequest, - /// GroupRoleDataReply - GroupRoleDataReply, - /// GroupRoleMembersRequest - GroupRoleMembersRequest, - /// GroupRoleMembersReply - GroupRoleMembersReply, - /// GroupTitlesRequest - GroupTitlesRequest, - /// GroupTitlesReply - GroupTitlesReply, - /// GroupTitleUpdate - GroupTitleUpdate, - /// GroupRoleUpdate - GroupRoleUpdate, - /// LiveHelpGroupRequest - LiveHelpGroupRequest, - /// LiveHelpGroupReply - LiveHelpGroupReply, - /// AgentWearablesRequest - AgentWearablesRequest, - /// AgentWearablesUpdate - AgentWearablesUpdate, - /// AgentIsNowWearing - AgentIsNowWearing, - /// AgentCachedTexture - AgentCachedTexture, - /// AgentCachedTextureResponse - AgentCachedTextureResponse, - /// AgentDataUpdateRequest - AgentDataUpdateRequest, - /// AgentDataUpdate - AgentDataUpdate, - /// GroupDataUpdate - GroupDataUpdate, - /// AgentGroupDataUpdate - AgentGroupDataUpdate, - /// AgentDropGroup - AgentDropGroup, - /// LogTextMessage - LogTextMessage, - /// CreateTrustedCircuit - CreateTrustedCircuit, - /// DenyTrustedCircuit - DenyTrustedCircuit, - /// RezSingleAttachmentFromInv - RezSingleAttachmentFromInv, - /// RezMultipleAttachmentsFromInv - RezMultipleAttachmentsFromInv, - /// DetachAttachmentIntoInv - DetachAttachmentIntoInv, - /// CreateNewOutfitAttachments - CreateNewOutfitAttachments, - /// UserInfoRequest - UserInfoRequest, - /// UserInfoReply - UserInfoReply, - /// UpdateUserInfo - UpdateUserInfo, - /// GodExpungeUser - GodExpungeUser, - /// StartExpungeProcess - StartExpungeProcess, - /// StartExpungeProcessAck - StartExpungeProcessAck, - /// StartParcelRename - StartParcelRename, - /// StartParcelRenameAck - StartParcelRenameAck, - /// BulkParcelRename - BulkParcelRename, - /// ParcelRename - ParcelRename, - /// StartParcelRemove - StartParcelRemove, - /// StartParcelRemoveAck - StartParcelRemoveAck, - /// BulkParcelRemove - BulkParcelRemove, - /// InitiateUpload - InitiateUpload, - /// InitiateDownload - InitiateDownload, - /// SystemMessage - SystemMessage, - /// MapLayerRequest - MapLayerRequest, - /// MapLayerReply - MapLayerReply, - /// MapBlockRequest - MapBlockRequest, - /// MapNameRequest - MapNameRequest, - /// MapBlockReply - MapBlockReply, - /// MapItemRequest - MapItemRequest, - /// MapItemReply - MapItemReply, - /// SendPostcard - SendPostcard, - /// RpcChannelRequest - RpcChannelRequest, - /// RpcChannelReply - RpcChannelReply, - /// RpcScriptRequestInbound - RpcScriptRequestInbound, - /// RpcScriptRequestInboundForward - RpcScriptRequestInboundForward, - /// RpcScriptReplyInbound - RpcScriptReplyInbound, - /// MailTaskSimRequest - MailTaskSimRequest, - /// MailTaskSimReply - MailTaskSimReply, - /// ScriptMailRegistration - ScriptMailRegistration, - /// ParcelMediaCommandMessage - ParcelMediaCommandMessage, - /// ParcelMediaUpdate - ParcelMediaUpdate, - /// LandStatRequest - LandStatRequest, - /// LandStatReply - LandStatReply, - /// SecuredTemplateChecksumRequest - SecuredTemplateChecksumRequest, - /// PacketAck - PacketAck, - /// OpenCircuit - OpenCircuit, - /// CloseCircuit - CloseCircuit, - /// TemplateChecksumRequest - TemplateChecksumRequest, - /// TemplateChecksumReply - TemplateChecksumReply, - /// ClosestSimulator - ClosestSimulator, - /// ObjectAdd - ObjectAdd, - /// MultipleObjectUpdate - MultipleObjectUpdate, - /// RequestMultipleObjects - RequestMultipleObjects, - /// ObjectPosition - ObjectPosition, - /// RequestObjectPropertiesFamily - RequestObjectPropertiesFamily, - /// CoarseLocationUpdate - CoarseLocationUpdate, - /// CrossedRegion - CrossedRegion, - /// ConfirmEnableSimulator - ConfirmEnableSimulator, - /// ObjectProperties - ObjectProperties, - /// ObjectPropertiesFamily - ObjectPropertiesFamily, - /// ParcelPropertiesRequest - ParcelPropertiesRequest, - /// SimStatus - SimStatus, - /// GestureUpdate - GestureUpdate, - /// AttachedSound - AttachedSound, - /// AttachedSoundGainChange - AttachedSoundGainChange, - /// AttachedSoundCutoffRadius - AttachedSoundCutoffRadius, - /// PreloadSound - PreloadSound, - /// InternalScriptMail - InternalScriptMail, - /// ViewerEffect - ViewerEffect, - /// SetSunPhase - SetSunPhase, - /// StartPingCheck - StartPingCheck, - /// CompletePingCheck - CompletePingCheck, - /// NeighborList - NeighborList, - /// MovedIntoSimulator - MovedIntoSimulator, - /// AgentUpdate - AgentUpdate, - /// AgentAnimation - AgentAnimation, - /// AgentRequestSit - AgentRequestSit, - /// AgentSit - AgentSit, - /// RequestImage - RequestImage, - /// ImageData - ImageData, - /// ImagePacket - ImagePacket, - /// LayerData - LayerData, - /// ObjectUpdate - ObjectUpdate, - /// ObjectUpdateCompressed - ObjectUpdateCompressed, - /// ObjectUpdateCached - ObjectUpdateCached, - /// ImprovedTerseObjectUpdate - ImprovedTerseObjectUpdate, - /// KillObject - KillObject, - /// AgentToNewRegion - AgentToNewRegion, - /// TransferPacket - TransferPacket, - /// SendXferPacket - SendXferPacket, - /// ConfirmXferPacket - ConfirmXferPacket, - /// AvatarAnimation - AvatarAnimation, - /// AvatarSitResponse - AvatarSitResponse, - /// CameraConstraint - CameraConstraint, - /// ParcelProperties - ParcelProperties, - /// EdgeDataPacket - EdgeDataPacket, - /// ChildAgentUpdate - ChildAgentUpdate, - /// ChildAgentAlive - ChildAgentAlive, - /// ChildAgentPositionUpdate - ChildAgentPositionUpdate, - /// PassObject - PassObject, - /// AtomicPassObject - AtomicPassObject, - /// SoundTrigger - SoundTrigger, + Default, + /// TestMessage + TestMessage, + /// AddCircuitCode + AddCircuitCode, + /// UseCircuitCode + UseCircuitCode, + /// LogControl + LogControl, + /// RelayLogControl + RelayLogControl, + /// LogMessages + LogMessages, + /// SimulatorAssign + SimulatorAssign, + /// SpaceServerSimulatorTimeMessage + SpaceServerSimulatorTimeMessage, + /// AvatarTextureUpdate + AvatarTextureUpdate, + /// SimulatorMapUpdate + SimulatorMapUpdate, + /// SimulatorSetMap + SimulatorSetMap, + /// SubscribeLoad + SubscribeLoad, + /// UnsubscribeLoad + UnsubscribeLoad, + /// SimulatorStart + SimulatorStart, + /// SimulatorReady + SimulatorReady, + /// TelehubInfo + TelehubInfo, + /// SimulatorPresentAtLocation + SimulatorPresentAtLocation, + /// SimulatorLoad + SimulatorLoad, + /// SimulatorShutdownRequest + SimulatorShutdownRequest, + /// RegionPresenceRequestByRegionID + RegionPresenceRequestByRegionID, + /// RegionPresenceRequestByHandle + RegionPresenceRequestByHandle, + /// RegionPresenceResponse + RegionPresenceResponse, + /// RecordAgentPresence + RecordAgentPresence, + /// EraseAgentPresence + EraseAgentPresence, + /// AgentPresenceRequest + AgentPresenceRequest, + /// AgentPresenceResponse + AgentPresenceResponse, + /// UpdateSimulator + UpdateSimulator, + /// TrackAgentSession + TrackAgentSession, + /// ClearAgentSessions + ClearAgentSessions, + /// LogDwellTime + LogDwellTime, + /// FeatureDisabled + FeatureDisabled, + /// LogFailedMoneyTransaction + LogFailedMoneyTransaction, + /// UserReportInternal + UserReportInternal, + /// SetSimStatusInDatabase + SetSimStatusInDatabase, + /// SetSimPresenceInDatabase + SetSimPresenceInDatabase, + /// EconomyDataRequest + EconomyDataRequest, + /// EconomyData + EconomyData, + /// AvatarPickerRequest + AvatarPickerRequest, + /// AvatarPickerRequestBackend + AvatarPickerRequestBackend, + /// AvatarPickerReply + AvatarPickerReply, + /// PlacesQuery + PlacesQuery, + /// PlacesReply + PlacesReply, + /// DirFindQuery + DirFindQuery, + /// DirFindQueryBackend + DirFindQueryBackend, + /// DirPlacesQuery + DirPlacesQuery, + /// DirPlacesQueryBackend + DirPlacesQueryBackend, + /// DirPlacesReply + DirPlacesReply, + /// DirPeopleQuery + DirPeopleQuery, + /// DirPeopleQueryBackend + DirPeopleQueryBackend, + /// DirPeopleReply + DirPeopleReply, + /// DirEventsReply + DirEventsReply, + /// DirGroupsQuery + DirGroupsQuery, + /// DirGroupsQueryBackend + DirGroupsQueryBackend, + /// DirGroupsReply + DirGroupsReply, + /// DirClassifiedQuery + DirClassifiedQuery, + /// DirClassifiedQueryBackend + DirClassifiedQueryBackend, + /// DirClassifiedReply + DirClassifiedReply, + /// AvatarClassifiedReply + AvatarClassifiedReply, + /// ClassifiedInfoRequest + ClassifiedInfoRequest, + /// ClassifiedInfoReply + ClassifiedInfoReply, + /// ClassifiedInfoUpdate + ClassifiedInfoUpdate, + /// ClassifiedDelete + ClassifiedDelete, + /// ClassifiedGodDelete + ClassifiedGodDelete, + /// DirPicksQuery + DirPicksQuery, + /// DirPicksQueryBackend + DirPicksQueryBackend, + /// DirPicksReply + DirPicksReply, + /// DirLandQuery + DirLandQuery, + /// DirLandQueryBackend + DirLandQueryBackend, + /// DirLandReply + DirLandReply, + /// DirPopularQuery + DirPopularQuery, + /// DirPopularQueryBackend + DirPopularQueryBackend, + /// DirPopularReply + DirPopularReply, + /// ParcelInfoRequest + ParcelInfoRequest, + /// ParcelInfoReply + ParcelInfoReply, + /// ParcelObjectOwnersRequest + ParcelObjectOwnersRequest, + /// OnlineStatusRequest + OnlineStatusRequest, + /// OnlineStatusReply + OnlineStatusReply, + /// ParcelObjectOwnersReply + ParcelObjectOwnersReply, + /// GroupNoticesListRequest + GroupNoticesListRequest, + /// GroupNoticesListReply + GroupNoticesListReply, + /// GroupNoticeRequest + GroupNoticeRequest, + /// GroupNoticeAdd + GroupNoticeAdd, + /// GroupNoticeDelete + GroupNoticeDelete, + /// TeleportRequest + TeleportRequest, + /// TeleportLocationRequest + TeleportLocationRequest, + /// TeleportLocal + TeleportLocal, + /// TeleportLandmarkRequest + TeleportLandmarkRequest, + /// TeleportProgress + TeleportProgress, + /// DataAgentAccessRequest + DataAgentAccessRequest, + /// DataAgentAccessReply + DataAgentAccessReply, + /// DataHomeLocationRequest + DataHomeLocationRequest, + /// DataHomeLocationReply + DataHomeLocationReply, + /// SpaceLocationTeleportRequest + SpaceLocationTeleportRequest, + /// SpaceLocationTeleportReply + SpaceLocationTeleportReply, + /// TeleportFinish + TeleportFinish, + /// StartLure + StartLure, + /// TeleportLureRequest + TeleportLureRequest, + /// TeleportCancel + TeleportCancel, + /// CompleteLure + CompleteLure, + /// TeleportStart + TeleportStart, + /// TeleportFailed + TeleportFailed, + /// LeaderBoardRequest + LeaderBoardRequest, + /// LeaderBoardData + LeaderBoardData, + /// RegisterNewAgent + RegisterNewAgent, + /// Undo + Undo, + /// Redo + Redo, + /// UndoLand + UndoLand, + /// RedoLand + RedoLand, + /// AgentPause + AgentPause, + /// AgentResume + AgentResume, + /// ChatFromViewer + ChatFromViewer, + /// AgentThrottle + AgentThrottle, + /// AgentFOV + AgentFOV, + /// AgentHeightWidth + AgentHeightWidth, + /// AgentSetAppearance + AgentSetAppearance, + /// AgentQuit + AgentQuit, + /// AgentQuitCopy + AgentQuitCopy, + /// ImageNotInDatabase + ImageNotInDatabase, + /// RebakeAvatarTextures + RebakeAvatarTextures, + /// SetAlwaysRun + SetAlwaysRun, + /// ObjectDelete + ObjectDelete, + /// ObjectDuplicate + ObjectDuplicate, + /// ObjectDuplicateOnRay + ObjectDuplicateOnRay, + /// ObjectScale + ObjectScale, + /// ObjectRotation + ObjectRotation, + /// ObjectFlagUpdate + ObjectFlagUpdate, + /// ObjectClickAction + ObjectClickAction, + /// ObjectImage + ObjectImage, + /// ObjectMaterial + ObjectMaterial, + /// ObjectShape + ObjectShape, + /// ObjectExtraParams + ObjectExtraParams, + /// ObjectOwner + ObjectOwner, + /// ObjectGroup + ObjectGroup, + /// ObjectBuy + ObjectBuy, + /// BuyObjectInventory + BuyObjectInventory, + /// DerezContainer + DerezContainer, + /// ObjectPermissions + ObjectPermissions, + /// ObjectSaleInfo + ObjectSaleInfo, + /// ObjectName + ObjectName, + /// ObjectDescription + ObjectDescription, + /// ObjectCategory + ObjectCategory, + /// ObjectSelect + ObjectSelect, + /// ObjectDeselect + ObjectDeselect, + /// ObjectAttach + ObjectAttach, + /// ObjectDetach + ObjectDetach, + /// ObjectDrop + ObjectDrop, + /// ObjectLink + ObjectLink, + /// ObjectDelink + ObjectDelink, + /// ObjectHinge + ObjectHinge, + /// ObjectDehinge + ObjectDehinge, + /// ObjectGrab + ObjectGrab, + /// ObjectGrabUpdate + ObjectGrabUpdate, + /// ObjectDeGrab + ObjectDeGrab, + /// ObjectSpinStart + ObjectSpinStart, + /// ObjectSpinUpdate + ObjectSpinUpdate, + /// ObjectSpinStop + ObjectSpinStop, + /// ObjectExportSelected + ObjectExportSelected, + /// ObjectImport + ObjectImport, + /// ModifyLand + ModifyLand, + /// VelocityInterpolateOn + VelocityInterpolateOn, + /// VelocityInterpolateOff + VelocityInterpolateOff, + /// StateSave + StateSave, + /// ReportAutosaveCrash + ReportAutosaveCrash, + /// SimWideDeletes + SimWideDeletes, + /// TrackAgent + TrackAgent, + /// GrantModification + GrantModification, + /// RevokeModification + RevokeModification, + /// RequestGrantedProxies + RequestGrantedProxies, + /// GrantedProxies + GrantedProxies, + /// AddModifyAbility + AddModifyAbility, + /// RemoveModifyAbility + RemoveModifyAbility, + /// ViewerStats + ViewerStats, + /// ScriptAnswerYes + ScriptAnswerYes, + /// UserReport + UserReport, + /// AlertMessage + AlertMessage, + /// AgentAlertMessage + AgentAlertMessage, + /// MeanCollisionAlert + MeanCollisionAlert, + /// ViewerFrozenMessage + ViewerFrozenMessage, + /// HealthMessage + HealthMessage, + /// ChatFromSimulator + ChatFromSimulator, + /// SimStats + SimStats, + /// RequestRegionInfo + RequestRegionInfo, + /// RegionInfo + RegionInfo, + /// GodUpdateRegionInfo + GodUpdateRegionInfo, + /// NearestLandingRegionRequest + NearestLandingRegionRequest, + /// NearestLandingRegionReply + NearestLandingRegionReply, + /// NearestLandingRegionUpdated + NearestLandingRegionUpdated, + /// TeleportLandingStatusChanged + TeleportLandingStatusChanged, + /// RegionHandshake + RegionHandshake, + /// RegionHandshakeReply + RegionHandshakeReply, + /// SimulatorViewerTimeMessage + SimulatorViewerTimeMessage, + /// EnableSimulator + EnableSimulator, + /// DisableSimulator + DisableSimulator, + /// TransferRequest + TransferRequest, + /// TransferInfo + TransferInfo, + /// TransferAbort + TransferAbort, + /// TransferPriority + TransferPriority, + /// RequestXfer + RequestXfer, + /// AbortXfer + AbortXfer, + /// RequestAvatarInfo + RequestAvatarInfo, + /// AvatarAppearance + AvatarAppearance, + /// SetFollowCamProperties + SetFollowCamProperties, + /// ClearFollowCamProperties + ClearFollowCamProperties, + /// RequestPayPrice + RequestPayPrice, + /// PayPriceReply + PayPriceReply, + /// KickUser + KickUser, + /// KickUserAck + KickUserAck, + /// GodKickUser + GodKickUser, + /// SystemKickUser + SystemKickUser, + /// EjectUser + EjectUser, + /// FreezeUser + FreezeUser, + /// AvatarPropertiesRequest + AvatarPropertiesRequest, + /// AvatarPropertiesRequestBackend + AvatarPropertiesRequestBackend, + /// AvatarPropertiesReply + AvatarPropertiesReply, + /// AvatarGroupsReply + AvatarGroupsReply, + /// AvatarPropertiesUpdate + AvatarPropertiesUpdate, + /// AvatarStatisticsReply + AvatarStatisticsReply, + /// AvatarNotesReply + AvatarNotesReply, + /// AvatarNotesUpdate + AvatarNotesUpdate, + /// AvatarPicksReply + AvatarPicksReply, + /// EventInfoRequest + EventInfoRequest, + /// EventInfoReply + EventInfoReply, + /// EventNotificationAddRequest + EventNotificationAddRequest, + /// EventNotificationRemoveRequest + EventNotificationRemoveRequest, + /// EventGodDelete + EventGodDelete, + /// PickInfoRequest + PickInfoRequest, + /// PickInfoReply + PickInfoReply, + /// PickInfoUpdate + PickInfoUpdate, + /// PickDelete + PickDelete, + /// PickGodDelete + PickGodDelete, + /// ScriptQuestion + ScriptQuestion, + /// ScriptControlChange + ScriptControlChange, + /// ScriptDialog + ScriptDialog, + /// ScriptDialogReply + ScriptDialogReply, + /// ForceScriptControlRelease + ForceScriptControlRelease, + /// RevokePermissions + RevokePermissions, + /// LoadURL + LoadURL, + /// ScriptTeleportRequest + ScriptTeleportRequest, + /// ParcelOverlay + ParcelOverlay, + /// ParcelPropertiesRequestByID + ParcelPropertiesRequestByID, + /// ParcelPropertiesUpdate + ParcelPropertiesUpdate, + /// ParcelReturnObjects + ParcelReturnObjects, + /// ParcelSetOtherCleanTime + ParcelSetOtherCleanTime, + /// ParcelDisableObjects + ParcelDisableObjects, + /// ParcelSelectObjects + ParcelSelectObjects, + /// EstateCovenantRequest + EstateCovenantRequest, + /// EstateCovenantReply + EstateCovenantReply, + /// ForceObjectSelect + ForceObjectSelect, + /// ParcelBuyPass + ParcelBuyPass, + /// ParcelDeedToGroup + ParcelDeedToGroup, + /// ParcelReclaim + ParcelReclaim, + /// ParcelClaim + ParcelClaim, + /// ParcelJoin + ParcelJoin, + /// ParcelDivide + ParcelDivide, + /// ParcelRelease + ParcelRelease, + /// ParcelBuy + ParcelBuy, + /// ParcelGodForceOwner + ParcelGodForceOwner, + /// ParcelAccessListRequest + ParcelAccessListRequest, + /// ParcelAccessListReply + ParcelAccessListReply, + /// ParcelAccessListUpdate + ParcelAccessListUpdate, + /// ParcelDwellRequest + ParcelDwellRequest, + /// ParcelDwellReply + ParcelDwellReply, + /// RequestParcelTransfer + RequestParcelTransfer, + /// UpdateParcel + UpdateParcel, + /// RemoveParcel + RemoveParcel, + /// MergeParcel + MergeParcel, + /// LogParcelChanges + LogParcelChanges, + /// CheckParcelSales + CheckParcelSales, + /// ParcelSales + ParcelSales, + /// ParcelGodMarkAsContent + ParcelGodMarkAsContent, + /// ParcelGodReserveForNewbie + ParcelGodReserveForNewbie, + /// ViewerStartAuction + ViewerStartAuction, + /// StartAuction + StartAuction, + /// ConfirmAuctionStart + ConfirmAuctionStart, + /// CompleteAuction + CompleteAuction, + /// CancelAuction + CancelAuction, + /// CheckParcelAuctions + CheckParcelAuctions, + /// ParcelAuctions + ParcelAuctions, + /// UUIDNameRequest + UUIDNameRequest, + /// UUIDNameReply + UUIDNameReply, + /// UUIDGroupNameRequest + UUIDGroupNameRequest, + /// UUIDGroupNameReply + UUIDGroupNameReply, + /// ChatPass + ChatPass, + /// ChildAgentDying + ChildAgentDying, + /// ChildAgentUnknown + ChildAgentUnknown, + /// KillChildAgents + KillChildAgents, + /// GetScriptRunning + GetScriptRunning, + /// ScriptRunningReply + ScriptRunningReply, + /// SetScriptRunning + SetScriptRunning, + /// ScriptReset + ScriptReset, + /// ScriptSensorRequest + ScriptSensorRequest, + /// ScriptSensorReply + ScriptSensorReply, + /// CompleteAgentMovement + CompleteAgentMovement, + /// AgentMovementComplete + AgentMovementComplete, + /// LogLogin + LogLogin, + /// ConnectAgentToUserserver + ConnectAgentToUserserver, + /// ConnectToUserserver + ConnectToUserserver, + /// DataServerLogout + DataServerLogout, + /// LogoutRequest + LogoutRequest, + /// FinalizeLogout + FinalizeLogout, + /// LogoutReply + LogoutReply, + /// LogoutDemand + LogoutDemand, + /// ImprovedInstantMessage + ImprovedInstantMessage, + /// RetrieveInstantMessages + RetrieveInstantMessages, + /// DequeueInstantMessages + DequeueInstantMessages, + /// FindAgent + FindAgent, + /// RequestGodlikePowers + RequestGodlikePowers, + /// GrantGodlikePowers + GrantGodlikePowers, + /// GodlikeMessage + GodlikeMessage, + /// EstateOwnerMessage + EstateOwnerMessage, + /// GenericMessage + GenericMessage, + /// MuteListRequest + MuteListRequest, + /// UpdateMuteListEntry + UpdateMuteListEntry, + /// RemoveMuteListEntry + RemoveMuteListEntry, + /// CopyInventoryFromNotecard + CopyInventoryFromNotecard, + /// UpdateInventoryItem + UpdateInventoryItem, + /// UpdateCreateInventoryItem + UpdateCreateInventoryItem, + /// MoveInventoryItem + MoveInventoryItem, + /// CopyInventoryItem + CopyInventoryItem, + /// RemoveInventoryItem + RemoveInventoryItem, + /// ChangeInventoryItemFlags + ChangeInventoryItemFlags, + /// SaveAssetIntoInventory + SaveAssetIntoInventory, + /// CreateInventoryFolder + CreateInventoryFolder, + /// UpdateInventoryFolder + UpdateInventoryFolder, + /// MoveInventoryFolder + MoveInventoryFolder, + /// RemoveInventoryFolder + RemoveInventoryFolder, + /// FetchInventoryDescendents + FetchInventoryDescendents, + /// InventoryDescendents + InventoryDescendents, + /// FetchInventory + FetchInventory, + /// FetchInventoryReply + FetchInventoryReply, + /// BulkUpdateInventory + BulkUpdateInventory, + /// RequestInventoryAsset + RequestInventoryAsset, + /// InventoryAssetResponse + InventoryAssetResponse, + /// RemoveInventoryObjects + RemoveInventoryObjects, + /// PurgeInventoryDescendents + PurgeInventoryDescendents, + /// UpdateTaskInventory + UpdateTaskInventory, + /// RemoveTaskInventory + RemoveTaskInventory, + /// MoveTaskInventory + MoveTaskInventory, + /// RequestTaskInventory + RequestTaskInventory, + /// ReplyTaskInventory + ReplyTaskInventory, + /// DeRezObject + DeRezObject, + /// DeRezAck + DeRezAck, + /// RezObject + RezObject, + /// RezObjectFromNotecard + RezObjectFromNotecard, + /// DeclineInventory + DeclineInventory, + /// TransferInventory + TransferInventory, + /// TransferInventoryAck + TransferInventoryAck, + /// RequestFriendship + RequestFriendship, + /// AcceptFriendship + AcceptFriendship, + /// DeclineFriendship + DeclineFriendship, + /// FormFriendship + FormFriendship, + /// TerminateFriendship + TerminateFriendship, + /// OfferCallingCard + OfferCallingCard, + /// AcceptCallingCard + AcceptCallingCard, + /// DeclineCallingCard + DeclineCallingCard, + /// RezScript + RezScript, + /// CreateInventoryItem + CreateInventoryItem, + /// CreateLandmarkForEvent + CreateLandmarkForEvent, + /// EventLocationRequest + EventLocationRequest, + /// EventLocationReply + EventLocationReply, + /// RegionHandleRequest + RegionHandleRequest, + /// RegionIDAndHandleReply + RegionIDAndHandleReply, + /// MoneyTransferRequest + MoneyTransferRequest, + /// MoneyTransferBackend + MoneyTransferBackend, + /// BulkMoneyTransfer + BulkMoneyTransfer, + /// AdjustBalance + AdjustBalance, + /// MoneyBalanceRequest + MoneyBalanceRequest, + /// MoneyBalanceReply + MoneyBalanceReply, + /// RoutedMoneyBalanceReply + RoutedMoneyBalanceReply, + /// MoneyHistoryRequest + MoneyHistoryRequest, + /// MoneyHistoryReply + MoneyHistoryReply, + /// MoneySummaryRequest + MoneySummaryRequest, + /// MoneySummaryReply + MoneySummaryReply, + /// MoneyDetailsRequest + MoneyDetailsRequest, + /// MoneyDetailsReply + MoneyDetailsReply, + /// MoneyTransactionsRequest + MoneyTransactionsRequest, + /// MoneyTransactionsReply + MoneyTransactionsReply, + /// GestureRequest + GestureRequest, + /// ActivateGestures + ActivateGestures, + /// DeactivateGestures + DeactivateGestures, + /// InventoryUpdate + InventoryUpdate, + /// MuteListUpdate + MuteListUpdate, + /// UseCachedMuteList + UseCachedMuteList, + /// UserLoginLocationReply + UserLoginLocationReply, + /// UserSimLocationReply + UserSimLocationReply, + /// UserListReply + UserListReply, + /// OnlineNotification + OnlineNotification, + /// OfflineNotification + OfflineNotification, + /// SetStartLocationRequest + SetStartLocationRequest, + /// SetStartLocation + SetStartLocation, + /// UserLoginLocationRequest + UserLoginLocationRequest, + /// SpaceLoginLocationReply + SpaceLoginLocationReply, + /// NetTest + NetTest, + /// SetCPURatio + SetCPURatio, + /// SimCrashed + SimCrashed, + /// SimulatorPauseState + SimulatorPauseState, + /// SimulatorThrottleSettings + SimulatorThrottleSettings, + /// NameValuePair + NameValuePair, + /// RemoveNameValuePair + RemoveNameValuePair, + /// GetNameValuePair + GetNameValuePair, + /// UpdateAttachment + UpdateAttachment, + /// RemoveAttachment + RemoveAttachment, + /// AssetUploadRequest + AssetUploadRequest, + /// AssetUploadComplete + AssetUploadComplete, + /// ReputationAgentAssign + ReputationAgentAssign, + /// ReputationIndividualRequest + ReputationIndividualRequest, + /// ReputationIndividualReply + ReputationIndividualReply, + /// EmailMessageRequest + EmailMessageRequest, + /// EmailMessageReply + EmailMessageReply, + /// ScriptDataRequest + ScriptDataRequest, + /// ScriptDataReply + ScriptDataReply, + /// CreateGroupRequest + CreateGroupRequest, + /// CreateGroupReply + CreateGroupReply, + /// UpdateGroupInfo + UpdateGroupInfo, + /// GroupRoleChanges + GroupRoleChanges, + /// JoinGroupRequest + JoinGroupRequest, + /// JoinGroupReply + JoinGroupReply, + /// EjectGroupMemberRequest + EjectGroupMemberRequest, + /// EjectGroupMemberReply + EjectGroupMemberReply, + /// LeaveGroupRequest + LeaveGroupRequest, + /// LeaveGroupReply + LeaveGroupReply, + /// InviteGroupRequest + InviteGroupRequest, + /// InviteGroupResponse + InviteGroupResponse, + /// GroupProfileRequest + GroupProfileRequest, + /// GroupProfileReply + GroupProfileReply, + /// GroupAccountSummaryRequest + GroupAccountSummaryRequest, + /// GroupAccountSummaryReply + GroupAccountSummaryReply, + /// GroupAccountDetailsRequest + GroupAccountDetailsRequest, + /// GroupAccountDetailsReply + GroupAccountDetailsReply, + /// GroupAccountTransactionsRequest + GroupAccountTransactionsRequest, + /// GroupAccountTransactionsReply + GroupAccountTransactionsReply, + /// GroupActiveProposalsRequest + GroupActiveProposalsRequest, + /// GroupActiveProposalItemReply + GroupActiveProposalItemReply, + /// GroupVoteHistoryRequest + GroupVoteHistoryRequest, + /// GroupVoteHistoryItemReply + GroupVoteHistoryItemReply, + /// StartGroupProposal + StartGroupProposal, + /// GroupProposalBallot + GroupProposalBallot, + /// TallyVotes + TallyVotes, + /// GroupMembersRequest + GroupMembersRequest, + /// GroupMembersReply + GroupMembersReply, + /// ActivateGroup + ActivateGroup, + /// SetGroupContribution + SetGroupContribution, + /// SetGroupAcceptNotices + SetGroupAcceptNotices, + /// GroupRoleDataRequest + GroupRoleDataRequest, + /// GroupRoleDataReply + GroupRoleDataReply, + /// GroupRoleMembersRequest + GroupRoleMembersRequest, + /// GroupRoleMembersReply + GroupRoleMembersReply, + /// GroupTitlesRequest + GroupTitlesRequest, + /// GroupTitlesReply + GroupTitlesReply, + /// GroupTitleUpdate + GroupTitleUpdate, + /// GroupRoleUpdate + GroupRoleUpdate, + /// LiveHelpGroupRequest + LiveHelpGroupRequest, + /// LiveHelpGroupReply + LiveHelpGroupReply, + /// AgentWearablesRequest + AgentWearablesRequest, + /// AgentWearablesUpdate + AgentWearablesUpdate, + /// AgentIsNowWearing + AgentIsNowWearing, + /// AgentCachedTexture + AgentCachedTexture, + /// AgentCachedTextureResponse + AgentCachedTextureResponse, + /// AgentDataUpdateRequest + AgentDataUpdateRequest, + /// AgentDataUpdate + AgentDataUpdate, + /// GroupDataUpdate + GroupDataUpdate, + /// AgentGroupDataUpdate + AgentGroupDataUpdate, + /// AgentDropGroup + AgentDropGroup, + /// LogTextMessage + LogTextMessage, + /// CreateTrustedCircuit + CreateTrustedCircuit, + /// DenyTrustedCircuit + DenyTrustedCircuit, + /// RezSingleAttachmentFromInv + RezSingleAttachmentFromInv, + /// RezMultipleAttachmentsFromInv + RezMultipleAttachmentsFromInv, + /// DetachAttachmentIntoInv + DetachAttachmentIntoInv, + /// CreateNewOutfitAttachments + CreateNewOutfitAttachments, + /// UserInfoRequest + UserInfoRequest, + /// UserInfoReply + UserInfoReply, + /// UpdateUserInfo + UpdateUserInfo, + /// GodExpungeUser + GodExpungeUser, + /// StartExpungeProcess + StartExpungeProcess, + /// StartExpungeProcessAck + StartExpungeProcessAck, + /// StartParcelRename + StartParcelRename, + /// StartParcelRenameAck + StartParcelRenameAck, + /// BulkParcelRename + BulkParcelRename, + /// ParcelRename + ParcelRename, + /// StartParcelRemove + StartParcelRemove, + /// StartParcelRemoveAck + StartParcelRemoveAck, + /// BulkParcelRemove + BulkParcelRemove, + /// InitiateUpload + InitiateUpload, + /// InitiateDownload + InitiateDownload, + /// SystemMessage + SystemMessage, + /// MapLayerRequest + MapLayerRequest, + /// MapLayerReply + MapLayerReply, + /// MapBlockRequest + MapBlockRequest, + /// MapNameRequest + MapNameRequest, + /// MapBlockReply + MapBlockReply, + /// MapItemRequest + MapItemRequest, + /// MapItemReply + MapItemReply, + /// SendPostcard + SendPostcard, + /// RpcChannelRequest + RpcChannelRequest, + /// RpcChannelReply + RpcChannelReply, + /// RpcScriptRequestInbound + RpcScriptRequestInbound, + /// RpcScriptRequestInboundForward + RpcScriptRequestInboundForward, + /// RpcScriptReplyInbound + RpcScriptReplyInbound, + /// MailTaskSimRequest + MailTaskSimRequest, + /// MailTaskSimReply + MailTaskSimReply, + /// ScriptMailRegistration + ScriptMailRegistration, + /// ParcelMediaCommandMessage + ParcelMediaCommandMessage, + /// ParcelMediaUpdate + ParcelMediaUpdate, + /// LandStatRequest + LandStatRequest, + /// LandStatReply + LandStatReply, + /// SecuredTemplateChecksumRequest + SecuredTemplateChecksumRequest, + /// PacketAck + PacketAck, + /// OpenCircuit + OpenCircuit, + /// CloseCircuit + CloseCircuit, + /// TemplateChecksumRequest + TemplateChecksumRequest, + /// TemplateChecksumReply + TemplateChecksumReply, + /// ClosestSimulator + ClosestSimulator, + /// ObjectAdd + ObjectAdd, + /// MultipleObjectUpdate + MultipleObjectUpdate, + /// RequestMultipleObjects + RequestMultipleObjects, + /// ObjectPosition + ObjectPosition, + /// RequestObjectPropertiesFamily + RequestObjectPropertiesFamily, + /// CoarseLocationUpdate + CoarseLocationUpdate, + /// CrossedRegion + CrossedRegion, + /// ConfirmEnableSimulator + ConfirmEnableSimulator, + /// ObjectProperties + ObjectProperties, + /// ObjectPropertiesFamily + ObjectPropertiesFamily, + /// ParcelPropertiesRequest + ParcelPropertiesRequest, + /// SimStatus + SimStatus, + /// GestureUpdate + GestureUpdate, + /// AttachedSound + AttachedSound, + /// AttachedSoundGainChange + AttachedSoundGainChange, + /// AttachedSoundCutoffRadius + AttachedSoundCutoffRadius, + /// PreloadSound + PreloadSound, + /// InternalScriptMail + InternalScriptMail, + /// ViewerEffect + ViewerEffect, + /// SetSunPhase + SetSunPhase, + /// StartPingCheck + StartPingCheck, + /// CompletePingCheck + CompletePingCheck, + /// NeighborList + NeighborList, + /// MovedIntoSimulator + MovedIntoSimulator, + /// AgentUpdate + AgentUpdate, + /// AgentAnimation + AgentAnimation, + /// AgentRequestSit + AgentRequestSit, + /// AgentSit + AgentSit, + /// RequestImage + RequestImage, + /// ImageData + ImageData, + /// ImagePacket + ImagePacket, + /// LayerData + LayerData, + /// ObjectUpdate + ObjectUpdate, + /// ObjectUpdateCompressed + ObjectUpdateCompressed, + /// ObjectUpdateCached + ObjectUpdateCached, + /// ImprovedTerseObjectUpdate + ImprovedTerseObjectUpdate, + /// KillObject + KillObject, + /// AgentToNewRegion + AgentToNewRegion, + /// TransferPacket + TransferPacket, + /// SendXferPacket + SendXferPacket, + /// ConfirmXferPacket + ConfirmXferPacket, + /// AvatarAnimation + AvatarAnimation, + /// AvatarSitResponse + AvatarSitResponse, + /// CameraConstraint + CameraConstraint, + /// ParcelProperties + ParcelProperties, + /// EdgeDataPacket + EdgeDataPacket, + /// ChildAgentUpdate + ChildAgentUpdate, + /// ChildAgentAlive + ChildAgentAlive, + /// ChildAgentPositionUpdate + ChildAgentPositionUpdate, + /// PassObject + PassObject, + /// AtomicPassObject + AtomicPassObject, + /// SoundTrigger + SoundTrigger, } - + /// Base class for all packet classes public abstract class Packet { @@ -1505,589 +1505,589 @@ namespace libsecondlife.Packets { case PacketFrequency.Low: switch (id) - { - case 1: return PacketType.TestMessage; - case 2: return PacketType.AddCircuitCode; - case 3: return PacketType.UseCircuitCode; - case 4: return PacketType.LogControl; - case 5: return PacketType.RelayLogControl; - case 6: return PacketType.LogMessages; - case 7: return PacketType.SimulatorAssign; - case 8: return PacketType.SpaceServerSimulatorTimeMessage; - case 9: return PacketType.AvatarTextureUpdate; - case 10: return PacketType.SimulatorMapUpdate; - case 11: return PacketType.SimulatorSetMap; - case 12: return PacketType.SubscribeLoad; - case 13: return PacketType.UnsubscribeLoad; - case 14: return PacketType.SimulatorStart; - case 15: return PacketType.SimulatorReady; - case 16: return PacketType.TelehubInfo; - case 17: return PacketType.SimulatorPresentAtLocation; - case 18: return PacketType.SimulatorLoad; - case 19: return PacketType.SimulatorShutdownRequest; - case 20: return PacketType.RegionPresenceRequestByRegionID; - case 21: return PacketType.RegionPresenceRequestByHandle; - case 22: return PacketType.RegionPresenceResponse; - case 23: return PacketType.RecordAgentPresence; - case 24: return PacketType.EraseAgentPresence; - case 25: return PacketType.AgentPresenceRequest; - case 26: return PacketType.AgentPresenceResponse; - case 27: return PacketType.UpdateSimulator; - case 28: return PacketType.TrackAgentSession; - case 29: return PacketType.ClearAgentSessions; - case 30: return PacketType.LogDwellTime; - case 31: return PacketType.FeatureDisabled; - case 32: return PacketType.LogFailedMoneyTransaction; - case 33: return PacketType.UserReportInternal; - case 34: return PacketType.SetSimStatusInDatabase; - case 35: return PacketType.SetSimPresenceInDatabase; - case 36: return PacketType.EconomyDataRequest; - case 37: return PacketType.EconomyData; - case 38: return PacketType.AvatarPickerRequest; - case 39: return PacketType.AvatarPickerRequestBackend; - case 40: return PacketType.AvatarPickerReply; - case 41: return PacketType.PlacesQuery; - case 42: return PacketType.PlacesReply; - case 43: return PacketType.DirFindQuery; - case 44: return PacketType.DirFindQueryBackend; - case 45: return PacketType.DirPlacesQuery; - case 46: return PacketType.DirPlacesQueryBackend; - case 47: return PacketType.DirPlacesReply; - case 48: return PacketType.DirPeopleQuery; - case 49: return PacketType.DirPeopleQueryBackend; - case 50: return PacketType.DirPeopleReply; - case 51: return PacketType.DirEventsReply; - case 52: return PacketType.DirGroupsQuery; - case 53: return PacketType.DirGroupsQueryBackend; - case 54: return PacketType.DirGroupsReply; - case 55: return PacketType.DirClassifiedQuery; - case 56: return PacketType.DirClassifiedQueryBackend; - case 57: return PacketType.DirClassifiedReply; - case 58: return PacketType.AvatarClassifiedReply; - case 59: return PacketType.ClassifiedInfoRequest; - case 60: return PacketType.ClassifiedInfoReply; - case 61: return PacketType.ClassifiedInfoUpdate; - case 62: return PacketType.ClassifiedDelete; - case 63: return PacketType.ClassifiedGodDelete; - case 64: return PacketType.DirPicksQuery; - case 65: return PacketType.DirPicksQueryBackend; - case 66: return PacketType.DirPicksReply; - case 67: return PacketType.DirLandQuery; - case 68: return PacketType.DirLandQueryBackend; - case 69: return PacketType.DirLandReply; - case 70: return PacketType.DirPopularQuery; - case 71: return PacketType.DirPopularQueryBackend; - case 72: return PacketType.DirPopularReply; - case 73: return PacketType.ParcelInfoRequest; - case 74: return PacketType.ParcelInfoReply; - case 75: return PacketType.ParcelObjectOwnersRequest; - case 76: return PacketType.OnlineStatusRequest; - case 77: return PacketType.OnlineStatusReply; - case 78: return PacketType.ParcelObjectOwnersReply; - case 79: return PacketType.GroupNoticesListRequest; - case 80: return PacketType.GroupNoticesListReply; - case 81: return PacketType.GroupNoticeRequest; - case 82: return PacketType.GroupNoticeAdd; - case 83: return PacketType.GroupNoticeDelete; - case 84: return PacketType.TeleportRequest; - case 85: return PacketType.TeleportLocationRequest; - case 86: return PacketType.TeleportLocal; - case 87: return PacketType.TeleportLandmarkRequest; - case 88: return PacketType.TeleportProgress; - case 89: return PacketType.DataAgentAccessRequest; - case 90: return PacketType.DataAgentAccessReply; - case 91: return PacketType.DataHomeLocationRequest; - case 92: return PacketType.DataHomeLocationReply; - case 93: return PacketType.SpaceLocationTeleportRequest; - case 94: return PacketType.SpaceLocationTeleportReply; - case 95: return PacketType.TeleportFinish; - case 96: return PacketType.StartLure; - case 97: return PacketType.TeleportLureRequest; - case 98: return PacketType.TeleportCancel; - case 99: return PacketType.CompleteLure; - case 100: return PacketType.TeleportStart; - case 101: return PacketType.TeleportFailed; - case 102: return PacketType.LeaderBoardRequest; - case 103: return PacketType.LeaderBoardData; - case 104: return PacketType.RegisterNewAgent; - case 105: return PacketType.Undo; - case 106: return PacketType.Redo; - case 107: return PacketType.UndoLand; - case 108: return PacketType.RedoLand; - case 109: return PacketType.AgentPause; - case 110: return PacketType.AgentResume; - case 111: return PacketType.ChatFromViewer; - case 112: return PacketType.AgentThrottle; - case 113: return PacketType.AgentFOV; - case 114: return PacketType.AgentHeightWidth; - case 115: return PacketType.AgentSetAppearance; - case 116: return PacketType.AgentQuit; - case 117: return PacketType.AgentQuitCopy; - case 118: return PacketType.ImageNotInDatabase; - case 119: return PacketType.RebakeAvatarTextures; - case 120: return PacketType.SetAlwaysRun; - case 121: return PacketType.ObjectDelete; - case 122: return PacketType.ObjectDuplicate; - case 123: return PacketType.ObjectDuplicateOnRay; - case 124: return PacketType.ObjectScale; - case 125: return PacketType.ObjectRotation; - case 126: return PacketType.ObjectFlagUpdate; - case 127: return PacketType.ObjectClickAction; - case 128: return PacketType.ObjectImage; - case 129: return PacketType.ObjectMaterial; - case 130: return PacketType.ObjectShape; - case 131: return PacketType.ObjectExtraParams; - case 132: return PacketType.ObjectOwner; - case 133: return PacketType.ObjectGroup; - case 134: return PacketType.ObjectBuy; - case 135: return PacketType.BuyObjectInventory; - case 136: return PacketType.DerezContainer; - case 137: return PacketType.ObjectPermissions; - case 138: return PacketType.ObjectSaleInfo; - case 139: return PacketType.ObjectName; - case 140: return PacketType.ObjectDescription; - case 141: return PacketType.ObjectCategory; - case 142: return PacketType.ObjectSelect; - case 143: return PacketType.ObjectDeselect; - case 144: return PacketType.ObjectAttach; - case 145: return PacketType.ObjectDetach; - case 146: return PacketType.ObjectDrop; - case 147: return PacketType.ObjectLink; - case 148: return PacketType.ObjectDelink; - case 149: return PacketType.ObjectHinge; - case 150: return PacketType.ObjectDehinge; - case 151: return PacketType.ObjectGrab; - case 152: return PacketType.ObjectGrabUpdate; - case 153: return PacketType.ObjectDeGrab; - case 154: return PacketType.ObjectSpinStart; - case 155: return PacketType.ObjectSpinUpdate; - case 156: return PacketType.ObjectSpinStop; - case 157: return PacketType.ObjectExportSelected; - case 158: return PacketType.ObjectImport; - case 159: return PacketType.ModifyLand; - case 160: return PacketType.VelocityInterpolateOn; - case 161: return PacketType.VelocityInterpolateOff; - case 162: return PacketType.StateSave; - case 163: return PacketType.ReportAutosaveCrash; - case 164: return PacketType.SimWideDeletes; - case 165: return PacketType.TrackAgent; - case 166: return PacketType.GrantModification; - case 167: return PacketType.RevokeModification; - case 168: return PacketType.RequestGrantedProxies; - case 169: return PacketType.GrantedProxies; - case 170: return PacketType.AddModifyAbility; - case 171: return PacketType.RemoveModifyAbility; - case 172: return PacketType.ViewerStats; - case 173: return PacketType.ScriptAnswerYes; - case 174: return PacketType.UserReport; - case 175: return PacketType.AlertMessage; - case 176: return PacketType.AgentAlertMessage; - case 177: return PacketType.MeanCollisionAlert; - case 178: return PacketType.ViewerFrozenMessage; - case 179: return PacketType.HealthMessage; - case 180: return PacketType.ChatFromSimulator; - case 181: return PacketType.SimStats; - case 182: return PacketType.RequestRegionInfo; - case 183: return PacketType.RegionInfo; - case 184: return PacketType.GodUpdateRegionInfo; - case 185: return PacketType.NearestLandingRegionRequest; - case 186: return PacketType.NearestLandingRegionReply; - case 187: return PacketType.NearestLandingRegionUpdated; - case 188: return PacketType.TeleportLandingStatusChanged; - case 189: return PacketType.RegionHandshake; - case 190: return PacketType.RegionHandshakeReply; - case 191: return PacketType.SimulatorViewerTimeMessage; - case 192: return PacketType.EnableSimulator; - case 193: return PacketType.DisableSimulator; - case 194: return PacketType.TransferRequest; - case 195: return PacketType.TransferInfo; - case 196: return PacketType.TransferAbort; - case 197: return PacketType.TransferPriority; - case 198: return PacketType.RequestXfer; - case 199: return PacketType.AbortXfer; - case 200: return PacketType.RequestAvatarInfo; - case 201: return PacketType.AvatarAppearance; - case 202: return PacketType.SetFollowCamProperties; - case 203: return PacketType.ClearFollowCamProperties; - case 204: return PacketType.RequestPayPrice; - case 205: return PacketType.PayPriceReply; - case 206: return PacketType.KickUser; - case 207: return PacketType.KickUserAck; - case 208: return PacketType.GodKickUser; - case 209: return PacketType.SystemKickUser; - case 210: return PacketType.EjectUser; - case 211: return PacketType.FreezeUser; - case 212: return PacketType.AvatarPropertiesRequest; - case 213: return PacketType.AvatarPropertiesRequestBackend; - case 214: return PacketType.AvatarPropertiesReply; - case 215: return PacketType.AvatarGroupsReply; - case 216: return PacketType.AvatarPropertiesUpdate; - case 217: return PacketType.AvatarStatisticsReply; - case 218: return PacketType.AvatarNotesReply; - case 219: return PacketType.AvatarNotesUpdate; - case 220: return PacketType.AvatarPicksReply; - case 221: return PacketType.EventInfoRequest; - case 222: return PacketType.EventInfoReply; - case 223: return PacketType.EventNotificationAddRequest; - case 224: return PacketType.EventNotificationRemoveRequest; - case 225: return PacketType.EventGodDelete; - case 226: return PacketType.PickInfoRequest; - case 227: return PacketType.PickInfoReply; - case 228: return PacketType.PickInfoUpdate; - case 229: return PacketType.PickDelete; - case 230: return PacketType.PickGodDelete; - case 231: return PacketType.ScriptQuestion; - case 232: return PacketType.ScriptControlChange; - case 233: return PacketType.ScriptDialog; - case 234: return PacketType.ScriptDialogReply; - case 235: return PacketType.ForceScriptControlRelease; - case 236: return PacketType.RevokePermissions; - case 237: return PacketType.LoadURL; - case 238: return PacketType.ScriptTeleportRequest; - case 239: return PacketType.ParcelOverlay; - case 240: return PacketType.ParcelPropertiesRequestByID; - case 241: return PacketType.ParcelPropertiesUpdate; - case 242: return PacketType.ParcelReturnObjects; - case 243: return PacketType.ParcelSetOtherCleanTime; - case 244: return PacketType.ParcelDisableObjects; - case 245: return PacketType.ParcelSelectObjects; - case 246: return PacketType.EstateCovenantRequest; - case 247: return PacketType.EstateCovenantReply; - case 248: return PacketType.ForceObjectSelect; - case 249: return PacketType.ParcelBuyPass; - case 250: return PacketType.ParcelDeedToGroup; - case 251: return PacketType.ParcelReclaim; - case 252: return PacketType.ParcelClaim; - case 253: return PacketType.ParcelJoin; - case 254: return PacketType.ParcelDivide; - case 255: return PacketType.ParcelRelease; - case 256: return PacketType.ParcelBuy; - case 257: return PacketType.ParcelGodForceOwner; - case 258: return PacketType.ParcelAccessListRequest; - case 259: return PacketType.ParcelAccessListReply; - case 260: return PacketType.ParcelAccessListUpdate; - case 261: return PacketType.ParcelDwellRequest; - case 262: return PacketType.ParcelDwellReply; - case 263: return PacketType.RequestParcelTransfer; - case 264: return PacketType.UpdateParcel; - case 265: return PacketType.RemoveParcel; - case 266: return PacketType.MergeParcel; - case 267: return PacketType.LogParcelChanges; - case 268: return PacketType.CheckParcelSales; - case 269: return PacketType.ParcelSales; - case 270: return PacketType.ParcelGodMarkAsContent; - case 271: return PacketType.ParcelGodReserveForNewbie; - case 272: return PacketType.ViewerStartAuction; - case 273: return PacketType.StartAuction; - case 274: return PacketType.ConfirmAuctionStart; - case 275: return PacketType.CompleteAuction; - case 276: return PacketType.CancelAuction; - case 277: return PacketType.CheckParcelAuctions; - case 278: return PacketType.ParcelAuctions; - case 279: return PacketType.UUIDNameRequest; - case 280: return PacketType.UUIDNameReply; - case 281: return PacketType.UUIDGroupNameRequest; - case 282: return PacketType.UUIDGroupNameReply; - case 283: return PacketType.ChatPass; - case 284: return PacketType.ChildAgentDying; - case 285: return PacketType.ChildAgentUnknown; - case 286: return PacketType.KillChildAgents; - case 287: return PacketType.GetScriptRunning; - case 288: return PacketType.ScriptRunningReply; - case 289: return PacketType.SetScriptRunning; - case 290: return PacketType.ScriptReset; - case 291: return PacketType.ScriptSensorRequest; - case 292: return PacketType.ScriptSensorReply; - case 293: return PacketType.CompleteAgentMovement; - case 294: return PacketType.AgentMovementComplete; - case 295: return PacketType.LogLogin; - case 296: return PacketType.ConnectAgentToUserserver; - case 297: return PacketType.ConnectToUserserver; - case 298: return PacketType.DataServerLogout; - case 299: return PacketType.LogoutRequest; - case 300: return PacketType.FinalizeLogout; - case 301: return PacketType.LogoutReply; - case 302: return PacketType.LogoutDemand; - case 303: return PacketType.ImprovedInstantMessage; - case 304: return PacketType.RetrieveInstantMessages; - case 305: return PacketType.DequeueInstantMessages; - case 306: return PacketType.FindAgent; - case 307: return PacketType.RequestGodlikePowers; - case 308: return PacketType.GrantGodlikePowers; - case 309: return PacketType.GodlikeMessage; - case 310: return PacketType.EstateOwnerMessage; - case 311: return PacketType.GenericMessage; - case 312: return PacketType.MuteListRequest; - case 313: return PacketType.UpdateMuteListEntry; - case 314: return PacketType.RemoveMuteListEntry; - case 315: return PacketType.CopyInventoryFromNotecard; - case 316: return PacketType.UpdateInventoryItem; - case 317: return PacketType.UpdateCreateInventoryItem; - case 318: return PacketType.MoveInventoryItem; - case 319: return PacketType.CopyInventoryItem; - case 320: return PacketType.RemoveInventoryItem; - case 321: return PacketType.ChangeInventoryItemFlags; - case 322: return PacketType.SaveAssetIntoInventory; - case 323: return PacketType.CreateInventoryFolder; - case 324: return PacketType.UpdateInventoryFolder; - case 325: return PacketType.MoveInventoryFolder; - case 326: return PacketType.RemoveInventoryFolder; - case 327: return PacketType.FetchInventoryDescendents; - case 328: return PacketType.InventoryDescendents; - case 329: return PacketType.FetchInventory; - case 330: return PacketType.FetchInventoryReply; - case 331: return PacketType.BulkUpdateInventory; - case 332: return PacketType.RequestInventoryAsset; - case 333: return PacketType.InventoryAssetResponse; - case 334: return PacketType.RemoveInventoryObjects; - case 335: return PacketType.PurgeInventoryDescendents; - case 336: return PacketType.UpdateTaskInventory; - case 337: return PacketType.RemoveTaskInventory; - case 338: return PacketType.MoveTaskInventory; - case 339: return PacketType.RequestTaskInventory; - case 340: return PacketType.ReplyTaskInventory; - case 341: return PacketType.DeRezObject; - case 342: return PacketType.DeRezAck; - case 343: return PacketType.RezObject; - case 344: return PacketType.RezObjectFromNotecard; - case 345: return PacketType.DeclineInventory; - case 346: return PacketType.TransferInventory; - case 347: return PacketType.TransferInventoryAck; - case 348: return PacketType.RequestFriendship; - case 349: return PacketType.AcceptFriendship; - case 350: return PacketType.DeclineFriendship; - case 351: return PacketType.FormFriendship; - case 352: return PacketType.TerminateFriendship; - case 353: return PacketType.OfferCallingCard; - case 354: return PacketType.AcceptCallingCard; - case 355: return PacketType.DeclineCallingCard; - case 356: return PacketType.RezScript; - case 357: return PacketType.CreateInventoryItem; - case 358: return PacketType.CreateLandmarkForEvent; - case 359: return PacketType.EventLocationRequest; - case 360: return PacketType.EventLocationReply; - case 361: return PacketType.RegionHandleRequest; - case 362: return PacketType.RegionIDAndHandleReply; - case 363: return PacketType.MoneyTransferRequest; - case 364: return PacketType.MoneyTransferBackend; - case 365: return PacketType.BulkMoneyTransfer; - case 366: return PacketType.AdjustBalance; - case 367: return PacketType.MoneyBalanceRequest; - case 368: return PacketType.MoneyBalanceReply; - case 369: return PacketType.RoutedMoneyBalanceReply; - case 370: return PacketType.MoneyHistoryRequest; - case 371: return PacketType.MoneyHistoryReply; - case 372: return PacketType.MoneySummaryRequest; - case 373: return PacketType.MoneySummaryReply; - case 374: return PacketType.MoneyDetailsRequest; - case 375: return PacketType.MoneyDetailsReply; - case 376: return PacketType.MoneyTransactionsRequest; - case 377: return PacketType.MoneyTransactionsReply; - case 378: return PacketType.GestureRequest; - case 379: return PacketType.ActivateGestures; - case 380: return PacketType.DeactivateGestures; - case 381: return PacketType.InventoryUpdate; - case 382: return PacketType.MuteListUpdate; - case 383: return PacketType.UseCachedMuteList; - case 384: return PacketType.UserLoginLocationReply; - case 385: return PacketType.UserSimLocationReply; - case 386: return PacketType.UserListReply; - case 387: return PacketType.OnlineNotification; - case 388: return PacketType.OfflineNotification; - case 389: return PacketType.SetStartLocationRequest; - case 390: return PacketType.SetStartLocation; - case 391: return PacketType.UserLoginLocationRequest; - case 392: return PacketType.SpaceLoginLocationReply; - case 393: return PacketType.NetTest; - case 394: return PacketType.SetCPURatio; - case 395: return PacketType.SimCrashed; - case 396: return PacketType.SimulatorPauseState; - case 397: return PacketType.SimulatorThrottleSettings; - case 398: return PacketType.NameValuePair; - case 399: return PacketType.RemoveNameValuePair; - case 400: return PacketType.GetNameValuePair; - case 401: return PacketType.UpdateAttachment; - case 402: return PacketType.RemoveAttachment; - case 403: return PacketType.AssetUploadRequest; - case 404: return PacketType.AssetUploadComplete; - case 405: return PacketType.ReputationAgentAssign; - case 406: return PacketType.ReputationIndividualRequest; - case 407: return PacketType.ReputationIndividualReply; - case 408: return PacketType.EmailMessageRequest; - case 409: return PacketType.EmailMessageReply; - case 410: return PacketType.ScriptDataRequest; - case 411: return PacketType.ScriptDataReply; - case 412: return PacketType.CreateGroupRequest; - case 413: return PacketType.CreateGroupReply; - case 414: return PacketType.UpdateGroupInfo; - case 415: return PacketType.GroupRoleChanges; - case 416: return PacketType.JoinGroupRequest; - case 417: return PacketType.JoinGroupReply; - case 418: return PacketType.EjectGroupMemberRequest; - case 419: return PacketType.EjectGroupMemberReply; - case 420: return PacketType.LeaveGroupRequest; - case 421: return PacketType.LeaveGroupReply; - case 422: return PacketType.InviteGroupRequest; - case 423: return PacketType.InviteGroupResponse; - case 424: return PacketType.GroupProfileRequest; - case 425: return PacketType.GroupProfileReply; - case 426: return PacketType.GroupAccountSummaryRequest; - case 427: return PacketType.GroupAccountSummaryReply; - case 428: return PacketType.GroupAccountDetailsRequest; - case 429: return PacketType.GroupAccountDetailsReply; - case 430: return PacketType.GroupAccountTransactionsRequest; - case 431: return PacketType.GroupAccountTransactionsReply; - case 432: return PacketType.GroupActiveProposalsRequest; - case 433: return PacketType.GroupActiveProposalItemReply; - case 434: return PacketType.GroupVoteHistoryRequest; - case 435: return PacketType.GroupVoteHistoryItemReply; - case 436: return PacketType.StartGroupProposal; - case 437: return PacketType.GroupProposalBallot; - case 438: return PacketType.TallyVotes; - case 439: return PacketType.GroupMembersRequest; - case 440: return PacketType.GroupMembersReply; - case 441: return PacketType.ActivateGroup; - case 442: return PacketType.SetGroupContribution; - case 443: return PacketType.SetGroupAcceptNotices; - case 444: return PacketType.GroupRoleDataRequest; - case 445: return PacketType.GroupRoleDataReply; - case 446: return PacketType.GroupRoleMembersRequest; - case 447: return PacketType.GroupRoleMembersReply; - case 448: return PacketType.GroupTitlesRequest; - case 449: return PacketType.GroupTitlesReply; - case 450: return PacketType.GroupTitleUpdate; - case 451: return PacketType.GroupRoleUpdate; - case 452: return PacketType.LiveHelpGroupRequest; - case 453: return PacketType.LiveHelpGroupReply; - case 454: return PacketType.AgentWearablesRequest; - case 455: return PacketType.AgentWearablesUpdate; - case 456: return PacketType.AgentIsNowWearing; - case 457: return PacketType.AgentCachedTexture; - case 458: return PacketType.AgentCachedTextureResponse; - case 459: return PacketType.AgentDataUpdateRequest; - case 460: return PacketType.AgentDataUpdate; - case 461: return PacketType.GroupDataUpdate; - case 462: return PacketType.AgentGroupDataUpdate; - case 463: return PacketType.AgentDropGroup; - case 464: return PacketType.LogTextMessage; - case 465: return PacketType.CreateTrustedCircuit; - case 466: return PacketType.DenyTrustedCircuit; - case 467: return PacketType.RezSingleAttachmentFromInv; - case 468: return PacketType.RezMultipleAttachmentsFromInv; - case 469: return PacketType.DetachAttachmentIntoInv; - case 470: return PacketType.CreateNewOutfitAttachments; - case 471: return PacketType.UserInfoRequest; - case 472: return PacketType.UserInfoReply; - case 473: return PacketType.UpdateUserInfo; - case 474: return PacketType.GodExpungeUser; - case 475: return PacketType.StartExpungeProcess; - case 476: return PacketType.StartExpungeProcessAck; - case 477: return PacketType.StartParcelRename; - case 478: return PacketType.StartParcelRenameAck; - case 479: return PacketType.BulkParcelRename; - case 480: return PacketType.ParcelRename; - case 481: return PacketType.StartParcelRemove; - case 482: return PacketType.StartParcelRemoveAck; - case 483: return PacketType.BulkParcelRemove; - case 484: return PacketType.InitiateUpload; - case 485: return PacketType.InitiateDownload; - case 486: return PacketType.SystemMessage; - case 487: return PacketType.MapLayerRequest; - case 488: return PacketType.MapLayerReply; - case 489: return PacketType.MapBlockRequest; - case 490: return PacketType.MapNameRequest; - case 491: return PacketType.MapBlockReply; - case 492: return PacketType.MapItemRequest; - case 493: return PacketType.MapItemReply; - case 494: return PacketType.SendPostcard; - case 495: return PacketType.RpcChannelRequest; - case 496: return PacketType.RpcChannelReply; - case 497: return PacketType.RpcScriptRequestInbound; - case 498: return PacketType.RpcScriptRequestInboundForward; - case 499: return PacketType.RpcScriptReplyInbound; - case 500: return PacketType.MailTaskSimRequest; - case 501: return PacketType.MailTaskSimReply; - case 502: return PacketType.ScriptMailRegistration; - case 503: return PacketType.ParcelMediaCommandMessage; - case 504: return PacketType.ParcelMediaUpdate; - case 505: return PacketType.LandStatRequest; - case 506: return PacketType.LandStatReply; - case 65530: return PacketType.SecuredTemplateChecksumRequest; - case 65531: return PacketType.PacketAck; - case 65532: return PacketType.OpenCircuit; - case 65533: return PacketType.CloseCircuit; - case 65534: return PacketType.TemplateChecksumRequest; - case 65535: return PacketType.TemplateChecksumReply; + { + case 1: return PacketType.TestMessage; + case 2: return PacketType.AddCircuitCode; + case 3: return PacketType.UseCircuitCode; + case 4: return PacketType.LogControl; + case 5: return PacketType.RelayLogControl; + case 6: return PacketType.LogMessages; + case 7: return PacketType.SimulatorAssign; + case 8: return PacketType.SpaceServerSimulatorTimeMessage; + case 9: return PacketType.AvatarTextureUpdate; + case 10: return PacketType.SimulatorMapUpdate; + case 11: return PacketType.SimulatorSetMap; + case 12: return PacketType.SubscribeLoad; + case 13: return PacketType.UnsubscribeLoad; + case 14: return PacketType.SimulatorStart; + case 15: return PacketType.SimulatorReady; + case 16: return PacketType.TelehubInfo; + case 17: return PacketType.SimulatorPresentAtLocation; + case 18: return PacketType.SimulatorLoad; + case 19: return PacketType.SimulatorShutdownRequest; + case 20: return PacketType.RegionPresenceRequestByRegionID; + case 21: return PacketType.RegionPresenceRequestByHandle; + case 22: return PacketType.RegionPresenceResponse; + case 23: return PacketType.RecordAgentPresence; + case 24: return PacketType.EraseAgentPresence; + case 25: return PacketType.AgentPresenceRequest; + case 26: return PacketType.AgentPresenceResponse; + case 27: return PacketType.UpdateSimulator; + case 28: return PacketType.TrackAgentSession; + case 29: return PacketType.ClearAgentSessions; + case 30: return PacketType.LogDwellTime; + case 31: return PacketType.FeatureDisabled; + case 32: return PacketType.LogFailedMoneyTransaction; + case 33: return PacketType.UserReportInternal; + case 34: return PacketType.SetSimStatusInDatabase; + case 35: return PacketType.SetSimPresenceInDatabase; + case 36: return PacketType.EconomyDataRequest; + case 37: return PacketType.EconomyData; + case 38: return PacketType.AvatarPickerRequest; + case 39: return PacketType.AvatarPickerRequestBackend; + case 40: return PacketType.AvatarPickerReply; + case 41: return PacketType.PlacesQuery; + case 42: return PacketType.PlacesReply; + case 43: return PacketType.DirFindQuery; + case 44: return PacketType.DirFindQueryBackend; + case 45: return PacketType.DirPlacesQuery; + case 46: return PacketType.DirPlacesQueryBackend; + case 47: return PacketType.DirPlacesReply; + case 48: return PacketType.DirPeopleQuery; + case 49: return PacketType.DirPeopleQueryBackend; + case 50: return PacketType.DirPeopleReply; + case 51: return PacketType.DirEventsReply; + case 52: return PacketType.DirGroupsQuery; + case 53: return PacketType.DirGroupsQueryBackend; + case 54: return PacketType.DirGroupsReply; + case 55: return PacketType.DirClassifiedQuery; + case 56: return PacketType.DirClassifiedQueryBackend; + case 57: return PacketType.DirClassifiedReply; + case 58: return PacketType.AvatarClassifiedReply; + case 59: return PacketType.ClassifiedInfoRequest; + case 60: return PacketType.ClassifiedInfoReply; + case 61: return PacketType.ClassifiedInfoUpdate; + case 62: return PacketType.ClassifiedDelete; + case 63: return PacketType.ClassifiedGodDelete; + case 64: return PacketType.DirPicksQuery; + case 65: return PacketType.DirPicksQueryBackend; + case 66: return PacketType.DirPicksReply; + case 67: return PacketType.DirLandQuery; + case 68: return PacketType.DirLandQueryBackend; + case 69: return PacketType.DirLandReply; + case 70: return PacketType.DirPopularQuery; + case 71: return PacketType.DirPopularQueryBackend; + case 72: return PacketType.DirPopularReply; + case 73: return PacketType.ParcelInfoRequest; + case 74: return PacketType.ParcelInfoReply; + case 75: return PacketType.ParcelObjectOwnersRequest; + case 76: return PacketType.OnlineStatusRequest; + case 77: return PacketType.OnlineStatusReply; + case 78: return PacketType.ParcelObjectOwnersReply; + case 79: return PacketType.GroupNoticesListRequest; + case 80: return PacketType.GroupNoticesListReply; + case 81: return PacketType.GroupNoticeRequest; + case 82: return PacketType.GroupNoticeAdd; + case 83: return PacketType.GroupNoticeDelete; + case 84: return PacketType.TeleportRequest; + case 85: return PacketType.TeleportLocationRequest; + case 86: return PacketType.TeleportLocal; + case 87: return PacketType.TeleportLandmarkRequest; + case 88: return PacketType.TeleportProgress; + case 89: return PacketType.DataAgentAccessRequest; + case 90: return PacketType.DataAgentAccessReply; + case 91: return PacketType.DataHomeLocationRequest; + case 92: return PacketType.DataHomeLocationReply; + case 93: return PacketType.SpaceLocationTeleportRequest; + case 94: return PacketType.SpaceLocationTeleportReply; + case 95: return PacketType.TeleportFinish; + case 96: return PacketType.StartLure; + case 97: return PacketType.TeleportLureRequest; + case 98: return PacketType.TeleportCancel; + case 99: return PacketType.CompleteLure; + case 100: return PacketType.TeleportStart; + case 101: return PacketType.TeleportFailed; + case 102: return PacketType.LeaderBoardRequest; + case 103: return PacketType.LeaderBoardData; + case 104: return PacketType.RegisterNewAgent; + case 105: return PacketType.Undo; + case 106: return PacketType.Redo; + case 107: return PacketType.UndoLand; + case 108: return PacketType.RedoLand; + case 109: return PacketType.AgentPause; + case 110: return PacketType.AgentResume; + case 111: return PacketType.ChatFromViewer; + case 112: return PacketType.AgentThrottle; + case 113: return PacketType.AgentFOV; + case 114: return PacketType.AgentHeightWidth; + case 115: return PacketType.AgentSetAppearance; + case 116: return PacketType.AgentQuit; + case 117: return PacketType.AgentQuitCopy; + case 118: return PacketType.ImageNotInDatabase; + case 119: return PacketType.RebakeAvatarTextures; + case 120: return PacketType.SetAlwaysRun; + case 121: return PacketType.ObjectDelete; + case 122: return PacketType.ObjectDuplicate; + case 123: return PacketType.ObjectDuplicateOnRay; + case 124: return PacketType.ObjectScale; + case 125: return PacketType.ObjectRotation; + case 126: return PacketType.ObjectFlagUpdate; + case 127: return PacketType.ObjectClickAction; + case 128: return PacketType.ObjectImage; + case 129: return PacketType.ObjectMaterial; + case 130: return PacketType.ObjectShape; + case 131: return PacketType.ObjectExtraParams; + case 132: return PacketType.ObjectOwner; + case 133: return PacketType.ObjectGroup; + case 134: return PacketType.ObjectBuy; + case 135: return PacketType.BuyObjectInventory; + case 136: return PacketType.DerezContainer; + case 137: return PacketType.ObjectPermissions; + case 138: return PacketType.ObjectSaleInfo; + case 139: return PacketType.ObjectName; + case 140: return PacketType.ObjectDescription; + case 141: return PacketType.ObjectCategory; + case 142: return PacketType.ObjectSelect; + case 143: return PacketType.ObjectDeselect; + case 144: return PacketType.ObjectAttach; + case 145: return PacketType.ObjectDetach; + case 146: return PacketType.ObjectDrop; + case 147: return PacketType.ObjectLink; + case 148: return PacketType.ObjectDelink; + case 149: return PacketType.ObjectHinge; + case 150: return PacketType.ObjectDehinge; + case 151: return PacketType.ObjectGrab; + case 152: return PacketType.ObjectGrabUpdate; + case 153: return PacketType.ObjectDeGrab; + case 154: return PacketType.ObjectSpinStart; + case 155: return PacketType.ObjectSpinUpdate; + case 156: return PacketType.ObjectSpinStop; + case 157: return PacketType.ObjectExportSelected; + case 158: return PacketType.ObjectImport; + case 159: return PacketType.ModifyLand; + case 160: return PacketType.VelocityInterpolateOn; + case 161: return PacketType.VelocityInterpolateOff; + case 162: return PacketType.StateSave; + case 163: return PacketType.ReportAutosaveCrash; + case 164: return PacketType.SimWideDeletes; + case 165: return PacketType.TrackAgent; + case 166: return PacketType.GrantModification; + case 167: return PacketType.RevokeModification; + case 168: return PacketType.RequestGrantedProxies; + case 169: return PacketType.GrantedProxies; + case 170: return PacketType.AddModifyAbility; + case 171: return PacketType.RemoveModifyAbility; + case 172: return PacketType.ViewerStats; + case 173: return PacketType.ScriptAnswerYes; + case 174: return PacketType.UserReport; + case 175: return PacketType.AlertMessage; + case 176: return PacketType.AgentAlertMessage; + case 177: return PacketType.MeanCollisionAlert; + case 178: return PacketType.ViewerFrozenMessage; + case 179: return PacketType.HealthMessage; + case 180: return PacketType.ChatFromSimulator; + case 181: return PacketType.SimStats; + case 182: return PacketType.RequestRegionInfo; + case 183: return PacketType.RegionInfo; + case 184: return PacketType.GodUpdateRegionInfo; + case 185: return PacketType.NearestLandingRegionRequest; + case 186: return PacketType.NearestLandingRegionReply; + case 187: return PacketType.NearestLandingRegionUpdated; + case 188: return PacketType.TeleportLandingStatusChanged; + case 189: return PacketType.RegionHandshake; + case 190: return PacketType.RegionHandshakeReply; + case 191: return PacketType.SimulatorViewerTimeMessage; + case 192: return PacketType.EnableSimulator; + case 193: return PacketType.DisableSimulator; + case 194: return PacketType.TransferRequest; + case 195: return PacketType.TransferInfo; + case 196: return PacketType.TransferAbort; + case 197: return PacketType.TransferPriority; + case 198: return PacketType.RequestXfer; + case 199: return PacketType.AbortXfer; + case 200: return PacketType.RequestAvatarInfo; + case 201: return PacketType.AvatarAppearance; + case 202: return PacketType.SetFollowCamProperties; + case 203: return PacketType.ClearFollowCamProperties; + case 204: return PacketType.RequestPayPrice; + case 205: return PacketType.PayPriceReply; + case 206: return PacketType.KickUser; + case 207: return PacketType.KickUserAck; + case 208: return PacketType.GodKickUser; + case 209: return PacketType.SystemKickUser; + case 210: return PacketType.EjectUser; + case 211: return PacketType.FreezeUser; + case 212: return PacketType.AvatarPropertiesRequest; + case 213: return PacketType.AvatarPropertiesRequestBackend; + case 214: return PacketType.AvatarPropertiesReply; + case 215: return PacketType.AvatarGroupsReply; + case 216: return PacketType.AvatarPropertiesUpdate; + case 217: return PacketType.AvatarStatisticsReply; + case 218: return PacketType.AvatarNotesReply; + case 219: return PacketType.AvatarNotesUpdate; + case 220: return PacketType.AvatarPicksReply; + case 221: return PacketType.EventInfoRequest; + case 222: return PacketType.EventInfoReply; + case 223: return PacketType.EventNotificationAddRequest; + case 224: return PacketType.EventNotificationRemoveRequest; + case 225: return PacketType.EventGodDelete; + case 226: return PacketType.PickInfoRequest; + case 227: return PacketType.PickInfoReply; + case 228: return PacketType.PickInfoUpdate; + case 229: return PacketType.PickDelete; + case 230: return PacketType.PickGodDelete; + case 231: return PacketType.ScriptQuestion; + case 232: return PacketType.ScriptControlChange; + case 233: return PacketType.ScriptDialog; + case 234: return PacketType.ScriptDialogReply; + case 235: return PacketType.ForceScriptControlRelease; + case 236: return PacketType.RevokePermissions; + case 237: return PacketType.LoadURL; + case 238: return PacketType.ScriptTeleportRequest; + case 239: return PacketType.ParcelOverlay; + case 240: return PacketType.ParcelPropertiesRequestByID; + case 241: return PacketType.ParcelPropertiesUpdate; + case 242: return PacketType.ParcelReturnObjects; + case 243: return PacketType.ParcelSetOtherCleanTime; + case 244: return PacketType.ParcelDisableObjects; + case 245: return PacketType.ParcelSelectObjects; + case 246: return PacketType.EstateCovenantRequest; + case 247: return PacketType.EstateCovenantReply; + case 248: return PacketType.ForceObjectSelect; + case 249: return PacketType.ParcelBuyPass; + case 250: return PacketType.ParcelDeedToGroup; + case 251: return PacketType.ParcelReclaim; + case 252: return PacketType.ParcelClaim; + case 253: return PacketType.ParcelJoin; + case 254: return PacketType.ParcelDivide; + case 255: return PacketType.ParcelRelease; + case 256: return PacketType.ParcelBuy; + case 257: return PacketType.ParcelGodForceOwner; + case 258: return PacketType.ParcelAccessListRequest; + case 259: return PacketType.ParcelAccessListReply; + case 260: return PacketType.ParcelAccessListUpdate; + case 261: return PacketType.ParcelDwellRequest; + case 262: return PacketType.ParcelDwellReply; + case 263: return PacketType.RequestParcelTransfer; + case 264: return PacketType.UpdateParcel; + case 265: return PacketType.RemoveParcel; + case 266: return PacketType.MergeParcel; + case 267: return PacketType.LogParcelChanges; + case 268: return PacketType.CheckParcelSales; + case 269: return PacketType.ParcelSales; + case 270: return PacketType.ParcelGodMarkAsContent; + case 271: return PacketType.ParcelGodReserveForNewbie; + case 272: return PacketType.ViewerStartAuction; + case 273: return PacketType.StartAuction; + case 274: return PacketType.ConfirmAuctionStart; + case 275: return PacketType.CompleteAuction; + case 276: return PacketType.CancelAuction; + case 277: return PacketType.CheckParcelAuctions; + case 278: return PacketType.ParcelAuctions; + case 279: return PacketType.UUIDNameRequest; + case 280: return PacketType.UUIDNameReply; + case 281: return PacketType.UUIDGroupNameRequest; + case 282: return PacketType.UUIDGroupNameReply; + case 283: return PacketType.ChatPass; + case 284: return PacketType.ChildAgentDying; + case 285: return PacketType.ChildAgentUnknown; + case 286: return PacketType.KillChildAgents; + case 287: return PacketType.GetScriptRunning; + case 288: return PacketType.ScriptRunningReply; + case 289: return PacketType.SetScriptRunning; + case 290: return PacketType.ScriptReset; + case 291: return PacketType.ScriptSensorRequest; + case 292: return PacketType.ScriptSensorReply; + case 293: return PacketType.CompleteAgentMovement; + case 294: return PacketType.AgentMovementComplete; + case 295: return PacketType.LogLogin; + case 296: return PacketType.ConnectAgentToUserserver; + case 297: return PacketType.ConnectToUserserver; + case 298: return PacketType.DataServerLogout; + case 299: return PacketType.LogoutRequest; + case 300: return PacketType.FinalizeLogout; + case 301: return PacketType.LogoutReply; + case 302: return PacketType.LogoutDemand; + case 303: return PacketType.ImprovedInstantMessage; + case 304: return PacketType.RetrieveInstantMessages; + case 305: return PacketType.DequeueInstantMessages; + case 306: return PacketType.FindAgent; + case 307: return PacketType.RequestGodlikePowers; + case 308: return PacketType.GrantGodlikePowers; + case 309: return PacketType.GodlikeMessage; + case 310: return PacketType.EstateOwnerMessage; + case 311: return PacketType.GenericMessage; + case 312: return PacketType.MuteListRequest; + case 313: return PacketType.UpdateMuteListEntry; + case 314: return PacketType.RemoveMuteListEntry; + case 315: return PacketType.CopyInventoryFromNotecard; + case 316: return PacketType.UpdateInventoryItem; + case 317: return PacketType.UpdateCreateInventoryItem; + case 318: return PacketType.MoveInventoryItem; + case 319: return PacketType.CopyInventoryItem; + case 320: return PacketType.RemoveInventoryItem; + case 321: return PacketType.ChangeInventoryItemFlags; + case 322: return PacketType.SaveAssetIntoInventory; + case 323: return PacketType.CreateInventoryFolder; + case 324: return PacketType.UpdateInventoryFolder; + case 325: return PacketType.MoveInventoryFolder; + case 326: return PacketType.RemoveInventoryFolder; + case 327: return PacketType.FetchInventoryDescendents; + case 328: return PacketType.InventoryDescendents; + case 329: return PacketType.FetchInventory; + case 330: return PacketType.FetchInventoryReply; + case 331: return PacketType.BulkUpdateInventory; + case 332: return PacketType.RequestInventoryAsset; + case 333: return PacketType.InventoryAssetResponse; + case 334: return PacketType.RemoveInventoryObjects; + case 335: return PacketType.PurgeInventoryDescendents; + case 336: return PacketType.UpdateTaskInventory; + case 337: return PacketType.RemoveTaskInventory; + case 338: return PacketType.MoveTaskInventory; + case 339: return PacketType.RequestTaskInventory; + case 340: return PacketType.ReplyTaskInventory; + case 341: return PacketType.DeRezObject; + case 342: return PacketType.DeRezAck; + case 343: return PacketType.RezObject; + case 344: return PacketType.RezObjectFromNotecard; + case 345: return PacketType.DeclineInventory; + case 346: return PacketType.TransferInventory; + case 347: return PacketType.TransferInventoryAck; + case 348: return PacketType.RequestFriendship; + case 349: return PacketType.AcceptFriendship; + case 350: return PacketType.DeclineFriendship; + case 351: return PacketType.FormFriendship; + case 352: return PacketType.TerminateFriendship; + case 353: return PacketType.OfferCallingCard; + case 354: return PacketType.AcceptCallingCard; + case 355: return PacketType.DeclineCallingCard; + case 356: return PacketType.RezScript; + case 357: return PacketType.CreateInventoryItem; + case 358: return PacketType.CreateLandmarkForEvent; + case 359: return PacketType.EventLocationRequest; + case 360: return PacketType.EventLocationReply; + case 361: return PacketType.RegionHandleRequest; + case 362: return PacketType.RegionIDAndHandleReply; + case 363: return PacketType.MoneyTransferRequest; + case 364: return PacketType.MoneyTransferBackend; + case 365: return PacketType.BulkMoneyTransfer; + case 366: return PacketType.AdjustBalance; + case 367: return PacketType.MoneyBalanceRequest; + case 368: return PacketType.MoneyBalanceReply; + case 369: return PacketType.RoutedMoneyBalanceReply; + case 370: return PacketType.MoneyHistoryRequest; + case 371: return PacketType.MoneyHistoryReply; + case 372: return PacketType.MoneySummaryRequest; + case 373: return PacketType.MoneySummaryReply; + case 374: return PacketType.MoneyDetailsRequest; + case 375: return PacketType.MoneyDetailsReply; + case 376: return PacketType.MoneyTransactionsRequest; + case 377: return PacketType.MoneyTransactionsReply; + case 378: return PacketType.GestureRequest; + case 379: return PacketType.ActivateGestures; + case 380: return PacketType.DeactivateGestures; + case 381: return PacketType.InventoryUpdate; + case 382: return PacketType.MuteListUpdate; + case 383: return PacketType.UseCachedMuteList; + case 384: return PacketType.UserLoginLocationReply; + case 385: return PacketType.UserSimLocationReply; + case 386: return PacketType.UserListReply; + case 387: return PacketType.OnlineNotification; + case 388: return PacketType.OfflineNotification; + case 389: return PacketType.SetStartLocationRequest; + case 390: return PacketType.SetStartLocation; + case 391: return PacketType.UserLoginLocationRequest; + case 392: return PacketType.SpaceLoginLocationReply; + case 393: return PacketType.NetTest; + case 394: return PacketType.SetCPURatio; + case 395: return PacketType.SimCrashed; + case 396: return PacketType.SimulatorPauseState; + case 397: return PacketType.SimulatorThrottleSettings; + case 398: return PacketType.NameValuePair; + case 399: return PacketType.RemoveNameValuePair; + case 400: return PacketType.GetNameValuePair; + case 401: return PacketType.UpdateAttachment; + case 402: return PacketType.RemoveAttachment; + case 403: return PacketType.AssetUploadRequest; + case 404: return PacketType.AssetUploadComplete; + case 405: return PacketType.ReputationAgentAssign; + case 406: return PacketType.ReputationIndividualRequest; + case 407: return PacketType.ReputationIndividualReply; + case 408: return PacketType.EmailMessageRequest; + case 409: return PacketType.EmailMessageReply; + case 410: return PacketType.ScriptDataRequest; + case 411: return PacketType.ScriptDataReply; + case 412: return PacketType.CreateGroupRequest; + case 413: return PacketType.CreateGroupReply; + case 414: return PacketType.UpdateGroupInfo; + case 415: return PacketType.GroupRoleChanges; + case 416: return PacketType.JoinGroupRequest; + case 417: return PacketType.JoinGroupReply; + case 418: return PacketType.EjectGroupMemberRequest; + case 419: return PacketType.EjectGroupMemberReply; + case 420: return PacketType.LeaveGroupRequest; + case 421: return PacketType.LeaveGroupReply; + case 422: return PacketType.InviteGroupRequest; + case 423: return PacketType.InviteGroupResponse; + case 424: return PacketType.GroupProfileRequest; + case 425: return PacketType.GroupProfileReply; + case 426: return PacketType.GroupAccountSummaryRequest; + case 427: return PacketType.GroupAccountSummaryReply; + case 428: return PacketType.GroupAccountDetailsRequest; + case 429: return PacketType.GroupAccountDetailsReply; + case 430: return PacketType.GroupAccountTransactionsRequest; + case 431: return PacketType.GroupAccountTransactionsReply; + case 432: return PacketType.GroupActiveProposalsRequest; + case 433: return PacketType.GroupActiveProposalItemReply; + case 434: return PacketType.GroupVoteHistoryRequest; + case 435: return PacketType.GroupVoteHistoryItemReply; + case 436: return PacketType.StartGroupProposal; + case 437: return PacketType.GroupProposalBallot; + case 438: return PacketType.TallyVotes; + case 439: return PacketType.GroupMembersRequest; + case 440: return PacketType.GroupMembersReply; + case 441: return PacketType.ActivateGroup; + case 442: return PacketType.SetGroupContribution; + case 443: return PacketType.SetGroupAcceptNotices; + case 444: return PacketType.GroupRoleDataRequest; + case 445: return PacketType.GroupRoleDataReply; + case 446: return PacketType.GroupRoleMembersRequest; + case 447: return PacketType.GroupRoleMembersReply; + case 448: return PacketType.GroupTitlesRequest; + case 449: return PacketType.GroupTitlesReply; + case 450: return PacketType.GroupTitleUpdate; + case 451: return PacketType.GroupRoleUpdate; + case 452: return PacketType.LiveHelpGroupRequest; + case 453: return PacketType.LiveHelpGroupReply; + case 454: return PacketType.AgentWearablesRequest; + case 455: return PacketType.AgentWearablesUpdate; + case 456: return PacketType.AgentIsNowWearing; + case 457: return PacketType.AgentCachedTexture; + case 458: return PacketType.AgentCachedTextureResponse; + case 459: return PacketType.AgentDataUpdateRequest; + case 460: return PacketType.AgentDataUpdate; + case 461: return PacketType.GroupDataUpdate; + case 462: return PacketType.AgentGroupDataUpdate; + case 463: return PacketType.AgentDropGroup; + case 464: return PacketType.LogTextMessage; + case 465: return PacketType.CreateTrustedCircuit; + case 466: return PacketType.DenyTrustedCircuit; + case 467: return PacketType.RezSingleAttachmentFromInv; + case 468: return PacketType.RezMultipleAttachmentsFromInv; + case 469: return PacketType.DetachAttachmentIntoInv; + case 470: return PacketType.CreateNewOutfitAttachments; + case 471: return PacketType.UserInfoRequest; + case 472: return PacketType.UserInfoReply; + case 473: return PacketType.UpdateUserInfo; + case 474: return PacketType.GodExpungeUser; + case 475: return PacketType.StartExpungeProcess; + case 476: return PacketType.StartExpungeProcessAck; + case 477: return PacketType.StartParcelRename; + case 478: return PacketType.StartParcelRenameAck; + case 479: return PacketType.BulkParcelRename; + case 480: return PacketType.ParcelRename; + case 481: return PacketType.StartParcelRemove; + case 482: return PacketType.StartParcelRemoveAck; + case 483: return PacketType.BulkParcelRemove; + case 484: return PacketType.InitiateUpload; + case 485: return PacketType.InitiateDownload; + case 486: return PacketType.SystemMessage; + case 487: return PacketType.MapLayerRequest; + case 488: return PacketType.MapLayerReply; + case 489: return PacketType.MapBlockRequest; + case 490: return PacketType.MapNameRequest; + case 491: return PacketType.MapBlockReply; + case 492: return PacketType.MapItemRequest; + case 493: return PacketType.MapItemReply; + case 494: return PacketType.SendPostcard; + case 495: return PacketType.RpcChannelRequest; + case 496: return PacketType.RpcChannelReply; + case 497: return PacketType.RpcScriptRequestInbound; + case 498: return PacketType.RpcScriptRequestInboundForward; + case 499: return PacketType.RpcScriptReplyInbound; + case 500: return PacketType.MailTaskSimRequest; + case 501: return PacketType.MailTaskSimReply; + case 502: return PacketType.ScriptMailRegistration; + case 503: return PacketType.ParcelMediaCommandMessage; + case 504: return PacketType.ParcelMediaUpdate; + case 505: return PacketType.LandStatRequest; + case 506: return PacketType.LandStatReply; + case 65530: return PacketType.SecuredTemplateChecksumRequest; + case 65531: return PacketType.PacketAck; + case 65532: return PacketType.OpenCircuit; + case 65533: return PacketType.CloseCircuit; + case 65534: return PacketType.TemplateChecksumRequest; + case 65535: return PacketType.TemplateChecksumReply; } break; case PacketFrequency.Medium: switch (id) - { - case 1: return PacketType.ClosestSimulator; - case 2: return PacketType.ObjectAdd; - case 3: return PacketType.MultipleObjectUpdate; - case 4: return PacketType.RequestMultipleObjects; - case 5: return PacketType.ObjectPosition; - case 6: return PacketType.RequestObjectPropertiesFamily; - case 7: return PacketType.CoarseLocationUpdate; - case 8: return PacketType.CrossedRegion; - case 9: return PacketType.ConfirmEnableSimulator; - case 10: return PacketType.ObjectProperties; - case 11: return PacketType.ObjectPropertiesFamily; - case 12: return PacketType.ParcelPropertiesRequest; - case 13: return PacketType.SimStatus; - case 14: return PacketType.GestureUpdate; - case 15: return PacketType.AttachedSound; - case 16: return PacketType.AttachedSoundGainChange; - case 17: return PacketType.AttachedSoundCutoffRadius; - case 18: return PacketType.PreloadSound; - case 19: return PacketType.InternalScriptMail; - case 20: return PacketType.ViewerEffect; - case 21: return PacketType.SetSunPhase; + { + case 1: return PacketType.ClosestSimulator; + case 2: return PacketType.ObjectAdd; + case 3: return PacketType.MultipleObjectUpdate; + case 4: return PacketType.RequestMultipleObjects; + case 5: return PacketType.ObjectPosition; + case 6: return PacketType.RequestObjectPropertiesFamily; + case 7: return PacketType.CoarseLocationUpdate; + case 8: return PacketType.CrossedRegion; + case 9: return PacketType.ConfirmEnableSimulator; + case 10: return PacketType.ObjectProperties; + case 11: return PacketType.ObjectPropertiesFamily; + case 12: return PacketType.ParcelPropertiesRequest; + case 13: return PacketType.SimStatus; + case 14: return PacketType.GestureUpdate; + case 15: return PacketType.AttachedSound; + case 16: return PacketType.AttachedSoundGainChange; + case 17: return PacketType.AttachedSoundCutoffRadius; + case 18: return PacketType.PreloadSound; + case 19: return PacketType.InternalScriptMail; + case 20: return PacketType.ViewerEffect; + case 21: return PacketType.SetSunPhase; } break; case PacketFrequency.High: switch (id) - { - case 1: return PacketType.StartPingCheck; - case 2: return PacketType.CompletePingCheck; - case 3: return PacketType.NeighborList; - case 4: return PacketType.MovedIntoSimulator; - case 5: return PacketType.AgentUpdate; - case 6: return PacketType.AgentAnimation; - case 7: return PacketType.AgentRequestSit; - case 8: return PacketType.AgentSit; - case 9: return PacketType.RequestImage; - case 10: return PacketType.ImageData; - case 11: return PacketType.ImagePacket; - case 12: return PacketType.LayerData; - case 13: return PacketType.ObjectUpdate; - case 14: return PacketType.ObjectUpdateCompressed; - case 15: return PacketType.ObjectUpdateCached; - case 16: return PacketType.ImprovedTerseObjectUpdate; - case 17: return PacketType.KillObject; - case 18: return PacketType.AgentToNewRegion; - case 19: return PacketType.TransferPacket; - case 20: return PacketType.SendXferPacket; - case 21: return PacketType.ConfirmXferPacket; - case 22: return PacketType.AvatarAnimation; - case 23: return PacketType.AvatarSitResponse; - case 24: return PacketType.CameraConstraint; - case 25: return PacketType.ParcelProperties; - case 26: return PacketType.EdgeDataPacket; - case 27: return PacketType.ChildAgentUpdate; - case 28: return PacketType.ChildAgentAlive; - case 29: return PacketType.ChildAgentPositionUpdate; - case 30: return PacketType.PassObject; - case 31: return PacketType.AtomicPassObject; - case 32: return PacketType.SoundTrigger; + { + case 1: return PacketType.StartPingCheck; + case 2: return PacketType.CompletePingCheck; + case 3: return PacketType.NeighborList; + case 4: return PacketType.MovedIntoSimulator; + case 5: return PacketType.AgentUpdate; + case 6: return PacketType.AgentAnimation; + case 7: return PacketType.AgentRequestSit; + case 8: return PacketType.AgentSit; + case 9: return PacketType.RequestImage; + case 10: return PacketType.ImageData; + case 11: return PacketType.ImagePacket; + case 12: return PacketType.LayerData; + case 13: return PacketType.ObjectUpdate; + case 14: return PacketType.ObjectUpdateCompressed; + case 15: return PacketType.ObjectUpdateCached; + case 16: return PacketType.ImprovedTerseObjectUpdate; + case 17: return PacketType.KillObject; + case 18: return PacketType.AgentToNewRegion; + case 19: return PacketType.TransferPacket; + case 20: return PacketType.SendXferPacket; + case 21: return PacketType.ConfirmXferPacket; + case 22: return PacketType.AvatarAnimation; + case 23: return PacketType.AvatarSitResponse; + case 24: return PacketType.CameraConstraint; + case 25: return PacketType.ParcelProperties; + case 26: return PacketType.EdgeDataPacket; + case 27: return PacketType.ChildAgentUpdate; + case 28: return PacketType.ChildAgentAlive; + case 29: return PacketType.ChildAgentPositionUpdate; + case 30: return PacketType.PassObject; + case 31: return PacketType.AtomicPassObject; + case 32: return PacketType.SoundTrigger; } break; } return PacketType.Default; } - + /// Construct a packet in it's native class from a byte array /// Byte array containing the packet, starting at position 0 /// The last byte of the packet. If the packet was 76 bytes long, packetEnd would be 75 @@ -2110,547 +2110,547 @@ namespace libsecondlife.Packets { id = (ushort)((bytes[6] << 8) + bytes[7]); switch (id) - { - case 1: return new TestMessagePacket(header, bytes, ref i); - case 2: return new AddCircuitCodePacket(header, bytes, ref i); - case 3: return new UseCircuitCodePacket(header, bytes, ref i); - case 4: return new LogControlPacket(header, bytes, ref i); - case 5: return new RelayLogControlPacket(header, bytes, ref i); - case 6: return new LogMessagesPacket(header, bytes, ref i); - case 7: return new SimulatorAssignPacket(header, bytes, ref i); - case 8: return new SpaceServerSimulatorTimeMessagePacket(header, bytes, ref i); - case 9: return new AvatarTextureUpdatePacket(header, bytes, ref i); - case 10: return new SimulatorMapUpdatePacket(header, bytes, ref i); - case 11: return new SimulatorSetMapPacket(header, bytes, ref i); - case 12: return new SubscribeLoadPacket(header, bytes, ref i); - case 13: return new UnsubscribeLoadPacket(header, bytes, ref i); - case 14: return new SimulatorStartPacket(header, bytes, ref i); - case 15: return new SimulatorReadyPacket(header, bytes, ref i); - case 16: return new TelehubInfoPacket(header, bytes, ref i); - case 17: return new SimulatorPresentAtLocationPacket(header, bytes, ref i); - case 18: return new SimulatorLoadPacket(header, bytes, ref i); - case 19: return new SimulatorShutdownRequestPacket(header, bytes, ref i); - case 20: return new RegionPresenceRequestByRegionIDPacket(header, bytes, ref i); - case 21: return new RegionPresenceRequestByHandlePacket(header, bytes, ref i); - case 22: return new RegionPresenceResponsePacket(header, bytes, ref i); - case 23: return new RecordAgentPresencePacket(header, bytes, ref i); - case 24: return new EraseAgentPresencePacket(header, bytes, ref i); - case 25: return new AgentPresenceRequestPacket(header, bytes, ref i); - case 26: return new AgentPresenceResponsePacket(header, bytes, ref i); - case 27: return new UpdateSimulatorPacket(header, bytes, ref i); - case 28: return new TrackAgentSessionPacket(header, bytes, ref i); - case 29: return new ClearAgentSessionsPacket(header, bytes, ref i); - case 30: return new LogDwellTimePacket(header, bytes, ref i); - case 31: return new FeatureDisabledPacket(header, bytes, ref i); - case 32: return new LogFailedMoneyTransactionPacket(header, bytes, ref i); - case 33: return new UserReportInternalPacket(header, bytes, ref i); - case 34: return new SetSimStatusInDatabasePacket(header, bytes, ref i); - case 35: return new SetSimPresenceInDatabasePacket(header, bytes, ref i); - case 36: return new EconomyDataRequestPacket(header, bytes, ref i); - case 37: return new EconomyDataPacket(header, bytes, ref i); - case 38: return new AvatarPickerRequestPacket(header, bytes, ref i); - case 39: return new AvatarPickerRequestBackendPacket(header, bytes, ref i); - case 40: return new AvatarPickerReplyPacket(header, bytes, ref i); - case 41: return new PlacesQueryPacket(header, bytes, ref i); - case 42: return new PlacesReplyPacket(header, bytes, ref i); - case 43: return new DirFindQueryPacket(header, bytes, ref i); - case 44: return new DirFindQueryBackendPacket(header, bytes, ref i); - case 45: return new DirPlacesQueryPacket(header, bytes, ref i); - case 46: return new DirPlacesQueryBackendPacket(header, bytes, ref i); - case 47: return new DirPlacesReplyPacket(header, bytes, ref i); - case 48: return new DirPeopleQueryPacket(header, bytes, ref i); - case 49: return new DirPeopleQueryBackendPacket(header, bytes, ref i); - case 50: return new DirPeopleReplyPacket(header, bytes, ref i); - case 51: return new DirEventsReplyPacket(header, bytes, ref i); - case 52: return new DirGroupsQueryPacket(header, bytes, ref i); - case 53: return new DirGroupsQueryBackendPacket(header, bytes, ref i); - case 54: return new DirGroupsReplyPacket(header, bytes, ref i); - case 55: return new DirClassifiedQueryPacket(header, bytes, ref i); - case 56: return new DirClassifiedQueryBackendPacket(header, bytes, ref i); - case 57: return new DirClassifiedReplyPacket(header, bytes, ref i); - case 58: return new AvatarClassifiedReplyPacket(header, bytes, ref i); - case 59: return new ClassifiedInfoRequestPacket(header, bytes, ref i); - case 60: return new ClassifiedInfoReplyPacket(header, bytes, ref i); - case 61: return new ClassifiedInfoUpdatePacket(header, bytes, ref i); - case 62: return new ClassifiedDeletePacket(header, bytes, ref i); - case 63: return new ClassifiedGodDeletePacket(header, bytes, ref i); - case 64: return new DirPicksQueryPacket(header, bytes, ref i); - case 65: return new DirPicksQueryBackendPacket(header, bytes, ref i); - case 66: return new DirPicksReplyPacket(header, bytes, ref i); - case 67: return new DirLandQueryPacket(header, bytes, ref i); - case 68: return new DirLandQueryBackendPacket(header, bytes, ref i); - case 69: return new DirLandReplyPacket(header, bytes, ref i); - case 70: return new DirPopularQueryPacket(header, bytes, ref i); - case 71: return new DirPopularQueryBackendPacket(header, bytes, ref i); - case 72: return new DirPopularReplyPacket(header, bytes, ref i); - case 73: return new ParcelInfoRequestPacket(header, bytes, ref i); - case 74: return new ParcelInfoReplyPacket(header, bytes, ref i); - case 75: return new ParcelObjectOwnersRequestPacket(header, bytes, ref i); - case 76: return new OnlineStatusRequestPacket(header, bytes, ref i); - case 77: return new OnlineStatusReplyPacket(header, bytes, ref i); - case 78: return new ParcelObjectOwnersReplyPacket(header, bytes, ref i); - case 79: return new GroupNoticesListRequestPacket(header, bytes, ref i); - case 80: return new GroupNoticesListReplyPacket(header, bytes, ref i); - case 81: return new GroupNoticeRequestPacket(header, bytes, ref i); - case 82: return new GroupNoticeAddPacket(header, bytes, ref i); - case 83: return new GroupNoticeDeletePacket(header, bytes, ref i); - case 84: return new TeleportRequestPacket(header, bytes, ref i); - case 85: return new TeleportLocationRequestPacket(header, bytes, ref i); - case 86: return new TeleportLocalPacket(header, bytes, ref i); - case 87: return new TeleportLandmarkRequestPacket(header, bytes, ref i); - case 88: return new TeleportProgressPacket(header, bytes, ref i); - case 89: return new DataAgentAccessRequestPacket(header, bytes, ref i); - case 90: return new DataAgentAccessReplyPacket(header, bytes, ref i); - case 91: return new DataHomeLocationRequestPacket(header, bytes, ref i); - case 92: return new DataHomeLocationReplyPacket(header, bytes, ref i); - case 93: return new SpaceLocationTeleportRequestPacket(header, bytes, ref i); - case 94: return new SpaceLocationTeleportReplyPacket(header, bytes, ref i); - case 95: return new TeleportFinishPacket(header, bytes, ref i); - case 96: return new StartLurePacket(header, bytes, ref i); - case 97: return new TeleportLureRequestPacket(header, bytes, ref i); - case 98: return new TeleportCancelPacket(header, bytes, ref i); - case 99: return new CompleteLurePacket(header, bytes, ref i); - case 100: return new TeleportStartPacket(header, bytes, ref i); - case 101: return new TeleportFailedPacket(header, bytes, ref i); - case 102: return new LeaderBoardRequestPacket(header, bytes, ref i); - case 103: return new LeaderBoardDataPacket(header, bytes, ref i); - case 104: return new RegisterNewAgentPacket(header, bytes, ref i); - case 105: return new UndoPacket(header, bytes, ref i); - case 106: return new RedoPacket(header, bytes, ref i); - case 107: return new UndoLandPacket(header, bytes, ref i); - case 108: return new RedoLandPacket(header, bytes, ref i); - case 109: return new AgentPausePacket(header, bytes, ref i); - case 110: return new AgentResumePacket(header, bytes, ref i); - case 111: return new ChatFromViewerPacket(header, bytes, ref i); - case 112: return new AgentThrottlePacket(header, bytes, ref i); - case 113: return new AgentFOVPacket(header, bytes, ref i); - case 114: return new AgentHeightWidthPacket(header, bytes, ref i); - case 115: return new AgentSetAppearancePacket(header, bytes, ref i); - case 116: return new AgentQuitPacket(header, bytes, ref i); - case 117: return new AgentQuitCopyPacket(header, bytes, ref i); - case 118: return new ImageNotInDatabasePacket(header, bytes, ref i); - case 119: return new RebakeAvatarTexturesPacket(header, bytes, ref i); - case 120: return new SetAlwaysRunPacket(header, bytes, ref i); - case 121: return new ObjectDeletePacket(header, bytes, ref i); - case 122: return new ObjectDuplicatePacket(header, bytes, ref i); - case 123: return new ObjectDuplicateOnRayPacket(header, bytes, ref i); - case 124: return new ObjectScalePacket(header, bytes, ref i); - case 125: return new ObjectRotationPacket(header, bytes, ref i); - case 126: return new ObjectFlagUpdatePacket(header, bytes, ref i); - case 127: return new ObjectClickActionPacket(header, bytes, ref i); - case 128: return new ObjectImagePacket(header, bytes, ref i); - case 129: return new ObjectMaterialPacket(header, bytes, ref i); - case 130: return new ObjectShapePacket(header, bytes, ref i); - case 131: return new ObjectExtraParamsPacket(header, bytes, ref i); - case 132: return new ObjectOwnerPacket(header, bytes, ref i); - case 133: return new ObjectGroupPacket(header, bytes, ref i); - case 134: return new ObjectBuyPacket(header, bytes, ref i); - case 135: return new BuyObjectInventoryPacket(header, bytes, ref i); - case 136: return new DerezContainerPacket(header, bytes, ref i); - case 137: return new ObjectPermissionsPacket(header, bytes, ref i); - case 138: return new ObjectSaleInfoPacket(header, bytes, ref i); - case 139: return new ObjectNamePacket(header, bytes, ref i); - case 140: return new ObjectDescriptionPacket(header, bytes, ref i); - case 141: return new ObjectCategoryPacket(header, bytes, ref i); - case 142: return new ObjectSelectPacket(header, bytes, ref i); - case 143: return new ObjectDeselectPacket(header, bytes, ref i); - case 144: return new ObjectAttachPacket(header, bytes, ref i); - case 145: return new ObjectDetachPacket(header, bytes, ref i); - case 146: return new ObjectDropPacket(header, bytes, ref i); - case 147: return new ObjectLinkPacket(header, bytes, ref i); - case 148: return new ObjectDelinkPacket(header, bytes, ref i); - case 149: return new ObjectHingePacket(header, bytes, ref i); - case 150: return new ObjectDehingePacket(header, bytes, ref i); - case 151: return new ObjectGrabPacket(header, bytes, ref i); - case 152: return new ObjectGrabUpdatePacket(header, bytes, ref i); - case 153: return new ObjectDeGrabPacket(header, bytes, ref i); - case 154: return new ObjectSpinStartPacket(header, bytes, ref i); - case 155: return new ObjectSpinUpdatePacket(header, bytes, ref i); - case 156: return new ObjectSpinStopPacket(header, bytes, ref i); - case 157: return new ObjectExportSelectedPacket(header, bytes, ref i); - case 158: return new ObjectImportPacket(header, bytes, ref i); - case 159: return new ModifyLandPacket(header, bytes, ref i); - case 160: return new VelocityInterpolateOnPacket(header, bytes, ref i); - case 161: return new VelocityInterpolateOffPacket(header, bytes, ref i); - case 162: return new StateSavePacket(header, bytes, ref i); - case 163: return new ReportAutosaveCrashPacket(header, bytes, ref i); - case 164: return new SimWideDeletesPacket(header, bytes, ref i); - case 165: return new TrackAgentPacket(header, bytes, ref i); - case 166: return new GrantModificationPacket(header, bytes, ref i); - case 167: return new RevokeModificationPacket(header, bytes, ref i); - case 168: return new RequestGrantedProxiesPacket(header, bytes, ref i); - case 169: return new GrantedProxiesPacket(header, bytes, ref i); - case 170: return new AddModifyAbilityPacket(header, bytes, ref i); - case 171: return new RemoveModifyAbilityPacket(header, bytes, ref i); - case 172: return new ViewerStatsPacket(header, bytes, ref i); - case 173: return new ScriptAnswerYesPacket(header, bytes, ref i); - case 174: return new UserReportPacket(header, bytes, ref i); - case 175: return new AlertMessagePacket(header, bytes, ref i); - case 176: return new AgentAlertMessagePacket(header, bytes, ref i); - case 177: return new MeanCollisionAlertPacket(header, bytes, ref i); - case 178: return new ViewerFrozenMessagePacket(header, bytes, ref i); - case 179: return new HealthMessagePacket(header, bytes, ref i); - case 180: return new ChatFromSimulatorPacket(header, bytes, ref i); - case 181: return new SimStatsPacket(header, bytes, ref i); - case 182: return new RequestRegionInfoPacket(header, bytes, ref i); - case 183: return new RegionInfoPacket(header, bytes, ref i); - case 184: return new GodUpdateRegionInfoPacket(header, bytes, ref i); - case 185: return new NearestLandingRegionRequestPacket(header, bytes, ref i); - case 186: return new NearestLandingRegionReplyPacket(header, bytes, ref i); - case 187: return new NearestLandingRegionUpdatedPacket(header, bytes, ref i); - case 188: return new TeleportLandingStatusChangedPacket(header, bytes, ref i); - case 189: return new RegionHandshakePacket(header, bytes, ref i); - case 190: return new RegionHandshakeReplyPacket(header, bytes, ref i); - case 191: return new SimulatorViewerTimeMessagePacket(header, bytes, ref i); - case 192: return new EnableSimulatorPacket(header, bytes, ref i); - case 193: return new DisableSimulatorPacket(header, bytes, ref i); - case 194: return new TransferRequestPacket(header, bytes, ref i); - case 195: return new TransferInfoPacket(header, bytes, ref i); - case 196: return new TransferAbortPacket(header, bytes, ref i); - case 197: return new TransferPriorityPacket(header, bytes, ref i); - case 198: return new RequestXferPacket(header, bytes, ref i); - case 199: return new AbortXferPacket(header, bytes, ref i); - case 200: return new RequestAvatarInfoPacket(header, bytes, ref i); - case 201: return new AvatarAppearancePacket(header, bytes, ref i); - case 202: return new SetFollowCamPropertiesPacket(header, bytes, ref i); - case 203: return new ClearFollowCamPropertiesPacket(header, bytes, ref i); - case 204: return new RequestPayPricePacket(header, bytes, ref i); - case 205: return new PayPriceReplyPacket(header, bytes, ref i); - case 206: return new KickUserPacket(header, bytes, ref i); - case 207: return new KickUserAckPacket(header, bytes, ref i); - case 208: return new GodKickUserPacket(header, bytes, ref i); - case 209: return new SystemKickUserPacket(header, bytes, ref i); - case 210: return new EjectUserPacket(header, bytes, ref i); - case 211: return new FreezeUserPacket(header, bytes, ref i); - case 212: return new AvatarPropertiesRequestPacket(header, bytes, ref i); - case 213: return new AvatarPropertiesRequestBackendPacket(header, bytes, ref i); - case 214: return new AvatarPropertiesReplyPacket(header, bytes, ref i); - case 215: return new AvatarGroupsReplyPacket(header, bytes, ref i); - case 216: return new AvatarPropertiesUpdatePacket(header, bytes, ref i); - case 217: return new AvatarStatisticsReplyPacket(header, bytes, ref i); - case 218: return new AvatarNotesReplyPacket(header, bytes, ref i); - case 219: return new AvatarNotesUpdatePacket(header, bytes, ref i); - case 220: return new AvatarPicksReplyPacket(header, bytes, ref i); - case 221: return new EventInfoRequestPacket(header, bytes, ref i); - case 222: return new EventInfoReplyPacket(header, bytes, ref i); - case 223: return new EventNotificationAddRequestPacket(header, bytes, ref i); - case 224: return new EventNotificationRemoveRequestPacket(header, bytes, ref i); - case 225: return new EventGodDeletePacket(header, bytes, ref i); - case 226: return new PickInfoRequestPacket(header, bytes, ref i); - case 227: return new PickInfoReplyPacket(header, bytes, ref i); - case 228: return new PickInfoUpdatePacket(header, bytes, ref i); - case 229: return new PickDeletePacket(header, bytes, ref i); - case 230: return new PickGodDeletePacket(header, bytes, ref i); - case 231: return new ScriptQuestionPacket(header, bytes, ref i); - case 232: return new ScriptControlChangePacket(header, bytes, ref i); - case 233: return new ScriptDialogPacket(header, bytes, ref i); - case 234: return new ScriptDialogReplyPacket(header, bytes, ref i); - case 235: return new ForceScriptControlReleasePacket(header, bytes, ref i); - case 236: return new RevokePermissionsPacket(header, bytes, ref i); - case 237: return new LoadURLPacket(header, bytes, ref i); - case 238: return new ScriptTeleportRequestPacket(header, bytes, ref i); - case 239: return new ParcelOverlayPacket(header, bytes, ref i); - case 240: return new ParcelPropertiesRequestByIDPacket(header, bytes, ref i); - case 241: return new ParcelPropertiesUpdatePacket(header, bytes, ref i); - case 242: return new ParcelReturnObjectsPacket(header, bytes, ref i); - case 243: return new ParcelSetOtherCleanTimePacket(header, bytes, ref i); - case 244: return new ParcelDisableObjectsPacket(header, bytes, ref i); - case 245: return new ParcelSelectObjectsPacket(header, bytes, ref i); - case 246: return new EstateCovenantRequestPacket(header, bytes, ref i); - case 247: return new EstateCovenantReplyPacket(header, bytes, ref i); - case 248: return new ForceObjectSelectPacket(header, bytes, ref i); - case 249: return new ParcelBuyPassPacket(header, bytes, ref i); - case 250: return new ParcelDeedToGroupPacket(header, bytes, ref i); - case 251: return new ParcelReclaimPacket(header, bytes, ref i); - case 252: return new ParcelClaimPacket(header, bytes, ref i); - case 253: return new ParcelJoinPacket(header, bytes, ref i); - case 254: return new ParcelDividePacket(header, bytes, ref i); - case 255: return new ParcelReleasePacket(header, bytes, ref i); - case 256: return new ParcelBuyPacket(header, bytes, ref i); - case 257: return new ParcelGodForceOwnerPacket(header, bytes, ref i); - case 258: return new ParcelAccessListRequestPacket(header, bytes, ref i); - case 259: return new ParcelAccessListReplyPacket(header, bytes, ref i); - case 260: return new ParcelAccessListUpdatePacket(header, bytes, ref i); - case 261: return new ParcelDwellRequestPacket(header, bytes, ref i); - case 262: return new ParcelDwellReplyPacket(header, bytes, ref i); - case 263: return new RequestParcelTransferPacket(header, bytes, ref i); - case 264: return new UpdateParcelPacket(header, bytes, ref i); - case 265: return new RemoveParcelPacket(header, bytes, ref i); - case 266: return new MergeParcelPacket(header, bytes, ref i); - case 267: return new LogParcelChangesPacket(header, bytes, ref i); - case 268: return new CheckParcelSalesPacket(header, bytes, ref i); - case 269: return new ParcelSalesPacket(header, bytes, ref i); - case 270: return new ParcelGodMarkAsContentPacket(header, bytes, ref i); - case 271: return new ParcelGodReserveForNewbiePacket(header, bytes, ref i); - case 272: return new ViewerStartAuctionPacket(header, bytes, ref i); - case 273: return new StartAuctionPacket(header, bytes, ref i); - case 274: return new ConfirmAuctionStartPacket(header, bytes, ref i); - case 275: return new CompleteAuctionPacket(header, bytes, ref i); - case 276: return new CancelAuctionPacket(header, bytes, ref i); - case 277: return new CheckParcelAuctionsPacket(header, bytes, ref i); - case 278: return new ParcelAuctionsPacket(header, bytes, ref i); - case 279: return new UUIDNameRequestPacket(header, bytes, ref i); - case 280: return new UUIDNameReplyPacket(header, bytes, ref i); - case 281: return new UUIDGroupNameRequestPacket(header, bytes, ref i); - case 282: return new UUIDGroupNameReplyPacket(header, bytes, ref i); - case 283: return new ChatPassPacket(header, bytes, ref i); - case 284: return new ChildAgentDyingPacket(header, bytes, ref i); - case 285: return new ChildAgentUnknownPacket(header, bytes, ref i); - case 286: return new KillChildAgentsPacket(header, bytes, ref i); - case 287: return new GetScriptRunningPacket(header, bytes, ref i); - case 288: return new ScriptRunningReplyPacket(header, bytes, ref i); - case 289: return new SetScriptRunningPacket(header, bytes, ref i); - case 290: return new ScriptResetPacket(header, bytes, ref i); - case 291: return new ScriptSensorRequestPacket(header, bytes, ref i); - case 292: return new ScriptSensorReplyPacket(header, bytes, ref i); - case 293: return new CompleteAgentMovementPacket(header, bytes, ref i); - case 294: return new AgentMovementCompletePacket(header, bytes, ref i); - case 295: return new LogLoginPacket(header, bytes, ref i); - case 296: return new ConnectAgentToUserserverPacket(header, bytes, ref i); - case 297: return new ConnectToUserserverPacket(header, bytes, ref i); - case 298: return new DataServerLogoutPacket(header, bytes, ref i); - case 299: return new LogoutRequestPacket(header, bytes, ref i); - case 300: return new FinalizeLogoutPacket(header, bytes, ref i); - case 301: return new LogoutReplyPacket(header, bytes, ref i); - case 302: return new LogoutDemandPacket(header, bytes, ref i); - case 303: return new ImprovedInstantMessagePacket(header, bytes, ref i); - case 304: return new RetrieveInstantMessagesPacket(header, bytes, ref i); - case 305: return new DequeueInstantMessagesPacket(header, bytes, ref i); - case 306: return new FindAgentPacket(header, bytes, ref i); - case 307: return new RequestGodlikePowersPacket(header, bytes, ref i); - case 308: return new GrantGodlikePowersPacket(header, bytes, ref i); - case 309: return new GodlikeMessagePacket(header, bytes, ref i); - case 310: return new EstateOwnerMessagePacket(header, bytes, ref i); - case 311: return new GenericMessagePacket(header, bytes, ref i); - case 312: return new MuteListRequestPacket(header, bytes, ref i); - case 313: return new UpdateMuteListEntryPacket(header, bytes, ref i); - case 314: return new RemoveMuteListEntryPacket(header, bytes, ref i); - case 315: return new CopyInventoryFromNotecardPacket(header, bytes, ref i); - case 316: return new UpdateInventoryItemPacket(header, bytes, ref i); - case 317: return new UpdateCreateInventoryItemPacket(header, bytes, ref i); - case 318: return new MoveInventoryItemPacket(header, bytes, ref i); - case 319: return new CopyInventoryItemPacket(header, bytes, ref i); - case 320: return new RemoveInventoryItemPacket(header, bytes, ref i); - case 321: return new ChangeInventoryItemFlagsPacket(header, bytes, ref i); - case 322: return new SaveAssetIntoInventoryPacket(header, bytes, ref i); - case 323: return new CreateInventoryFolderPacket(header, bytes, ref i); - case 324: return new UpdateInventoryFolderPacket(header, bytes, ref i); - case 325: return new MoveInventoryFolderPacket(header, bytes, ref i); - case 326: return new RemoveInventoryFolderPacket(header, bytes, ref i); - case 327: return new FetchInventoryDescendentsPacket(header, bytes, ref i); - case 328: return new InventoryDescendentsPacket(header, bytes, ref i); - case 329: return new FetchInventoryPacket(header, bytes, ref i); - case 330: return new FetchInventoryReplyPacket(header, bytes, ref i); - case 331: return new BulkUpdateInventoryPacket(header, bytes, ref i); - case 332: return new RequestInventoryAssetPacket(header, bytes, ref i); - case 333: return new InventoryAssetResponsePacket(header, bytes, ref i); - case 334: return new RemoveInventoryObjectsPacket(header, bytes, ref i); - case 335: return new PurgeInventoryDescendentsPacket(header, bytes, ref i); - case 336: return new UpdateTaskInventoryPacket(header, bytes, ref i); - case 337: return new RemoveTaskInventoryPacket(header, bytes, ref i); - case 338: return new MoveTaskInventoryPacket(header, bytes, ref i); - case 339: return new RequestTaskInventoryPacket(header, bytes, ref i); - case 340: return new ReplyTaskInventoryPacket(header, bytes, ref i); - case 341: return new DeRezObjectPacket(header, bytes, ref i); - case 342: return new DeRezAckPacket(header, bytes, ref i); - case 343: return new RezObjectPacket(header, bytes, ref i); - case 344: return new RezObjectFromNotecardPacket(header, bytes, ref i); - case 345: return new DeclineInventoryPacket(header, bytes, ref i); - case 346: return new TransferInventoryPacket(header, bytes, ref i); - case 347: return new TransferInventoryAckPacket(header, bytes, ref i); - case 348: return new RequestFriendshipPacket(header, bytes, ref i); - case 349: return new AcceptFriendshipPacket(header, bytes, ref i); - case 350: return new DeclineFriendshipPacket(header, bytes, ref i); - case 351: return new FormFriendshipPacket(header, bytes, ref i); - case 352: return new TerminateFriendshipPacket(header, bytes, ref i); - case 353: return new OfferCallingCardPacket(header, bytes, ref i); - case 354: return new AcceptCallingCardPacket(header, bytes, ref i); - case 355: return new DeclineCallingCardPacket(header, bytes, ref i); - case 356: return new RezScriptPacket(header, bytes, ref i); - case 357: return new CreateInventoryItemPacket(header, bytes, ref i); - case 358: return new CreateLandmarkForEventPacket(header, bytes, ref i); - case 359: return new EventLocationRequestPacket(header, bytes, ref i); - case 360: return new EventLocationReplyPacket(header, bytes, ref i); - case 361: return new RegionHandleRequestPacket(header, bytes, ref i); - case 362: return new RegionIDAndHandleReplyPacket(header, bytes, ref i); - case 363: return new MoneyTransferRequestPacket(header, bytes, ref i); - case 364: return new MoneyTransferBackendPacket(header, bytes, ref i); - case 365: return new BulkMoneyTransferPacket(header, bytes, ref i); - case 366: return new AdjustBalancePacket(header, bytes, ref i); - case 367: return new MoneyBalanceRequestPacket(header, bytes, ref i); - case 368: return new MoneyBalanceReplyPacket(header, bytes, ref i); - case 369: return new RoutedMoneyBalanceReplyPacket(header, bytes, ref i); - case 370: return new MoneyHistoryRequestPacket(header, bytes, ref i); - case 371: return new MoneyHistoryReplyPacket(header, bytes, ref i); - case 372: return new MoneySummaryRequestPacket(header, bytes, ref i); - case 373: return new MoneySummaryReplyPacket(header, bytes, ref i); - case 374: return new MoneyDetailsRequestPacket(header, bytes, ref i); - case 375: return new MoneyDetailsReplyPacket(header, bytes, ref i); - case 376: return new MoneyTransactionsRequestPacket(header, bytes, ref i); - case 377: return new MoneyTransactionsReplyPacket(header, bytes, ref i); - case 378: return new GestureRequestPacket(header, bytes, ref i); - case 379: return new ActivateGesturesPacket(header, bytes, ref i); - case 380: return new DeactivateGesturesPacket(header, bytes, ref i); - case 381: return new InventoryUpdatePacket(header, bytes, ref i); - case 382: return new MuteListUpdatePacket(header, bytes, ref i); - case 383: return new UseCachedMuteListPacket(header, bytes, ref i); - case 384: return new UserLoginLocationReplyPacket(header, bytes, ref i); - case 385: return new UserSimLocationReplyPacket(header, bytes, ref i); - case 386: return new UserListReplyPacket(header, bytes, ref i); - case 387: return new OnlineNotificationPacket(header, bytes, ref i); - case 388: return new OfflineNotificationPacket(header, bytes, ref i); - case 389: return new SetStartLocationRequestPacket(header, bytes, ref i); - case 390: return new SetStartLocationPacket(header, bytes, ref i); - case 391: return new UserLoginLocationRequestPacket(header, bytes, ref i); - case 392: return new SpaceLoginLocationReplyPacket(header, bytes, ref i); - case 393: return new NetTestPacket(header, bytes, ref i); - case 394: return new SetCPURatioPacket(header, bytes, ref i); - case 395: return new SimCrashedPacket(header, bytes, ref i); - case 396: return new SimulatorPauseStatePacket(header, bytes, ref i); - case 397: return new SimulatorThrottleSettingsPacket(header, bytes, ref i); - case 398: return new NameValuePairPacket(header, bytes, ref i); - case 399: return new RemoveNameValuePairPacket(header, bytes, ref i); - case 400: return new GetNameValuePairPacket(header, bytes, ref i); - case 401: return new UpdateAttachmentPacket(header, bytes, ref i); - case 402: return new RemoveAttachmentPacket(header, bytes, ref i); - case 403: return new AssetUploadRequestPacket(header, bytes, ref i); - case 404: return new AssetUploadCompletePacket(header, bytes, ref i); - case 405: return new ReputationAgentAssignPacket(header, bytes, ref i); - case 406: return new ReputationIndividualRequestPacket(header, bytes, ref i); - case 407: return new ReputationIndividualReplyPacket(header, bytes, ref i); - case 408: return new EmailMessageRequestPacket(header, bytes, ref i); - case 409: return new EmailMessageReplyPacket(header, bytes, ref i); - case 410: return new ScriptDataRequestPacket(header, bytes, ref i); - case 411: return new ScriptDataReplyPacket(header, bytes, ref i); - case 412: return new CreateGroupRequestPacket(header, bytes, ref i); - case 413: return new CreateGroupReplyPacket(header, bytes, ref i); - case 414: return new UpdateGroupInfoPacket(header, bytes, ref i); - case 415: return new GroupRoleChangesPacket(header, bytes, ref i); - case 416: return new JoinGroupRequestPacket(header, bytes, ref i); - case 417: return new JoinGroupReplyPacket(header, bytes, ref i); - case 418: return new EjectGroupMemberRequestPacket(header, bytes, ref i); - case 419: return new EjectGroupMemberReplyPacket(header, bytes, ref i); - case 420: return new LeaveGroupRequestPacket(header, bytes, ref i); - case 421: return new LeaveGroupReplyPacket(header, bytes, ref i); - case 422: return new InviteGroupRequestPacket(header, bytes, ref i); - case 423: return new InviteGroupResponsePacket(header, bytes, ref i); - case 424: return new GroupProfileRequestPacket(header, bytes, ref i); - case 425: return new GroupProfileReplyPacket(header, bytes, ref i); - case 426: return new GroupAccountSummaryRequestPacket(header, bytes, ref i); - case 427: return new GroupAccountSummaryReplyPacket(header, bytes, ref i); - case 428: return new GroupAccountDetailsRequestPacket(header, bytes, ref i); - case 429: return new GroupAccountDetailsReplyPacket(header, bytes, ref i); - case 430: return new GroupAccountTransactionsRequestPacket(header, bytes, ref i); - case 431: return new GroupAccountTransactionsReplyPacket(header, bytes, ref i); - case 432: return new GroupActiveProposalsRequestPacket(header, bytes, ref i); - case 433: return new GroupActiveProposalItemReplyPacket(header, bytes, ref i); - case 434: return new GroupVoteHistoryRequestPacket(header, bytes, ref i); - case 435: return new GroupVoteHistoryItemReplyPacket(header, bytes, ref i); - case 436: return new StartGroupProposalPacket(header, bytes, ref i); - case 437: return new GroupProposalBallotPacket(header, bytes, ref i); - case 438: return new TallyVotesPacket(header, bytes, ref i); - case 439: return new GroupMembersRequestPacket(header, bytes, ref i); - case 440: return new GroupMembersReplyPacket(header, bytes, ref i); - case 441: return new ActivateGroupPacket(header, bytes, ref i); - case 442: return new SetGroupContributionPacket(header, bytes, ref i); - case 443: return new SetGroupAcceptNoticesPacket(header, bytes, ref i); - case 444: return new GroupRoleDataRequestPacket(header, bytes, ref i); - case 445: return new GroupRoleDataReplyPacket(header, bytes, ref i); - case 446: return new GroupRoleMembersRequestPacket(header, bytes, ref i); - case 447: return new GroupRoleMembersReplyPacket(header, bytes, ref i); - case 448: return new GroupTitlesRequestPacket(header, bytes, ref i); - case 449: return new GroupTitlesReplyPacket(header, bytes, ref i); - case 450: return new GroupTitleUpdatePacket(header, bytes, ref i); - case 451: return new GroupRoleUpdatePacket(header, bytes, ref i); - case 452: return new LiveHelpGroupRequestPacket(header, bytes, ref i); - case 453: return new LiveHelpGroupReplyPacket(header, bytes, ref i); - case 454: return new AgentWearablesRequestPacket(header, bytes, ref i); - case 455: return new AgentWearablesUpdatePacket(header, bytes, ref i); - case 456: return new AgentIsNowWearingPacket(header, bytes, ref i); - case 457: return new AgentCachedTexturePacket(header, bytes, ref i); - case 458: return new AgentCachedTextureResponsePacket(header, bytes, ref i); - case 459: return new AgentDataUpdateRequestPacket(header, bytes, ref i); - case 460: return new AgentDataUpdatePacket(header, bytes, ref i); - case 461: return new GroupDataUpdatePacket(header, bytes, ref i); - case 462: return new AgentGroupDataUpdatePacket(header, bytes, ref i); - case 463: return new AgentDropGroupPacket(header, bytes, ref i); - case 464: return new LogTextMessagePacket(header, bytes, ref i); - case 465: return new CreateTrustedCircuitPacket(header, bytes, ref i); - case 466: return new DenyTrustedCircuitPacket(header, bytes, ref i); - case 467: return new RezSingleAttachmentFromInvPacket(header, bytes, ref i); - case 468: return new RezMultipleAttachmentsFromInvPacket(header, bytes, ref i); - case 469: return new DetachAttachmentIntoInvPacket(header, bytes, ref i); - case 470: return new CreateNewOutfitAttachmentsPacket(header, bytes, ref i); - case 471: return new UserInfoRequestPacket(header, bytes, ref i); - case 472: return new UserInfoReplyPacket(header, bytes, ref i); - case 473: return new UpdateUserInfoPacket(header, bytes, ref i); - case 474: return new GodExpungeUserPacket(header, bytes, ref i); - case 475: return new StartExpungeProcessPacket(header, bytes, ref i); - case 476: return new StartExpungeProcessAckPacket(header, bytes, ref i); - case 477: return new StartParcelRenamePacket(header, bytes, ref i); - case 478: return new StartParcelRenameAckPacket(header, bytes, ref i); - case 479: return new BulkParcelRenamePacket(header, bytes, ref i); - case 480: return new ParcelRenamePacket(header, bytes, ref i); - case 481: return new StartParcelRemovePacket(header, bytes, ref i); - case 482: return new StartParcelRemoveAckPacket(header, bytes, ref i); - case 483: return new BulkParcelRemovePacket(header, bytes, ref i); - case 484: return new InitiateUploadPacket(header, bytes, ref i); - case 485: return new InitiateDownloadPacket(header, bytes, ref i); - case 486: return new SystemMessagePacket(header, bytes, ref i); - case 487: return new MapLayerRequestPacket(header, bytes, ref i); - case 488: return new MapLayerReplyPacket(header, bytes, ref i); - case 489: return new MapBlockRequestPacket(header, bytes, ref i); - case 490: return new MapNameRequestPacket(header, bytes, ref i); - case 491: return new MapBlockReplyPacket(header, bytes, ref i); - case 492: return new MapItemRequestPacket(header, bytes, ref i); - case 493: return new MapItemReplyPacket(header, bytes, ref i); - case 494: return new SendPostcardPacket(header, bytes, ref i); - case 495: return new RpcChannelRequestPacket(header, bytes, ref i); - case 496: return new RpcChannelReplyPacket(header, bytes, ref i); - case 497: return new RpcScriptRequestInboundPacket(header, bytes, ref i); - case 498: return new RpcScriptRequestInboundForwardPacket(header, bytes, ref i); - case 499: return new RpcScriptReplyInboundPacket(header, bytes, ref i); - case 500: return new MailTaskSimRequestPacket(header, bytes, ref i); - case 501: return new MailTaskSimReplyPacket(header, bytes, ref i); - case 502: return new ScriptMailRegistrationPacket(header, bytes, ref i); - case 503: return new ParcelMediaCommandMessagePacket(header, bytes, ref i); - case 504: return new ParcelMediaUpdatePacket(header, bytes, ref i); - case 505: return new LandStatRequestPacket(header, bytes, ref i); - case 506: return new LandStatReplyPacket(header, bytes, ref i); - case 65530: return new SecuredTemplateChecksumRequestPacket(header, bytes, ref i); - case 65531: return new PacketAckPacket(header, bytes, ref i); - case 65532: return new OpenCircuitPacket(header, bytes, ref i); - case 65533: return new CloseCircuitPacket(header, bytes, ref i); - case 65534: return new TemplateChecksumRequestPacket(header, bytes, ref i); - case 65535: return new TemplateChecksumReplyPacket(header, bytes, ref i); + { + case 1: return new TestMessagePacket(header, bytes, ref i); + case 2: return new AddCircuitCodePacket(header, bytes, ref i); + case 3: return new UseCircuitCodePacket(header, bytes, ref i); + case 4: return new LogControlPacket(header, bytes, ref i); + case 5: return new RelayLogControlPacket(header, bytes, ref i); + case 6: return new LogMessagesPacket(header, bytes, ref i); + case 7: return new SimulatorAssignPacket(header, bytes, ref i); + case 8: return new SpaceServerSimulatorTimeMessagePacket(header, bytes, ref i); + case 9: return new AvatarTextureUpdatePacket(header, bytes, ref i); + case 10: return new SimulatorMapUpdatePacket(header, bytes, ref i); + case 11: return new SimulatorSetMapPacket(header, bytes, ref i); + case 12: return new SubscribeLoadPacket(header, bytes, ref i); + case 13: return new UnsubscribeLoadPacket(header, bytes, ref i); + case 14: return new SimulatorStartPacket(header, bytes, ref i); + case 15: return new SimulatorReadyPacket(header, bytes, ref i); + case 16: return new TelehubInfoPacket(header, bytes, ref i); + case 17: return new SimulatorPresentAtLocationPacket(header, bytes, ref i); + case 18: return new SimulatorLoadPacket(header, bytes, ref i); + case 19: return new SimulatorShutdownRequestPacket(header, bytes, ref i); + case 20: return new RegionPresenceRequestByRegionIDPacket(header, bytes, ref i); + case 21: return new RegionPresenceRequestByHandlePacket(header, bytes, ref i); + case 22: return new RegionPresenceResponsePacket(header, bytes, ref i); + case 23: return new RecordAgentPresencePacket(header, bytes, ref i); + case 24: return new EraseAgentPresencePacket(header, bytes, ref i); + case 25: return new AgentPresenceRequestPacket(header, bytes, ref i); + case 26: return new AgentPresenceResponsePacket(header, bytes, ref i); + case 27: return new UpdateSimulatorPacket(header, bytes, ref i); + case 28: return new TrackAgentSessionPacket(header, bytes, ref i); + case 29: return new ClearAgentSessionsPacket(header, bytes, ref i); + case 30: return new LogDwellTimePacket(header, bytes, ref i); + case 31: return new FeatureDisabledPacket(header, bytes, ref i); + case 32: return new LogFailedMoneyTransactionPacket(header, bytes, ref i); + case 33: return new UserReportInternalPacket(header, bytes, ref i); + case 34: return new SetSimStatusInDatabasePacket(header, bytes, ref i); + case 35: return new SetSimPresenceInDatabasePacket(header, bytes, ref i); + case 36: return new EconomyDataRequestPacket(header, bytes, ref i); + case 37: return new EconomyDataPacket(header, bytes, ref i); + case 38: return new AvatarPickerRequestPacket(header, bytes, ref i); + case 39: return new AvatarPickerRequestBackendPacket(header, bytes, ref i); + case 40: return new AvatarPickerReplyPacket(header, bytes, ref i); + case 41: return new PlacesQueryPacket(header, bytes, ref i); + case 42: return new PlacesReplyPacket(header, bytes, ref i); + case 43: return new DirFindQueryPacket(header, bytes, ref i); + case 44: return new DirFindQueryBackendPacket(header, bytes, ref i); + case 45: return new DirPlacesQueryPacket(header, bytes, ref i); + case 46: return new DirPlacesQueryBackendPacket(header, bytes, ref i); + case 47: return new DirPlacesReplyPacket(header, bytes, ref i); + case 48: return new DirPeopleQueryPacket(header, bytes, ref i); + case 49: return new DirPeopleQueryBackendPacket(header, bytes, ref i); + case 50: return new DirPeopleReplyPacket(header, bytes, ref i); + case 51: return new DirEventsReplyPacket(header, bytes, ref i); + case 52: return new DirGroupsQueryPacket(header, bytes, ref i); + case 53: return new DirGroupsQueryBackendPacket(header, bytes, ref i); + case 54: return new DirGroupsReplyPacket(header, bytes, ref i); + case 55: return new DirClassifiedQueryPacket(header, bytes, ref i); + case 56: return new DirClassifiedQueryBackendPacket(header, bytes, ref i); + case 57: return new DirClassifiedReplyPacket(header, bytes, ref i); + case 58: return new AvatarClassifiedReplyPacket(header, bytes, ref i); + case 59: return new ClassifiedInfoRequestPacket(header, bytes, ref i); + case 60: return new ClassifiedInfoReplyPacket(header, bytes, ref i); + case 61: return new ClassifiedInfoUpdatePacket(header, bytes, ref i); + case 62: return new ClassifiedDeletePacket(header, bytes, ref i); + case 63: return new ClassifiedGodDeletePacket(header, bytes, ref i); + case 64: return new DirPicksQueryPacket(header, bytes, ref i); + case 65: return new DirPicksQueryBackendPacket(header, bytes, ref i); + case 66: return new DirPicksReplyPacket(header, bytes, ref i); + case 67: return new DirLandQueryPacket(header, bytes, ref i); + case 68: return new DirLandQueryBackendPacket(header, bytes, ref i); + case 69: return new DirLandReplyPacket(header, bytes, ref i); + case 70: return new DirPopularQueryPacket(header, bytes, ref i); + case 71: return new DirPopularQueryBackendPacket(header, bytes, ref i); + case 72: return new DirPopularReplyPacket(header, bytes, ref i); + case 73: return new ParcelInfoRequestPacket(header, bytes, ref i); + case 74: return new ParcelInfoReplyPacket(header, bytes, ref i); + case 75: return new ParcelObjectOwnersRequestPacket(header, bytes, ref i); + case 76: return new OnlineStatusRequestPacket(header, bytes, ref i); + case 77: return new OnlineStatusReplyPacket(header, bytes, ref i); + case 78: return new ParcelObjectOwnersReplyPacket(header, bytes, ref i); + case 79: return new GroupNoticesListRequestPacket(header, bytes, ref i); + case 80: return new GroupNoticesListReplyPacket(header, bytes, ref i); + case 81: return new GroupNoticeRequestPacket(header, bytes, ref i); + case 82: return new GroupNoticeAddPacket(header, bytes, ref i); + case 83: return new GroupNoticeDeletePacket(header, bytes, ref i); + case 84: return new TeleportRequestPacket(header, bytes, ref i); + case 85: return new TeleportLocationRequestPacket(header, bytes, ref i); + case 86: return new TeleportLocalPacket(header, bytes, ref i); + case 87: return new TeleportLandmarkRequestPacket(header, bytes, ref i); + case 88: return new TeleportProgressPacket(header, bytes, ref i); + case 89: return new DataAgentAccessRequestPacket(header, bytes, ref i); + case 90: return new DataAgentAccessReplyPacket(header, bytes, ref i); + case 91: return new DataHomeLocationRequestPacket(header, bytes, ref i); + case 92: return new DataHomeLocationReplyPacket(header, bytes, ref i); + case 93: return new SpaceLocationTeleportRequestPacket(header, bytes, ref i); + case 94: return new SpaceLocationTeleportReplyPacket(header, bytes, ref i); + case 95: return new TeleportFinishPacket(header, bytes, ref i); + case 96: return new StartLurePacket(header, bytes, ref i); + case 97: return new TeleportLureRequestPacket(header, bytes, ref i); + case 98: return new TeleportCancelPacket(header, bytes, ref i); + case 99: return new CompleteLurePacket(header, bytes, ref i); + case 100: return new TeleportStartPacket(header, bytes, ref i); + case 101: return new TeleportFailedPacket(header, bytes, ref i); + case 102: return new LeaderBoardRequestPacket(header, bytes, ref i); + case 103: return new LeaderBoardDataPacket(header, bytes, ref i); + case 104: return new RegisterNewAgentPacket(header, bytes, ref i); + case 105: return new UndoPacket(header, bytes, ref i); + case 106: return new RedoPacket(header, bytes, ref i); + case 107: return new UndoLandPacket(header, bytes, ref i); + case 108: return new RedoLandPacket(header, bytes, ref i); + case 109: return new AgentPausePacket(header, bytes, ref i); + case 110: return new AgentResumePacket(header, bytes, ref i); + case 111: return new ChatFromViewerPacket(header, bytes, ref i); + case 112: return new AgentThrottlePacket(header, bytes, ref i); + case 113: return new AgentFOVPacket(header, bytes, ref i); + case 114: return new AgentHeightWidthPacket(header, bytes, ref i); + case 115: return new AgentSetAppearancePacket(header, bytes, ref i); + case 116: return new AgentQuitPacket(header, bytes, ref i); + case 117: return new AgentQuitCopyPacket(header, bytes, ref i); + case 118: return new ImageNotInDatabasePacket(header, bytes, ref i); + case 119: return new RebakeAvatarTexturesPacket(header, bytes, ref i); + case 120: return new SetAlwaysRunPacket(header, bytes, ref i); + case 121: return new ObjectDeletePacket(header, bytes, ref i); + case 122: return new ObjectDuplicatePacket(header, bytes, ref i); + case 123: return new ObjectDuplicateOnRayPacket(header, bytes, ref i); + case 124: return new ObjectScalePacket(header, bytes, ref i); + case 125: return new ObjectRotationPacket(header, bytes, ref i); + case 126: return new ObjectFlagUpdatePacket(header, bytes, ref i); + case 127: return new ObjectClickActionPacket(header, bytes, ref i); + case 128: return new ObjectImagePacket(header, bytes, ref i); + case 129: return new ObjectMaterialPacket(header, bytes, ref i); + case 130: return new ObjectShapePacket(header, bytes, ref i); + case 131: return new ObjectExtraParamsPacket(header, bytes, ref i); + case 132: return new ObjectOwnerPacket(header, bytes, ref i); + case 133: return new ObjectGroupPacket(header, bytes, ref i); + case 134: return new ObjectBuyPacket(header, bytes, ref i); + case 135: return new BuyObjectInventoryPacket(header, bytes, ref i); + case 136: return new DerezContainerPacket(header, bytes, ref i); + case 137: return new ObjectPermissionsPacket(header, bytes, ref i); + case 138: return new ObjectSaleInfoPacket(header, bytes, ref i); + case 139: return new ObjectNamePacket(header, bytes, ref i); + case 140: return new ObjectDescriptionPacket(header, bytes, ref i); + case 141: return new ObjectCategoryPacket(header, bytes, ref i); + case 142: return new ObjectSelectPacket(header, bytes, ref i); + case 143: return new ObjectDeselectPacket(header, bytes, ref i); + case 144: return new ObjectAttachPacket(header, bytes, ref i); + case 145: return new ObjectDetachPacket(header, bytes, ref i); + case 146: return new ObjectDropPacket(header, bytes, ref i); + case 147: return new ObjectLinkPacket(header, bytes, ref i); + case 148: return new ObjectDelinkPacket(header, bytes, ref i); + case 149: return new ObjectHingePacket(header, bytes, ref i); + case 150: return new ObjectDehingePacket(header, bytes, ref i); + case 151: return new ObjectGrabPacket(header, bytes, ref i); + case 152: return new ObjectGrabUpdatePacket(header, bytes, ref i); + case 153: return new ObjectDeGrabPacket(header, bytes, ref i); + case 154: return new ObjectSpinStartPacket(header, bytes, ref i); + case 155: return new ObjectSpinUpdatePacket(header, bytes, ref i); + case 156: return new ObjectSpinStopPacket(header, bytes, ref i); + case 157: return new ObjectExportSelectedPacket(header, bytes, ref i); + case 158: return new ObjectImportPacket(header, bytes, ref i); + case 159: return new ModifyLandPacket(header, bytes, ref i); + case 160: return new VelocityInterpolateOnPacket(header, bytes, ref i); + case 161: return new VelocityInterpolateOffPacket(header, bytes, ref i); + case 162: return new StateSavePacket(header, bytes, ref i); + case 163: return new ReportAutosaveCrashPacket(header, bytes, ref i); + case 164: return new SimWideDeletesPacket(header, bytes, ref i); + case 165: return new TrackAgentPacket(header, bytes, ref i); + case 166: return new GrantModificationPacket(header, bytes, ref i); + case 167: return new RevokeModificationPacket(header, bytes, ref i); + case 168: return new RequestGrantedProxiesPacket(header, bytes, ref i); + case 169: return new GrantedProxiesPacket(header, bytes, ref i); + case 170: return new AddModifyAbilityPacket(header, bytes, ref i); + case 171: return new RemoveModifyAbilityPacket(header, bytes, ref i); + case 172: return new ViewerStatsPacket(header, bytes, ref i); + case 173: return new ScriptAnswerYesPacket(header, bytes, ref i); + case 174: return new UserReportPacket(header, bytes, ref i); + case 175: return new AlertMessagePacket(header, bytes, ref i); + case 176: return new AgentAlertMessagePacket(header, bytes, ref i); + case 177: return new MeanCollisionAlertPacket(header, bytes, ref i); + case 178: return new ViewerFrozenMessagePacket(header, bytes, ref i); + case 179: return new HealthMessagePacket(header, bytes, ref i); + case 180: return new ChatFromSimulatorPacket(header, bytes, ref i); + case 181: return new SimStatsPacket(header, bytes, ref i); + case 182: return new RequestRegionInfoPacket(header, bytes, ref i); + case 183: return new RegionInfoPacket(header, bytes, ref i); + case 184: return new GodUpdateRegionInfoPacket(header, bytes, ref i); + case 185: return new NearestLandingRegionRequestPacket(header, bytes, ref i); + case 186: return new NearestLandingRegionReplyPacket(header, bytes, ref i); + case 187: return new NearestLandingRegionUpdatedPacket(header, bytes, ref i); + case 188: return new TeleportLandingStatusChangedPacket(header, bytes, ref i); + case 189: return new RegionHandshakePacket(header, bytes, ref i); + case 190: return new RegionHandshakeReplyPacket(header, bytes, ref i); + case 191: return new SimulatorViewerTimeMessagePacket(header, bytes, ref i); + case 192: return new EnableSimulatorPacket(header, bytes, ref i); + case 193: return new DisableSimulatorPacket(header, bytes, ref i); + case 194: return new TransferRequestPacket(header, bytes, ref i); + case 195: return new TransferInfoPacket(header, bytes, ref i); + case 196: return new TransferAbortPacket(header, bytes, ref i); + case 197: return new TransferPriorityPacket(header, bytes, ref i); + case 198: return new RequestXferPacket(header, bytes, ref i); + case 199: return new AbortXferPacket(header, bytes, ref i); + case 200: return new RequestAvatarInfoPacket(header, bytes, ref i); + case 201: return new AvatarAppearancePacket(header, bytes, ref i); + case 202: return new SetFollowCamPropertiesPacket(header, bytes, ref i); + case 203: return new ClearFollowCamPropertiesPacket(header, bytes, ref i); + case 204: return new RequestPayPricePacket(header, bytes, ref i); + case 205: return new PayPriceReplyPacket(header, bytes, ref i); + case 206: return new KickUserPacket(header, bytes, ref i); + case 207: return new KickUserAckPacket(header, bytes, ref i); + case 208: return new GodKickUserPacket(header, bytes, ref i); + case 209: return new SystemKickUserPacket(header, bytes, ref i); + case 210: return new EjectUserPacket(header, bytes, ref i); + case 211: return new FreezeUserPacket(header, bytes, ref i); + case 212: return new AvatarPropertiesRequestPacket(header, bytes, ref i); + case 213: return new AvatarPropertiesRequestBackendPacket(header, bytes, ref i); + case 214: return new AvatarPropertiesReplyPacket(header, bytes, ref i); + case 215: return new AvatarGroupsReplyPacket(header, bytes, ref i); + case 216: return new AvatarPropertiesUpdatePacket(header, bytes, ref i); + case 217: return new AvatarStatisticsReplyPacket(header, bytes, ref i); + case 218: return new AvatarNotesReplyPacket(header, bytes, ref i); + case 219: return new AvatarNotesUpdatePacket(header, bytes, ref i); + case 220: return new AvatarPicksReplyPacket(header, bytes, ref i); + case 221: return new EventInfoRequestPacket(header, bytes, ref i); + case 222: return new EventInfoReplyPacket(header, bytes, ref i); + case 223: return new EventNotificationAddRequestPacket(header, bytes, ref i); + case 224: return new EventNotificationRemoveRequestPacket(header, bytes, ref i); + case 225: return new EventGodDeletePacket(header, bytes, ref i); + case 226: return new PickInfoRequestPacket(header, bytes, ref i); + case 227: return new PickInfoReplyPacket(header, bytes, ref i); + case 228: return new PickInfoUpdatePacket(header, bytes, ref i); + case 229: return new PickDeletePacket(header, bytes, ref i); + case 230: return new PickGodDeletePacket(header, bytes, ref i); + case 231: return new ScriptQuestionPacket(header, bytes, ref i); + case 232: return new ScriptControlChangePacket(header, bytes, ref i); + case 233: return new ScriptDialogPacket(header, bytes, ref i); + case 234: return new ScriptDialogReplyPacket(header, bytes, ref i); + case 235: return new ForceScriptControlReleasePacket(header, bytes, ref i); + case 236: return new RevokePermissionsPacket(header, bytes, ref i); + case 237: return new LoadURLPacket(header, bytes, ref i); + case 238: return new ScriptTeleportRequestPacket(header, bytes, ref i); + case 239: return new ParcelOverlayPacket(header, bytes, ref i); + case 240: return new ParcelPropertiesRequestByIDPacket(header, bytes, ref i); + case 241: return new ParcelPropertiesUpdatePacket(header, bytes, ref i); + case 242: return new ParcelReturnObjectsPacket(header, bytes, ref i); + case 243: return new ParcelSetOtherCleanTimePacket(header, bytes, ref i); + case 244: return new ParcelDisableObjectsPacket(header, bytes, ref i); + case 245: return new ParcelSelectObjectsPacket(header, bytes, ref i); + case 246: return new EstateCovenantRequestPacket(header, bytes, ref i); + case 247: return new EstateCovenantReplyPacket(header, bytes, ref i); + case 248: return new ForceObjectSelectPacket(header, bytes, ref i); + case 249: return new ParcelBuyPassPacket(header, bytes, ref i); + case 250: return new ParcelDeedToGroupPacket(header, bytes, ref i); + case 251: return new ParcelReclaimPacket(header, bytes, ref i); + case 252: return new ParcelClaimPacket(header, bytes, ref i); + case 253: return new ParcelJoinPacket(header, bytes, ref i); + case 254: return new ParcelDividePacket(header, bytes, ref i); + case 255: return new ParcelReleasePacket(header, bytes, ref i); + case 256: return new ParcelBuyPacket(header, bytes, ref i); + case 257: return new ParcelGodForceOwnerPacket(header, bytes, ref i); + case 258: return new ParcelAccessListRequestPacket(header, bytes, ref i); + case 259: return new ParcelAccessListReplyPacket(header, bytes, ref i); + case 260: return new ParcelAccessListUpdatePacket(header, bytes, ref i); + case 261: return new ParcelDwellRequestPacket(header, bytes, ref i); + case 262: return new ParcelDwellReplyPacket(header, bytes, ref i); + case 263: return new RequestParcelTransferPacket(header, bytes, ref i); + case 264: return new UpdateParcelPacket(header, bytes, ref i); + case 265: return new RemoveParcelPacket(header, bytes, ref i); + case 266: return new MergeParcelPacket(header, bytes, ref i); + case 267: return new LogParcelChangesPacket(header, bytes, ref i); + case 268: return new CheckParcelSalesPacket(header, bytes, ref i); + case 269: return new ParcelSalesPacket(header, bytes, ref i); + case 270: return new ParcelGodMarkAsContentPacket(header, bytes, ref i); + case 271: return new ParcelGodReserveForNewbiePacket(header, bytes, ref i); + case 272: return new ViewerStartAuctionPacket(header, bytes, ref i); + case 273: return new StartAuctionPacket(header, bytes, ref i); + case 274: return new ConfirmAuctionStartPacket(header, bytes, ref i); + case 275: return new CompleteAuctionPacket(header, bytes, ref i); + case 276: return new CancelAuctionPacket(header, bytes, ref i); + case 277: return new CheckParcelAuctionsPacket(header, bytes, ref i); + case 278: return new ParcelAuctionsPacket(header, bytes, ref i); + case 279: return new UUIDNameRequestPacket(header, bytes, ref i); + case 280: return new UUIDNameReplyPacket(header, bytes, ref i); + case 281: return new UUIDGroupNameRequestPacket(header, bytes, ref i); + case 282: return new UUIDGroupNameReplyPacket(header, bytes, ref i); + case 283: return new ChatPassPacket(header, bytes, ref i); + case 284: return new ChildAgentDyingPacket(header, bytes, ref i); + case 285: return new ChildAgentUnknownPacket(header, bytes, ref i); + case 286: return new KillChildAgentsPacket(header, bytes, ref i); + case 287: return new GetScriptRunningPacket(header, bytes, ref i); + case 288: return new ScriptRunningReplyPacket(header, bytes, ref i); + case 289: return new SetScriptRunningPacket(header, bytes, ref i); + case 290: return new ScriptResetPacket(header, bytes, ref i); + case 291: return new ScriptSensorRequestPacket(header, bytes, ref i); + case 292: return new ScriptSensorReplyPacket(header, bytes, ref i); + case 293: return new CompleteAgentMovementPacket(header, bytes, ref i); + case 294: return new AgentMovementCompletePacket(header, bytes, ref i); + case 295: return new LogLoginPacket(header, bytes, ref i); + case 296: return new ConnectAgentToUserserverPacket(header, bytes, ref i); + case 297: return new ConnectToUserserverPacket(header, bytes, ref i); + case 298: return new DataServerLogoutPacket(header, bytes, ref i); + case 299: return new LogoutRequestPacket(header, bytes, ref i); + case 300: return new FinalizeLogoutPacket(header, bytes, ref i); + case 301: return new LogoutReplyPacket(header, bytes, ref i); + case 302: return new LogoutDemandPacket(header, bytes, ref i); + case 303: return new ImprovedInstantMessagePacket(header, bytes, ref i); + case 304: return new RetrieveInstantMessagesPacket(header, bytes, ref i); + case 305: return new DequeueInstantMessagesPacket(header, bytes, ref i); + case 306: return new FindAgentPacket(header, bytes, ref i); + case 307: return new RequestGodlikePowersPacket(header, bytes, ref i); + case 308: return new GrantGodlikePowersPacket(header, bytes, ref i); + case 309: return new GodlikeMessagePacket(header, bytes, ref i); + case 310: return new EstateOwnerMessagePacket(header, bytes, ref i); + case 311: return new GenericMessagePacket(header, bytes, ref i); + case 312: return new MuteListRequestPacket(header, bytes, ref i); + case 313: return new UpdateMuteListEntryPacket(header, bytes, ref i); + case 314: return new RemoveMuteListEntryPacket(header, bytes, ref i); + case 315: return new CopyInventoryFromNotecardPacket(header, bytes, ref i); + case 316: return new UpdateInventoryItemPacket(header, bytes, ref i); + case 317: return new UpdateCreateInventoryItemPacket(header, bytes, ref i); + case 318: return new MoveInventoryItemPacket(header, bytes, ref i); + case 319: return new CopyInventoryItemPacket(header, bytes, ref i); + case 320: return new RemoveInventoryItemPacket(header, bytes, ref i); + case 321: return new ChangeInventoryItemFlagsPacket(header, bytes, ref i); + case 322: return new SaveAssetIntoInventoryPacket(header, bytes, ref i); + case 323: return new CreateInventoryFolderPacket(header, bytes, ref i); + case 324: return new UpdateInventoryFolderPacket(header, bytes, ref i); + case 325: return new MoveInventoryFolderPacket(header, bytes, ref i); + case 326: return new RemoveInventoryFolderPacket(header, bytes, ref i); + case 327: return new FetchInventoryDescendentsPacket(header, bytes, ref i); + case 328: return new InventoryDescendentsPacket(header, bytes, ref i); + case 329: return new FetchInventoryPacket(header, bytes, ref i); + case 330: return new FetchInventoryReplyPacket(header, bytes, ref i); + case 331: return new BulkUpdateInventoryPacket(header, bytes, ref i); + case 332: return new RequestInventoryAssetPacket(header, bytes, ref i); + case 333: return new InventoryAssetResponsePacket(header, bytes, ref i); + case 334: return new RemoveInventoryObjectsPacket(header, bytes, ref i); + case 335: return new PurgeInventoryDescendentsPacket(header, bytes, ref i); + case 336: return new UpdateTaskInventoryPacket(header, bytes, ref i); + case 337: return new RemoveTaskInventoryPacket(header, bytes, ref i); + case 338: return new MoveTaskInventoryPacket(header, bytes, ref i); + case 339: return new RequestTaskInventoryPacket(header, bytes, ref i); + case 340: return new ReplyTaskInventoryPacket(header, bytes, ref i); + case 341: return new DeRezObjectPacket(header, bytes, ref i); + case 342: return new DeRezAckPacket(header, bytes, ref i); + case 343: return new RezObjectPacket(header, bytes, ref i); + case 344: return new RezObjectFromNotecardPacket(header, bytes, ref i); + case 345: return new DeclineInventoryPacket(header, bytes, ref i); + case 346: return new TransferInventoryPacket(header, bytes, ref i); + case 347: return new TransferInventoryAckPacket(header, bytes, ref i); + case 348: return new RequestFriendshipPacket(header, bytes, ref i); + case 349: return new AcceptFriendshipPacket(header, bytes, ref i); + case 350: return new DeclineFriendshipPacket(header, bytes, ref i); + case 351: return new FormFriendshipPacket(header, bytes, ref i); + case 352: return new TerminateFriendshipPacket(header, bytes, ref i); + case 353: return new OfferCallingCardPacket(header, bytes, ref i); + case 354: return new AcceptCallingCardPacket(header, bytes, ref i); + case 355: return new DeclineCallingCardPacket(header, bytes, ref i); + case 356: return new RezScriptPacket(header, bytes, ref i); + case 357: return new CreateInventoryItemPacket(header, bytes, ref i); + case 358: return new CreateLandmarkForEventPacket(header, bytes, ref i); + case 359: return new EventLocationRequestPacket(header, bytes, ref i); + case 360: return new EventLocationReplyPacket(header, bytes, ref i); + case 361: return new RegionHandleRequestPacket(header, bytes, ref i); + case 362: return new RegionIDAndHandleReplyPacket(header, bytes, ref i); + case 363: return new MoneyTransferRequestPacket(header, bytes, ref i); + case 364: return new MoneyTransferBackendPacket(header, bytes, ref i); + case 365: return new BulkMoneyTransferPacket(header, bytes, ref i); + case 366: return new AdjustBalancePacket(header, bytes, ref i); + case 367: return new MoneyBalanceRequestPacket(header, bytes, ref i); + case 368: return new MoneyBalanceReplyPacket(header, bytes, ref i); + case 369: return new RoutedMoneyBalanceReplyPacket(header, bytes, ref i); + case 370: return new MoneyHistoryRequestPacket(header, bytes, ref i); + case 371: return new MoneyHistoryReplyPacket(header, bytes, ref i); + case 372: return new MoneySummaryRequestPacket(header, bytes, ref i); + case 373: return new MoneySummaryReplyPacket(header, bytes, ref i); + case 374: return new MoneyDetailsRequestPacket(header, bytes, ref i); + case 375: return new MoneyDetailsReplyPacket(header, bytes, ref i); + case 376: return new MoneyTransactionsRequestPacket(header, bytes, ref i); + case 377: return new MoneyTransactionsReplyPacket(header, bytes, ref i); + case 378: return new GestureRequestPacket(header, bytes, ref i); + case 379: return new ActivateGesturesPacket(header, bytes, ref i); + case 380: return new DeactivateGesturesPacket(header, bytes, ref i); + case 381: return new InventoryUpdatePacket(header, bytes, ref i); + case 382: return new MuteListUpdatePacket(header, bytes, ref i); + case 383: return new UseCachedMuteListPacket(header, bytes, ref i); + case 384: return new UserLoginLocationReplyPacket(header, bytes, ref i); + case 385: return new UserSimLocationReplyPacket(header, bytes, ref i); + case 386: return new UserListReplyPacket(header, bytes, ref i); + case 387: return new OnlineNotificationPacket(header, bytes, ref i); + case 388: return new OfflineNotificationPacket(header, bytes, ref i); + case 389: return new SetStartLocationRequestPacket(header, bytes, ref i); + case 390: return new SetStartLocationPacket(header, bytes, ref i); + case 391: return new UserLoginLocationRequestPacket(header, bytes, ref i); + case 392: return new SpaceLoginLocationReplyPacket(header, bytes, ref i); + case 393: return new NetTestPacket(header, bytes, ref i); + case 394: return new SetCPURatioPacket(header, bytes, ref i); + case 395: return new SimCrashedPacket(header, bytes, ref i); + case 396: return new SimulatorPauseStatePacket(header, bytes, ref i); + case 397: return new SimulatorThrottleSettingsPacket(header, bytes, ref i); + case 398: return new NameValuePairPacket(header, bytes, ref i); + case 399: return new RemoveNameValuePairPacket(header, bytes, ref i); + case 400: return new GetNameValuePairPacket(header, bytes, ref i); + case 401: return new UpdateAttachmentPacket(header, bytes, ref i); + case 402: return new RemoveAttachmentPacket(header, bytes, ref i); + case 403: return new AssetUploadRequestPacket(header, bytes, ref i); + case 404: return new AssetUploadCompletePacket(header, bytes, ref i); + case 405: return new ReputationAgentAssignPacket(header, bytes, ref i); + case 406: return new ReputationIndividualRequestPacket(header, bytes, ref i); + case 407: return new ReputationIndividualReplyPacket(header, bytes, ref i); + case 408: return new EmailMessageRequestPacket(header, bytes, ref i); + case 409: return new EmailMessageReplyPacket(header, bytes, ref i); + case 410: return new ScriptDataRequestPacket(header, bytes, ref i); + case 411: return new ScriptDataReplyPacket(header, bytes, ref i); + case 412: return new CreateGroupRequestPacket(header, bytes, ref i); + case 413: return new CreateGroupReplyPacket(header, bytes, ref i); + case 414: return new UpdateGroupInfoPacket(header, bytes, ref i); + case 415: return new GroupRoleChangesPacket(header, bytes, ref i); + case 416: return new JoinGroupRequestPacket(header, bytes, ref i); + case 417: return new JoinGroupReplyPacket(header, bytes, ref i); + case 418: return new EjectGroupMemberRequestPacket(header, bytes, ref i); + case 419: return new EjectGroupMemberReplyPacket(header, bytes, ref i); + case 420: return new LeaveGroupRequestPacket(header, bytes, ref i); + case 421: return new LeaveGroupReplyPacket(header, bytes, ref i); + case 422: return new InviteGroupRequestPacket(header, bytes, ref i); + case 423: return new InviteGroupResponsePacket(header, bytes, ref i); + case 424: return new GroupProfileRequestPacket(header, bytes, ref i); + case 425: return new GroupProfileReplyPacket(header, bytes, ref i); + case 426: return new GroupAccountSummaryRequestPacket(header, bytes, ref i); + case 427: return new GroupAccountSummaryReplyPacket(header, bytes, ref i); + case 428: return new GroupAccountDetailsRequestPacket(header, bytes, ref i); + case 429: return new GroupAccountDetailsReplyPacket(header, bytes, ref i); + case 430: return new GroupAccountTransactionsRequestPacket(header, bytes, ref i); + case 431: return new GroupAccountTransactionsReplyPacket(header, bytes, ref i); + case 432: return new GroupActiveProposalsRequestPacket(header, bytes, ref i); + case 433: return new GroupActiveProposalItemReplyPacket(header, bytes, ref i); + case 434: return new GroupVoteHistoryRequestPacket(header, bytes, ref i); + case 435: return new GroupVoteHistoryItemReplyPacket(header, bytes, ref i); + case 436: return new StartGroupProposalPacket(header, bytes, ref i); + case 437: return new GroupProposalBallotPacket(header, bytes, ref i); + case 438: return new TallyVotesPacket(header, bytes, ref i); + case 439: return new GroupMembersRequestPacket(header, bytes, ref i); + case 440: return new GroupMembersReplyPacket(header, bytes, ref i); + case 441: return new ActivateGroupPacket(header, bytes, ref i); + case 442: return new SetGroupContributionPacket(header, bytes, ref i); + case 443: return new SetGroupAcceptNoticesPacket(header, bytes, ref i); + case 444: return new GroupRoleDataRequestPacket(header, bytes, ref i); + case 445: return new GroupRoleDataReplyPacket(header, bytes, ref i); + case 446: return new GroupRoleMembersRequestPacket(header, bytes, ref i); + case 447: return new GroupRoleMembersReplyPacket(header, bytes, ref i); + case 448: return new GroupTitlesRequestPacket(header, bytes, ref i); + case 449: return new GroupTitlesReplyPacket(header, bytes, ref i); + case 450: return new GroupTitleUpdatePacket(header, bytes, ref i); + case 451: return new GroupRoleUpdatePacket(header, bytes, ref i); + case 452: return new LiveHelpGroupRequestPacket(header, bytes, ref i); + case 453: return new LiveHelpGroupReplyPacket(header, bytes, ref i); + case 454: return new AgentWearablesRequestPacket(header, bytes, ref i); + case 455: return new AgentWearablesUpdatePacket(header, bytes, ref i); + case 456: return new AgentIsNowWearingPacket(header, bytes, ref i); + case 457: return new AgentCachedTexturePacket(header, bytes, ref i); + case 458: return new AgentCachedTextureResponsePacket(header, bytes, ref i); + case 459: return new AgentDataUpdateRequestPacket(header, bytes, ref i); + case 460: return new AgentDataUpdatePacket(header, bytes, ref i); + case 461: return new GroupDataUpdatePacket(header, bytes, ref i); + case 462: return new AgentGroupDataUpdatePacket(header, bytes, ref i); + case 463: return new AgentDropGroupPacket(header, bytes, ref i); + case 464: return new LogTextMessagePacket(header, bytes, ref i); + case 465: return new CreateTrustedCircuitPacket(header, bytes, ref i); + case 466: return new DenyTrustedCircuitPacket(header, bytes, ref i); + case 467: return new RezSingleAttachmentFromInvPacket(header, bytes, ref i); + case 468: return new RezMultipleAttachmentsFromInvPacket(header, bytes, ref i); + case 469: return new DetachAttachmentIntoInvPacket(header, bytes, ref i); + case 470: return new CreateNewOutfitAttachmentsPacket(header, bytes, ref i); + case 471: return new UserInfoRequestPacket(header, bytes, ref i); + case 472: return new UserInfoReplyPacket(header, bytes, ref i); + case 473: return new UpdateUserInfoPacket(header, bytes, ref i); + case 474: return new GodExpungeUserPacket(header, bytes, ref i); + case 475: return new StartExpungeProcessPacket(header, bytes, ref i); + case 476: return new StartExpungeProcessAckPacket(header, bytes, ref i); + case 477: return new StartParcelRenamePacket(header, bytes, ref i); + case 478: return new StartParcelRenameAckPacket(header, bytes, ref i); + case 479: return new BulkParcelRenamePacket(header, bytes, ref i); + case 480: return new ParcelRenamePacket(header, bytes, ref i); + case 481: return new StartParcelRemovePacket(header, bytes, ref i); + case 482: return new StartParcelRemoveAckPacket(header, bytes, ref i); + case 483: return new BulkParcelRemovePacket(header, bytes, ref i); + case 484: return new InitiateUploadPacket(header, bytes, ref i); + case 485: return new InitiateDownloadPacket(header, bytes, ref i); + case 486: return new SystemMessagePacket(header, bytes, ref i); + case 487: return new MapLayerRequestPacket(header, bytes, ref i); + case 488: return new MapLayerReplyPacket(header, bytes, ref i); + case 489: return new MapBlockRequestPacket(header, bytes, ref i); + case 490: return new MapNameRequestPacket(header, bytes, ref i); + case 491: return new MapBlockReplyPacket(header, bytes, ref i); + case 492: return new MapItemRequestPacket(header, bytes, ref i); + case 493: return new MapItemReplyPacket(header, bytes, ref i); + case 494: return new SendPostcardPacket(header, bytes, ref i); + case 495: return new RpcChannelRequestPacket(header, bytes, ref i); + case 496: return new RpcChannelReplyPacket(header, bytes, ref i); + case 497: return new RpcScriptRequestInboundPacket(header, bytes, ref i); + case 498: return new RpcScriptRequestInboundForwardPacket(header, bytes, ref i); + case 499: return new RpcScriptReplyInboundPacket(header, bytes, ref i); + case 500: return new MailTaskSimRequestPacket(header, bytes, ref i); + case 501: return new MailTaskSimReplyPacket(header, bytes, ref i); + case 502: return new ScriptMailRegistrationPacket(header, bytes, ref i); + case 503: return new ParcelMediaCommandMessagePacket(header, bytes, ref i); + case 504: return new ParcelMediaUpdatePacket(header, bytes, ref i); + case 505: return new LandStatRequestPacket(header, bytes, ref i); + case 506: return new LandStatReplyPacket(header, bytes, ref i); + case 65530: return new SecuredTemplateChecksumRequestPacket(header, bytes, ref i); + case 65531: return new PacketAckPacket(header, bytes, ref i); + case 65532: return new OpenCircuitPacket(header, bytes, ref i); + case 65533: return new CloseCircuitPacket(header, bytes, ref i); + case 65534: return new TemplateChecksumRequestPacket(header, bytes, ref i); + case 65535: return new TemplateChecksumReplyPacket(header, bytes, ref i); } } else { id = (ushort)bytes[5]; switch (id) - { - case 1: return new ClosestSimulatorPacket(header, bytes, ref i); - case 2: return new ObjectAddPacket(header, bytes, ref i); - case 3: return new MultipleObjectUpdatePacket(header, bytes, ref i); - case 4: return new RequestMultipleObjectsPacket(header, bytes, ref i); - case 5: return new ObjectPositionPacket(header, bytes, ref i); - case 6: return new RequestObjectPropertiesFamilyPacket(header, bytes, ref i); - case 7: return new CoarseLocationUpdatePacket(header, bytes, ref i); - case 8: return new CrossedRegionPacket(header, bytes, ref i); - case 9: return new ConfirmEnableSimulatorPacket(header, bytes, ref i); - case 10: return new ObjectPropertiesPacket(header, bytes, ref i); - case 11: return new ObjectPropertiesFamilyPacket(header, bytes, ref i); - case 12: return new ParcelPropertiesRequestPacket(header, bytes, ref i); - case 13: return new SimStatusPacket(header, bytes, ref i); - case 14: return new GestureUpdatePacket(header, bytes, ref i); - case 15: return new AttachedSoundPacket(header, bytes, ref i); - case 16: return new AttachedSoundGainChangePacket(header, bytes, ref i); - case 17: return new AttachedSoundCutoffRadiusPacket(header, bytes, ref i); - case 18: return new PreloadSoundPacket(header, bytes, ref i); - case 19: return new InternalScriptMailPacket(header, bytes, ref i); - case 20: return new ViewerEffectPacket(header, bytes, ref i); - case 21: return new SetSunPhasePacket(header, bytes, ref i); + { + case 1: return new ClosestSimulatorPacket(header, bytes, ref i); + case 2: return new ObjectAddPacket(header, bytes, ref i); + case 3: return new MultipleObjectUpdatePacket(header, bytes, ref i); + case 4: return new RequestMultipleObjectsPacket(header, bytes, ref i); + case 5: return new ObjectPositionPacket(header, bytes, ref i); + case 6: return new RequestObjectPropertiesFamilyPacket(header, bytes, ref i); + case 7: return new CoarseLocationUpdatePacket(header, bytes, ref i); + case 8: return new CrossedRegionPacket(header, bytes, ref i); + case 9: return new ConfirmEnableSimulatorPacket(header, bytes, ref i); + case 10: return new ObjectPropertiesPacket(header, bytes, ref i); + case 11: return new ObjectPropertiesFamilyPacket(header, bytes, ref i); + case 12: return new ParcelPropertiesRequestPacket(header, bytes, ref i); + case 13: return new SimStatusPacket(header, bytes, ref i); + case 14: return new GestureUpdatePacket(header, bytes, ref i); + case 15: return new AttachedSoundPacket(header, bytes, ref i); + case 16: return new AttachedSoundGainChangePacket(header, bytes, ref i); + case 17: return new AttachedSoundCutoffRadiusPacket(header, bytes, ref i); + case 18: return new PreloadSoundPacket(header, bytes, ref i); + case 19: return new InternalScriptMailPacket(header, bytes, ref i); + case 20: return new ViewerEffectPacket(header, bytes, ref i); + case 21: return new SetSunPhasePacket(header, bytes, ref i); } } } @@ -2658,105781 +2658,105782 @@ namespace libsecondlife.Packets { id = (ushort)bytes[4]; switch (id) - { - case 1: return new StartPingCheckPacket(header, bytes, ref i); - case 2: return new CompletePingCheckPacket(header, bytes, ref i); - case 3: return new NeighborListPacket(header, bytes, ref i); - case 4: return new MovedIntoSimulatorPacket(header, bytes, ref i); - case 5: return new AgentUpdatePacket(header, bytes, ref i); - case 6: return new AgentAnimationPacket(header, bytes, ref i); - case 7: return new AgentRequestSitPacket(header, bytes, ref i); - case 8: return new AgentSitPacket(header, bytes, ref i); - case 9: return new RequestImagePacket(header, bytes, ref i); - case 10: return new ImageDataPacket(header, bytes, ref i); - case 11: return new ImagePacketPacket(header, bytes, ref i); - case 12: return new LayerDataPacket(header, bytes, ref i); - case 13: return new ObjectUpdatePacket(header, bytes, ref i); - case 14: return new ObjectUpdateCompressedPacket(header, bytes, ref i); - case 15: return new ObjectUpdateCachedPacket(header, bytes, ref i); - case 16: return new ImprovedTerseObjectUpdatePacket(header, bytes, ref i); - case 17: return new KillObjectPacket(header, bytes, ref i); - case 18: return new AgentToNewRegionPacket(header, bytes, ref i); - case 19: return new TransferPacketPacket(header, bytes, ref i); - case 20: return new SendXferPacketPacket(header, bytes, ref i); - case 21: return new ConfirmXferPacketPacket(header, bytes, ref i); - case 22: return new AvatarAnimationPacket(header, bytes, ref i); - case 23: return new AvatarSitResponsePacket(header, bytes, ref i); - case 24: return new CameraConstraintPacket(header, bytes, ref i); - case 25: return new ParcelPropertiesPacket(header, bytes, ref i); - case 26: return new EdgeDataPacketPacket(header, bytes, ref i); - case 27: return new ChildAgentUpdatePacket(header, bytes, ref i); - case 28: return new ChildAgentAlivePacket(header, bytes, ref i); - case 29: return new ChildAgentPositionUpdatePacket(header, bytes, ref i); - case 30: return new PassObjectPacket(header, bytes, ref i); - case 31: return new AtomicPassObjectPacket(header, bytes, ref i); - case 32: return new SoundTriggerPacket(header, bytes, ref i); + { + case 1: return new StartPingCheckPacket(header, bytes, ref i); + case 2: return new CompletePingCheckPacket(header, bytes, ref i); + case 3: return new NeighborListPacket(header, bytes, ref i); + case 4: return new MovedIntoSimulatorPacket(header, bytes, ref i); + case 5: return new AgentUpdatePacket(header, bytes, ref i); + case 6: return new AgentAnimationPacket(header, bytes, ref i); + case 7: return new AgentRequestSitPacket(header, bytes, ref i); + case 8: return new AgentSitPacket(header, bytes, ref i); + case 9: return new RequestImagePacket(header, bytes, ref i); + case 10: return new ImageDataPacket(header, bytes, ref i); + case 11: return new ImagePacketPacket(header, bytes, ref i); + case 12: return new LayerDataPacket(header, bytes, ref i); + case 13: return new ObjectUpdatePacket(header, bytes, ref i); + case 14: return new ObjectUpdateCompressedPacket(header, bytes, ref i); + case 15: return new ObjectUpdateCachedPacket(header, bytes, ref i); + case 16: return new ImprovedTerseObjectUpdatePacket(header, bytes, ref i); + case 17: return new KillObjectPacket(header, bytes, ref i); + case 18: return new AgentToNewRegionPacket(header, bytes, ref i); + case 19: return new TransferPacketPacket(header, bytes, ref i); + case 20: return new SendXferPacketPacket(header, bytes, ref i); + case 21: return new ConfirmXferPacketPacket(header, bytes, ref i); + case 22: return new AvatarAnimationPacket(header, bytes, ref i); + case 23: return new AvatarSitResponsePacket(header, bytes, ref i); + case 24: return new CameraConstraintPacket(header, bytes, ref i); + case 25: return new ParcelPropertiesPacket(header, bytes, ref i); + case 26: return new EdgeDataPacketPacket(header, bytes, ref i); + case 27: return new ChildAgentUpdatePacket(header, bytes, ref i); + case 28: return new ChildAgentAlivePacket(header, bytes, ref i); + case 29: return new ChildAgentPositionUpdatePacket(header, bytes, ref i); + case 30: return new PassObjectPacket(header, bytes, ref i); + case 31: return new AtomicPassObjectPacket(header, bytes, ref i); + case 32: return new SoundTriggerPacket(header, bytes, ref i); } } throw new MalformedDataException("Unknown packet ID"); } } - - /// TestMessage packet + + /// TestMessage packet public class TestMessagePacket : Packet - { - /// TestBlock1 block + { + /// TestBlock1 block public class TestBlock1Block - { - /// Test1 field - public uint Test1; - - /// Length of this block serialized in bytes + { + /// Test1 field + public uint Test1; + + /// Length of this block serialized in bytes public int Length { get - { - return 4; + { + return 4; } } - - /// Default constructor - public TestBlock1Block() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public TestBlock1Block() { } + /// Constructor for building the block from a byte array public TestBlock1Block(byte[] bytes, ref int i) - { + { try - { - Test1 = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + Test1 = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(Test1 % 256); - bytes[i++] = (byte)((Test1 >> 8) % 256); - bytes[i++] = (byte)((Test1 >> 16) % 256); - bytes[i++] = (byte)((Test1 >> 24) % 256); + { + bytes[i++] = (byte)(Test1 % 256); + bytes[i++] = (byte)((Test1 >> 8) % 256); + bytes[i++] = (byte)((Test1 >> 16) % 256); + bytes[i++] = (byte)((Test1 >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- TestBlock1 --\n"; - output += "Test1: " + Test1.ToString() + "\n"; + { + string output = "-- TestBlock1 --\n"; + output += "Test1: " + Test1.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// NeighborBlock block + + /// NeighborBlock block public class NeighborBlockBlock - { - /// Test0 field - public uint Test0; - /// Test1 field - public uint Test1; - /// Test2 field - public uint Test2; - - /// Length of this block serialized in bytes + { + /// Test0 field + public uint Test0; + /// Test1 field + public uint Test1; + /// Test2 field + public uint Test2; + + /// Length of this block serialized in bytes public int Length { get - { - return 12; + { + return 12; } } - - /// Default constructor - public NeighborBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public NeighborBlockBlock() { } + /// Constructor for building the block from a byte array public NeighborBlockBlock(byte[] bytes, ref int i) - { + { try - { - Test0 = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Test1 = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Test2 = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + Test0 = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Test1 = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Test2 = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(Test0 % 256); - bytes[i++] = (byte)((Test0 >> 8) % 256); - bytes[i++] = (byte)((Test0 >> 16) % 256); - bytes[i++] = (byte)((Test0 >> 24) % 256); - bytes[i++] = (byte)(Test1 % 256); - bytes[i++] = (byte)((Test1 >> 8) % 256); - bytes[i++] = (byte)((Test1 >> 16) % 256); - bytes[i++] = (byte)((Test1 >> 24) % 256); - bytes[i++] = (byte)(Test2 % 256); - bytes[i++] = (byte)((Test2 >> 8) % 256); - bytes[i++] = (byte)((Test2 >> 16) % 256); - bytes[i++] = (byte)((Test2 >> 24) % 256); + { + bytes[i++] = (byte)(Test0 % 256); + bytes[i++] = (byte)((Test0 >> 8) % 256); + bytes[i++] = (byte)((Test0 >> 16) % 256); + bytes[i++] = (byte)((Test0 >> 24) % 256); + bytes[i++] = (byte)(Test1 % 256); + bytes[i++] = (byte)((Test1 >> 8) % 256); + bytes[i++] = (byte)((Test1 >> 16) % 256); + bytes[i++] = (byte)((Test1 >> 24) % 256); + bytes[i++] = (byte)(Test2 % 256); + bytes[i++] = (byte)((Test2 >> 8) % 256); + bytes[i++] = (byte)((Test2 >> 16) % 256); + bytes[i++] = (byte)((Test2 >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- NeighborBlock --\n"; - output += "Test0: " + Test0.ToString() + "\n"; - output += "Test1: " + Test1.ToString() + "\n"; - output += "Test2: " + Test2.ToString() + "\n"; + { + string output = "-- NeighborBlock --\n"; + output += "Test0: " + Test0.ToString() + "\n"; + output += "Test1: " + Test1.ToString() + "\n"; + output += "Test2: " + Test2.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.TestMessage - public override PacketType Type { get { return PacketType.TestMessage; } } - /// TestBlock1 block - public TestBlock1Block TestBlock1; - /// NeighborBlock block - public NeighborBlockBlock[] NeighborBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.TestMessage + public override PacketType Type { get { return PacketType.TestMessage; } } + /// TestBlock1 block + public TestBlock1Block TestBlock1; + /// NeighborBlock block + public NeighborBlockBlock[] NeighborBlock; + + /// Default constructor public TestMessagePacket() - { - Header = new LowHeader(); - Header.ID = 1; - Header.Reliable = true; - Header.Zerocoded = true; - TestBlock1 = new TestBlock1Block(); - NeighborBlock = new NeighborBlockBlock[4]; + { + Header = new LowHeader(); + Header.ID = 1; + Header.Reliable = true; + Header.Zerocoded = true; + TestBlock1 = new TestBlock1Block(); + NeighborBlock = new NeighborBlockBlock[4]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public TestMessagePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - TestBlock1 = new TestBlock1Block(bytes, ref i); - NeighborBlock = new NeighborBlockBlock[4]; - for (int j = 0; j < 4; j++) - { NeighborBlock[j] = new NeighborBlockBlock(bytes, ref i); } - } - - /// Constructor that takes a byte array and a prebuilt header - public TestMessagePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - TestBlock1 = new TestBlock1Block(bytes, ref i); - NeighborBlock = new NeighborBlockBlock[4]; - for (int j = 0; j < 4; j++) - { NeighborBlock[j] = new NeighborBlockBlock(bytes, ref i); } - } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet - public override byte[] ToBytes() - { - int length = 8; - length += TestBlock1.Length;; - for (int j = 0; j < 4; j++) { length += NeighborBlock[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - TestBlock1.ToBytes(bytes, ref i); - for (int j = 0; j < 4; j++) { NeighborBlock[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } - return bytes; - } - - /// Serialize this packet to a stringA string containing the serialized packet - public override string ToString() - { - string output = "--- TestMessage ---\n"; - output += TestBlock1.ToString() + "\n"; + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + TestBlock1 = new TestBlock1Block(bytes, ref i); + NeighborBlock = new NeighborBlockBlock[4]; for (int j = 0; j < 4; j++) - { + { NeighborBlock[j] = new NeighborBlockBlock(bytes, ref i); } + } + + /// Constructor that takes a byte array and a prebuilt header + public TestMessagePacket(Header head, byte[] bytes, ref int i) + { + Header = head; + TestBlock1 = new TestBlock1Block(bytes, ref i); + NeighborBlock = new NeighborBlockBlock[4]; + for (int j = 0; j < 4; j++) + { NeighborBlock[j] = new NeighborBlockBlock(bytes, ref i); } + } + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet + public override byte[] ToBytes() + { + int length = 8; + length += TestBlock1.Length;; + for (int j = 0; j < 4; j++) { length += NeighborBlock[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + TestBlock1.ToBytes(bytes, ref i); + for (int j = 0; j < 4; j++) { NeighborBlock[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + return bytes; + } + + /// Serialize this packet to a stringA string containing the serialized packet + public override string ToString() + { + string output = "--- TestMessage ---\n"; + output += TestBlock1.ToString() + "\n"; + for (int j = 0; j < 4; j++) + { output += NeighborBlock[j].ToString() + "\n"; - } + } return output; } - + } - - /// AddCircuitCode packet + + /// AddCircuitCode packet public class AddCircuitCodePacket : Packet - { - /// CircuitCode block + { + /// CircuitCode block public class CircuitCodeBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - /// Code field - public uint Code; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + /// Code field + public uint Code; + + /// Length of this block serialized in bytes public int Length { get - { - return 36; + { + return 36; } } - - /// Default constructor - public CircuitCodeBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public CircuitCodeBlock() { } + /// Constructor for building the block from a byte array public CircuitCodeBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; - Code = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; + Code = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(Code % 256); - bytes[i++] = (byte)((Code >> 8) % 256); - bytes[i++] = (byte)((Code >> 16) % 256); - bytes[i++] = (byte)((Code >> 24) % 256); + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(Code % 256); + bytes[i++] = (byte)((Code >> 8) % 256); + bytes[i++] = (byte)((Code >> 16) % 256); + bytes[i++] = (byte)((Code >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- CircuitCode --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "Code: " + Code.ToString() + "\n"; + { + string output = "-- CircuitCode --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "Code: " + Code.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AddCircuitCode - public override PacketType Type { get { return PacketType.AddCircuitCode; } } - /// CircuitCode block - public CircuitCodeBlock CircuitCode; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AddCircuitCode + public override PacketType Type { get { return PacketType.AddCircuitCode; } } + /// CircuitCode block + public CircuitCodeBlock CircuitCode; + + /// Default constructor public AddCircuitCodePacket() - { - Header = new LowHeader(); - Header.ID = 2; - Header.Reliable = true; - CircuitCode = new CircuitCodeBlock(); + { + Header = new LowHeader(); + Header.ID = 2; + Header.Reliable = true; + CircuitCode = new CircuitCodeBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AddCircuitCodePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - CircuitCode = new CircuitCodeBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + CircuitCode = new CircuitCodeBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AddCircuitCodePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - CircuitCode = new CircuitCodeBlock(bytes, ref i); + { + Header = head; + CircuitCode = new CircuitCodeBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += CircuitCode.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - CircuitCode.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += CircuitCode.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + CircuitCode.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AddCircuitCode ---\n"; - output += CircuitCode.ToString() + "\n"; + { + string output = "--- AddCircuitCode ---\n"; + output += CircuitCode.ToString() + "\n"; return output; } - + } - - /// UseCircuitCode packet + + /// UseCircuitCode packet public class UseCircuitCodePacket : Packet - { - /// CircuitCode block + { + /// CircuitCode block public class CircuitCodeBlock - { - /// ID field - public LLUUID ID; - /// SessionID field - public LLUUID SessionID; - /// Code field - public uint Code; - - /// Length of this block serialized in bytes + { + /// ID field + public LLUUID ID; + /// SessionID field + public LLUUID SessionID; + /// Code field + public uint Code; + + /// Length of this block serialized in bytes public int Length { get - { - return 36; + { + return 36; } } - - /// Default constructor - public CircuitCodeBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public CircuitCodeBlock() { } + /// Constructor for building the block from a byte array public CircuitCodeBlock(byte[] bytes, ref int i) - { + { try - { - ID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; - Code = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + ID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; + Code = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } - Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(Code % 256); - bytes[i++] = (byte)((Code >> 8) % 256); - bytes[i++] = (byte)((Code >> 16) % 256); - bytes[i++] = (byte)((Code >> 24) % 256); + { + if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } + Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(Code % 256); + bytes[i++] = (byte)((Code >> 8) % 256); + bytes[i++] = (byte)((Code >> 16) % 256); + bytes[i++] = (byte)((Code >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- CircuitCode --\n"; - output += "ID: " + ID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "Code: " + Code.ToString() + "\n"; + { + string output = "-- CircuitCode --\n"; + output += "ID: " + ID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "Code: " + Code.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.UseCircuitCode - public override PacketType Type { get { return PacketType.UseCircuitCode; } } - /// CircuitCode block - public CircuitCodeBlock CircuitCode; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.UseCircuitCode + public override PacketType Type { get { return PacketType.UseCircuitCode; } } + /// CircuitCode block + public CircuitCodeBlock CircuitCode; + + /// Default constructor public UseCircuitCodePacket() - { - Header = new LowHeader(); - Header.ID = 3; - Header.Reliable = true; - CircuitCode = new CircuitCodeBlock(); + { + Header = new LowHeader(); + Header.ID = 3; + Header.Reliable = true; + CircuitCode = new CircuitCodeBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public UseCircuitCodePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - CircuitCode = new CircuitCodeBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + CircuitCode = new CircuitCodeBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public UseCircuitCodePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - CircuitCode = new CircuitCodeBlock(bytes, ref i); + { + Header = head; + CircuitCode = new CircuitCodeBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += CircuitCode.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - CircuitCode.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += CircuitCode.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + CircuitCode.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- UseCircuitCode ---\n"; - output += CircuitCode.ToString() + "\n"; + { + string output = "--- UseCircuitCode ---\n"; + output += CircuitCode.ToString() + "\n"; return output; } - + } - - /// LogControl packet + + /// LogControl packet public class LogControlPacket : Packet - { - /// Options block + { + /// Options block public class OptionsBlock - { - /// Mask field - public uint Mask; - /// Time field - public bool Time; - /// RemoteInfos field - public bool RemoteInfos; - /// Location field - public bool Location; - /// Level field - public byte Level; - - /// Length of this block serialized in bytes + { + /// Mask field + public uint Mask; + /// Time field + public bool Time; + /// RemoteInfos field + public bool RemoteInfos; + /// Location field + public bool Location; + /// Level field + public byte Level; + + /// Length of this block serialized in bytes public int Length { get - { - return 8; + { + return 8; } } - - /// Default constructor - public OptionsBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public OptionsBlock() { } + /// Constructor for building the block from a byte array public OptionsBlock(byte[] bytes, ref int i) - { + { try - { - Mask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Time = (bytes[i++] != 0) ? (bool)true : (bool)false; - RemoteInfos = (bytes[i++] != 0) ? (bool)true : (bool)false; - Location = (bytes[i++] != 0) ? (bool)true : (bool)false; - Level = (byte)bytes[i++]; + { + Mask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Time = (bytes[i++] != 0) ? (bool)true : (bool)false; + RemoteInfos = (bytes[i++] != 0) ? (bool)true : (bool)false; + Location = (bytes[i++] != 0) ? (bool)true : (bool)false; + Level = (byte)bytes[i++]; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(Mask % 256); - bytes[i++] = (byte)((Mask >> 8) % 256); - bytes[i++] = (byte)((Mask >> 16) % 256); - bytes[i++] = (byte)((Mask >> 24) % 256); - bytes[i++] = (byte)((Time) ? 1 : 0); - bytes[i++] = (byte)((RemoteInfos) ? 1 : 0); - bytes[i++] = (byte)((Location) ? 1 : 0); - bytes[i++] = Level; + { + bytes[i++] = (byte)(Mask % 256); + bytes[i++] = (byte)((Mask >> 8) % 256); + bytes[i++] = (byte)((Mask >> 16) % 256); + bytes[i++] = (byte)((Mask >> 24) % 256); + bytes[i++] = (byte)((Time) ? 1 : 0); + bytes[i++] = (byte)((RemoteInfos) ? 1 : 0); + bytes[i++] = (byte)((Location) ? 1 : 0); + bytes[i++] = Level; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Options --\n"; - output += "Mask: " + Mask.ToString() + "\n"; - output += "Time: " + Time.ToString() + "\n"; - output += "RemoteInfos: " + RemoteInfos.ToString() + "\n"; - output += "Location: " + Location.ToString() + "\n"; - output += "Level: " + Level.ToString() + "\n"; + { + string output = "-- Options --\n"; + output += "Mask: " + Mask.ToString() + "\n"; + output += "Time: " + Time.ToString() + "\n"; + output += "RemoteInfos: " + RemoteInfos.ToString() + "\n"; + output += "Location: " + Location.ToString() + "\n"; + output += "Level: " + Level.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.LogControl - public override PacketType Type { get { return PacketType.LogControl; } } - /// Options block - public OptionsBlock Options; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.LogControl + public override PacketType Type { get { return PacketType.LogControl; } } + /// Options block + public OptionsBlock Options; + + /// Default constructor public LogControlPacket() - { - Header = new LowHeader(); - Header.ID = 4; - Header.Reliable = true; - Options = new OptionsBlock(); + { + Header = new LowHeader(); + Header.ID = 4; + Header.Reliable = true; + Options = new OptionsBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public LogControlPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Options = new OptionsBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Options = new OptionsBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public LogControlPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Options = new OptionsBlock(bytes, ref i); + { + Header = head; + Options = new OptionsBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Options.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Options.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Options.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Options.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- LogControl ---\n"; - output += Options.ToString() + "\n"; + { + string output = "--- LogControl ---\n"; + output += Options.ToString() + "\n"; return output; } - + } - - /// RelayLogControl packet + + /// RelayLogControl packet public class RelayLogControlPacket : Packet - { - /// Options block + { + /// Options block public class OptionsBlock - { - /// Mask field - public uint Mask; - /// Time field - public bool Time; - /// RemoteInfos field - public bool RemoteInfos; - /// Location field - public bool Location; - /// Level field - public byte Level; - - /// Length of this block serialized in bytes + { + /// Mask field + public uint Mask; + /// Time field + public bool Time; + /// RemoteInfos field + public bool RemoteInfos; + /// Location field + public bool Location; + /// Level field + public byte Level; + + /// Length of this block serialized in bytes public int Length { get - { - return 8; + { + return 8; } } - - /// Default constructor - public OptionsBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public OptionsBlock() { } + /// Constructor for building the block from a byte array public OptionsBlock(byte[] bytes, ref int i) - { + { try - { - Mask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Time = (bytes[i++] != 0) ? (bool)true : (bool)false; - RemoteInfos = (bytes[i++] != 0) ? (bool)true : (bool)false; - Location = (bytes[i++] != 0) ? (bool)true : (bool)false; - Level = (byte)bytes[i++]; + { + Mask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Time = (bytes[i++] != 0) ? (bool)true : (bool)false; + RemoteInfos = (bytes[i++] != 0) ? (bool)true : (bool)false; + Location = (bytes[i++] != 0) ? (bool)true : (bool)false; + Level = (byte)bytes[i++]; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(Mask % 256); - bytes[i++] = (byte)((Mask >> 8) % 256); - bytes[i++] = (byte)((Mask >> 16) % 256); - bytes[i++] = (byte)((Mask >> 24) % 256); - bytes[i++] = (byte)((Time) ? 1 : 0); - bytes[i++] = (byte)((RemoteInfos) ? 1 : 0); - bytes[i++] = (byte)((Location) ? 1 : 0); - bytes[i++] = Level; + { + bytes[i++] = (byte)(Mask % 256); + bytes[i++] = (byte)((Mask >> 8) % 256); + bytes[i++] = (byte)((Mask >> 16) % 256); + bytes[i++] = (byte)((Mask >> 24) % 256); + bytes[i++] = (byte)((Time) ? 1 : 0); + bytes[i++] = (byte)((RemoteInfos) ? 1 : 0); + bytes[i++] = (byte)((Location) ? 1 : 0); + bytes[i++] = Level; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Options --\n"; - output += "Mask: " + Mask.ToString() + "\n"; - output += "Time: " + Time.ToString() + "\n"; - output += "RemoteInfos: " + RemoteInfos.ToString() + "\n"; - output += "Location: " + Location.ToString() + "\n"; - output += "Level: " + Level.ToString() + "\n"; + { + string output = "-- Options --\n"; + output += "Mask: " + Mask.ToString() + "\n"; + output += "Time: " + Time.ToString() + "\n"; + output += "RemoteInfos: " + RemoteInfos.ToString() + "\n"; + output += "Location: " + Location.ToString() + "\n"; + output += "Level: " + Level.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.RelayLogControl - public override PacketType Type { get { return PacketType.RelayLogControl; } } - /// Options block - public OptionsBlock Options; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.RelayLogControl + public override PacketType Type { get { return PacketType.RelayLogControl; } } + /// Options block + public OptionsBlock Options; + + /// Default constructor public RelayLogControlPacket() - { - Header = new LowHeader(); - Header.ID = 5; - Header.Reliable = true; - Options = new OptionsBlock(); + { + Header = new LowHeader(); + Header.ID = 5; + Header.Reliable = true; + Options = new OptionsBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public RelayLogControlPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Options = new OptionsBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Options = new OptionsBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public RelayLogControlPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Options = new OptionsBlock(bytes, ref i); + { + Header = head; + Options = new OptionsBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Options.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Options.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Options.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Options.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- RelayLogControl ---\n"; - output += Options.ToString() + "\n"; + { + string output = "--- RelayLogControl ---\n"; + output += Options.ToString() + "\n"; return output; } - + } - - /// LogMessages packet + + /// LogMessages packet public class LogMessagesPacket : Packet - { - /// Options block + { + /// Options block public class OptionsBlock - { - /// Enable field - public bool Enable; - - /// Length of this block serialized in bytes + { + /// Enable field + public bool Enable; + + /// Length of this block serialized in bytes public int Length { get - { - return 1; + { + return 1; } } - - /// Default constructor - public OptionsBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public OptionsBlock() { } + /// Constructor for building the block from a byte array public OptionsBlock(byte[] bytes, ref int i) - { + { try - { - Enable = (bytes[i++] != 0) ? (bool)true : (bool)false; + { + Enable = (bytes[i++] != 0) ? (bool)true : (bool)false; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)((Enable) ? 1 : 0); + { + bytes[i++] = (byte)((Enable) ? 1 : 0); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Options --\n"; - output += "Enable: " + Enable.ToString() + "\n"; + { + string output = "-- Options --\n"; + output += "Enable: " + Enable.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.LogMessages - public override PacketType Type { get { return PacketType.LogMessages; } } - /// Options block - public OptionsBlock Options; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.LogMessages + public override PacketType Type { get { return PacketType.LogMessages; } } + /// Options block + public OptionsBlock Options; + + /// Default constructor public LogMessagesPacket() - { - Header = new LowHeader(); - Header.ID = 6; - Header.Reliable = true; - Options = new OptionsBlock(); + { + Header = new LowHeader(); + Header.ID = 6; + Header.Reliable = true; + Options = new OptionsBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public LogMessagesPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Options = new OptionsBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Options = new OptionsBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public LogMessagesPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Options = new OptionsBlock(bytes, ref i); + { + Header = head; + Options = new OptionsBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Options.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Options.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Options.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Options.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- LogMessages ---\n"; - output += Options.ToString() + "\n"; + { + string output = "--- LogMessages ---\n"; + output += Options.ToString() + "\n"; return output; } - + } - - /// SimulatorAssign packet + + /// SimulatorAssign packet public class SimulatorAssignPacket : Packet - { - /// RegionInfo block + { + /// RegionInfo block public class RegionInfoBlock - { - /// IP field - public uint IP; - /// SecPerDay field - public uint SecPerDay; - /// MetersPerGrid field - public float MetersPerGrid; - /// UsecSinceStart field - public ulong UsecSinceStart; - /// Port field - public ushort Port; - /// SecPerYear field - public uint SecPerYear; - /// GridsPerEdge field - public int GridsPerEdge; - /// Handle field - public ulong Handle; - /// SunAngVelocity field - public LLVector3 SunAngVelocity; - /// SunDirection field - public LLVector3 SunDirection; - - /// Length of this block serialized in bytes + { + /// IP field + public uint IP; + /// SecPerDay field + public uint SecPerDay; + /// MetersPerGrid field + public float MetersPerGrid; + /// UsecSinceStart field + public ulong UsecSinceStart; + /// Port field + public ushort Port; + /// SecPerYear field + public uint SecPerYear; + /// GridsPerEdge field + public int GridsPerEdge; + /// Handle field + public ulong Handle; + /// SunAngVelocity field + public LLVector3 SunAngVelocity; + /// SunDirection field + public LLVector3 SunDirection; + + /// Length of this block serialized in bytes public int Length { get - { - return 62; + { + return 62; } } - - /// Default constructor - public RegionInfoBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public RegionInfoBlock() { } + /// Constructor for building the block from a byte array public RegionInfoBlock(byte[] bytes, ref int i) - { + { try - { - IP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - SecPerDay = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - MetersPerGrid = BitConverter.ToSingle(bytes, i); i += 4; - UsecSinceStart = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); - Port = (ushort)((bytes[i++] << 8) + bytes[i++]); - SecPerYear = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - GridsPerEdge = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Handle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); - SunAngVelocity = new LLVector3(bytes, i); i += 12; - SunDirection = new LLVector3(bytes, i); i += 12; + { + IP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + SecPerDay = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + MetersPerGrid = BitConverter.ToSingle(bytes, i); i += 4; + UsecSinceStart = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + Port = (ushort)((bytes[i++] << 8) + bytes[i++]); + SecPerYear = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + GridsPerEdge = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Handle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + SunAngVelocity = new LLVector3(bytes, i); i += 12; + SunDirection = new LLVector3(bytes, i); i += 12; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; - bytes[i++] = (byte)(IP % 256); - bytes[i++] = (byte)((IP >> 8) % 256); - bytes[i++] = (byte)((IP >> 16) % 256); - bytes[i++] = (byte)((IP >> 24) % 256); - bytes[i++] = (byte)(SecPerDay % 256); - bytes[i++] = (byte)((SecPerDay >> 8) % 256); - bytes[i++] = (byte)((SecPerDay >> 16) % 256); - bytes[i++] = (byte)((SecPerDay >> 24) % 256); + { + byte[] ba; + bytes[i++] = (byte)(IP % 256); + bytes[i++] = (byte)((IP >> 8) % 256); + bytes[i++] = (byte)((IP >> 16) % 256); + bytes[i++] = (byte)((IP >> 24) % 256); + bytes[i++] = (byte)(SecPerDay % 256); + bytes[i++] = (byte)((SecPerDay >> 8) % 256); + bytes[i++] = (byte)((SecPerDay >> 16) % 256); + bytes[i++] = (byte)((SecPerDay >> 24) % 256); ba = BitConverter.GetBytes(MetersPerGrid); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - bytes[i++] = (byte)(UsecSinceStart % 256); - bytes[i++] = (byte)((UsecSinceStart >> 8) % 256); - bytes[i++] = (byte)((UsecSinceStart >> 16) % 256); - bytes[i++] = (byte)((UsecSinceStart >> 24) % 256); - bytes[i++] = (byte)((UsecSinceStart >> 32) % 256); - bytes[i++] = (byte)((UsecSinceStart >> 40) % 256); - bytes[i++] = (byte)((UsecSinceStart >> 48) % 256); - bytes[i++] = (byte)((UsecSinceStart >> 56) % 256); - bytes[i++] = (byte)((Port >> 8) % 256); - bytes[i++] = (byte)(Port % 256); - bytes[i++] = (byte)(SecPerYear % 256); - bytes[i++] = (byte)((SecPerYear >> 8) % 256); - bytes[i++] = (byte)((SecPerYear >> 16) % 256); - bytes[i++] = (byte)((SecPerYear >> 24) % 256); - bytes[i++] = (byte)(GridsPerEdge % 256); - bytes[i++] = (byte)((GridsPerEdge >> 8) % 256); - bytes[i++] = (byte)((GridsPerEdge >> 16) % 256); - bytes[i++] = (byte)((GridsPerEdge >> 24) % 256); - bytes[i++] = (byte)(Handle % 256); - bytes[i++] = (byte)((Handle >> 8) % 256); - bytes[i++] = (byte)((Handle >> 16) % 256); - bytes[i++] = (byte)((Handle >> 24) % 256); - bytes[i++] = (byte)((Handle >> 32) % 256); - bytes[i++] = (byte)((Handle >> 40) % 256); - bytes[i++] = (byte)((Handle >> 48) % 256); - bytes[i++] = (byte)((Handle >> 56) % 256); - if(SunAngVelocity == null) { Console.WriteLine("Warning: SunAngVelocity is null, in " + this.GetType()); } - Array.Copy(SunAngVelocity.GetBytes(), 0, bytes, i, 12); i += 12; - if(SunDirection == null) { Console.WriteLine("Warning: SunDirection is null, in " + this.GetType()); } - Array.Copy(SunDirection.GetBytes(), 0, bytes, i, 12); i += 12; + Array.Copy(ba, 0, bytes, i, 4); i += 4; + bytes[i++] = (byte)(UsecSinceStart % 256); + bytes[i++] = (byte)((UsecSinceStart >> 8) % 256); + bytes[i++] = (byte)((UsecSinceStart >> 16) % 256); + bytes[i++] = (byte)((UsecSinceStart >> 24) % 256); + bytes[i++] = (byte)((UsecSinceStart >> 32) % 256); + bytes[i++] = (byte)((UsecSinceStart >> 40) % 256); + bytes[i++] = (byte)((UsecSinceStart >> 48) % 256); + bytes[i++] = (byte)((UsecSinceStart >> 56) % 256); + bytes[i++] = (byte)((Port >> 8) % 256); + bytes[i++] = (byte)(Port % 256); + bytes[i++] = (byte)(SecPerYear % 256); + bytes[i++] = (byte)((SecPerYear >> 8) % 256); + bytes[i++] = (byte)((SecPerYear >> 16) % 256); + bytes[i++] = (byte)((SecPerYear >> 24) % 256); + bytes[i++] = (byte)(GridsPerEdge % 256); + bytes[i++] = (byte)((GridsPerEdge >> 8) % 256); + bytes[i++] = (byte)((GridsPerEdge >> 16) % 256); + bytes[i++] = (byte)((GridsPerEdge >> 24) % 256); + bytes[i++] = (byte)(Handle % 256); + bytes[i++] = (byte)((Handle >> 8) % 256); + bytes[i++] = (byte)((Handle >> 16) % 256); + bytes[i++] = (byte)((Handle >> 24) % 256); + bytes[i++] = (byte)((Handle >> 32) % 256); + bytes[i++] = (byte)((Handle >> 40) % 256); + bytes[i++] = (byte)((Handle >> 48) % 256); + bytes[i++] = (byte)((Handle >> 56) % 256); + if(SunAngVelocity == null) { Console.WriteLine("Warning: SunAngVelocity is null, in " + this.GetType()); } + Array.Copy(SunAngVelocity.GetBytes(), 0, bytes, i, 12); i += 12; + if(SunDirection == null) { Console.WriteLine("Warning: SunDirection is null, in " + this.GetType()); } + Array.Copy(SunDirection.GetBytes(), 0, bytes, i, 12); i += 12; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- RegionInfo --\n"; - output += "IP: " + IP.ToString() + "\n"; - output += "SecPerDay: " + SecPerDay.ToString() + "\n"; - output += "MetersPerGrid: " + MetersPerGrid.ToString() + "\n"; - output += "UsecSinceStart: " + UsecSinceStart.ToString() + "\n"; - output += "Port: " + Port.ToString() + "\n"; - output += "SecPerYear: " + SecPerYear.ToString() + "\n"; - output += "GridsPerEdge: " + GridsPerEdge.ToString() + "\n"; - output += "Handle: " + Handle.ToString() + "\n"; - output += "SunAngVelocity: " + SunAngVelocity.ToString() + "\n"; - output += "SunDirection: " + SunDirection.ToString() + "\n"; + { + string output = "-- RegionInfo --\n"; + output += "IP: " + IP.ToString() + "\n"; + output += "SecPerDay: " + SecPerDay.ToString() + "\n"; + output += "MetersPerGrid: " + MetersPerGrid.ToString() + "\n"; + output += "UsecSinceStart: " + UsecSinceStart.ToString() + "\n"; + output += "Port: " + Port.ToString() + "\n"; + output += "SecPerYear: " + SecPerYear.ToString() + "\n"; + output += "GridsPerEdge: " + GridsPerEdge.ToString() + "\n"; + output += "Handle: " + Handle.ToString() + "\n"; + output += "SunAngVelocity: " + SunAngVelocity.ToString() + "\n"; + output += "SunDirection: " + SunDirection.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// NeighborBlock block + + /// NeighborBlock block public class NeighborBlockBlock - { - /// IP field - public uint IP; - /// PublicPort field - public ushort PublicPort; - private byte[] _name; - /// Name field + { + /// IP field + public uint IP; + /// PublicPort field + public ushort PublicPort; + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - /// Port field - public ushort Port; - /// SimAccess field - public byte SimAccess; - /// PublicIP field - public uint PublicIP; - - /// Length of this block serialized in bytes + } + /// Port field + public ushort Port; + /// SimAccess field + public byte SimAccess; + /// PublicIP field + public uint PublicIP; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 13; - if (Name != null) { length += 1 + Name.Length; } - return length; + { + int length = 13; + if (Name != null) { length += 1 + Name.Length; } + return length; } } - - /// Default constructor - public NeighborBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public NeighborBlockBlock() { } + /// Constructor for building the block from a byte array public NeighborBlockBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - IP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - PublicPort = (ushort)((bytes[i++] << 8) + bytes[i++]); - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; - Port = (ushort)((bytes[i++] << 8) + bytes[i++]); - SimAccess = (byte)bytes[i++]; - PublicIP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + IP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + PublicPort = (ushort)((bytes[i++] << 8) + bytes[i++]); + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; + Port = (ushort)((bytes[i++] << 8) + bytes[i++]); + SimAccess = (byte)bytes[i++]; + PublicIP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(IP % 256); - bytes[i++] = (byte)((IP >> 8) % 256); - bytes[i++] = (byte)((IP >> 16) % 256); - bytes[i++] = (byte)((IP >> 24) % 256); - bytes[i++] = (byte)((PublicPort >> 8) % 256); - bytes[i++] = (byte)(PublicPort % 256); - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; - bytes[i++] = (byte)((Port >> 8) % 256); - bytes[i++] = (byte)(Port % 256); - bytes[i++] = SimAccess; - bytes[i++] = (byte)(PublicIP % 256); - bytes[i++] = (byte)((PublicIP >> 8) % 256); - bytes[i++] = (byte)((PublicIP >> 16) % 256); - bytes[i++] = (byte)((PublicIP >> 24) % 256); + { + bytes[i++] = (byte)(IP % 256); + bytes[i++] = (byte)((IP >> 8) % 256); + bytes[i++] = (byte)((IP >> 16) % 256); + bytes[i++] = (byte)((IP >> 24) % 256); + bytes[i++] = (byte)((PublicPort >> 8) % 256); + bytes[i++] = (byte)(PublicPort % 256); + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + bytes[i++] = (byte)((Port >> 8) % 256); + bytes[i++] = (byte)(Port % 256); + bytes[i++] = SimAccess; + bytes[i++] = (byte)(PublicIP % 256); + bytes[i++] = (byte)((PublicIP >> 8) % 256); + bytes[i++] = (byte)((PublicIP >> 16) % 256); + bytes[i++] = (byte)((PublicIP >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- NeighborBlock --\n"; - output += "IP: " + IP.ToString() + "\n"; - output += "PublicPort: " + PublicPort.ToString() + "\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; - output += "Port: " + Port.ToString() + "\n"; - output += "SimAccess: " + SimAccess.ToString() + "\n"; - output += "PublicIP: " + PublicIP.ToString() + "\n"; + { + string output = "-- NeighborBlock --\n"; + output += "IP: " + IP.ToString() + "\n"; + output += "PublicPort: " + PublicPort.ToString() + "\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; + output += "Port: " + Port.ToString() + "\n"; + output += "SimAccess: " + SimAccess.ToString() + "\n"; + output += "PublicIP: " + PublicIP.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.SimulatorAssign - public override PacketType Type { get { return PacketType.SimulatorAssign; } } - /// RegionInfo block - public RegionInfoBlock RegionInfo; - /// NeighborBlock block - public NeighborBlockBlock[] NeighborBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.SimulatorAssign + public override PacketType Type { get { return PacketType.SimulatorAssign; } } + /// RegionInfo block + public RegionInfoBlock RegionInfo; + /// NeighborBlock block + public NeighborBlockBlock[] NeighborBlock; + + /// Default constructor public SimulatorAssignPacket() - { - Header = new LowHeader(); - Header.ID = 7; - Header.Reliable = true; - Header.Zerocoded = true; - RegionInfo = new RegionInfoBlock(); - NeighborBlock = new NeighborBlockBlock[4]; + { + Header = new LowHeader(); + Header.ID = 7; + Header.Reliable = true; + Header.Zerocoded = true; + RegionInfo = new RegionInfoBlock(); + NeighborBlock = new NeighborBlockBlock[4]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public SimulatorAssignPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - RegionInfo = new RegionInfoBlock(bytes, ref i); - NeighborBlock = new NeighborBlockBlock[4]; - for (int j = 0; j < 4; j++) - { NeighborBlock[j] = new NeighborBlockBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + RegionInfo = new RegionInfoBlock(bytes, ref i); + NeighborBlock = new NeighborBlockBlock[4]; + for (int j = 0; j < 4; j++) + { NeighborBlock[j] = new NeighborBlockBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public SimulatorAssignPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - RegionInfo = new RegionInfoBlock(bytes, ref i); - NeighborBlock = new NeighborBlockBlock[4]; - for (int j = 0; j < 4; j++) - { NeighborBlock[j] = new NeighborBlockBlock(bytes, ref i); } + { + Header = head; + RegionInfo = new RegionInfoBlock(bytes, ref i); + NeighborBlock = new NeighborBlockBlock[4]; + for (int j = 0; j < 4; j++) + { NeighborBlock[j] = new NeighborBlockBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += RegionInfo.Length;; - for (int j = 0; j < 4; j++) { length += NeighborBlock[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - RegionInfo.ToBytes(bytes, ref i); - for (int j = 0; j < 4; j++) { NeighborBlock[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += RegionInfo.Length;; + for (int j = 0; j < 4; j++) { length += NeighborBlock[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + RegionInfo.ToBytes(bytes, ref i); + for (int j = 0; j < 4; j++) { NeighborBlock[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- SimulatorAssign ---\n"; - output += RegionInfo.ToString() + "\n"; + { + string output = "--- SimulatorAssign ---\n"; + output += RegionInfo.ToString() + "\n"; for (int j = 0; j < 4; j++) - { + { output += NeighborBlock[j].ToString() + "\n"; - } + } return output; } - + } - - /// SpaceServerSimulatorTimeMessage packet + + /// SpaceServerSimulatorTimeMessage packet public class SpaceServerSimulatorTimeMessagePacket : Packet - { - /// TimeInfo block + { + /// TimeInfo block public class TimeInfoBlock - { - /// SecPerDay field - public uint SecPerDay; - /// UsecSinceStart field - public ulong UsecSinceStart; - /// SecPerYear field - public uint SecPerYear; - /// SunAngVelocity field - public LLVector3 SunAngVelocity; - /// SunPhase field - public float SunPhase; - /// SunDirection field - public LLVector3 SunDirection; - - /// Length of this block serialized in bytes + { + /// SecPerDay field + public uint SecPerDay; + /// UsecSinceStart field + public ulong UsecSinceStart; + /// SecPerYear field + public uint SecPerYear; + /// SunAngVelocity field + public LLVector3 SunAngVelocity; + /// SunPhase field + public float SunPhase; + /// SunDirection field + public LLVector3 SunDirection; + + /// Length of this block serialized in bytes public int Length { get - { - return 44; + { + return 44; } } - - /// Default constructor - public TimeInfoBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public TimeInfoBlock() { } + /// Constructor for building the block from a byte array public TimeInfoBlock(byte[] bytes, ref int i) - { + { try - { - SecPerDay = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - UsecSinceStart = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); - SecPerYear = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - SunAngVelocity = new LLVector3(bytes, i); i += 12; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - SunPhase = BitConverter.ToSingle(bytes, i); i += 4; - SunDirection = new LLVector3(bytes, i); i += 12; + { + SecPerDay = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + UsecSinceStart = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + SecPerYear = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + SunAngVelocity = new LLVector3(bytes, i); i += 12; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + SunPhase = BitConverter.ToSingle(bytes, i); i += 4; + SunDirection = new LLVector3(bytes, i); i += 12; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; - bytes[i++] = (byte)(SecPerDay % 256); - bytes[i++] = (byte)((SecPerDay >> 8) % 256); - bytes[i++] = (byte)((SecPerDay >> 16) % 256); - bytes[i++] = (byte)((SecPerDay >> 24) % 256); - bytes[i++] = (byte)(UsecSinceStart % 256); - bytes[i++] = (byte)((UsecSinceStart >> 8) % 256); - bytes[i++] = (byte)((UsecSinceStart >> 16) % 256); - bytes[i++] = (byte)((UsecSinceStart >> 24) % 256); - bytes[i++] = (byte)((UsecSinceStart >> 32) % 256); - bytes[i++] = (byte)((UsecSinceStart >> 40) % 256); - bytes[i++] = (byte)((UsecSinceStart >> 48) % 256); - bytes[i++] = (byte)((UsecSinceStart >> 56) % 256); - bytes[i++] = (byte)(SecPerYear % 256); - bytes[i++] = (byte)((SecPerYear >> 8) % 256); - bytes[i++] = (byte)((SecPerYear >> 16) % 256); - bytes[i++] = (byte)((SecPerYear >> 24) % 256); - if(SunAngVelocity == null) { Console.WriteLine("Warning: SunAngVelocity is null, in " + this.GetType()); } - Array.Copy(SunAngVelocity.GetBytes(), 0, bytes, i, 12); i += 12; + { + byte[] ba; + bytes[i++] = (byte)(SecPerDay % 256); + bytes[i++] = (byte)((SecPerDay >> 8) % 256); + bytes[i++] = (byte)((SecPerDay >> 16) % 256); + bytes[i++] = (byte)((SecPerDay >> 24) % 256); + bytes[i++] = (byte)(UsecSinceStart % 256); + bytes[i++] = (byte)((UsecSinceStart >> 8) % 256); + bytes[i++] = (byte)((UsecSinceStart >> 16) % 256); + bytes[i++] = (byte)((UsecSinceStart >> 24) % 256); + bytes[i++] = (byte)((UsecSinceStart >> 32) % 256); + bytes[i++] = (byte)((UsecSinceStart >> 40) % 256); + bytes[i++] = (byte)((UsecSinceStart >> 48) % 256); + bytes[i++] = (byte)((UsecSinceStart >> 56) % 256); + bytes[i++] = (byte)(SecPerYear % 256); + bytes[i++] = (byte)((SecPerYear >> 8) % 256); + bytes[i++] = (byte)((SecPerYear >> 16) % 256); + bytes[i++] = (byte)((SecPerYear >> 24) % 256); + if(SunAngVelocity == null) { Console.WriteLine("Warning: SunAngVelocity is null, in " + this.GetType()); } + Array.Copy(SunAngVelocity.GetBytes(), 0, bytes, i, 12); i += 12; ba = BitConverter.GetBytes(SunPhase); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - if(SunDirection == null) { Console.WriteLine("Warning: SunDirection is null, in " + this.GetType()); } - Array.Copy(SunDirection.GetBytes(), 0, bytes, i, 12); i += 12; + Array.Copy(ba, 0, bytes, i, 4); i += 4; + if(SunDirection == null) { Console.WriteLine("Warning: SunDirection is null, in " + this.GetType()); } + Array.Copy(SunDirection.GetBytes(), 0, bytes, i, 12); i += 12; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- TimeInfo --\n"; - output += "SecPerDay: " + SecPerDay.ToString() + "\n"; - output += "UsecSinceStart: " + UsecSinceStart.ToString() + "\n"; - output += "SecPerYear: " + SecPerYear.ToString() + "\n"; - output += "SunAngVelocity: " + SunAngVelocity.ToString() + "\n"; - output += "SunPhase: " + SunPhase.ToString() + "\n"; - output += "SunDirection: " + SunDirection.ToString() + "\n"; + { + string output = "-- TimeInfo --\n"; + output += "SecPerDay: " + SecPerDay.ToString() + "\n"; + output += "UsecSinceStart: " + UsecSinceStart.ToString() + "\n"; + output += "SecPerYear: " + SecPerYear.ToString() + "\n"; + output += "SunAngVelocity: " + SunAngVelocity.ToString() + "\n"; + output += "SunPhase: " + SunPhase.ToString() + "\n"; + output += "SunDirection: " + SunDirection.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.SpaceServerSimulatorTimeMessage - public override PacketType Type { get { return PacketType.SpaceServerSimulatorTimeMessage; } } - /// TimeInfo block - public TimeInfoBlock TimeInfo; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.SpaceServerSimulatorTimeMessage + public override PacketType Type { get { return PacketType.SpaceServerSimulatorTimeMessage; } } + /// TimeInfo block + public TimeInfoBlock TimeInfo; + + /// Default constructor public SpaceServerSimulatorTimeMessagePacket() - { - Header = new LowHeader(); - Header.ID = 8; - Header.Reliable = true; - TimeInfo = new TimeInfoBlock(); + { + Header = new LowHeader(); + Header.ID = 8; + Header.Reliable = true; + TimeInfo = new TimeInfoBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public SpaceServerSimulatorTimeMessagePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - TimeInfo = new TimeInfoBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + TimeInfo = new TimeInfoBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public SpaceServerSimulatorTimeMessagePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - TimeInfo = new TimeInfoBlock(bytes, ref i); + { + Header = head; + TimeInfo = new TimeInfoBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += TimeInfo.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - TimeInfo.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += TimeInfo.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + TimeInfo.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- SpaceServerSimulatorTimeMessage ---\n"; - output += TimeInfo.ToString() + "\n"; + { + string output = "--- SpaceServerSimulatorTimeMessage ---\n"; + output += TimeInfo.ToString() + "\n"; return output; } - + } - - /// AvatarTextureUpdate packet + + /// AvatarTextureUpdate packet public class AvatarTextureUpdatePacket : Packet - { - /// WearableData block + { + /// WearableData block public class WearableDataBlock - { - /// TextureIndex field - public byte TextureIndex; - private byte[] _hostname; - /// HostName field + { + /// TextureIndex field + public byte TextureIndex; + private byte[] _hostname; + /// HostName field public byte[] HostName - { - get { return _hostname; } + { + get { return _hostname; } set - { - if (value == null) { _hostname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _hostname = new byte[value.Length]; Array.Copy(value, _hostname, value.Length); } + { + if (value == null) { _hostname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _hostname = new byte[value.Length]; Array.Copy(value, _hostname, value.Length); } } - } - /// CacheID field - public LLUUID CacheID; - - /// Length of this block serialized in bytes + } + /// CacheID field + public LLUUID CacheID; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 17; - if (HostName != null) { length += 1 + HostName.Length; } - return length; + { + int length = 17; + if (HostName != null) { length += 1 + HostName.Length; } + return length; } } - - /// Default constructor - public WearableDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public WearableDataBlock() { } + /// Constructor for building the block from a byte array public WearableDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - TextureIndex = (byte)bytes[i++]; - length = (ushort)bytes[i++]; - _hostname = new byte[length]; - Array.Copy(bytes, i, _hostname, 0, length); i += length; - CacheID = new LLUUID(bytes, i); i += 16; + { + TextureIndex = (byte)bytes[i++]; + length = (ushort)bytes[i++]; + _hostname = new byte[length]; + Array.Copy(bytes, i, _hostname, 0, length); i += length; + CacheID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = TextureIndex; - if(HostName == null) { Console.WriteLine("Warning: HostName is null, in " + this.GetType()); } - bytes[i++] = (byte)HostName.Length; - Array.Copy(HostName, 0, bytes, i, HostName.Length); i += HostName.Length; - if(CacheID == null) { Console.WriteLine("Warning: CacheID is null, in " + this.GetType()); } - Array.Copy(CacheID.GetBytes(), 0, bytes, i, 16); i += 16; + { + bytes[i++] = TextureIndex; + if(HostName == null) { Console.WriteLine("Warning: HostName is null, in " + this.GetType()); } + bytes[i++] = (byte)HostName.Length; + Array.Copy(HostName, 0, bytes, i, HostName.Length); i += HostName.Length; + if(CacheID == null) { Console.WriteLine("Warning: CacheID is null, in " + this.GetType()); } + Array.Copy(CacheID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- WearableData --\n"; - output += "TextureIndex: " + TextureIndex.ToString() + "\n"; - output += Helpers.FieldToString(HostName, "HostName") + "\n"; - output += "CacheID: " + CacheID.ToString() + "\n"; + { + string output = "-- WearableData --\n"; + output += "TextureIndex: " + TextureIndex.ToString() + "\n"; + output += Helpers.FieldToString(HostName, "HostName") + "\n"; + output += "CacheID: " + CacheID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// TextureData block + + /// TextureData block public class TextureDataBlock - { - /// TextureID field - public LLUUID TextureID; - - /// Length of this block serialized in bytes + { + /// TextureID field + public LLUUID TextureID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public TextureDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public TextureDataBlock() { } + /// Constructor for building the block from a byte array public TextureDataBlock(byte[] bytes, ref int i) - { + { try - { - TextureID = new LLUUID(bytes, i); i += 16; + { + TextureID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(TextureID == null) { Console.WriteLine("Warning: TextureID is null, in " + this.GetType()); } - Array.Copy(TextureID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(TextureID == null) { Console.WriteLine("Warning: TextureID is null, in " + this.GetType()); } + Array.Copy(TextureID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- TextureData --\n"; - output += "TextureID: " + TextureID.ToString() + "\n"; + { + string output = "-- TextureData --\n"; + output += "TextureID: " + TextureID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// TexturesChanged field - public bool TexturesChanged; - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// TexturesChanged field + public bool TexturesChanged; + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 17; + { + return 17; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - TexturesChanged = (bytes[i++] != 0) ? (bool)true : (bool)false; - AgentID = new LLUUID(bytes, i); i += 16; + { + TexturesChanged = (bytes[i++] != 0) ? (bool)true : (bool)false; + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)((TexturesChanged) ? 1 : 0); - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + bytes[i++] = (byte)((TexturesChanged) ? 1 : 0); + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "TexturesChanged: " + TexturesChanged.ToString() + "\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "TexturesChanged: " + TexturesChanged.ToString() + "\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AvatarTextureUpdate - public override PacketType Type { get { return PacketType.AvatarTextureUpdate; } } - /// WearableData block - public WearableDataBlock[] WearableData; - /// TextureData block - public TextureDataBlock[] TextureData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AvatarTextureUpdate + public override PacketType Type { get { return PacketType.AvatarTextureUpdate; } } + /// WearableData block + public WearableDataBlock[] WearableData; + /// TextureData block + public TextureDataBlock[] TextureData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public AvatarTextureUpdatePacket() - { - Header = new LowHeader(); - Header.ID = 9; - Header.Reliable = true; - Header.Zerocoded = true; - WearableData = new WearableDataBlock[0]; - TextureData = new TextureDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 9; + Header.Reliable = true; + Header.Zerocoded = true; + WearableData = new WearableDataBlock[0]; + TextureData = new TextureDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AvatarTextureUpdatePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - WearableData = new WearableDataBlock[count]; - for (int j = 0; j < count; j++) - { WearableData[j] = new WearableDataBlock(bytes, ref i); } - count = (int)bytes[i++]; - TextureData = new TextureDataBlock[count]; - for (int j = 0; j < count; j++) - { TextureData[j] = new TextureDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + WearableData = new WearableDataBlock[count]; + for (int j = 0; j < count; j++) + { WearableData[j] = new WearableDataBlock(bytes, ref i); } + count = (int)bytes[i++]; + TextureData = new TextureDataBlock[count]; + for (int j = 0; j < count; j++) + { TextureData[j] = new TextureDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AvatarTextureUpdatePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - WearableData = new WearableDataBlock[count]; - for (int j = 0; j < count; j++) - { WearableData[j] = new WearableDataBlock(bytes, ref i); } - count = (int)bytes[i++]; - TextureData = new TextureDataBlock[count]; - for (int j = 0; j < count; j++) - { TextureData[j] = new TextureDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + WearableData = new WearableDataBlock[count]; + for (int j = 0; j < count; j++) + { WearableData[j] = new WearableDataBlock(bytes, ref i); } + count = (int)bytes[i++]; + TextureData = new TextureDataBlock[count]; + for (int j = 0; j < count; j++) + { TextureData[j] = new TextureDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < WearableData.Length; j++) { length += WearableData[j].Length; } - length++; - for (int j = 0; j < TextureData.Length; j++) { length += TextureData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)WearableData.Length; - for (int j = 0; j < WearableData.Length; j++) { WearableData[j].ToBytes(bytes, ref i); } - bytes[i++] = (byte)TextureData.Length; - for (int j = 0; j < TextureData.Length; j++) { TextureData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < WearableData.Length; j++) { length += WearableData[j].Length; } + length++; + for (int j = 0; j < TextureData.Length; j++) { length += TextureData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)WearableData.Length; + for (int j = 0; j < WearableData.Length; j++) { WearableData[j].ToBytes(bytes, ref i); } + bytes[i++] = (byte)TextureData.Length; + for (int j = 0; j < TextureData.Length; j++) { TextureData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AvatarTextureUpdate ---\n"; + { + string output = "--- AvatarTextureUpdate ---\n"; for (int j = 0; j < WearableData.Length; j++) - { + { output += WearableData[j].ToString() + "\n"; - } + } for (int j = 0; j < TextureData.Length; j++) - { + { output += TextureData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// SimulatorMapUpdate packet + + /// SimulatorMapUpdate packet public class SimulatorMapUpdatePacket : Packet - { - /// MapData block + { + /// MapData block public class MapDataBlock - { - /// Flags field - public uint Flags; - - /// Length of this block serialized in bytes + { + /// Flags field + public uint Flags; + + /// Length of this block serialized in bytes public int Length { get - { - return 4; + { + return 4; } } - - /// Default constructor - public MapDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public MapDataBlock() { } + /// Constructor for building the block from a byte array public MapDataBlock(byte[] bytes, ref int i) - { + { try - { - Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(Flags % 256); - bytes[i++] = (byte)((Flags >> 8) % 256); - bytes[i++] = (byte)((Flags >> 16) % 256); - bytes[i++] = (byte)((Flags >> 24) % 256); + { + bytes[i++] = (byte)(Flags % 256); + bytes[i++] = (byte)((Flags >> 8) % 256); + bytes[i++] = (byte)((Flags >> 16) % 256); + bytes[i++] = (byte)((Flags >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- MapData --\n"; - output += "Flags: " + Flags.ToString() + "\n"; + { + string output = "-- MapData --\n"; + output += "Flags: " + Flags.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.SimulatorMapUpdate - public override PacketType Type { get { return PacketType.SimulatorMapUpdate; } } - /// MapData block - public MapDataBlock MapData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.SimulatorMapUpdate + public override PacketType Type { get { return PacketType.SimulatorMapUpdate; } } + /// MapData block + public MapDataBlock MapData; + + /// Default constructor public SimulatorMapUpdatePacket() - { - Header = new LowHeader(); - Header.ID = 10; - Header.Reliable = true; - MapData = new MapDataBlock(); + { + Header = new LowHeader(); + Header.ID = 10; + Header.Reliable = true; + MapData = new MapDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public SimulatorMapUpdatePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - MapData = new MapDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + MapData = new MapDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public SimulatorMapUpdatePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - MapData = new MapDataBlock(bytes, ref i); + { + Header = head; + MapData = new MapDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += MapData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - MapData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += MapData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + MapData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- SimulatorMapUpdate ---\n"; - output += MapData.ToString() + "\n"; + { + string output = "--- SimulatorMapUpdate ---\n"; + output += MapData.ToString() + "\n"; return output; } - + } - - /// SimulatorSetMap packet + + /// SimulatorSetMap packet public class SimulatorSetMapPacket : Packet - { - /// MapData block + { + /// MapData block public class MapDataBlock - { - /// MapImage field - public LLUUID MapImage; - /// Type field - public int Type; - /// RegionHandle field - public ulong RegionHandle; - - /// Length of this block serialized in bytes + { + /// MapImage field + public LLUUID MapImage; + /// Type field + public int Type; + /// RegionHandle field + public ulong RegionHandle; + + /// Length of this block serialized in bytes public int Length { get - { - return 28; + { + return 28; } } - - /// Default constructor - public MapDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public MapDataBlock() { } + /// Constructor for building the block from a byte array public MapDataBlock(byte[] bytes, ref int i) - { + { try - { - MapImage = new LLUUID(bytes, i); i += 16; - Type = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + { + MapImage = new LLUUID(bytes, i); i += 16; + Type = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(MapImage == null) { Console.WriteLine("Warning: MapImage is null, in " + this.GetType()); } - Array.Copy(MapImage.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(Type % 256); - bytes[i++] = (byte)((Type >> 8) % 256); - bytes[i++] = (byte)((Type >> 16) % 256); - bytes[i++] = (byte)((Type >> 24) % 256); - bytes[i++] = (byte)(RegionHandle % 256); - bytes[i++] = (byte)((RegionHandle >> 8) % 256); - bytes[i++] = (byte)((RegionHandle >> 16) % 256); - bytes[i++] = (byte)((RegionHandle >> 24) % 256); - bytes[i++] = (byte)((RegionHandle >> 32) % 256); - bytes[i++] = (byte)((RegionHandle >> 40) % 256); - bytes[i++] = (byte)((RegionHandle >> 48) % 256); - bytes[i++] = (byte)((RegionHandle >> 56) % 256); + { + if(MapImage == null) { Console.WriteLine("Warning: MapImage is null, in " + this.GetType()); } + Array.Copy(MapImage.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(Type % 256); + bytes[i++] = (byte)((Type >> 8) % 256); + bytes[i++] = (byte)((Type >> 16) % 256); + bytes[i++] = (byte)((Type >> 24) % 256); + bytes[i++] = (byte)(RegionHandle % 256); + bytes[i++] = (byte)((RegionHandle >> 8) % 256); + bytes[i++] = (byte)((RegionHandle >> 16) % 256); + bytes[i++] = (byte)((RegionHandle >> 24) % 256); + bytes[i++] = (byte)((RegionHandle >> 32) % 256); + bytes[i++] = (byte)((RegionHandle >> 40) % 256); + bytes[i++] = (byte)((RegionHandle >> 48) % 256); + bytes[i++] = (byte)((RegionHandle >> 56) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- MapData --\n"; - output += "MapImage: " + MapImage.ToString() + "\n"; - output += "Type: " + Type.ToString() + "\n"; - output += "RegionHandle: " + RegionHandle.ToString() + "\n"; + { + string output = "-- MapData --\n"; + output += "MapImage: " + MapImage.ToString() + "\n"; + output += "Type: " + Type.ToString() + "\n"; + output += "RegionHandle: " + RegionHandle.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.SimulatorSetMap - public override PacketType Type { get { return PacketType.SimulatorSetMap; } } - /// MapData block - public MapDataBlock MapData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.SimulatorSetMap + public override PacketType Type { get { return PacketType.SimulatorSetMap; } } + /// MapData block + public MapDataBlock MapData; + + /// Default constructor public SimulatorSetMapPacket() - { - Header = new LowHeader(); - Header.ID = 11; - Header.Reliable = true; - MapData = new MapDataBlock(); + { + Header = new LowHeader(); + Header.ID = 11; + Header.Reliable = true; + MapData = new MapDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public SimulatorSetMapPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - MapData = new MapDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + MapData = new MapDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public SimulatorSetMapPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - MapData = new MapDataBlock(bytes, ref i); + { + Header = head; + MapData = new MapDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += MapData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - MapData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += MapData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + MapData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- SimulatorSetMap ---\n"; - output += MapData.ToString() + "\n"; + { + string output = "--- SimulatorSetMap ---\n"; + output += MapData.ToString() + "\n"; return output; } - + } - - /// SubscribeLoad packet + + /// SubscribeLoad packet public class SubscribeLoadPacket : Packet - { - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.SubscribeLoad - public override PacketType Type { get { return PacketType.SubscribeLoad; } } - - /// Default constructor + { + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.SubscribeLoad + public override PacketType Type { get { return PacketType.SubscribeLoad; } } + + /// Default constructor public SubscribeLoadPacket() - { - Header = new LowHeader(); - Header.ID = 12; - Header.Reliable = true; + { + Header = new LowHeader(); + Header.ID = 12; + Header.Reliable = true; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public SubscribeLoadPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public SubscribeLoadPacket(Header head, byte[] bytes, ref int i) - { - Header = head; + { + Header = head; } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; -; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; +; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- SubscribeLoad ---\n"; + { + string output = "--- SubscribeLoad ---\n"; return output; } - + } - - /// UnsubscribeLoad packet + + /// UnsubscribeLoad packet public class UnsubscribeLoadPacket : Packet - { - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.UnsubscribeLoad - public override PacketType Type { get { return PacketType.UnsubscribeLoad; } } - - /// Default constructor + { + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.UnsubscribeLoad + public override PacketType Type { get { return PacketType.UnsubscribeLoad; } } + + /// Default constructor public UnsubscribeLoadPacket() - { - Header = new LowHeader(); - Header.ID = 13; - Header.Reliable = true; + { + Header = new LowHeader(); + Header.ID = 13; + Header.Reliable = true; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public UnsubscribeLoadPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public UnsubscribeLoadPacket(Header head, byte[] bytes, ref int i) - { - Header = head; + { + Header = head; } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; -; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; +; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- UnsubscribeLoad ---\n"; + { + string output = "--- UnsubscribeLoad ---\n"; return output; } - + } - - /// SimulatorStart packet + + /// SimulatorStart packet public class SimulatorStartPacket : Packet - { - /// PositionSuggestion block + { + /// PositionSuggestion block public class PositionSuggestionBlock - { - /// Ignore field - public bool Ignore; - /// GridX field - public int GridX; - /// GridY field - public int GridY; - - /// Length of this block serialized in bytes + { + /// Ignore field + public bool Ignore; + /// GridX field + public int GridX; + /// GridY field + public int GridY; + + /// Length of this block serialized in bytes public int Length { get - { - return 9; + { + return 9; } } - - /// Default constructor - public PositionSuggestionBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public PositionSuggestionBlock() { } + /// Constructor for building the block from a byte array public PositionSuggestionBlock(byte[] bytes, ref int i) - { + { try - { - Ignore = (bytes[i++] != 0) ? (bool)true : (bool)false; - GridX = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - GridY = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + Ignore = (bytes[i++] != 0) ? (bool)true : (bool)false; + GridX = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + GridY = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)((Ignore) ? 1 : 0); - bytes[i++] = (byte)(GridX % 256); - bytes[i++] = (byte)((GridX >> 8) % 256); - bytes[i++] = (byte)((GridX >> 16) % 256); - bytes[i++] = (byte)((GridX >> 24) % 256); - bytes[i++] = (byte)(GridY % 256); - bytes[i++] = (byte)((GridY >> 8) % 256); - bytes[i++] = (byte)((GridY >> 16) % 256); - bytes[i++] = (byte)((GridY >> 24) % 256); + { + bytes[i++] = (byte)((Ignore) ? 1 : 0); + bytes[i++] = (byte)(GridX % 256); + bytes[i++] = (byte)((GridX >> 8) % 256); + bytes[i++] = (byte)((GridX >> 16) % 256); + bytes[i++] = (byte)((GridX >> 24) % 256); + bytes[i++] = (byte)(GridY % 256); + bytes[i++] = (byte)((GridY >> 8) % 256); + bytes[i++] = (byte)((GridY >> 16) % 256); + bytes[i++] = (byte)((GridY >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- PositionSuggestion --\n"; - output += "Ignore: " + Ignore.ToString() + "\n"; - output += "GridX: " + GridX.ToString() + "\n"; - output += "GridY: " + GridY.ToString() + "\n"; + { + string output = "-- PositionSuggestion --\n"; + output += "Ignore: " + Ignore.ToString() + "\n"; + output += "GridX: " + GridX.ToString() + "\n"; + output += "GridY: " + GridY.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// ControlPort block + + /// ControlPort block public class ControlPortBlock - { - /// PublicPort field - public ushort PublicPort; - /// Port field - public ushort Port; - /// PublicIP field - public uint PublicIP; - - /// Length of this block serialized in bytes + { + /// PublicPort field + public ushort PublicPort; + /// Port field + public ushort Port; + /// PublicIP field + public uint PublicIP; + + /// Length of this block serialized in bytes public int Length { get - { - return 8; + { + return 8; } } - - /// Default constructor - public ControlPortBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ControlPortBlock() { } + /// Constructor for building the block from a byte array public ControlPortBlock(byte[] bytes, ref int i) - { + { try - { - PublicPort = (ushort)((bytes[i++] << 8) + bytes[i++]); - Port = (ushort)((bytes[i++] << 8) + bytes[i++]); - PublicIP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + PublicPort = (ushort)((bytes[i++] << 8) + bytes[i++]); + Port = (ushort)((bytes[i++] << 8) + bytes[i++]); + PublicIP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)((PublicPort >> 8) % 256); - bytes[i++] = (byte)(PublicPort % 256); - bytes[i++] = (byte)((Port >> 8) % 256); - bytes[i++] = (byte)(Port % 256); - bytes[i++] = (byte)(PublicIP % 256); - bytes[i++] = (byte)((PublicIP >> 8) % 256); - bytes[i++] = (byte)((PublicIP >> 16) % 256); - bytes[i++] = (byte)((PublicIP >> 24) % 256); + { + bytes[i++] = (byte)((PublicPort >> 8) % 256); + bytes[i++] = (byte)(PublicPort % 256); + bytes[i++] = (byte)((Port >> 8) % 256); + bytes[i++] = (byte)(Port % 256); + bytes[i++] = (byte)(PublicIP % 256); + bytes[i++] = (byte)((PublicIP >> 8) % 256); + bytes[i++] = (byte)((PublicIP >> 16) % 256); + bytes[i++] = (byte)((PublicIP >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ControlPort --\n"; - output += "PublicPort: " + PublicPort.ToString() + "\n"; - output += "Port: " + Port.ToString() + "\n"; - output += "PublicIP: " + PublicIP.ToString() + "\n"; + { + string output = "-- ControlPort --\n"; + output += "PublicPort: " + PublicPort.ToString() + "\n"; + output += "Port: " + Port.ToString() + "\n"; + output += "PublicIP: " + PublicIP.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.SimulatorStart - public override PacketType Type { get { return PacketType.SimulatorStart; } } - /// PositionSuggestion block - public PositionSuggestionBlock PositionSuggestion; - /// ControlPort block - public ControlPortBlock ControlPort; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.SimulatorStart + public override PacketType Type { get { return PacketType.SimulatorStart; } } + /// PositionSuggestion block + public PositionSuggestionBlock PositionSuggestion; + /// ControlPort block + public ControlPortBlock ControlPort; + + /// Default constructor public SimulatorStartPacket() - { - Header = new LowHeader(); - Header.ID = 14; - Header.Reliable = true; - PositionSuggestion = new PositionSuggestionBlock(); - ControlPort = new ControlPortBlock(); + { + Header = new LowHeader(); + Header.ID = 14; + Header.Reliable = true; + PositionSuggestion = new PositionSuggestionBlock(); + ControlPort = new ControlPortBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public SimulatorStartPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - PositionSuggestion = new PositionSuggestionBlock(bytes, ref i); - ControlPort = new ControlPortBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + PositionSuggestion = new PositionSuggestionBlock(bytes, ref i); + ControlPort = new ControlPortBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public SimulatorStartPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - PositionSuggestion = new PositionSuggestionBlock(bytes, ref i); - ControlPort = new ControlPortBlock(bytes, ref i); + { + Header = head; + PositionSuggestion = new PositionSuggestionBlock(bytes, ref i); + ControlPort = new ControlPortBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += PositionSuggestion.Length; length += ControlPort.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - PositionSuggestion.ToBytes(bytes, ref i); - ControlPort.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += PositionSuggestion.Length; length += ControlPort.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + PositionSuggestion.ToBytes(bytes, ref i); + ControlPort.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- SimulatorStart ---\n"; - output += PositionSuggestion.ToString() + "\n"; - output += ControlPort.ToString() + "\n"; + { + string output = "--- SimulatorStart ---\n"; + output += PositionSuggestion.ToString() + "\n"; + output += ControlPort.ToString() + "\n"; return output; } - + } - - /// SimulatorReady packet + + /// SimulatorReady packet public class SimulatorReadyPacket : Packet - { - /// TelehubBlock block + { + /// TelehubBlock block public class TelehubBlockBlock - { - /// HasTelehub field - public bool HasTelehub; - /// TelehubPos field - public LLVector3 TelehubPos; - - /// Length of this block serialized in bytes + { + /// HasTelehub field + public bool HasTelehub; + /// TelehubPos field + public LLVector3 TelehubPos; + + /// Length of this block serialized in bytes public int Length { get - { - return 13; + { + return 13; } } - - /// Default constructor - public TelehubBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public TelehubBlockBlock() { } + /// Constructor for building the block from a byte array public TelehubBlockBlock(byte[] bytes, ref int i) - { + { try - { - HasTelehub = (bytes[i++] != 0) ? (bool)true : (bool)false; - TelehubPos = new LLVector3(bytes, i); i += 12; + { + HasTelehub = (bytes[i++] != 0) ? (bool)true : (bool)false; + TelehubPos = new LLVector3(bytes, i); i += 12; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)((HasTelehub) ? 1 : 0); - if(TelehubPos == null) { Console.WriteLine("Warning: TelehubPos is null, in " + this.GetType()); } - Array.Copy(TelehubPos.GetBytes(), 0, bytes, i, 12); i += 12; + { + bytes[i++] = (byte)((HasTelehub) ? 1 : 0); + if(TelehubPos == null) { Console.WriteLine("Warning: TelehubPos is null, in " + this.GetType()); } + Array.Copy(TelehubPos.GetBytes(), 0, bytes, i, 12); i += 12; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- TelehubBlock --\n"; - output += "HasTelehub: " + HasTelehub.ToString() + "\n"; - output += "TelehubPos: " + TelehubPos.ToString() + "\n"; + { + string output = "-- TelehubBlock --\n"; + output += "HasTelehub: " + HasTelehub.ToString() + "\n"; + output += "TelehubPos: " + TelehubPos.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// SimulatorBlock block + + /// SimulatorBlock block public class SimulatorBlockBlock - { - private byte[] _simname; - /// SimName field + { + private byte[] _simname; + /// SimName field public byte[] SimName - { - get { return _simname; } + { + get { return _simname; } set - { - if (value == null) { _simname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _simname = new byte[value.Length]; Array.Copy(value, _simname, value.Length); } + { + if (value == null) { _simname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _simname = new byte[value.Length]; Array.Copy(value, _simname, value.Length); } } - } - /// RegionFlags field - public uint RegionFlags; - /// RegionID field - public LLUUID RegionID; - /// SimAccess field - public byte SimAccess; - /// ParentEstateID field - public uint ParentEstateID; - /// EstateID field - public uint EstateID; - - /// Length of this block serialized in bytes + } + /// RegionFlags field + public uint RegionFlags; + /// RegionID field + public LLUUID RegionID; + /// SimAccess field + public byte SimAccess; + /// ParentEstateID field + public uint ParentEstateID; + /// EstateID field + public uint EstateID; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 29; - if (SimName != null) { length += 1 + SimName.Length; } - return length; + { + int length = 29; + if (SimName != null) { length += 1 + SimName.Length; } + return length; } } - - /// Default constructor - public SimulatorBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public SimulatorBlockBlock() { } + /// Constructor for building the block from a byte array public SimulatorBlockBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _simname = new byte[length]; - Array.Copy(bytes, i, _simname, 0, length); i += length; - RegionFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - RegionID = new LLUUID(bytes, i); i += 16; - SimAccess = (byte)bytes[i++]; - ParentEstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - EstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + length = (ushort)bytes[i++]; + _simname = new byte[length]; + Array.Copy(bytes, i, _simname, 0, length); i += length; + RegionFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + RegionID = new LLUUID(bytes, i); i += 16; + SimAccess = (byte)bytes[i++]; + ParentEstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + EstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(SimName == null) { Console.WriteLine("Warning: SimName is null, in " + this.GetType()); } - bytes[i++] = (byte)SimName.Length; - Array.Copy(SimName, 0, bytes, i, SimName.Length); i += SimName.Length; - bytes[i++] = (byte)(RegionFlags % 256); - bytes[i++] = (byte)((RegionFlags >> 8) % 256); - bytes[i++] = (byte)((RegionFlags >> 16) % 256); - bytes[i++] = (byte)((RegionFlags >> 24) % 256); - if(RegionID == null) { Console.WriteLine("Warning: RegionID is null, in " + this.GetType()); } - Array.Copy(RegionID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = SimAccess; - bytes[i++] = (byte)(ParentEstateID % 256); - bytes[i++] = (byte)((ParentEstateID >> 8) % 256); - bytes[i++] = (byte)((ParentEstateID >> 16) % 256); - bytes[i++] = (byte)((ParentEstateID >> 24) % 256); - bytes[i++] = (byte)(EstateID % 256); - bytes[i++] = (byte)((EstateID >> 8) % 256); - bytes[i++] = (byte)((EstateID >> 16) % 256); - bytes[i++] = (byte)((EstateID >> 24) % 256); + { + if(SimName == null) { Console.WriteLine("Warning: SimName is null, in " + this.GetType()); } + bytes[i++] = (byte)SimName.Length; + Array.Copy(SimName, 0, bytes, i, SimName.Length); i += SimName.Length; + bytes[i++] = (byte)(RegionFlags % 256); + bytes[i++] = (byte)((RegionFlags >> 8) % 256); + bytes[i++] = (byte)((RegionFlags >> 16) % 256); + bytes[i++] = (byte)((RegionFlags >> 24) % 256); + if(RegionID == null) { Console.WriteLine("Warning: RegionID is null, in " + this.GetType()); } + Array.Copy(RegionID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = SimAccess; + bytes[i++] = (byte)(ParentEstateID % 256); + bytes[i++] = (byte)((ParentEstateID >> 8) % 256); + bytes[i++] = (byte)((ParentEstateID >> 16) % 256); + bytes[i++] = (byte)((ParentEstateID >> 24) % 256); + bytes[i++] = (byte)(EstateID % 256); + bytes[i++] = (byte)((EstateID >> 8) % 256); + bytes[i++] = (byte)((EstateID >> 16) % 256); + bytes[i++] = (byte)((EstateID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- SimulatorBlock --\n"; - output += Helpers.FieldToString(SimName, "SimName") + "\n"; - output += "RegionFlags: " + RegionFlags.ToString() + "\n"; - output += "RegionID: " + RegionID.ToString() + "\n"; - output += "SimAccess: " + SimAccess.ToString() + "\n"; - output += "ParentEstateID: " + ParentEstateID.ToString() + "\n"; - output += "EstateID: " + EstateID.ToString() + "\n"; + { + string output = "-- SimulatorBlock --\n"; + output += Helpers.FieldToString(SimName, "SimName") + "\n"; + output += "RegionFlags: " + RegionFlags.ToString() + "\n"; + output += "RegionID: " + RegionID.ToString() + "\n"; + output += "SimAccess: " + SimAccess.ToString() + "\n"; + output += "ParentEstateID: " + ParentEstateID.ToString() + "\n"; + output += "EstateID: " + EstateID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.SimulatorReady - public override PacketType Type { get { return PacketType.SimulatorReady; } } - /// TelehubBlock block - public TelehubBlockBlock TelehubBlock; - /// SimulatorBlock block - public SimulatorBlockBlock SimulatorBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.SimulatorReady + public override PacketType Type { get { return PacketType.SimulatorReady; } } + /// TelehubBlock block + public TelehubBlockBlock TelehubBlock; + /// SimulatorBlock block + public SimulatorBlockBlock SimulatorBlock; + + /// Default constructor public SimulatorReadyPacket() - { - Header = new LowHeader(); - Header.ID = 15; - Header.Reliable = true; - Header.Zerocoded = true; - TelehubBlock = new TelehubBlockBlock(); - SimulatorBlock = new SimulatorBlockBlock(); + { + Header = new LowHeader(); + Header.ID = 15; + Header.Reliable = true; + Header.Zerocoded = true; + TelehubBlock = new TelehubBlockBlock(); + SimulatorBlock = new SimulatorBlockBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public SimulatorReadyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - TelehubBlock = new TelehubBlockBlock(bytes, ref i); - SimulatorBlock = new SimulatorBlockBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + TelehubBlock = new TelehubBlockBlock(bytes, ref i); + SimulatorBlock = new SimulatorBlockBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public SimulatorReadyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - TelehubBlock = new TelehubBlockBlock(bytes, ref i); - SimulatorBlock = new SimulatorBlockBlock(bytes, ref i); + { + Header = head; + TelehubBlock = new TelehubBlockBlock(bytes, ref i); + SimulatorBlock = new SimulatorBlockBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += TelehubBlock.Length; length += SimulatorBlock.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - TelehubBlock.ToBytes(bytes, ref i); - SimulatorBlock.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += TelehubBlock.Length; length += SimulatorBlock.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + TelehubBlock.ToBytes(bytes, ref i); + SimulatorBlock.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- SimulatorReady ---\n"; - output += TelehubBlock.ToString() + "\n"; - output += SimulatorBlock.ToString() + "\n"; + { + string output = "--- SimulatorReady ---\n"; + output += TelehubBlock.ToString() + "\n"; + output += SimulatorBlock.ToString() + "\n"; return output; } - + } - - /// TelehubInfo packet + + /// TelehubInfo packet public class TelehubInfoPacket : Packet - { - /// TelehubBlock block + { + /// TelehubBlock block public class TelehubBlockBlock - { - private byte[] _objectname; - /// ObjectName field + { + private byte[] _objectname; + /// ObjectName field public byte[] ObjectName - { - get { return _objectname; } + { + get { return _objectname; } set - { - if (value == null) { _objectname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _objectname = new byte[value.Length]; Array.Copy(value, _objectname, value.Length); } + { + if (value == null) { _objectname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _objectname = new byte[value.Length]; Array.Copy(value, _objectname, value.Length); } } - } - /// ObjectID field - public LLUUID ObjectID; - /// TelehubPos field - public LLVector3 TelehubPos; - /// TelehubRot field - public LLQuaternion TelehubRot; - - /// Length of this block serialized in bytes + } + /// ObjectID field + public LLUUID ObjectID; + /// TelehubPos field + public LLVector3 TelehubPos; + /// TelehubRot field + public LLQuaternion TelehubRot; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 40; - if (ObjectName != null) { length += 1 + ObjectName.Length; } - return length; + { + int length = 40; + if (ObjectName != null) { length += 1 + ObjectName.Length; } + return length; } } - - /// Default constructor - public TelehubBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public TelehubBlockBlock() { } + /// Constructor for building the block from a byte array public TelehubBlockBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _objectname = new byte[length]; - Array.Copy(bytes, i, _objectname, 0, length); i += length; - ObjectID = new LLUUID(bytes, i); i += 16; - TelehubPos = new LLVector3(bytes, i); i += 12; - TelehubRot = new LLQuaternion(bytes, i, true); i += 12; + { + length = (ushort)bytes[i++]; + _objectname = new byte[length]; + Array.Copy(bytes, i, _objectname, 0, length); i += length; + ObjectID = new LLUUID(bytes, i); i += 16; + TelehubPos = new LLVector3(bytes, i); i += 12; + TelehubRot = new LLQuaternion(bytes, i, true); i += 12; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ObjectName == null) { Console.WriteLine("Warning: ObjectName is null, in " + this.GetType()); } - bytes[i++] = (byte)ObjectName.Length; - Array.Copy(ObjectName, 0, bytes, i, ObjectName.Length); i += ObjectName.Length; - if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } - Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; - if(TelehubPos == null) { Console.WriteLine("Warning: TelehubPos is null, in " + this.GetType()); } - Array.Copy(TelehubPos.GetBytes(), 0, bytes, i, 12); i += 12; - if(TelehubRot == null) { Console.WriteLine("Warning: TelehubRot is null, in " + this.GetType()); } - Array.Copy(TelehubRot.GetBytes(), 0, bytes, i, 12); i += 12; + { + if(ObjectName == null) { Console.WriteLine("Warning: ObjectName is null, in " + this.GetType()); } + bytes[i++] = (byte)ObjectName.Length; + Array.Copy(ObjectName, 0, bytes, i, ObjectName.Length); i += ObjectName.Length; + if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } + Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; + if(TelehubPos == null) { Console.WriteLine("Warning: TelehubPos is null, in " + this.GetType()); } + Array.Copy(TelehubPos.GetBytes(), 0, bytes, i, 12); i += 12; + if(TelehubRot == null) { Console.WriteLine("Warning: TelehubRot is null, in " + this.GetType()); } + Array.Copy(TelehubRot.GetBytes(), 0, bytes, i, 12); i += 12; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- TelehubBlock --\n"; - output += Helpers.FieldToString(ObjectName, "ObjectName") + "\n"; - output += "ObjectID: " + ObjectID.ToString() + "\n"; - output += "TelehubPos: " + TelehubPos.ToString() + "\n"; - output += "TelehubRot: " + TelehubRot.ToString() + "\n"; + { + string output = "-- TelehubBlock --\n"; + output += Helpers.FieldToString(ObjectName, "ObjectName") + "\n"; + output += "ObjectID: " + ObjectID.ToString() + "\n"; + output += "TelehubPos: " + TelehubPos.ToString() + "\n"; + output += "TelehubRot: " + TelehubRot.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// SpawnPointBlock block + + /// SpawnPointBlock block public class SpawnPointBlockBlock - { - /// SpawnPointPos field - public LLVector3 SpawnPointPos; - - /// Length of this block serialized in bytes + { + /// SpawnPointPos field + public LLVector3 SpawnPointPos; + + /// Length of this block serialized in bytes public int Length { get - { - return 12; + { + return 12; } } - - /// Default constructor - public SpawnPointBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public SpawnPointBlockBlock() { } + /// Constructor for building the block from a byte array public SpawnPointBlockBlock(byte[] bytes, ref int i) - { + { try - { - SpawnPointPos = new LLVector3(bytes, i); i += 12; + { + SpawnPointPos = new LLVector3(bytes, i); i += 12; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(SpawnPointPos == null) { Console.WriteLine("Warning: SpawnPointPos is null, in " + this.GetType()); } - Array.Copy(SpawnPointPos.GetBytes(), 0, bytes, i, 12); i += 12; + { + if(SpawnPointPos == null) { Console.WriteLine("Warning: SpawnPointPos is null, in " + this.GetType()); } + Array.Copy(SpawnPointPos.GetBytes(), 0, bytes, i, 12); i += 12; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- SpawnPointBlock --\n"; - output += "SpawnPointPos: " + SpawnPointPos.ToString() + "\n"; + { + string output = "-- SpawnPointBlock --\n"; + output += "SpawnPointPos: " + SpawnPointPos.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.TelehubInfo - public override PacketType Type { get { return PacketType.TelehubInfo; } } - /// TelehubBlock block - public TelehubBlockBlock TelehubBlock; - /// SpawnPointBlock block - public SpawnPointBlockBlock[] SpawnPointBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.TelehubInfo + public override PacketType Type { get { return PacketType.TelehubInfo; } } + /// TelehubBlock block + public TelehubBlockBlock TelehubBlock; + /// SpawnPointBlock block + public SpawnPointBlockBlock[] SpawnPointBlock; + + /// Default constructor public TelehubInfoPacket() - { - Header = new LowHeader(); - Header.ID = 16; - Header.Reliable = true; - TelehubBlock = new TelehubBlockBlock(); - SpawnPointBlock = new SpawnPointBlockBlock[0]; + { + Header = new LowHeader(); + Header.ID = 16; + Header.Reliable = true; + TelehubBlock = new TelehubBlockBlock(); + SpawnPointBlock = new SpawnPointBlockBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public TelehubInfoPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - TelehubBlock = new TelehubBlockBlock(bytes, ref i); - int count = (int)bytes[i++]; - SpawnPointBlock = new SpawnPointBlockBlock[count]; - for (int j = 0; j < count; j++) - { SpawnPointBlock[j] = new SpawnPointBlockBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + TelehubBlock = new TelehubBlockBlock(bytes, ref i); + int count = (int)bytes[i++]; + SpawnPointBlock = new SpawnPointBlockBlock[count]; + for (int j = 0; j < count; j++) + { SpawnPointBlock[j] = new SpawnPointBlockBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public TelehubInfoPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - TelehubBlock = new TelehubBlockBlock(bytes, ref i); - int count = (int)bytes[i++]; - SpawnPointBlock = new SpawnPointBlockBlock[count]; - for (int j = 0; j < count; j++) - { SpawnPointBlock[j] = new SpawnPointBlockBlock(bytes, ref i); } + { + Header = head; + TelehubBlock = new TelehubBlockBlock(bytes, ref i); + int count = (int)bytes[i++]; + SpawnPointBlock = new SpawnPointBlockBlock[count]; + for (int j = 0; j < count; j++) + { SpawnPointBlock[j] = new SpawnPointBlockBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += TelehubBlock.Length;; - length++; - for (int j = 0; j < SpawnPointBlock.Length; j++) { length += SpawnPointBlock[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - TelehubBlock.ToBytes(bytes, ref i); - bytes[i++] = (byte)SpawnPointBlock.Length; - for (int j = 0; j < SpawnPointBlock.Length; j++) { SpawnPointBlock[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += TelehubBlock.Length;; + length++; + for (int j = 0; j < SpawnPointBlock.Length; j++) { length += SpawnPointBlock[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + TelehubBlock.ToBytes(bytes, ref i); + bytes[i++] = (byte)SpawnPointBlock.Length; + for (int j = 0; j < SpawnPointBlock.Length; j++) { SpawnPointBlock[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- TelehubInfo ---\n"; - output += TelehubBlock.ToString() + "\n"; + { + string output = "--- TelehubInfo ---\n"; + output += TelehubBlock.ToString() + "\n"; for (int j = 0; j < SpawnPointBlock.Length; j++) - { + { output += SpawnPointBlock[j].ToString() + "\n"; - } + } return output; } - + } - - /// SimulatorPresentAtLocation packet + + /// SimulatorPresentAtLocation packet public class SimulatorPresentAtLocationPacket : Packet - { - /// TelehubBlock block + { + /// TelehubBlock block public class TelehubBlockBlock - { - /// HasTelehub field - public bool HasTelehub; - /// TelehubPos field - public LLVector3 TelehubPos; - - /// Length of this block serialized in bytes + { + /// HasTelehub field + public bool HasTelehub; + /// TelehubPos field + public LLVector3 TelehubPos; + + /// Length of this block serialized in bytes public int Length { get - { - return 13; + { + return 13; } } - - /// Default constructor - public TelehubBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public TelehubBlockBlock() { } + /// Constructor for building the block from a byte array public TelehubBlockBlock(byte[] bytes, ref int i) - { + { try - { - HasTelehub = (bytes[i++] != 0) ? (bool)true : (bool)false; - TelehubPos = new LLVector3(bytes, i); i += 12; + { + HasTelehub = (bytes[i++] != 0) ? (bool)true : (bool)false; + TelehubPos = new LLVector3(bytes, i); i += 12; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)((HasTelehub) ? 1 : 0); - if(TelehubPos == null) { Console.WriteLine("Warning: TelehubPos is null, in " + this.GetType()); } - Array.Copy(TelehubPos.GetBytes(), 0, bytes, i, 12); i += 12; + { + bytes[i++] = (byte)((HasTelehub) ? 1 : 0); + if(TelehubPos == null) { Console.WriteLine("Warning: TelehubPos is null, in " + this.GetType()); } + Array.Copy(TelehubPos.GetBytes(), 0, bytes, i, 12); i += 12; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- TelehubBlock --\n"; - output += "HasTelehub: " + HasTelehub.ToString() + "\n"; - output += "TelehubPos: " + TelehubPos.ToString() + "\n"; + { + string output = "-- TelehubBlock --\n"; + output += "HasTelehub: " + HasTelehub.ToString() + "\n"; + output += "TelehubPos: " + TelehubPos.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// SimulatorBlock block + + /// SimulatorBlock block public class SimulatorBlockBlock - { - private byte[] _simname; - /// SimName field + { + private byte[] _simname; + /// SimName field public byte[] SimName - { - get { return _simname; } + { + get { return _simname; } set - { - if (value == null) { _simname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _simname = new byte[value.Length]; Array.Copy(value, _simname, value.Length); } + { + if (value == null) { _simname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _simname = new byte[value.Length]; Array.Copy(value, _simname, value.Length); } } - } - /// RegionFlags field - public uint RegionFlags; - /// RegionID field - public LLUUID RegionID; - /// SimAccess field - public byte SimAccess; - /// ParentEstateID field - public uint ParentEstateID; - /// EstateID field - public uint EstateID; - - /// Length of this block serialized in bytes + } + /// RegionFlags field + public uint RegionFlags; + /// RegionID field + public LLUUID RegionID; + /// SimAccess field + public byte SimAccess; + /// ParentEstateID field + public uint ParentEstateID; + /// EstateID field + public uint EstateID; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 29; - if (SimName != null) { length += 1 + SimName.Length; } - return length; + { + int length = 29; + if (SimName != null) { length += 1 + SimName.Length; } + return length; } } - - /// Default constructor - public SimulatorBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public SimulatorBlockBlock() { } + /// Constructor for building the block from a byte array public SimulatorBlockBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _simname = new byte[length]; - Array.Copy(bytes, i, _simname, 0, length); i += length; - RegionFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - RegionID = new LLUUID(bytes, i); i += 16; - SimAccess = (byte)bytes[i++]; - ParentEstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - EstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + length = (ushort)bytes[i++]; + _simname = new byte[length]; + Array.Copy(bytes, i, _simname, 0, length); i += length; + RegionFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + RegionID = new LLUUID(bytes, i); i += 16; + SimAccess = (byte)bytes[i++]; + ParentEstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + EstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(SimName == null) { Console.WriteLine("Warning: SimName is null, in " + this.GetType()); } - bytes[i++] = (byte)SimName.Length; - Array.Copy(SimName, 0, bytes, i, SimName.Length); i += SimName.Length; - bytes[i++] = (byte)(RegionFlags % 256); - bytes[i++] = (byte)((RegionFlags >> 8) % 256); - bytes[i++] = (byte)((RegionFlags >> 16) % 256); - bytes[i++] = (byte)((RegionFlags >> 24) % 256); - if(RegionID == null) { Console.WriteLine("Warning: RegionID is null, in " + this.GetType()); } - Array.Copy(RegionID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = SimAccess; - bytes[i++] = (byte)(ParentEstateID % 256); - bytes[i++] = (byte)((ParentEstateID >> 8) % 256); - bytes[i++] = (byte)((ParentEstateID >> 16) % 256); - bytes[i++] = (byte)((ParentEstateID >> 24) % 256); - bytes[i++] = (byte)(EstateID % 256); - bytes[i++] = (byte)((EstateID >> 8) % 256); - bytes[i++] = (byte)((EstateID >> 16) % 256); - bytes[i++] = (byte)((EstateID >> 24) % 256); + { + if(SimName == null) { Console.WriteLine("Warning: SimName is null, in " + this.GetType()); } + bytes[i++] = (byte)SimName.Length; + Array.Copy(SimName, 0, bytes, i, SimName.Length); i += SimName.Length; + bytes[i++] = (byte)(RegionFlags % 256); + bytes[i++] = (byte)((RegionFlags >> 8) % 256); + bytes[i++] = (byte)((RegionFlags >> 16) % 256); + bytes[i++] = (byte)((RegionFlags >> 24) % 256); + if(RegionID == null) { Console.WriteLine("Warning: RegionID is null, in " + this.GetType()); } + Array.Copy(RegionID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = SimAccess; + bytes[i++] = (byte)(ParentEstateID % 256); + bytes[i++] = (byte)((ParentEstateID >> 8) % 256); + bytes[i++] = (byte)((ParentEstateID >> 16) % 256); + bytes[i++] = (byte)((ParentEstateID >> 24) % 256); + bytes[i++] = (byte)(EstateID % 256); + bytes[i++] = (byte)((EstateID >> 8) % 256); + bytes[i++] = (byte)((EstateID >> 16) % 256); + bytes[i++] = (byte)((EstateID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- SimulatorBlock --\n"; - output += Helpers.FieldToString(SimName, "SimName") + "\n"; - output += "RegionFlags: " + RegionFlags.ToString() + "\n"; - output += "RegionID: " + RegionID.ToString() + "\n"; - output += "SimAccess: " + SimAccess.ToString() + "\n"; - output += "ParentEstateID: " + ParentEstateID.ToString() + "\n"; - output += "EstateID: " + EstateID.ToString() + "\n"; + { + string output = "-- SimulatorBlock --\n"; + output += Helpers.FieldToString(SimName, "SimName") + "\n"; + output += "RegionFlags: " + RegionFlags.ToString() + "\n"; + output += "RegionID: " + RegionID.ToString() + "\n"; + output += "SimAccess: " + SimAccess.ToString() + "\n"; + output += "ParentEstateID: " + ParentEstateID.ToString() + "\n"; + output += "EstateID: " + EstateID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// SimulatorPublicHostBlock block + + /// SimulatorPublicHostBlock block public class SimulatorPublicHostBlockBlock - { - /// Port field - public ushort Port; - /// SimulatorIP field - public uint SimulatorIP; - /// GridX field - public uint GridX; - /// GridY field - public uint GridY; - - /// Length of this block serialized in bytes + { + /// Port field + public ushort Port; + /// SimulatorIP field + public uint SimulatorIP; + /// GridX field + public uint GridX; + /// GridY field + public uint GridY; + + /// Length of this block serialized in bytes public int Length { get - { - return 14; + { + return 14; } } - - /// Default constructor - public SimulatorPublicHostBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public SimulatorPublicHostBlockBlock() { } + /// Constructor for building the block from a byte array public SimulatorPublicHostBlockBlock(byte[] bytes, ref int i) - { + { try - { - Port = (ushort)((bytes[i++] << 8) + bytes[i++]); - SimulatorIP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - GridX = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - GridY = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + Port = (ushort)((bytes[i++] << 8) + bytes[i++]); + SimulatorIP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + GridX = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + GridY = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)((Port >> 8) % 256); - bytes[i++] = (byte)(Port % 256); - bytes[i++] = (byte)(SimulatorIP % 256); - bytes[i++] = (byte)((SimulatorIP >> 8) % 256); - bytes[i++] = (byte)((SimulatorIP >> 16) % 256); - bytes[i++] = (byte)((SimulatorIP >> 24) % 256); - bytes[i++] = (byte)(GridX % 256); - bytes[i++] = (byte)((GridX >> 8) % 256); - bytes[i++] = (byte)((GridX >> 16) % 256); - bytes[i++] = (byte)((GridX >> 24) % 256); - bytes[i++] = (byte)(GridY % 256); - bytes[i++] = (byte)((GridY >> 8) % 256); - bytes[i++] = (byte)((GridY >> 16) % 256); - bytes[i++] = (byte)((GridY >> 24) % 256); + { + bytes[i++] = (byte)((Port >> 8) % 256); + bytes[i++] = (byte)(Port % 256); + bytes[i++] = (byte)(SimulatorIP % 256); + bytes[i++] = (byte)((SimulatorIP >> 8) % 256); + bytes[i++] = (byte)((SimulatorIP >> 16) % 256); + bytes[i++] = (byte)((SimulatorIP >> 24) % 256); + bytes[i++] = (byte)(GridX % 256); + bytes[i++] = (byte)((GridX >> 8) % 256); + bytes[i++] = (byte)((GridX >> 16) % 256); + bytes[i++] = (byte)((GridX >> 24) % 256); + bytes[i++] = (byte)(GridY % 256); + bytes[i++] = (byte)((GridY >> 8) % 256); + bytes[i++] = (byte)((GridY >> 16) % 256); + bytes[i++] = (byte)((GridY >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- SimulatorPublicHostBlock --\n"; - output += "Port: " + Port.ToString() + "\n"; - output += "SimulatorIP: " + SimulatorIP.ToString() + "\n"; - output += "GridX: " + GridX.ToString() + "\n"; - output += "GridY: " + GridY.ToString() + "\n"; + { + string output = "-- SimulatorPublicHostBlock --\n"; + output += "Port: " + Port.ToString() + "\n"; + output += "SimulatorIP: " + SimulatorIP.ToString() + "\n"; + output += "GridX: " + GridX.ToString() + "\n"; + output += "GridY: " + GridY.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// NeighborBlock block + + /// NeighborBlock block public class NeighborBlockBlock - { - /// IP field - public uint IP; - /// Port field - public ushort Port; - - /// Length of this block serialized in bytes + { + /// IP field + public uint IP; + /// Port field + public ushort Port; + + /// Length of this block serialized in bytes public int Length { get - { - return 6; + { + return 6; } } - - /// Default constructor - public NeighborBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public NeighborBlockBlock() { } + /// Constructor for building the block from a byte array public NeighborBlockBlock(byte[] bytes, ref int i) - { + { try - { - IP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Port = (ushort)((bytes[i++] << 8) + bytes[i++]); + { + IP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Port = (ushort)((bytes[i++] << 8) + bytes[i++]); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(IP % 256); - bytes[i++] = (byte)((IP >> 8) % 256); - bytes[i++] = (byte)((IP >> 16) % 256); - bytes[i++] = (byte)((IP >> 24) % 256); - bytes[i++] = (byte)((Port >> 8) % 256); - bytes[i++] = (byte)(Port % 256); + { + bytes[i++] = (byte)(IP % 256); + bytes[i++] = (byte)((IP >> 8) % 256); + bytes[i++] = (byte)((IP >> 16) % 256); + bytes[i++] = (byte)((IP >> 24) % 256); + bytes[i++] = (byte)((Port >> 8) % 256); + bytes[i++] = (byte)(Port % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- NeighborBlock --\n"; - output += "IP: " + IP.ToString() + "\n"; - output += "Port: " + Port.ToString() + "\n"; + { + string output = "-- NeighborBlock --\n"; + output += "IP: " + IP.ToString() + "\n"; + output += "Port: " + Port.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.SimulatorPresentAtLocation - public override PacketType Type { get { return PacketType.SimulatorPresentAtLocation; } } - /// TelehubBlock block - public TelehubBlockBlock[] TelehubBlock; - /// SimulatorBlock block - public SimulatorBlockBlock SimulatorBlock; - /// SimulatorPublicHostBlock block - public SimulatorPublicHostBlockBlock SimulatorPublicHostBlock; - /// NeighborBlock block - public NeighborBlockBlock[] NeighborBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.SimulatorPresentAtLocation + public override PacketType Type { get { return PacketType.SimulatorPresentAtLocation; } } + /// TelehubBlock block + public TelehubBlockBlock[] TelehubBlock; + /// SimulatorBlock block + public SimulatorBlockBlock SimulatorBlock; + /// SimulatorPublicHostBlock block + public SimulatorPublicHostBlockBlock SimulatorPublicHostBlock; + /// NeighborBlock block + public NeighborBlockBlock[] NeighborBlock; + + /// Default constructor public SimulatorPresentAtLocationPacket() - { - Header = new LowHeader(); - Header.ID = 17; - Header.Reliable = true; - TelehubBlock = new TelehubBlockBlock[0]; - SimulatorBlock = new SimulatorBlockBlock(); - SimulatorPublicHostBlock = new SimulatorPublicHostBlockBlock(); - NeighborBlock = new NeighborBlockBlock[4]; + { + Header = new LowHeader(); + Header.ID = 17; + Header.Reliable = true; + TelehubBlock = new TelehubBlockBlock[0]; + SimulatorBlock = new SimulatorBlockBlock(); + SimulatorPublicHostBlock = new SimulatorPublicHostBlockBlock(); + NeighborBlock = new NeighborBlockBlock[4]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public SimulatorPresentAtLocationPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - TelehubBlock = new TelehubBlockBlock[count]; - for (int j = 0; j < count; j++) - { TelehubBlock[j] = new TelehubBlockBlock(bytes, ref i); } - SimulatorBlock = new SimulatorBlockBlock(bytes, ref i); - SimulatorPublicHostBlock = new SimulatorPublicHostBlockBlock(bytes, ref i); - NeighborBlock = new NeighborBlockBlock[4]; - for (int j = 0; j < 4; j++) - { NeighborBlock[j] = new NeighborBlockBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + TelehubBlock = new TelehubBlockBlock[count]; + for (int j = 0; j < count; j++) + { TelehubBlock[j] = new TelehubBlockBlock(bytes, ref i); } + SimulatorBlock = new SimulatorBlockBlock(bytes, ref i); + SimulatorPublicHostBlock = new SimulatorPublicHostBlockBlock(bytes, ref i); + NeighborBlock = new NeighborBlockBlock[4]; + for (int j = 0; j < 4; j++) + { NeighborBlock[j] = new NeighborBlockBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public SimulatorPresentAtLocationPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - TelehubBlock = new TelehubBlockBlock[count]; - for (int j = 0; j < count; j++) - { TelehubBlock[j] = new TelehubBlockBlock(bytes, ref i); } - SimulatorBlock = new SimulatorBlockBlock(bytes, ref i); - SimulatorPublicHostBlock = new SimulatorPublicHostBlockBlock(bytes, ref i); - NeighborBlock = new NeighborBlockBlock[4]; - for (int j = 0; j < 4; j++) - { NeighborBlock[j] = new NeighborBlockBlock(bytes, ref i); } + { + Header = head; + int count = (int)bytes[i++]; + TelehubBlock = new TelehubBlockBlock[count]; + for (int j = 0; j < count; j++) + { TelehubBlock[j] = new TelehubBlockBlock(bytes, ref i); } + SimulatorBlock = new SimulatorBlockBlock(bytes, ref i); + SimulatorPublicHostBlock = new SimulatorPublicHostBlockBlock(bytes, ref i); + NeighborBlock = new NeighborBlockBlock[4]; + for (int j = 0; j < 4; j++) + { NeighborBlock[j] = new NeighborBlockBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += SimulatorBlock.Length; length += SimulatorPublicHostBlock.Length;; - length++; - for (int j = 0; j < TelehubBlock.Length; j++) { length += TelehubBlock[j].Length; } - for (int j = 0; j < 4; j++) { length += NeighborBlock[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)TelehubBlock.Length; - for (int j = 0; j < TelehubBlock.Length; j++) { TelehubBlock[j].ToBytes(bytes, ref i); } - SimulatorBlock.ToBytes(bytes, ref i); - SimulatorPublicHostBlock.ToBytes(bytes, ref i); - for (int j = 0; j < 4; j++) { NeighborBlock[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += SimulatorBlock.Length; length += SimulatorPublicHostBlock.Length;; + length++; + for (int j = 0; j < TelehubBlock.Length; j++) { length += TelehubBlock[j].Length; } + for (int j = 0; j < 4; j++) { length += NeighborBlock[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)TelehubBlock.Length; + for (int j = 0; j < TelehubBlock.Length; j++) { TelehubBlock[j].ToBytes(bytes, ref i); } + SimulatorBlock.ToBytes(bytes, ref i); + SimulatorPublicHostBlock.ToBytes(bytes, ref i); + for (int j = 0; j < 4; j++) { NeighborBlock[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- SimulatorPresentAtLocation ---\n"; + { + string output = "--- SimulatorPresentAtLocation ---\n"; for (int j = 0; j < TelehubBlock.Length; j++) - { + { output += TelehubBlock[j].ToString() + "\n"; - } - output += SimulatorBlock.ToString() + "\n"; - output += SimulatorPublicHostBlock.ToString() + "\n"; + } + output += SimulatorBlock.ToString() + "\n"; + output += SimulatorPublicHostBlock.ToString() + "\n"; for (int j = 0; j < 4; j++) - { + { output += NeighborBlock[j].ToString() + "\n"; - } + } return output; } - + } - - /// SimulatorLoad packet + + /// SimulatorLoad packet public class SimulatorLoadPacket : Packet - { - /// SimulatorLoad block + { + /// SimulatorLoad block public class SimulatorLoadBlock - { - /// CanAcceptAgents field - public bool CanAcceptAgents; - /// TimeDilation field - public float TimeDilation; - /// AgentCount field - public int AgentCount; - - /// Length of this block serialized in bytes + { + /// CanAcceptAgents field + public bool CanAcceptAgents; + /// TimeDilation field + public float TimeDilation; + /// AgentCount field + public int AgentCount; + + /// Length of this block serialized in bytes public int Length { get - { - return 9; + { + return 9; } } - - /// Default constructor - public SimulatorLoadBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public SimulatorLoadBlock() { } + /// Constructor for building the block from a byte array public SimulatorLoadBlock(byte[] bytes, ref int i) - { + { try - { - CanAcceptAgents = (bytes[i++] != 0) ? (bool)true : (bool)false; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - TimeDilation = BitConverter.ToSingle(bytes, i); i += 4; - AgentCount = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + CanAcceptAgents = (bytes[i++] != 0) ? (bool)true : (bool)false; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + TimeDilation = BitConverter.ToSingle(bytes, i); i += 4; + AgentCount = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; - bytes[i++] = (byte)((CanAcceptAgents) ? 1 : 0); + { + byte[] ba; + bytes[i++] = (byte)((CanAcceptAgents) ? 1 : 0); ba = BitConverter.GetBytes(TimeDilation); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - bytes[i++] = (byte)(AgentCount % 256); - bytes[i++] = (byte)((AgentCount >> 8) % 256); - bytes[i++] = (byte)((AgentCount >> 16) % 256); - bytes[i++] = (byte)((AgentCount >> 24) % 256); + Array.Copy(ba, 0, bytes, i, 4); i += 4; + bytes[i++] = (byte)(AgentCount % 256); + bytes[i++] = (byte)((AgentCount >> 8) % 256); + bytes[i++] = (byte)((AgentCount >> 16) % 256); + bytes[i++] = (byte)((AgentCount >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- SimulatorLoad --\n"; - output += "CanAcceptAgents: " + CanAcceptAgents.ToString() + "\n"; - output += "TimeDilation: " + TimeDilation.ToString() + "\n"; - output += "AgentCount: " + AgentCount.ToString() + "\n"; + { + string output = "-- SimulatorLoad --\n"; + output += "CanAcceptAgents: " + CanAcceptAgents.ToString() + "\n"; + output += "TimeDilation: " + TimeDilation.ToString() + "\n"; + output += "AgentCount: " + AgentCount.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentList block + + /// AgentList block public class AgentListBlock - { - /// X field - public byte X; - /// Y field - public byte Y; - /// CircuitCode field - public uint CircuitCode; - - /// Length of this block serialized in bytes + { + /// X field + public byte X; + /// Y field + public byte Y; + /// CircuitCode field + public uint CircuitCode; + + /// Length of this block serialized in bytes public int Length { get - { - return 6; + { + return 6; } } - - /// Default constructor - public AgentListBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentListBlock() { } + /// Constructor for building the block from a byte array public AgentListBlock(byte[] bytes, ref int i) - { + { try - { - X = (byte)bytes[i++]; - Y = (byte)bytes[i++]; - CircuitCode = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + X = (byte)bytes[i++]; + Y = (byte)bytes[i++]; + CircuitCode = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = X; - bytes[i++] = Y; - bytes[i++] = (byte)(CircuitCode % 256); - bytes[i++] = (byte)((CircuitCode >> 8) % 256); - bytes[i++] = (byte)((CircuitCode >> 16) % 256); - bytes[i++] = (byte)((CircuitCode >> 24) % 256); + { + bytes[i++] = X; + bytes[i++] = Y; + bytes[i++] = (byte)(CircuitCode % 256); + bytes[i++] = (byte)((CircuitCode >> 8) % 256); + bytes[i++] = (byte)((CircuitCode >> 16) % 256); + bytes[i++] = (byte)((CircuitCode >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentList --\n"; - output += "X: " + X.ToString() + "\n"; - output += "Y: " + Y.ToString() + "\n"; - output += "CircuitCode: " + CircuitCode.ToString() + "\n"; + { + string output = "-- AgentList --\n"; + output += "X: " + X.ToString() + "\n"; + output += "Y: " + Y.ToString() + "\n"; + output += "CircuitCode: " + CircuitCode.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.SimulatorLoad - public override PacketType Type { get { return PacketType.SimulatorLoad; } } - /// SimulatorLoad block - public SimulatorLoadBlock SimulatorLoad; - /// AgentList block - public AgentListBlock[] AgentList; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.SimulatorLoad + public override PacketType Type { get { return PacketType.SimulatorLoad; } } + /// SimulatorLoad block + public SimulatorLoadBlock SimulatorLoad; + /// AgentList block + public AgentListBlock[] AgentList; + + /// Default constructor public SimulatorLoadPacket() - { - Header = new LowHeader(); - Header.ID = 18; - Header.Reliable = true; - SimulatorLoad = new SimulatorLoadBlock(); - AgentList = new AgentListBlock[0]; + { + Header = new LowHeader(); + Header.ID = 18; + Header.Reliable = true; + SimulatorLoad = new SimulatorLoadBlock(); + AgentList = new AgentListBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public SimulatorLoadPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - SimulatorLoad = new SimulatorLoadBlock(bytes, ref i); - int count = (int)bytes[i++]; - AgentList = new AgentListBlock[count]; - for (int j = 0; j < count; j++) - { AgentList[j] = new AgentListBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + SimulatorLoad = new SimulatorLoadBlock(bytes, ref i); + int count = (int)bytes[i++]; + AgentList = new AgentListBlock[count]; + for (int j = 0; j < count; j++) + { AgentList[j] = new AgentListBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public SimulatorLoadPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - SimulatorLoad = new SimulatorLoadBlock(bytes, ref i); - int count = (int)bytes[i++]; - AgentList = new AgentListBlock[count]; - for (int j = 0; j < count; j++) - { AgentList[j] = new AgentListBlock(bytes, ref i); } + { + Header = head; + SimulatorLoad = new SimulatorLoadBlock(bytes, ref i); + int count = (int)bytes[i++]; + AgentList = new AgentListBlock[count]; + for (int j = 0; j < count; j++) + { AgentList[j] = new AgentListBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += SimulatorLoad.Length;; - length++; - for (int j = 0; j < AgentList.Length; j++) { length += AgentList[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - SimulatorLoad.ToBytes(bytes, ref i); - bytes[i++] = (byte)AgentList.Length; - for (int j = 0; j < AgentList.Length; j++) { AgentList[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += SimulatorLoad.Length;; + length++; + for (int j = 0; j < AgentList.Length; j++) { length += AgentList[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + SimulatorLoad.ToBytes(bytes, ref i); + bytes[i++] = (byte)AgentList.Length; + for (int j = 0; j < AgentList.Length; j++) { AgentList[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- SimulatorLoad ---\n"; - output += SimulatorLoad.ToString() + "\n"; + { + string output = "--- SimulatorLoad ---\n"; + output += SimulatorLoad.ToString() + "\n"; for (int j = 0; j < AgentList.Length; j++) - { + { output += AgentList[j].ToString() + "\n"; - } + } return output; } - + } - - /// SimulatorShutdownRequest packet + + /// SimulatorShutdownRequest packet public class SimulatorShutdownRequestPacket : Packet - { - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.SimulatorShutdownRequest - public override PacketType Type { get { return PacketType.SimulatorShutdownRequest; } } - - /// Default constructor + { + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.SimulatorShutdownRequest + public override PacketType Type { get { return PacketType.SimulatorShutdownRequest; } } + + /// Default constructor public SimulatorShutdownRequestPacket() - { - Header = new LowHeader(); - Header.ID = 19; - Header.Reliable = true; + { + Header = new LowHeader(); + Header.ID = 19; + Header.Reliable = true; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public SimulatorShutdownRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public SimulatorShutdownRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; + { + Header = head; } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; -; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; +; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- SimulatorShutdownRequest ---\n"; + { + string output = "--- SimulatorShutdownRequest ---\n"; return output; } - + } - - /// RegionPresenceRequestByRegionID packet + + /// RegionPresenceRequestByRegionID packet public class RegionPresenceRequestByRegionIDPacket : Packet - { - /// RegionData block + { + /// RegionData block public class RegionDataBlock - { - /// RegionID field - public LLUUID RegionID; - - /// Length of this block serialized in bytes + { + /// RegionID field + public LLUUID RegionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public RegionDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public RegionDataBlock() { } + /// Constructor for building the block from a byte array public RegionDataBlock(byte[] bytes, ref int i) - { + { try - { - RegionID = new LLUUID(bytes, i); i += 16; + { + RegionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(RegionID == null) { Console.WriteLine("Warning: RegionID is null, in " + this.GetType()); } - Array.Copy(RegionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(RegionID == null) { Console.WriteLine("Warning: RegionID is null, in " + this.GetType()); } + Array.Copy(RegionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- RegionData --\n"; - output += "RegionID: " + RegionID.ToString() + "\n"; + { + string output = "-- RegionData --\n"; + output += "RegionID: " + RegionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.RegionPresenceRequestByRegionID - public override PacketType Type { get { return PacketType.RegionPresenceRequestByRegionID; } } - /// RegionData block - public RegionDataBlock[] RegionData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.RegionPresenceRequestByRegionID + public override PacketType Type { get { return PacketType.RegionPresenceRequestByRegionID; } } + /// RegionData block + public RegionDataBlock[] RegionData; + + /// Default constructor public RegionPresenceRequestByRegionIDPacket() - { - Header = new LowHeader(); - Header.ID = 20; - Header.Reliable = true; - RegionData = new RegionDataBlock[0]; + { + Header = new LowHeader(); + Header.ID = 20; + Header.Reliable = true; + RegionData = new RegionDataBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public RegionPresenceRequestByRegionIDPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - RegionData = new RegionDataBlock[count]; - for (int j = 0; j < count; j++) - { RegionData[j] = new RegionDataBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + RegionData = new RegionDataBlock[count]; + for (int j = 0; j < count; j++) + { RegionData[j] = new RegionDataBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public RegionPresenceRequestByRegionIDPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - RegionData = new RegionDataBlock[count]; - for (int j = 0; j < count; j++) - { RegionData[j] = new RegionDataBlock(bytes, ref i); } + { + Header = head; + int count = (int)bytes[i++]; + RegionData = new RegionDataBlock[count]; + for (int j = 0; j < count; j++) + { RegionData[j] = new RegionDataBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; -; - length++; - for (int j = 0; j < RegionData.Length; j++) { length += RegionData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)RegionData.Length; - for (int j = 0; j < RegionData.Length; j++) { RegionData[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; +; + length++; + for (int j = 0; j < RegionData.Length; j++) { length += RegionData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)RegionData.Length; + for (int j = 0; j < RegionData.Length; j++) { RegionData[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- RegionPresenceRequestByRegionID ---\n"; + { + string output = "--- RegionPresenceRequestByRegionID ---\n"; for (int j = 0; j < RegionData.Length; j++) - { + { output += RegionData[j].ToString() + "\n"; - } + } return output; } - + } - - /// RegionPresenceRequestByHandle packet + + /// RegionPresenceRequestByHandle packet public class RegionPresenceRequestByHandlePacket : Packet - { - /// RegionData block + { + /// RegionData block public class RegionDataBlock - { - /// RegionHandle field - public ulong RegionHandle; - - /// Length of this block serialized in bytes + { + /// RegionHandle field + public ulong RegionHandle; + + /// Length of this block serialized in bytes public int Length { get - { - return 8; + { + return 8; } } - - /// Default constructor - public RegionDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public RegionDataBlock() { } + /// Constructor for building the block from a byte array public RegionDataBlock(byte[] bytes, ref int i) - { + { try - { - RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + { + RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(RegionHandle % 256); - bytes[i++] = (byte)((RegionHandle >> 8) % 256); - bytes[i++] = (byte)((RegionHandle >> 16) % 256); - bytes[i++] = (byte)((RegionHandle >> 24) % 256); - bytes[i++] = (byte)((RegionHandle >> 32) % 256); - bytes[i++] = (byte)((RegionHandle >> 40) % 256); - bytes[i++] = (byte)((RegionHandle >> 48) % 256); - bytes[i++] = (byte)((RegionHandle >> 56) % 256); + { + bytes[i++] = (byte)(RegionHandle % 256); + bytes[i++] = (byte)((RegionHandle >> 8) % 256); + bytes[i++] = (byte)((RegionHandle >> 16) % 256); + bytes[i++] = (byte)((RegionHandle >> 24) % 256); + bytes[i++] = (byte)((RegionHandle >> 32) % 256); + bytes[i++] = (byte)((RegionHandle >> 40) % 256); + bytes[i++] = (byte)((RegionHandle >> 48) % 256); + bytes[i++] = (byte)((RegionHandle >> 56) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- RegionData --\n"; - output += "RegionHandle: " + RegionHandle.ToString() + "\n"; + { + string output = "-- RegionData --\n"; + output += "RegionHandle: " + RegionHandle.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.RegionPresenceRequestByHandle - public override PacketType Type { get { return PacketType.RegionPresenceRequestByHandle; } } - /// RegionData block - public RegionDataBlock[] RegionData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.RegionPresenceRequestByHandle + public override PacketType Type { get { return PacketType.RegionPresenceRequestByHandle; } } + /// RegionData block + public RegionDataBlock[] RegionData; + + /// Default constructor public RegionPresenceRequestByHandlePacket() - { - Header = new LowHeader(); - Header.ID = 21; - Header.Reliable = true; - RegionData = new RegionDataBlock[0]; + { + Header = new LowHeader(); + Header.ID = 21; + Header.Reliable = true; + RegionData = new RegionDataBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public RegionPresenceRequestByHandlePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - RegionData = new RegionDataBlock[count]; - for (int j = 0; j < count; j++) - { RegionData[j] = new RegionDataBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + RegionData = new RegionDataBlock[count]; + for (int j = 0; j < count; j++) + { RegionData[j] = new RegionDataBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public RegionPresenceRequestByHandlePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - RegionData = new RegionDataBlock[count]; - for (int j = 0; j < count; j++) - { RegionData[j] = new RegionDataBlock(bytes, ref i); } + { + Header = head; + int count = (int)bytes[i++]; + RegionData = new RegionDataBlock[count]; + for (int j = 0; j < count; j++) + { RegionData[j] = new RegionDataBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; -; - length++; - for (int j = 0; j < RegionData.Length; j++) { length += RegionData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)RegionData.Length; - for (int j = 0; j < RegionData.Length; j++) { RegionData[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; +; + length++; + for (int j = 0; j < RegionData.Length; j++) { length += RegionData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)RegionData.Length; + for (int j = 0; j < RegionData.Length; j++) { RegionData[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- RegionPresenceRequestByHandle ---\n"; + { + string output = "--- RegionPresenceRequestByHandle ---\n"; for (int j = 0; j < RegionData.Length; j++) - { + { output += RegionData[j].ToString() + "\n"; - } + } return output; } - + } - - /// RegionPresenceResponse packet + + /// RegionPresenceResponse packet public class RegionPresenceResponsePacket : Packet - { - /// RegionData block + { + /// RegionData block public class RegionDataBlock - { - /// ValidUntil field - public double ValidUntil; - /// InternalRegionIP field - public uint InternalRegionIP; - /// ExternalRegionIP field - public uint ExternalRegionIP; - private byte[] _message; - /// Message field + { + /// ValidUntil field + public double ValidUntil; + /// InternalRegionIP field + public uint InternalRegionIP; + /// ExternalRegionIP field + public uint ExternalRegionIP; + private byte[] _message; + /// Message field public byte[] Message - { - get { return _message; } + { + get { return _message; } set - { - if (value == null) { _message = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _message = new byte[value.Length]; Array.Copy(value, _message, value.Length); } + { + if (value == null) { _message = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _message = new byte[value.Length]; Array.Copy(value, _message, value.Length); } } - } - /// RegionID field - public LLUUID RegionID; - /// RegionHandle field - public ulong RegionHandle; - /// RegionPort field - public ushort RegionPort; - - /// Length of this block serialized in bytes + } + /// RegionID field + public LLUUID RegionID; + /// RegionHandle field + public ulong RegionHandle; + /// RegionPort field + public ushort RegionPort; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 42; - if (Message != null) { length += 1 + Message.Length; } - return length; + { + int length = 42; + if (Message != null) { length += 1 + Message.Length; } + return length; } } - - /// Default constructor - public RegionDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public RegionDataBlock() { } + /// Constructor for building the block from a byte array public RegionDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 8); - ValidUntil = BitConverter.ToDouble(bytes, i); i += 8; - InternalRegionIP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - ExternalRegionIP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _message = new byte[length]; - Array.Copy(bytes, i, _message, 0, length); i += length; - RegionID = new LLUUID(bytes, i); i += 16; - RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); - RegionPort = (ushort)((bytes[i++] << 8) + bytes[i++]); + { + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 8); + ValidUntil = BitConverter.ToDouble(bytes, i); i += 8; + InternalRegionIP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + ExternalRegionIP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _message = new byte[length]; + Array.Copy(bytes, i, _message, 0, length); i += length; + RegionID = new LLUUID(bytes, i); i += 16; + RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + RegionPort = (ushort)((bytes[i++] << 8) + bytes[i++]); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; + { + byte[] ba; ba = BitConverter.GetBytes(ValidUntil); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 8); } - Array.Copy(ba, 0, bytes, i, 8); i += 8; - bytes[i++] = (byte)(InternalRegionIP % 256); - bytes[i++] = (byte)((InternalRegionIP >> 8) % 256); - bytes[i++] = (byte)((InternalRegionIP >> 16) % 256); - bytes[i++] = (byte)((InternalRegionIP >> 24) % 256); - bytes[i++] = (byte)(ExternalRegionIP % 256); - bytes[i++] = (byte)((ExternalRegionIP >> 8) % 256); - bytes[i++] = (byte)((ExternalRegionIP >> 16) % 256); - bytes[i++] = (byte)((ExternalRegionIP >> 24) % 256); - if(Message == null) { Console.WriteLine("Warning: Message is null, in " + this.GetType()); } - bytes[i++] = (byte)Message.Length; - Array.Copy(Message, 0, bytes, i, Message.Length); i += Message.Length; - if(RegionID == null) { Console.WriteLine("Warning: RegionID is null, in " + this.GetType()); } - Array.Copy(RegionID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(RegionHandle % 256); - bytes[i++] = (byte)((RegionHandle >> 8) % 256); - bytes[i++] = (byte)((RegionHandle >> 16) % 256); - bytes[i++] = (byte)((RegionHandle >> 24) % 256); - bytes[i++] = (byte)((RegionHandle >> 32) % 256); - bytes[i++] = (byte)((RegionHandle >> 40) % 256); - bytes[i++] = (byte)((RegionHandle >> 48) % 256); - bytes[i++] = (byte)((RegionHandle >> 56) % 256); - bytes[i++] = (byte)((RegionPort >> 8) % 256); - bytes[i++] = (byte)(RegionPort % 256); + Array.Copy(ba, 0, bytes, i, 8); i += 8; + bytes[i++] = (byte)(InternalRegionIP % 256); + bytes[i++] = (byte)((InternalRegionIP >> 8) % 256); + bytes[i++] = (byte)((InternalRegionIP >> 16) % 256); + bytes[i++] = (byte)((InternalRegionIP >> 24) % 256); + bytes[i++] = (byte)(ExternalRegionIP % 256); + bytes[i++] = (byte)((ExternalRegionIP >> 8) % 256); + bytes[i++] = (byte)((ExternalRegionIP >> 16) % 256); + bytes[i++] = (byte)((ExternalRegionIP >> 24) % 256); + if(Message == null) { Console.WriteLine("Warning: Message is null, in " + this.GetType()); } + bytes[i++] = (byte)Message.Length; + Array.Copy(Message, 0, bytes, i, Message.Length); i += Message.Length; + if(RegionID == null) { Console.WriteLine("Warning: RegionID is null, in " + this.GetType()); } + Array.Copy(RegionID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(RegionHandle % 256); + bytes[i++] = (byte)((RegionHandle >> 8) % 256); + bytes[i++] = (byte)((RegionHandle >> 16) % 256); + bytes[i++] = (byte)((RegionHandle >> 24) % 256); + bytes[i++] = (byte)((RegionHandle >> 32) % 256); + bytes[i++] = (byte)((RegionHandle >> 40) % 256); + bytes[i++] = (byte)((RegionHandle >> 48) % 256); + bytes[i++] = (byte)((RegionHandle >> 56) % 256); + bytes[i++] = (byte)((RegionPort >> 8) % 256); + bytes[i++] = (byte)(RegionPort % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- RegionData --\n"; - output += "ValidUntil: " + ValidUntil.ToString() + "\n"; - output += "InternalRegionIP: " + InternalRegionIP.ToString() + "\n"; - output += "ExternalRegionIP: " + ExternalRegionIP.ToString() + "\n"; - output += Helpers.FieldToString(Message, "Message") + "\n"; - output += "RegionID: " + RegionID.ToString() + "\n"; - output += "RegionHandle: " + RegionHandle.ToString() + "\n"; - output += "RegionPort: " + RegionPort.ToString() + "\n"; + { + string output = "-- RegionData --\n"; + output += "ValidUntil: " + ValidUntil.ToString() + "\n"; + output += "InternalRegionIP: " + InternalRegionIP.ToString() + "\n"; + output += "ExternalRegionIP: " + ExternalRegionIP.ToString() + "\n"; + output += Helpers.FieldToString(Message, "Message") + "\n"; + output += "RegionID: " + RegionID.ToString() + "\n"; + output += "RegionHandle: " + RegionHandle.ToString() + "\n"; + output += "RegionPort: " + RegionPort.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.RegionPresenceResponse - public override PacketType Type { get { return PacketType.RegionPresenceResponse; } } - /// RegionData block - public RegionDataBlock[] RegionData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.RegionPresenceResponse + public override PacketType Type { get { return PacketType.RegionPresenceResponse; } } + /// RegionData block + public RegionDataBlock[] RegionData; + + /// Default constructor public RegionPresenceResponsePacket() - { - Header = new LowHeader(); - Header.ID = 22; - Header.Reliable = true; - Header.Zerocoded = true; - RegionData = new RegionDataBlock[0]; + { + Header = new LowHeader(); + Header.ID = 22; + Header.Reliable = true; + Header.Zerocoded = true; + RegionData = new RegionDataBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public RegionPresenceResponsePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - RegionData = new RegionDataBlock[count]; - for (int j = 0; j < count; j++) - { RegionData[j] = new RegionDataBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + RegionData = new RegionDataBlock[count]; + for (int j = 0; j < count; j++) + { RegionData[j] = new RegionDataBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public RegionPresenceResponsePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - RegionData = new RegionDataBlock[count]; - for (int j = 0; j < count; j++) - { RegionData[j] = new RegionDataBlock(bytes, ref i); } + { + Header = head; + int count = (int)bytes[i++]; + RegionData = new RegionDataBlock[count]; + for (int j = 0; j < count; j++) + { RegionData[j] = new RegionDataBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; -; - length++; - for (int j = 0; j < RegionData.Length; j++) { length += RegionData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)RegionData.Length; - for (int j = 0; j < RegionData.Length; j++) { RegionData[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; +; + length++; + for (int j = 0; j < RegionData.Length; j++) { length += RegionData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)RegionData.Length; + for (int j = 0; j < RegionData.Length; j++) { RegionData[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- RegionPresenceResponse ---\n"; + { + string output = "--- RegionPresenceResponse ---\n"; for (int j = 0; j < RegionData.Length; j++) - { + { output += RegionData[j].ToString() + "\n"; - } + } return output; } - + } - - /// RecordAgentPresence packet + + /// RecordAgentPresence packet public class RecordAgentPresencePacket : Packet - { - /// RegionData block + { + /// RegionData block public class RegionDataBlock - { - /// RegionID field - public LLUUID RegionID; - - /// Length of this block serialized in bytes + { + /// RegionID field + public LLUUID RegionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public RegionDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public RegionDataBlock() { } + /// Constructor for building the block from a byte array public RegionDataBlock(byte[] bytes, ref int i) - { + { try - { - RegionID = new LLUUID(bytes, i); i += 16; + { + RegionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(RegionID == null) { Console.WriteLine("Warning: RegionID is null, in " + this.GetType()); } - Array.Copy(RegionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(RegionID == null) { Console.WriteLine("Warning: RegionID is null, in " + this.GetType()); } + Array.Copy(RegionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- RegionData --\n"; - output += "RegionID: " + RegionID.ToString() + "\n"; + { + string output = "-- RegionData --\n"; + output += "RegionID: " + RegionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - /// LocalX field - public short LocalX; - /// LocalY field - public short LocalY; - /// Status field - public int Status; - /// SecureSessionID field - public LLUUID SecureSessionID; - /// EstateID field - public uint EstateID; - /// TimeToLive field - public int TimeToLive; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + /// LocalX field + public short LocalX; + /// LocalY field + public short LocalY; + /// Status field + public int Status; + /// SecureSessionID field + public LLUUID SecureSessionID; + /// EstateID field + public uint EstateID; + /// TimeToLive field + public int TimeToLive; + + /// Length of this block serialized in bytes public int Length { get - { - return 64; + { + return 64; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; - LocalX = (short)(bytes[i++] + (bytes[i++] << 8)); - LocalY = (short)(bytes[i++] + (bytes[i++] << 8)); - Status = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - SecureSessionID = new LLUUID(bytes, i); i += 16; - EstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - TimeToLive = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; + LocalX = (short)(bytes[i++] + (bytes[i++] << 8)); + LocalY = (short)(bytes[i++] + (bytes[i++] << 8)); + Status = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + SecureSessionID = new LLUUID(bytes, i); i += 16; + EstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + TimeToLive = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(LocalX % 256); - bytes[i++] = (byte)((LocalX >> 8) % 256); - bytes[i++] = (byte)(LocalY % 256); - bytes[i++] = (byte)((LocalY >> 8) % 256); - bytes[i++] = (byte)(Status % 256); - bytes[i++] = (byte)((Status >> 8) % 256); - bytes[i++] = (byte)((Status >> 16) % 256); - bytes[i++] = (byte)((Status >> 24) % 256); - if(SecureSessionID == null) { Console.WriteLine("Warning: SecureSessionID is null, in " + this.GetType()); } - Array.Copy(SecureSessionID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(EstateID % 256); - bytes[i++] = (byte)((EstateID >> 8) % 256); - bytes[i++] = (byte)((EstateID >> 16) % 256); - bytes[i++] = (byte)((EstateID >> 24) % 256); - bytes[i++] = (byte)(TimeToLive % 256); - bytes[i++] = (byte)((TimeToLive >> 8) % 256); - bytes[i++] = (byte)((TimeToLive >> 16) % 256); - bytes[i++] = (byte)((TimeToLive >> 24) % 256); + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(LocalX % 256); + bytes[i++] = (byte)((LocalX >> 8) % 256); + bytes[i++] = (byte)(LocalY % 256); + bytes[i++] = (byte)((LocalY >> 8) % 256); + bytes[i++] = (byte)(Status % 256); + bytes[i++] = (byte)((Status >> 8) % 256); + bytes[i++] = (byte)((Status >> 16) % 256); + bytes[i++] = (byte)((Status >> 24) % 256); + if(SecureSessionID == null) { Console.WriteLine("Warning: SecureSessionID is null, in " + this.GetType()); } + Array.Copy(SecureSessionID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(EstateID % 256); + bytes[i++] = (byte)((EstateID >> 8) % 256); + bytes[i++] = (byte)((EstateID >> 16) % 256); + bytes[i++] = (byte)((EstateID >> 24) % 256); + bytes[i++] = (byte)(TimeToLive % 256); + bytes[i++] = (byte)((TimeToLive >> 8) % 256); + bytes[i++] = (byte)((TimeToLive >> 16) % 256); + bytes[i++] = (byte)((TimeToLive >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "LocalX: " + LocalX.ToString() + "\n"; - output += "LocalY: " + LocalY.ToString() + "\n"; - output += "Status: " + Status.ToString() + "\n"; - output += "SecureSessionID: " + SecureSessionID.ToString() + "\n"; - output += "EstateID: " + EstateID.ToString() + "\n"; - output += "TimeToLive: " + TimeToLive.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "LocalX: " + LocalX.ToString() + "\n"; + output += "LocalY: " + LocalY.ToString() + "\n"; + output += "Status: " + Status.ToString() + "\n"; + output += "SecureSessionID: " + SecureSessionID.ToString() + "\n"; + output += "EstateID: " + EstateID.ToString() + "\n"; + output += "TimeToLive: " + TimeToLive.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.RecordAgentPresence - public override PacketType Type { get { return PacketType.RecordAgentPresence; } } - /// RegionData block - public RegionDataBlock RegionData; - /// AgentData block - public AgentDataBlock[] AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.RecordAgentPresence + public override PacketType Type { get { return PacketType.RecordAgentPresence; } } + /// RegionData block + public RegionDataBlock RegionData; + /// AgentData block + public AgentDataBlock[] AgentData; + + /// Default constructor public RecordAgentPresencePacket() - { - Header = new LowHeader(); - Header.ID = 23; - Header.Reliable = true; - RegionData = new RegionDataBlock(); - AgentData = new AgentDataBlock[0]; + { + Header = new LowHeader(); + Header.ID = 23; + Header.Reliable = true; + RegionData = new RegionDataBlock(); + AgentData = new AgentDataBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public RecordAgentPresencePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - RegionData = new RegionDataBlock(bytes, ref i); - int count = (int)bytes[i++]; - AgentData = new AgentDataBlock[count]; - for (int j = 0; j < count; j++) - { AgentData[j] = new AgentDataBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + RegionData = new RegionDataBlock(bytes, ref i); + int count = (int)bytes[i++]; + AgentData = new AgentDataBlock[count]; + for (int j = 0; j < count; j++) + { AgentData[j] = new AgentDataBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public RecordAgentPresencePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - RegionData = new RegionDataBlock(bytes, ref i); - int count = (int)bytes[i++]; - AgentData = new AgentDataBlock[count]; - for (int j = 0; j < count; j++) - { AgentData[j] = new AgentDataBlock(bytes, ref i); } + { + Header = head; + RegionData = new RegionDataBlock(bytes, ref i); + int count = (int)bytes[i++]; + AgentData = new AgentDataBlock[count]; + for (int j = 0; j < count; j++) + { AgentData[j] = new AgentDataBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += RegionData.Length;; - length++; - for (int j = 0; j < AgentData.Length; j++) { length += AgentData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - RegionData.ToBytes(bytes, ref i); - bytes[i++] = (byte)AgentData.Length; - for (int j = 0; j < AgentData.Length; j++) { AgentData[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += RegionData.Length;; + length++; + for (int j = 0; j < AgentData.Length; j++) { length += AgentData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + RegionData.ToBytes(bytes, ref i); + bytes[i++] = (byte)AgentData.Length; + for (int j = 0; j < AgentData.Length; j++) { AgentData[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- RecordAgentPresence ---\n"; - output += RegionData.ToString() + "\n"; + { + string output = "--- RecordAgentPresence ---\n"; + output += RegionData.ToString() + "\n"; for (int j = 0; j < AgentData.Length; j++) - { + { output += AgentData[j].ToString() + "\n"; - } + } return output; } - + } - - /// EraseAgentPresence packet + + /// EraseAgentPresence packet public class EraseAgentPresencePacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.EraseAgentPresence - public override PacketType Type { get { return PacketType.EraseAgentPresence; } } - /// AgentData block - public AgentDataBlock[] AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.EraseAgentPresence + public override PacketType Type { get { return PacketType.EraseAgentPresence; } } + /// AgentData block + public AgentDataBlock[] AgentData; + + /// Default constructor public EraseAgentPresencePacket() - { - Header = new LowHeader(); - Header.ID = 24; - Header.Reliable = true; - AgentData = new AgentDataBlock[0]; + { + Header = new LowHeader(); + Header.ID = 24; + Header.Reliable = true; + AgentData = new AgentDataBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public EraseAgentPresencePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - AgentData = new AgentDataBlock[count]; - for (int j = 0; j < count; j++) - { AgentData[j] = new AgentDataBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + AgentData = new AgentDataBlock[count]; + for (int j = 0; j < count; j++) + { AgentData[j] = new AgentDataBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public EraseAgentPresencePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - AgentData = new AgentDataBlock[count]; - for (int j = 0; j < count; j++) - { AgentData[j] = new AgentDataBlock(bytes, ref i); } + { + Header = head; + int count = (int)bytes[i++]; + AgentData = new AgentDataBlock[count]; + for (int j = 0; j < count; j++) + { AgentData[j] = new AgentDataBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; -; - length++; - for (int j = 0; j < AgentData.Length; j++) { length += AgentData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)AgentData.Length; - for (int j = 0; j < AgentData.Length; j++) { AgentData[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; +; + length++; + for (int j = 0; j < AgentData.Length; j++) { length += AgentData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)AgentData.Length; + for (int j = 0; j < AgentData.Length; j++) { AgentData[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- EraseAgentPresence ---\n"; + { + string output = "--- EraseAgentPresence ---\n"; for (int j = 0; j < AgentData.Length; j++) - { + { output += AgentData[j].ToString() + "\n"; - } + } return output; } - + } - - /// AgentPresenceRequest packet + + /// AgentPresenceRequest packet public class AgentPresenceRequestPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AgentPresenceRequest - public override PacketType Type { get { return PacketType.AgentPresenceRequest; } } - /// AgentData block - public AgentDataBlock[] AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AgentPresenceRequest + public override PacketType Type { get { return PacketType.AgentPresenceRequest; } } + /// AgentData block + public AgentDataBlock[] AgentData; + + /// Default constructor public AgentPresenceRequestPacket() - { - Header = new LowHeader(); - Header.ID = 25; - Header.Reliable = true; - AgentData = new AgentDataBlock[0]; + { + Header = new LowHeader(); + Header.ID = 25; + Header.Reliable = true; + AgentData = new AgentDataBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AgentPresenceRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - AgentData = new AgentDataBlock[count]; - for (int j = 0; j < count; j++) - { AgentData[j] = new AgentDataBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + AgentData = new AgentDataBlock[count]; + for (int j = 0; j < count; j++) + { AgentData[j] = new AgentDataBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AgentPresenceRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - AgentData = new AgentDataBlock[count]; - for (int j = 0; j < count; j++) - { AgentData[j] = new AgentDataBlock(bytes, ref i); } + { + Header = head; + int count = (int)bytes[i++]; + AgentData = new AgentDataBlock[count]; + for (int j = 0; j < count; j++) + { AgentData[j] = new AgentDataBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; -; - length++; - for (int j = 0; j < AgentData.Length; j++) { length += AgentData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)AgentData.Length; - for (int j = 0; j < AgentData.Length; j++) { AgentData[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; +; + length++; + for (int j = 0; j < AgentData.Length; j++) { length += AgentData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)AgentData.Length; + for (int j = 0; j < AgentData.Length; j++) { AgentData[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AgentPresenceRequest ---\n"; + { + string output = "--- AgentPresenceRequest ---\n"; for (int j = 0; j < AgentData.Length; j++) - { + { output += AgentData[j].ToString() + "\n"; - } + } return output; } - + } - - /// AgentPresenceResponse packet + + /// AgentPresenceResponse packet public class AgentPresenceResponsePacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// ValidUntil field - public double ValidUntil; - /// RegionIP field - public uint RegionIP; - /// RegionPort field - public ushort RegionPort; - /// EstateID field - public uint EstateID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// ValidUntil field + public double ValidUntil; + /// RegionIP field + public uint RegionIP; + /// RegionPort field + public ushort RegionPort; + /// EstateID field + public uint EstateID; + + /// Length of this block serialized in bytes public int Length { get - { - return 34; + { + return 34; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 8); - ValidUntil = BitConverter.ToDouble(bytes, i); i += 8; - RegionIP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - RegionPort = (ushort)((bytes[i++] << 8) + bytes[i++]); - EstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + AgentID = new LLUUID(bytes, i); i += 16; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 8); + ValidUntil = BitConverter.ToDouble(bytes, i); i += 8; + RegionIP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + RegionPort = (ushort)((bytes[i++] << 8) + bytes[i++]); + EstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + byte[] ba; + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; ba = BitConverter.GetBytes(ValidUntil); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 8); } - Array.Copy(ba, 0, bytes, i, 8); i += 8; - bytes[i++] = (byte)(RegionIP % 256); - bytes[i++] = (byte)((RegionIP >> 8) % 256); - bytes[i++] = (byte)((RegionIP >> 16) % 256); - bytes[i++] = (byte)((RegionIP >> 24) % 256); - bytes[i++] = (byte)((RegionPort >> 8) % 256); - bytes[i++] = (byte)(RegionPort % 256); - bytes[i++] = (byte)(EstateID % 256); - bytes[i++] = (byte)((EstateID >> 8) % 256); - bytes[i++] = (byte)((EstateID >> 16) % 256); - bytes[i++] = (byte)((EstateID >> 24) % 256); + Array.Copy(ba, 0, bytes, i, 8); i += 8; + bytes[i++] = (byte)(RegionIP % 256); + bytes[i++] = (byte)((RegionIP >> 8) % 256); + bytes[i++] = (byte)((RegionIP >> 16) % 256); + bytes[i++] = (byte)((RegionIP >> 24) % 256); + bytes[i++] = (byte)((RegionPort >> 8) % 256); + bytes[i++] = (byte)(RegionPort % 256); + bytes[i++] = (byte)(EstateID % 256); + bytes[i++] = (byte)((EstateID >> 8) % 256); + bytes[i++] = (byte)((EstateID >> 16) % 256); + bytes[i++] = (byte)((EstateID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "ValidUntil: " + ValidUntil.ToString() + "\n"; - output += "RegionIP: " + RegionIP.ToString() + "\n"; - output += "RegionPort: " + RegionPort.ToString() + "\n"; - output += "EstateID: " + EstateID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "ValidUntil: " + ValidUntil.ToString() + "\n"; + output += "RegionIP: " + RegionIP.ToString() + "\n"; + output += "RegionPort: " + RegionPort.ToString() + "\n"; + output += "EstateID: " + EstateID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AgentPresenceResponse - public override PacketType Type { get { return PacketType.AgentPresenceResponse; } } - /// AgentData block - public AgentDataBlock[] AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AgentPresenceResponse + public override PacketType Type { get { return PacketType.AgentPresenceResponse; } } + /// AgentData block + public AgentDataBlock[] AgentData; + + /// Default constructor public AgentPresenceResponsePacket() - { - Header = new LowHeader(); - Header.ID = 26; - Header.Reliable = true; - AgentData = new AgentDataBlock[0]; + { + Header = new LowHeader(); + Header.ID = 26; + Header.Reliable = true; + AgentData = new AgentDataBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AgentPresenceResponsePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - AgentData = new AgentDataBlock[count]; - for (int j = 0; j < count; j++) - { AgentData[j] = new AgentDataBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + AgentData = new AgentDataBlock[count]; + for (int j = 0; j < count; j++) + { AgentData[j] = new AgentDataBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AgentPresenceResponsePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - AgentData = new AgentDataBlock[count]; - for (int j = 0; j < count; j++) - { AgentData[j] = new AgentDataBlock(bytes, ref i); } + { + Header = head; + int count = (int)bytes[i++]; + AgentData = new AgentDataBlock[count]; + for (int j = 0; j < count; j++) + { AgentData[j] = new AgentDataBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; -; - length++; - for (int j = 0; j < AgentData.Length; j++) { length += AgentData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)AgentData.Length; - for (int j = 0; j < AgentData.Length; j++) { AgentData[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; +; + length++; + for (int j = 0; j < AgentData.Length; j++) { length += AgentData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)AgentData.Length; + for (int j = 0; j < AgentData.Length; j++) { AgentData[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AgentPresenceResponse ---\n"; + { + string output = "--- AgentPresenceResponse ---\n"; for (int j = 0; j < AgentData.Length; j++) - { + { output += AgentData[j].ToString() + "\n"; - } + } return output; } - + } - - /// UpdateSimulator packet + + /// UpdateSimulator packet public class UpdateSimulatorPacket : Packet - { - /// SimulatorInfo block + { + /// SimulatorInfo block public class SimulatorInfoBlock - { - private byte[] _simname; - /// SimName field + { + private byte[] _simname; + /// SimName field public byte[] SimName - { - get { return _simname; } + { + get { return _simname; } set - { - if (value == null) { _simname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _simname = new byte[value.Length]; Array.Copy(value, _simname, value.Length); } + { + if (value == null) { _simname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _simname = new byte[value.Length]; Array.Copy(value, _simname, value.Length); } } - } - /// RegionID field - public LLUUID RegionID; - /// SimAccess field - public byte SimAccess; - /// EstateID field - public uint EstateID; - - /// Length of this block serialized in bytes + } + /// RegionID field + public LLUUID RegionID; + /// SimAccess field + public byte SimAccess; + /// EstateID field + public uint EstateID; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 21; - if (SimName != null) { length += 1 + SimName.Length; } - return length; + { + int length = 21; + if (SimName != null) { length += 1 + SimName.Length; } + return length; } } - - /// Default constructor - public SimulatorInfoBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public SimulatorInfoBlock() { } + /// Constructor for building the block from a byte array public SimulatorInfoBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _simname = new byte[length]; - Array.Copy(bytes, i, _simname, 0, length); i += length; - RegionID = new LLUUID(bytes, i); i += 16; - SimAccess = (byte)bytes[i++]; - EstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + length = (ushort)bytes[i++]; + _simname = new byte[length]; + Array.Copy(bytes, i, _simname, 0, length); i += length; + RegionID = new LLUUID(bytes, i); i += 16; + SimAccess = (byte)bytes[i++]; + EstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(SimName == null) { Console.WriteLine("Warning: SimName is null, in " + this.GetType()); } - bytes[i++] = (byte)SimName.Length; - Array.Copy(SimName, 0, bytes, i, SimName.Length); i += SimName.Length; - if(RegionID == null) { Console.WriteLine("Warning: RegionID is null, in " + this.GetType()); } - Array.Copy(RegionID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = SimAccess; - bytes[i++] = (byte)(EstateID % 256); - bytes[i++] = (byte)((EstateID >> 8) % 256); - bytes[i++] = (byte)((EstateID >> 16) % 256); - bytes[i++] = (byte)((EstateID >> 24) % 256); + { + if(SimName == null) { Console.WriteLine("Warning: SimName is null, in " + this.GetType()); } + bytes[i++] = (byte)SimName.Length; + Array.Copy(SimName, 0, bytes, i, SimName.Length); i += SimName.Length; + if(RegionID == null) { Console.WriteLine("Warning: RegionID is null, in " + this.GetType()); } + Array.Copy(RegionID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = SimAccess; + bytes[i++] = (byte)(EstateID % 256); + bytes[i++] = (byte)((EstateID >> 8) % 256); + bytes[i++] = (byte)((EstateID >> 16) % 256); + bytes[i++] = (byte)((EstateID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- SimulatorInfo --\n"; - output += Helpers.FieldToString(SimName, "SimName") + "\n"; - output += "RegionID: " + RegionID.ToString() + "\n"; - output += "SimAccess: " + SimAccess.ToString() + "\n"; - output += "EstateID: " + EstateID.ToString() + "\n"; + { + string output = "-- SimulatorInfo --\n"; + output += Helpers.FieldToString(SimName, "SimName") + "\n"; + output += "RegionID: " + RegionID.ToString() + "\n"; + output += "SimAccess: " + SimAccess.ToString() + "\n"; + output += "EstateID: " + EstateID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.UpdateSimulator - public override PacketType Type { get { return PacketType.UpdateSimulator; } } - /// SimulatorInfo block - public SimulatorInfoBlock SimulatorInfo; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.UpdateSimulator + public override PacketType Type { get { return PacketType.UpdateSimulator; } } + /// SimulatorInfo block + public SimulatorInfoBlock SimulatorInfo; + + /// Default constructor public UpdateSimulatorPacket() - { - Header = new LowHeader(); - Header.ID = 27; - Header.Reliable = true; - SimulatorInfo = new SimulatorInfoBlock(); + { + Header = new LowHeader(); + Header.ID = 27; + Header.Reliable = true; + SimulatorInfo = new SimulatorInfoBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public UpdateSimulatorPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - SimulatorInfo = new SimulatorInfoBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + SimulatorInfo = new SimulatorInfoBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public UpdateSimulatorPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - SimulatorInfo = new SimulatorInfoBlock(bytes, ref i); + { + Header = head; + SimulatorInfo = new SimulatorInfoBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += SimulatorInfo.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - SimulatorInfo.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += SimulatorInfo.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + SimulatorInfo.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- UpdateSimulator ---\n"; - output += SimulatorInfo.ToString() + "\n"; + { + string output = "--- UpdateSimulator ---\n"; + output += SimulatorInfo.ToString() + "\n"; return output; } - + } - - /// TrackAgentSession packet + + /// TrackAgentSession packet public class TrackAgentSessionPacket : Packet - { - /// SessionInfo block + { + /// SessionInfo block public class SessionInfoBlock - { - /// GlobalX field - public double GlobalX; - /// GlobalY field - public double GlobalY; - /// SessionID field - public LLUUID SessionID; - /// ViewerPort field - public ushort ViewerPort; - /// ViewerIP field - public uint ViewerIP; - - /// Length of this block serialized in bytes + { + /// GlobalX field + public double GlobalX; + /// GlobalY field + public double GlobalY; + /// SessionID field + public LLUUID SessionID; + /// ViewerPort field + public ushort ViewerPort; + /// ViewerIP field + public uint ViewerIP; + + /// Length of this block serialized in bytes public int Length { get - { - return 38; + { + return 38; } } - - /// Default constructor - public SessionInfoBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public SessionInfoBlock() { } + /// Constructor for building the block from a byte array public SessionInfoBlock(byte[] bytes, ref int i) - { + { try - { - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 8); - GlobalX = BitConverter.ToDouble(bytes, i); i += 8; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 8); - GlobalY = BitConverter.ToDouble(bytes, i); i += 8; - SessionID = new LLUUID(bytes, i); i += 16; - ViewerPort = (ushort)((bytes[i++] << 8) + bytes[i++]); - ViewerIP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 8); + GlobalX = BitConverter.ToDouble(bytes, i); i += 8; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 8); + GlobalY = BitConverter.ToDouble(bytes, i); i += 8; + SessionID = new LLUUID(bytes, i); i += 16; + ViewerPort = (ushort)((bytes[i++] << 8) + bytes[i++]); + ViewerIP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; + { + byte[] ba; ba = BitConverter.GetBytes(GlobalX); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 8); } - Array.Copy(ba, 0, bytes, i, 8); i += 8; + Array.Copy(ba, 0, bytes, i, 8); i += 8; ba = BitConverter.GetBytes(GlobalY); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 8); } - Array.Copy(ba, 0, bytes, i, 8); i += 8; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((ViewerPort >> 8) % 256); - bytes[i++] = (byte)(ViewerPort % 256); - bytes[i++] = (byte)(ViewerIP % 256); - bytes[i++] = (byte)((ViewerIP >> 8) % 256); - bytes[i++] = (byte)((ViewerIP >> 16) % 256); - bytes[i++] = (byte)((ViewerIP >> 24) % 256); + Array.Copy(ba, 0, bytes, i, 8); i += 8; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((ViewerPort >> 8) % 256); + bytes[i++] = (byte)(ViewerPort % 256); + bytes[i++] = (byte)(ViewerIP % 256); + bytes[i++] = (byte)((ViewerIP >> 8) % 256); + bytes[i++] = (byte)((ViewerIP >> 16) % 256); + bytes[i++] = (byte)((ViewerIP >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- SessionInfo --\n"; - output += "GlobalX: " + GlobalX.ToString() + "\n"; - output += "GlobalY: " + GlobalY.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "ViewerPort: " + ViewerPort.ToString() + "\n"; - output += "ViewerIP: " + ViewerIP.ToString() + "\n"; + { + string output = "-- SessionInfo --\n"; + output += "GlobalX: " + GlobalX.ToString() + "\n"; + output += "GlobalY: " + GlobalY.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "ViewerPort: " + ViewerPort.ToString() + "\n"; + output += "ViewerIP: " + ViewerIP.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// RegionData block + + /// RegionData block public class RegionDataBlock - { - /// RegionX field - public float RegionX; - /// RegionY field - public float RegionY; - /// SpaceIP field - public uint SpaceIP; - /// AgentCount field - public uint AgentCount; - /// EstateID field - public uint EstateID; - - /// Length of this block serialized in bytes + { + /// RegionX field + public float RegionX; + /// RegionY field + public float RegionY; + /// SpaceIP field + public uint SpaceIP; + /// AgentCount field + public uint AgentCount; + /// EstateID field + public uint EstateID; + + /// Length of this block serialized in bytes public int Length { get - { - return 20; + { + return 20; } } - - /// Default constructor - public RegionDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public RegionDataBlock() { } + /// Constructor for building the block from a byte array public RegionDataBlock(byte[] bytes, ref int i) - { + { try - { - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - RegionX = BitConverter.ToSingle(bytes, i); i += 4; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - RegionY = BitConverter.ToSingle(bytes, i); i += 4; - SpaceIP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - AgentCount = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - EstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + RegionX = BitConverter.ToSingle(bytes, i); i += 4; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + RegionY = BitConverter.ToSingle(bytes, i); i += 4; + SpaceIP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + AgentCount = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + EstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; + { + byte[] ba; ba = BitConverter.GetBytes(RegionX); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; ba = BitConverter.GetBytes(RegionY); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - bytes[i++] = (byte)(SpaceIP % 256); - bytes[i++] = (byte)((SpaceIP >> 8) % 256); - bytes[i++] = (byte)((SpaceIP >> 16) % 256); - bytes[i++] = (byte)((SpaceIP >> 24) % 256); - bytes[i++] = (byte)(AgentCount % 256); - bytes[i++] = (byte)((AgentCount >> 8) % 256); - bytes[i++] = (byte)((AgentCount >> 16) % 256); - bytes[i++] = (byte)((AgentCount >> 24) % 256); - bytes[i++] = (byte)(EstateID % 256); - bytes[i++] = (byte)((EstateID >> 8) % 256); - bytes[i++] = (byte)((EstateID >> 16) % 256); - bytes[i++] = (byte)((EstateID >> 24) % 256); + Array.Copy(ba, 0, bytes, i, 4); i += 4; + bytes[i++] = (byte)(SpaceIP % 256); + bytes[i++] = (byte)((SpaceIP >> 8) % 256); + bytes[i++] = (byte)((SpaceIP >> 16) % 256); + bytes[i++] = (byte)((SpaceIP >> 24) % 256); + bytes[i++] = (byte)(AgentCount % 256); + bytes[i++] = (byte)((AgentCount >> 8) % 256); + bytes[i++] = (byte)((AgentCount >> 16) % 256); + bytes[i++] = (byte)((AgentCount >> 24) % 256); + bytes[i++] = (byte)(EstateID % 256); + bytes[i++] = (byte)((EstateID >> 8) % 256); + bytes[i++] = (byte)((EstateID >> 16) % 256); + bytes[i++] = (byte)((EstateID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- RegionData --\n"; - output += "RegionX: " + RegionX.ToString() + "\n"; - output += "RegionY: " + RegionY.ToString() + "\n"; - output += "SpaceIP: " + SpaceIP.ToString() + "\n"; - output += "AgentCount: " + AgentCount.ToString() + "\n"; - output += "EstateID: " + EstateID.ToString() + "\n"; + { + string output = "-- RegionData --\n"; + output += "RegionX: " + RegionX.ToString() + "\n"; + output += "RegionY: " + RegionY.ToString() + "\n"; + output += "SpaceIP: " + SpaceIP.ToString() + "\n"; + output += "AgentCount: " + AgentCount.ToString() + "\n"; + output += "EstateID: " + EstateID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.TrackAgentSession - public override PacketType Type { get { return PacketType.TrackAgentSession; } } - /// SessionInfo block - public SessionInfoBlock[] SessionInfo; - /// RegionData block - public RegionDataBlock RegionData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.TrackAgentSession + public override PacketType Type { get { return PacketType.TrackAgentSession; } } + /// SessionInfo block + public SessionInfoBlock[] SessionInfo; + /// RegionData block + public RegionDataBlock RegionData; + + /// Default constructor public TrackAgentSessionPacket() - { - Header = new LowHeader(); - Header.ID = 28; - Header.Reliable = true; - SessionInfo = new SessionInfoBlock[0]; - RegionData = new RegionDataBlock(); + { + Header = new LowHeader(); + Header.ID = 28; + Header.Reliable = true; + SessionInfo = new SessionInfoBlock[0]; + RegionData = new RegionDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public TrackAgentSessionPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - SessionInfo = new SessionInfoBlock[count]; - for (int j = 0; j < count; j++) - { SessionInfo[j] = new SessionInfoBlock(bytes, ref i); } - RegionData = new RegionDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + SessionInfo = new SessionInfoBlock[count]; + for (int j = 0; j < count; j++) + { SessionInfo[j] = new SessionInfoBlock(bytes, ref i); } + RegionData = new RegionDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public TrackAgentSessionPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - SessionInfo = new SessionInfoBlock[count]; - for (int j = 0; j < count; j++) - { SessionInfo[j] = new SessionInfoBlock(bytes, ref i); } - RegionData = new RegionDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + SessionInfo = new SessionInfoBlock[count]; + for (int j = 0; j < count; j++) + { SessionInfo[j] = new SessionInfoBlock(bytes, ref i); } + RegionData = new RegionDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += RegionData.Length;; - length++; - for (int j = 0; j < SessionInfo.Length; j++) { length += SessionInfo[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)SessionInfo.Length; - for (int j = 0; j < SessionInfo.Length; j++) { SessionInfo[j].ToBytes(bytes, ref i); } - RegionData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += RegionData.Length;; + length++; + for (int j = 0; j < SessionInfo.Length; j++) { length += SessionInfo[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)SessionInfo.Length; + for (int j = 0; j < SessionInfo.Length; j++) { SessionInfo[j].ToBytes(bytes, ref i); } + RegionData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- TrackAgentSession ---\n"; + { + string output = "--- TrackAgentSession ---\n"; for (int j = 0; j < SessionInfo.Length; j++) - { + { output += SessionInfo[j].ToString() + "\n"; - } - output += RegionData.ToString() + "\n"; + } + output += RegionData.ToString() + "\n"; return output; } - + } - - /// ClearAgentSessions packet + + /// ClearAgentSessions packet public class ClearAgentSessionsPacket : Packet - { - /// RegionInfo block + { + /// RegionInfo block public class RegionInfoBlock - { - /// RegionX field - public uint RegionX; - /// RegionY field - public uint RegionY; - /// SpaceIP field - public uint SpaceIP; - - /// Length of this block serialized in bytes + { + /// RegionX field + public uint RegionX; + /// RegionY field + public uint RegionY; + /// SpaceIP field + public uint SpaceIP; + + /// Length of this block serialized in bytes public int Length { get - { - return 12; + { + return 12; } } - - /// Default constructor - public RegionInfoBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public RegionInfoBlock() { } + /// Constructor for building the block from a byte array public RegionInfoBlock(byte[] bytes, ref int i) - { + { try - { - RegionX = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - RegionY = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - SpaceIP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + RegionX = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + RegionY = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + SpaceIP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(RegionX % 256); - bytes[i++] = (byte)((RegionX >> 8) % 256); - bytes[i++] = (byte)((RegionX >> 16) % 256); - bytes[i++] = (byte)((RegionX >> 24) % 256); - bytes[i++] = (byte)(RegionY % 256); - bytes[i++] = (byte)((RegionY >> 8) % 256); - bytes[i++] = (byte)((RegionY >> 16) % 256); - bytes[i++] = (byte)((RegionY >> 24) % 256); - bytes[i++] = (byte)(SpaceIP % 256); - bytes[i++] = (byte)((SpaceIP >> 8) % 256); - bytes[i++] = (byte)((SpaceIP >> 16) % 256); - bytes[i++] = (byte)((SpaceIP >> 24) % 256); + { + bytes[i++] = (byte)(RegionX % 256); + bytes[i++] = (byte)((RegionX >> 8) % 256); + bytes[i++] = (byte)((RegionX >> 16) % 256); + bytes[i++] = (byte)((RegionX >> 24) % 256); + bytes[i++] = (byte)(RegionY % 256); + bytes[i++] = (byte)((RegionY >> 8) % 256); + bytes[i++] = (byte)((RegionY >> 16) % 256); + bytes[i++] = (byte)((RegionY >> 24) % 256); + bytes[i++] = (byte)(SpaceIP % 256); + bytes[i++] = (byte)((SpaceIP >> 8) % 256); + bytes[i++] = (byte)((SpaceIP >> 16) % 256); + bytes[i++] = (byte)((SpaceIP >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- RegionInfo --\n"; - output += "RegionX: " + RegionX.ToString() + "\n"; - output += "RegionY: " + RegionY.ToString() + "\n"; - output += "SpaceIP: " + SpaceIP.ToString() + "\n"; + { + string output = "-- RegionInfo --\n"; + output += "RegionX: " + RegionX.ToString() + "\n"; + output += "RegionY: " + RegionY.ToString() + "\n"; + output += "SpaceIP: " + SpaceIP.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ClearAgentSessions - public override PacketType Type { get { return PacketType.ClearAgentSessions; } } - /// RegionInfo block - public RegionInfoBlock RegionInfo; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ClearAgentSessions + public override PacketType Type { get { return PacketType.ClearAgentSessions; } } + /// RegionInfo block + public RegionInfoBlock RegionInfo; + + /// Default constructor public ClearAgentSessionsPacket() - { - Header = new LowHeader(); - Header.ID = 29; - Header.Reliable = true; - RegionInfo = new RegionInfoBlock(); + { + Header = new LowHeader(); + Header.ID = 29; + Header.Reliable = true; + RegionInfo = new RegionInfoBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ClearAgentSessionsPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - RegionInfo = new RegionInfoBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + RegionInfo = new RegionInfoBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ClearAgentSessionsPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - RegionInfo = new RegionInfoBlock(bytes, ref i); + { + Header = head; + RegionInfo = new RegionInfoBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += RegionInfo.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - RegionInfo.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += RegionInfo.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + RegionInfo.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ClearAgentSessions ---\n"; - output += RegionInfo.ToString() + "\n"; + { + string output = "--- ClearAgentSessions ---\n"; + output += RegionInfo.ToString() + "\n"; return output; } - + } - - /// LogDwellTime packet + + /// LogDwellTime packet public class LogDwellTimePacket : Packet - { - /// DwellInfo block + { + /// DwellInfo block public class DwellInfoBlock - { - /// Duration field - public float Duration; - private byte[] _simname; - /// SimName field + { + /// Duration field + public float Duration; + private byte[] _simname; + /// SimName field public byte[] SimName - { - get { return _simname; } + { + get { return _simname; } set - { - if (value == null) { _simname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _simname = new byte[value.Length]; Array.Copy(value, _simname, value.Length); } + { + if (value == null) { _simname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _simname = new byte[value.Length]; Array.Copy(value, _simname, value.Length); } } - } - /// AgentID field - public LLUUID AgentID; - /// RegionX field - public uint RegionX; - /// RegionY field - public uint RegionY; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + } + /// AgentID field + public LLUUID AgentID; + /// RegionX field + public uint RegionX; + /// RegionY field + public uint RegionY; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 44; - if (SimName != null) { length += 1 + SimName.Length; } - return length; + { + int length = 44; + if (SimName != null) { length += 1 + SimName.Length; } + return length; } } - - /// Default constructor - public DwellInfoBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DwellInfoBlock() { } + /// Constructor for building the block from a byte array public DwellInfoBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - Duration = BitConverter.ToSingle(bytes, i); i += 4; - length = (ushort)bytes[i++]; - _simname = new byte[length]; - Array.Copy(bytes, i, _simname, 0, length); i += length; - AgentID = new LLUUID(bytes, i); i += 16; - RegionX = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - RegionY = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - SessionID = new LLUUID(bytes, i); i += 16; + { + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + Duration = BitConverter.ToSingle(bytes, i); i += 4; + length = (ushort)bytes[i++]; + _simname = new byte[length]; + Array.Copy(bytes, i, _simname, 0, length); i += length; + AgentID = new LLUUID(bytes, i); i += 16; + RegionX = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + RegionY = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; + { + byte[] ba; ba = BitConverter.GetBytes(Duration); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - if(SimName == null) { Console.WriteLine("Warning: SimName is null, in " + this.GetType()); } - bytes[i++] = (byte)SimName.Length; - Array.Copy(SimName, 0, bytes, i, SimName.Length); i += SimName.Length; - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(RegionX % 256); - bytes[i++] = (byte)((RegionX >> 8) % 256); - bytes[i++] = (byte)((RegionX >> 16) % 256); - bytes[i++] = (byte)((RegionX >> 24) % 256); - bytes[i++] = (byte)(RegionY % 256); - bytes[i++] = (byte)((RegionY >> 8) % 256); - bytes[i++] = (byte)((RegionY >> 16) % 256); - bytes[i++] = (byte)((RegionY >> 24) % 256); - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + Array.Copy(ba, 0, bytes, i, 4); i += 4; + if(SimName == null) { Console.WriteLine("Warning: SimName is null, in " + this.GetType()); } + bytes[i++] = (byte)SimName.Length; + Array.Copy(SimName, 0, bytes, i, SimName.Length); i += SimName.Length; + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(RegionX % 256); + bytes[i++] = (byte)((RegionX >> 8) % 256); + bytes[i++] = (byte)((RegionX >> 16) % 256); + bytes[i++] = (byte)((RegionX >> 24) % 256); + bytes[i++] = (byte)(RegionY % 256); + bytes[i++] = (byte)((RegionY >> 8) % 256); + bytes[i++] = (byte)((RegionY >> 16) % 256); + bytes[i++] = (byte)((RegionY >> 24) % 256); + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- DwellInfo --\n"; - output += "Duration: " + Duration.ToString() + "\n"; - output += Helpers.FieldToString(SimName, "SimName") + "\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "RegionX: " + RegionX.ToString() + "\n"; - output += "RegionY: " + RegionY.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- DwellInfo --\n"; + output += "Duration: " + Duration.ToString() + "\n"; + output += Helpers.FieldToString(SimName, "SimName") + "\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "RegionX: " + RegionX.ToString() + "\n"; + output += "RegionY: " + RegionY.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.LogDwellTime - public override PacketType Type { get { return PacketType.LogDwellTime; } } - /// DwellInfo block - public DwellInfoBlock DwellInfo; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.LogDwellTime + public override PacketType Type { get { return PacketType.LogDwellTime; } } + /// DwellInfo block + public DwellInfoBlock DwellInfo; + + /// Default constructor public LogDwellTimePacket() - { - Header = new LowHeader(); - Header.ID = 30; - Header.Reliable = true; - DwellInfo = new DwellInfoBlock(); + { + Header = new LowHeader(); + Header.ID = 30; + Header.Reliable = true; + DwellInfo = new DwellInfoBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public LogDwellTimePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - DwellInfo = new DwellInfoBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + DwellInfo = new DwellInfoBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public LogDwellTimePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - DwellInfo = new DwellInfoBlock(bytes, ref i); + { + Header = head; + DwellInfo = new DwellInfoBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += DwellInfo.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - DwellInfo.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += DwellInfo.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + DwellInfo.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- LogDwellTime ---\n"; - output += DwellInfo.ToString() + "\n"; + { + string output = "--- LogDwellTime ---\n"; + output += DwellInfo.ToString() + "\n"; return output; } - + } - - /// FeatureDisabled packet + + /// FeatureDisabled packet public class FeatureDisabledPacket : Packet - { - /// FailureInfo block + { + /// FailureInfo block public class FailureInfoBlock - { - /// AgentID field - public LLUUID AgentID; - private byte[] _errormessage; - /// ErrorMessage field + { + /// AgentID field + public LLUUID AgentID; + private byte[] _errormessage; + /// ErrorMessage field public byte[] ErrorMessage - { - get { return _errormessage; } + { + get { return _errormessage; } set - { - if (value == null) { _errormessage = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _errormessage = new byte[value.Length]; Array.Copy(value, _errormessage, value.Length); } + { + if (value == null) { _errormessage = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _errormessage = new byte[value.Length]; Array.Copy(value, _errormessage, value.Length); } } - } - /// TransactionID field - public LLUUID TransactionID; - - /// Length of this block serialized in bytes + } + /// TransactionID field + public LLUUID TransactionID; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 32; - if (ErrorMessage != null) { length += 1 + ErrorMessage.Length; } - return length; + { + int length = 32; + if (ErrorMessage != null) { length += 1 + ErrorMessage.Length; } + return length; } } - - /// Default constructor - public FailureInfoBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public FailureInfoBlock() { } + /// Constructor for building the block from a byte array public FailureInfoBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - AgentID = new LLUUID(bytes, i); i += 16; - length = (ushort)bytes[i++]; - _errormessage = new byte[length]; - Array.Copy(bytes, i, _errormessage, 0, length); i += length; - TransactionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + length = (ushort)bytes[i++]; + _errormessage = new byte[length]; + Array.Copy(bytes, i, _errormessage, 0, length); i += length; + TransactionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(ErrorMessage == null) { Console.WriteLine("Warning: ErrorMessage is null, in " + this.GetType()); } - bytes[i++] = (byte)ErrorMessage.Length; - Array.Copy(ErrorMessage, 0, bytes, i, ErrorMessage.Length); i += ErrorMessage.Length; - if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } - Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(ErrorMessage == null) { Console.WriteLine("Warning: ErrorMessage is null, in " + this.GetType()); } + bytes[i++] = (byte)ErrorMessage.Length; + Array.Copy(ErrorMessage, 0, bytes, i, ErrorMessage.Length); i += ErrorMessage.Length; + if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } + Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- FailureInfo --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += Helpers.FieldToString(ErrorMessage, "ErrorMessage") + "\n"; - output += "TransactionID: " + TransactionID.ToString() + "\n"; + { + string output = "-- FailureInfo --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += Helpers.FieldToString(ErrorMessage, "ErrorMessage") + "\n"; + output += "TransactionID: " + TransactionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.FeatureDisabled - public override PacketType Type { get { return PacketType.FeatureDisabled; } } - /// FailureInfo block - public FailureInfoBlock FailureInfo; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.FeatureDisabled + public override PacketType Type { get { return PacketType.FeatureDisabled; } } + /// FailureInfo block + public FailureInfoBlock FailureInfo; + + /// Default constructor public FeatureDisabledPacket() - { - Header = new LowHeader(); - Header.ID = 31; - Header.Reliable = true; - FailureInfo = new FailureInfoBlock(); + { + Header = new LowHeader(); + Header.ID = 31; + Header.Reliable = true; + FailureInfo = new FailureInfoBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public FeatureDisabledPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - FailureInfo = new FailureInfoBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + FailureInfo = new FailureInfoBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public FeatureDisabledPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - FailureInfo = new FailureInfoBlock(bytes, ref i); + { + Header = head; + FailureInfo = new FailureInfoBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += FailureInfo.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - FailureInfo.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += FailureInfo.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + FailureInfo.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- FeatureDisabled ---\n"; - output += FailureInfo.ToString() + "\n"; + { + string output = "--- FeatureDisabled ---\n"; + output += FailureInfo.ToString() + "\n"; return output; } - + } - - /// LogFailedMoneyTransaction packet + + /// LogFailedMoneyTransaction packet public class LogFailedMoneyTransactionPacket : Packet - { - /// TransactionData block + { + /// TransactionData block public class TransactionDataBlock - { - /// FailureType field - public byte FailureType; - /// DestID field - public LLUUID DestID; - /// Amount field - public int Amount; - /// SimulatorIP field - public uint SimulatorIP; - /// Flags field - public byte Flags; - /// GridX field - public uint GridX; - /// GridY field - public uint GridY; - /// SourceID field - public LLUUID SourceID; - /// TransactionID field - public LLUUID TransactionID; - /// TransactionTime field - public uint TransactionTime; - /// TransactionType field - public int TransactionType; - - /// Length of this block serialized in bytes + { + /// FailureType field + public byte FailureType; + /// DestID field + public LLUUID DestID; + /// Amount field + public int Amount; + /// SimulatorIP field + public uint SimulatorIP; + /// Flags field + public byte Flags; + /// GridX field + public uint GridX; + /// GridY field + public uint GridY; + /// SourceID field + public LLUUID SourceID; + /// TransactionID field + public LLUUID TransactionID; + /// TransactionTime field + public uint TransactionTime; + /// TransactionType field + public int TransactionType; + + /// Length of this block serialized in bytes public int Length { get - { - return 74; + { + return 74; } } - - /// Default constructor - public TransactionDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public TransactionDataBlock() { } + /// Constructor for building the block from a byte array public TransactionDataBlock(byte[] bytes, ref int i) - { + { try - { - FailureType = (byte)bytes[i++]; - DestID = new LLUUID(bytes, i); i += 16; - Amount = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - SimulatorIP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Flags = (byte)bytes[i++]; - GridX = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - GridY = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - SourceID = new LLUUID(bytes, i); i += 16; - TransactionID = new LLUUID(bytes, i); i += 16; - TransactionTime = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - TransactionType = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + FailureType = (byte)bytes[i++]; + DestID = new LLUUID(bytes, i); i += 16; + Amount = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + SimulatorIP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Flags = (byte)bytes[i++]; + GridX = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + GridY = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + SourceID = new LLUUID(bytes, i); i += 16; + TransactionID = new LLUUID(bytes, i); i += 16; + TransactionTime = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + TransactionType = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = FailureType; - if(DestID == null) { Console.WriteLine("Warning: DestID is null, in " + this.GetType()); } - Array.Copy(DestID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(Amount % 256); - bytes[i++] = (byte)((Amount >> 8) % 256); - bytes[i++] = (byte)((Amount >> 16) % 256); - bytes[i++] = (byte)((Amount >> 24) % 256); - bytes[i++] = (byte)(SimulatorIP % 256); - bytes[i++] = (byte)((SimulatorIP >> 8) % 256); - bytes[i++] = (byte)((SimulatorIP >> 16) % 256); - bytes[i++] = (byte)((SimulatorIP >> 24) % 256); - bytes[i++] = Flags; - bytes[i++] = (byte)(GridX % 256); - bytes[i++] = (byte)((GridX >> 8) % 256); - bytes[i++] = (byte)((GridX >> 16) % 256); - bytes[i++] = (byte)((GridX >> 24) % 256); - bytes[i++] = (byte)(GridY % 256); - bytes[i++] = (byte)((GridY >> 8) % 256); - bytes[i++] = (byte)((GridY >> 16) % 256); - bytes[i++] = (byte)((GridY >> 24) % 256); - if(SourceID == null) { Console.WriteLine("Warning: SourceID is null, in " + this.GetType()); } - Array.Copy(SourceID.GetBytes(), 0, bytes, i, 16); i += 16; - if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } - Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(TransactionTime % 256); - bytes[i++] = (byte)((TransactionTime >> 8) % 256); - bytes[i++] = (byte)((TransactionTime >> 16) % 256); - bytes[i++] = (byte)((TransactionTime >> 24) % 256); - bytes[i++] = (byte)(TransactionType % 256); - bytes[i++] = (byte)((TransactionType >> 8) % 256); - bytes[i++] = (byte)((TransactionType >> 16) % 256); - bytes[i++] = (byte)((TransactionType >> 24) % 256); + { + bytes[i++] = FailureType; + if(DestID == null) { Console.WriteLine("Warning: DestID is null, in " + this.GetType()); } + Array.Copy(DestID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(Amount % 256); + bytes[i++] = (byte)((Amount >> 8) % 256); + bytes[i++] = (byte)((Amount >> 16) % 256); + bytes[i++] = (byte)((Amount >> 24) % 256); + bytes[i++] = (byte)(SimulatorIP % 256); + bytes[i++] = (byte)((SimulatorIP >> 8) % 256); + bytes[i++] = (byte)((SimulatorIP >> 16) % 256); + bytes[i++] = (byte)((SimulatorIP >> 24) % 256); + bytes[i++] = Flags; + bytes[i++] = (byte)(GridX % 256); + bytes[i++] = (byte)((GridX >> 8) % 256); + bytes[i++] = (byte)((GridX >> 16) % 256); + bytes[i++] = (byte)((GridX >> 24) % 256); + bytes[i++] = (byte)(GridY % 256); + bytes[i++] = (byte)((GridY >> 8) % 256); + bytes[i++] = (byte)((GridY >> 16) % 256); + bytes[i++] = (byte)((GridY >> 24) % 256); + if(SourceID == null) { Console.WriteLine("Warning: SourceID is null, in " + this.GetType()); } + Array.Copy(SourceID.GetBytes(), 0, bytes, i, 16); i += 16; + if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } + Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(TransactionTime % 256); + bytes[i++] = (byte)((TransactionTime >> 8) % 256); + bytes[i++] = (byte)((TransactionTime >> 16) % 256); + bytes[i++] = (byte)((TransactionTime >> 24) % 256); + bytes[i++] = (byte)(TransactionType % 256); + bytes[i++] = (byte)((TransactionType >> 8) % 256); + bytes[i++] = (byte)((TransactionType >> 16) % 256); + bytes[i++] = (byte)((TransactionType >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- TransactionData --\n"; - output += "FailureType: " + FailureType.ToString() + "\n"; - output += "DestID: " + DestID.ToString() + "\n"; - output += "Amount: " + Amount.ToString() + "\n"; - output += "SimulatorIP: " + SimulatorIP.ToString() + "\n"; - output += "Flags: " + Flags.ToString() + "\n"; - output += "GridX: " + GridX.ToString() + "\n"; - output += "GridY: " + GridY.ToString() + "\n"; - output += "SourceID: " + SourceID.ToString() + "\n"; - output += "TransactionID: " + TransactionID.ToString() + "\n"; - output += "TransactionTime: " + TransactionTime.ToString() + "\n"; - output += "TransactionType: " + TransactionType.ToString() + "\n"; + { + string output = "-- TransactionData --\n"; + output += "FailureType: " + FailureType.ToString() + "\n"; + output += "DestID: " + DestID.ToString() + "\n"; + output += "Amount: " + Amount.ToString() + "\n"; + output += "SimulatorIP: " + SimulatorIP.ToString() + "\n"; + output += "Flags: " + Flags.ToString() + "\n"; + output += "GridX: " + GridX.ToString() + "\n"; + output += "GridY: " + GridY.ToString() + "\n"; + output += "SourceID: " + SourceID.ToString() + "\n"; + output += "TransactionID: " + TransactionID.ToString() + "\n"; + output += "TransactionTime: " + TransactionTime.ToString() + "\n"; + output += "TransactionType: " + TransactionType.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.LogFailedMoneyTransaction - public override PacketType Type { get { return PacketType.LogFailedMoneyTransaction; } } - /// TransactionData block - public TransactionDataBlock TransactionData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.LogFailedMoneyTransaction + public override PacketType Type { get { return PacketType.LogFailedMoneyTransaction; } } + /// TransactionData block + public TransactionDataBlock TransactionData; + + /// Default constructor public LogFailedMoneyTransactionPacket() - { - Header = new LowHeader(); - Header.ID = 32; - Header.Reliable = true; - TransactionData = new TransactionDataBlock(); + { + Header = new LowHeader(); + Header.ID = 32; + Header.Reliable = true; + TransactionData = new TransactionDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public LogFailedMoneyTransactionPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - TransactionData = new TransactionDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + TransactionData = new TransactionDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public LogFailedMoneyTransactionPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - TransactionData = new TransactionDataBlock(bytes, ref i); + { + Header = head; + TransactionData = new TransactionDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += TransactionData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - TransactionData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += TransactionData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + TransactionData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- LogFailedMoneyTransaction ---\n"; - output += TransactionData.ToString() + "\n"; + { + string output = "--- LogFailedMoneyTransaction ---\n"; + output += TransactionData.ToString() + "\n"; return output; } - + } - - /// UserReportInternal packet + + /// UserReportInternal packet public class UserReportInternalPacket : Packet - { - /// MeanCollision block + { + /// MeanCollision block public class MeanCollisionBlock - { - /// Mag field - public float Mag; - /// Time field - public uint Time; - /// Perp field - public LLUUID Perp; - /// Type field - public byte Type; - - /// Length of this block serialized in bytes + { + /// Mag field + public float Mag; + /// Time field + public uint Time; + /// Perp field + public LLUUID Perp; + /// Type field + public byte Type; + + /// Length of this block serialized in bytes public int Length { get - { - return 25; + { + return 25; } } - - /// Default constructor - public MeanCollisionBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public MeanCollisionBlock() { } + /// Constructor for building the block from a byte array public MeanCollisionBlock(byte[] bytes, ref int i) - { + { try - { - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - Mag = BitConverter.ToSingle(bytes, i); i += 4; - Time = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Perp = new LLUUID(bytes, i); i += 16; - Type = (byte)bytes[i++]; + { + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + Mag = BitConverter.ToSingle(bytes, i); i += 4; + Time = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Perp = new LLUUID(bytes, i); i += 16; + Type = (byte)bytes[i++]; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; + { + byte[] ba; ba = BitConverter.GetBytes(Mag); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - bytes[i++] = (byte)(Time % 256); - bytes[i++] = (byte)((Time >> 8) % 256); - bytes[i++] = (byte)((Time >> 16) % 256); - bytes[i++] = (byte)((Time >> 24) % 256); - if(Perp == null) { Console.WriteLine("Warning: Perp is null, in " + this.GetType()); } - Array.Copy(Perp.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = Type; + Array.Copy(ba, 0, bytes, i, 4); i += 4; + bytes[i++] = (byte)(Time % 256); + bytes[i++] = (byte)((Time >> 8) % 256); + bytes[i++] = (byte)((Time >> 16) % 256); + bytes[i++] = (byte)((Time >> 24) % 256); + if(Perp == null) { Console.WriteLine("Warning: Perp is null, in " + this.GetType()); } + Array.Copy(Perp.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = Type; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- MeanCollision --\n"; - output += "Mag: " + Mag.ToString() + "\n"; - output += "Time: " + Time.ToString() + "\n"; - output += "Perp: " + Perp.ToString() + "\n"; - output += "Type: " + Type.ToString() + "\n"; + { + string output = "-- MeanCollision --\n"; + output += "Mag: " + Mag.ToString() + "\n"; + output += "Time: " + Time.ToString() + "\n"; + output += "Perp: " + Perp.ToString() + "\n"; + output += "Type: " + Type.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// ReportData block + + /// ReportData block public class ReportDataBlock - { - private byte[] _simname; - /// SimName field + { + private byte[] _simname; + /// SimName field public byte[] SimName - { - get { return _simname; } + { + get { return _simname; } set - { - if (value == null) { _simname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _simname = new byte[value.Length]; Array.Copy(value, _simname, value.Length); } + { + if (value == null) { _simname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _simname = new byte[value.Length]; Array.Copy(value, _simname, value.Length); } } - } - /// ObjectID field - public LLUUID ObjectID; - private byte[] _details; - /// Details field + } + /// ObjectID field + public LLUUID ObjectID; + private byte[] _details; + /// Details field public byte[] Details - { - get { return _details; } + { + get { return _details; } set - { - if (value == null) { _details = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _details = new byte[value.Length]; Array.Copy(value, _details, value.Length); } + { + if (value == null) { _details = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _details = new byte[value.Length]; Array.Copy(value, _details, value.Length); } } - } - private byte[] _versionstring; - /// VersionString field + } + private byte[] _versionstring; + /// VersionString field public byte[] VersionString - { - get { return _versionstring; } + { + get { return _versionstring; } set - { - if (value == null) { _versionstring = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _versionstring = new byte[value.Length]; Array.Copy(value, _versionstring, value.Length); } + { + if (value == null) { _versionstring = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _versionstring = new byte[value.Length]; Array.Copy(value, _versionstring, value.Length); } } - } - /// AgentPosition field - public LLVector3 AgentPosition; - /// Category field - public byte Category; - /// OwnerID field - public LLUUID OwnerID; - /// CreatorID field - public LLUUID CreatorID; - private byte[] _summary; - /// Summary field + } + /// AgentPosition field + public LLVector3 AgentPosition; + /// Category field + public byte Category; + /// OwnerID field + public LLUUID OwnerID; + /// CreatorID field + public LLUUID CreatorID; + private byte[] _summary; + /// Summary field public byte[] Summary - { - get { return _summary; } + { + get { return _summary; } set - { - if (value == null) { _summary = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _summary = new byte[value.Length]; Array.Copy(value, _summary, value.Length); } + { + if (value == null) { _summary = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _summary = new byte[value.Length]; Array.Copy(value, _summary, value.Length); } } - } - /// ReporterID field - public LLUUID ReporterID; - /// ReportType field - public byte ReportType; - /// ScreenshotID field - public LLUUID ScreenshotID; - /// LastOwnerID field - public LLUUID LastOwnerID; - /// ViewerPosition field - public LLVector3 ViewerPosition; - - /// Length of this block serialized in bytes + } + /// ReporterID field + public LLUUID ReporterID; + /// ReportType field + public byte ReportType; + /// ScreenshotID field + public LLUUID ScreenshotID; + /// LastOwnerID field + public LLUUID LastOwnerID; + /// ViewerPosition field + public LLVector3 ViewerPosition; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 122; - if (SimName != null) { length += 1 + SimName.Length; } - if (Details != null) { length += 2 + Details.Length; } - if (VersionString != null) { length += 1 + VersionString.Length; } - if (Summary != null) { length += 1 + Summary.Length; } - return length; + { + int length = 122; + if (SimName != null) { length += 1 + SimName.Length; } + if (Details != null) { length += 2 + Details.Length; } + if (VersionString != null) { length += 1 + VersionString.Length; } + if (Summary != null) { length += 1 + Summary.Length; } + return length; } } - - /// Default constructor - public ReportDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ReportDataBlock() { } + /// Constructor for building the block from a byte array public ReportDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _simname = new byte[length]; - Array.Copy(bytes, i, _simname, 0, length); i += length; - ObjectID = new LLUUID(bytes, i); i += 16; - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _details = new byte[length]; - Array.Copy(bytes, i, _details, 0, length); i += length; - length = (ushort)bytes[i++]; - _versionstring = new byte[length]; - Array.Copy(bytes, i, _versionstring, 0, length); i += length; - AgentPosition = new LLVector3(bytes, i); i += 12; - Category = (byte)bytes[i++]; - OwnerID = new LLUUID(bytes, i); i += 16; - CreatorID = new LLUUID(bytes, i); i += 16; - length = (ushort)bytes[i++]; - _summary = new byte[length]; - Array.Copy(bytes, i, _summary, 0, length); i += length; - ReporterID = new LLUUID(bytes, i); i += 16; - ReportType = (byte)bytes[i++]; - ScreenshotID = new LLUUID(bytes, i); i += 16; - LastOwnerID = new LLUUID(bytes, i); i += 16; - ViewerPosition = new LLVector3(bytes, i); i += 12; + { + length = (ushort)bytes[i++]; + _simname = new byte[length]; + Array.Copy(bytes, i, _simname, 0, length); i += length; + ObjectID = new LLUUID(bytes, i); i += 16; + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _details = new byte[length]; + Array.Copy(bytes, i, _details, 0, length); i += length; + length = (ushort)bytes[i++]; + _versionstring = new byte[length]; + Array.Copy(bytes, i, _versionstring, 0, length); i += length; + AgentPosition = new LLVector3(bytes, i); i += 12; + Category = (byte)bytes[i++]; + OwnerID = new LLUUID(bytes, i); i += 16; + CreatorID = new LLUUID(bytes, i); i += 16; + length = (ushort)bytes[i++]; + _summary = new byte[length]; + Array.Copy(bytes, i, _summary, 0, length); i += length; + ReporterID = new LLUUID(bytes, i); i += 16; + ReportType = (byte)bytes[i++]; + ScreenshotID = new LLUUID(bytes, i); i += 16; + LastOwnerID = new LLUUID(bytes, i); i += 16; + ViewerPosition = new LLVector3(bytes, i); i += 12; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(SimName == null) { Console.WriteLine("Warning: SimName is null, in " + this.GetType()); } - bytes[i++] = (byte)SimName.Length; - Array.Copy(SimName, 0, bytes, i, SimName.Length); i += SimName.Length; - if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } - Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; - if(Details == null) { Console.WriteLine("Warning: Details is null, in " + this.GetType()); } - bytes[i++] = (byte)(Details.Length % 256); - bytes[i++] = (byte)((Details.Length >> 8) % 256); - Array.Copy(Details, 0, bytes, i, Details.Length); i += Details.Length; - if(VersionString == null) { Console.WriteLine("Warning: VersionString is null, in " + this.GetType()); } - bytes[i++] = (byte)VersionString.Length; - Array.Copy(VersionString, 0, bytes, i, VersionString.Length); i += VersionString.Length; - if(AgentPosition == null) { Console.WriteLine("Warning: AgentPosition is null, in " + this.GetType()); } - Array.Copy(AgentPosition.GetBytes(), 0, bytes, i, 12); i += 12; - bytes[i++] = Category; - if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } - Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; - if(CreatorID == null) { Console.WriteLine("Warning: CreatorID is null, in " + this.GetType()); } - Array.Copy(CreatorID.GetBytes(), 0, bytes, i, 16); i += 16; - if(Summary == null) { Console.WriteLine("Warning: Summary is null, in " + this.GetType()); } - bytes[i++] = (byte)Summary.Length; - Array.Copy(Summary, 0, bytes, i, Summary.Length); i += Summary.Length; - if(ReporterID == null) { Console.WriteLine("Warning: ReporterID is null, in " + this.GetType()); } - Array.Copy(ReporterID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = ReportType; - if(ScreenshotID == null) { Console.WriteLine("Warning: ScreenshotID is null, in " + this.GetType()); } - Array.Copy(ScreenshotID.GetBytes(), 0, bytes, i, 16); i += 16; - if(LastOwnerID == null) { Console.WriteLine("Warning: LastOwnerID is null, in " + this.GetType()); } - Array.Copy(LastOwnerID.GetBytes(), 0, bytes, i, 16); i += 16; - if(ViewerPosition == null) { Console.WriteLine("Warning: ViewerPosition is null, in " + this.GetType()); } - Array.Copy(ViewerPosition.GetBytes(), 0, bytes, i, 12); i += 12; + { + if(SimName == null) { Console.WriteLine("Warning: SimName is null, in " + this.GetType()); } + bytes[i++] = (byte)SimName.Length; + Array.Copy(SimName, 0, bytes, i, SimName.Length); i += SimName.Length; + if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } + Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; + if(Details == null) { Console.WriteLine("Warning: Details is null, in " + this.GetType()); } + bytes[i++] = (byte)(Details.Length % 256); + bytes[i++] = (byte)((Details.Length >> 8) % 256); + Array.Copy(Details, 0, bytes, i, Details.Length); i += Details.Length; + if(VersionString == null) { Console.WriteLine("Warning: VersionString is null, in " + this.GetType()); } + bytes[i++] = (byte)VersionString.Length; + Array.Copy(VersionString, 0, bytes, i, VersionString.Length); i += VersionString.Length; + if(AgentPosition == null) { Console.WriteLine("Warning: AgentPosition is null, in " + this.GetType()); } + Array.Copy(AgentPosition.GetBytes(), 0, bytes, i, 12); i += 12; + bytes[i++] = Category; + if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } + Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; + if(CreatorID == null) { Console.WriteLine("Warning: CreatorID is null, in " + this.GetType()); } + Array.Copy(CreatorID.GetBytes(), 0, bytes, i, 16); i += 16; + if(Summary == null) { Console.WriteLine("Warning: Summary is null, in " + this.GetType()); } + bytes[i++] = (byte)Summary.Length; + Array.Copy(Summary, 0, bytes, i, Summary.Length); i += Summary.Length; + if(ReporterID == null) { Console.WriteLine("Warning: ReporterID is null, in " + this.GetType()); } + Array.Copy(ReporterID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = ReportType; + if(ScreenshotID == null) { Console.WriteLine("Warning: ScreenshotID is null, in " + this.GetType()); } + Array.Copy(ScreenshotID.GetBytes(), 0, bytes, i, 16); i += 16; + if(LastOwnerID == null) { Console.WriteLine("Warning: LastOwnerID is null, in " + this.GetType()); } + Array.Copy(LastOwnerID.GetBytes(), 0, bytes, i, 16); i += 16; + if(ViewerPosition == null) { Console.WriteLine("Warning: ViewerPosition is null, in " + this.GetType()); } + Array.Copy(ViewerPosition.GetBytes(), 0, bytes, i, 12); i += 12; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ReportData --\n"; - output += Helpers.FieldToString(SimName, "SimName") + "\n"; - output += "ObjectID: " + ObjectID.ToString() + "\n"; - output += Helpers.FieldToString(Details, "Details") + "\n"; - output += Helpers.FieldToString(VersionString, "VersionString") + "\n"; - output += "AgentPosition: " + AgentPosition.ToString() + "\n"; - output += "Category: " + Category.ToString() + "\n"; - output += "OwnerID: " + OwnerID.ToString() + "\n"; - output += "CreatorID: " + CreatorID.ToString() + "\n"; - output += Helpers.FieldToString(Summary, "Summary") + "\n"; - output += "ReporterID: " + ReporterID.ToString() + "\n"; - output += "ReportType: " + ReportType.ToString() + "\n"; - output += "ScreenshotID: " + ScreenshotID.ToString() + "\n"; - output += "LastOwnerID: " + LastOwnerID.ToString() + "\n"; - output += "ViewerPosition: " + ViewerPosition.ToString() + "\n"; + { + string output = "-- ReportData --\n"; + output += Helpers.FieldToString(SimName, "SimName") + "\n"; + output += "ObjectID: " + ObjectID.ToString() + "\n"; + output += Helpers.FieldToString(Details, "Details") + "\n"; + output += Helpers.FieldToString(VersionString, "VersionString") + "\n"; + output += "AgentPosition: " + AgentPosition.ToString() + "\n"; + output += "Category: " + Category.ToString() + "\n"; + output += "OwnerID: " + OwnerID.ToString() + "\n"; + output += "CreatorID: " + CreatorID.ToString() + "\n"; + output += Helpers.FieldToString(Summary, "Summary") + "\n"; + output += "ReporterID: " + ReporterID.ToString() + "\n"; + output += "ReportType: " + ReportType.ToString() + "\n"; + output += "ScreenshotID: " + ScreenshotID.ToString() + "\n"; + output += "LastOwnerID: " + LastOwnerID.ToString() + "\n"; + output += "ViewerPosition: " + ViewerPosition.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.UserReportInternal - public override PacketType Type { get { return PacketType.UserReportInternal; } } - /// MeanCollision block - public MeanCollisionBlock[] MeanCollision; - /// ReportData block - public ReportDataBlock ReportData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.UserReportInternal + public override PacketType Type { get { return PacketType.UserReportInternal; } } + /// MeanCollision block + public MeanCollisionBlock[] MeanCollision; + /// ReportData block + public ReportDataBlock ReportData; + + /// Default constructor public UserReportInternalPacket() - { - Header = new LowHeader(); - Header.ID = 33; - Header.Reliable = true; - Header.Zerocoded = true; - MeanCollision = new MeanCollisionBlock[0]; - ReportData = new ReportDataBlock(); + { + Header = new LowHeader(); + Header.ID = 33; + Header.Reliable = true; + Header.Zerocoded = true; + MeanCollision = new MeanCollisionBlock[0]; + ReportData = new ReportDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public UserReportInternalPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - MeanCollision = new MeanCollisionBlock[count]; - for (int j = 0; j < count; j++) - { MeanCollision[j] = new MeanCollisionBlock(bytes, ref i); } - ReportData = new ReportDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + MeanCollision = new MeanCollisionBlock[count]; + for (int j = 0; j < count; j++) + { MeanCollision[j] = new MeanCollisionBlock(bytes, ref i); } + ReportData = new ReportDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public UserReportInternalPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - MeanCollision = new MeanCollisionBlock[count]; - for (int j = 0; j < count; j++) - { MeanCollision[j] = new MeanCollisionBlock(bytes, ref i); } - ReportData = new ReportDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + MeanCollision = new MeanCollisionBlock[count]; + for (int j = 0; j < count; j++) + { MeanCollision[j] = new MeanCollisionBlock(bytes, ref i); } + ReportData = new ReportDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += ReportData.Length;; - length++; - for (int j = 0; j < MeanCollision.Length; j++) { length += MeanCollision[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)MeanCollision.Length; - for (int j = 0; j < MeanCollision.Length; j++) { MeanCollision[j].ToBytes(bytes, ref i); } - ReportData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += ReportData.Length;; + length++; + for (int j = 0; j < MeanCollision.Length; j++) { length += MeanCollision[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)MeanCollision.Length; + for (int j = 0; j < MeanCollision.Length; j++) { MeanCollision[j].ToBytes(bytes, ref i); } + ReportData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- UserReportInternal ---\n"; + { + string output = "--- UserReportInternal ---\n"; for (int j = 0; j < MeanCollision.Length; j++) - { + { output += MeanCollision[j].ToString() + "\n"; - } - output += ReportData.ToString() + "\n"; + } + output += ReportData.ToString() + "\n"; return output; } - + } - - /// SetSimStatusInDatabase packet + + /// SetSimStatusInDatabase packet public class SetSimStatusInDatabasePacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - /// X field - public int X; - /// Y field - public int Y; - /// PID field - public int PID; - /// RegionID field - public LLUUID RegionID; - private byte[] _status; - /// Status field + { + /// X field + public int X; + /// Y field + public int Y; + /// PID field + public int PID; + /// RegionID field + public LLUUID RegionID; + private byte[] _status; + /// Status field public byte[] Status - { - get { return _status; } + { + get { return _status; } set - { - if (value == null) { _status = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _status = new byte[value.Length]; Array.Copy(value, _status, value.Length); } + { + if (value == null) { _status = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _status = new byte[value.Length]; Array.Copy(value, _status, value.Length); } } - } - /// AgentCount field - public int AgentCount; - private byte[] _hostname; - /// HostName field + } + /// AgentCount field + public int AgentCount; + private byte[] _hostname; + /// HostName field public byte[] HostName - { - get { return _hostname; } + { + get { return _hostname; } set - { - if (value == null) { _hostname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _hostname = new byte[value.Length]; Array.Copy(value, _hostname, value.Length); } + { + if (value == null) { _hostname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _hostname = new byte[value.Length]; Array.Copy(value, _hostname, value.Length); } } - } - /// TimeToLive field - public int TimeToLive; - - /// Length of this block serialized in bytes + } + /// TimeToLive field + public int TimeToLive; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 36; - if (Status != null) { length += 1 + Status.Length; } - if (HostName != null) { length += 1 + HostName.Length; } - return length; + { + int length = 36; + if (Status != null) { length += 1 + Status.Length; } + if (HostName != null) { length += 1 + HostName.Length; } + return length; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - X = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Y = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - PID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - RegionID = new LLUUID(bytes, i); i += 16; - length = (ushort)bytes[i++]; - _status = new byte[length]; - Array.Copy(bytes, i, _status, 0, length); i += length; - AgentCount = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _hostname = new byte[length]; - Array.Copy(bytes, i, _hostname, 0, length); i += length; - TimeToLive = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + X = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Y = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + PID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + RegionID = new LLUUID(bytes, i); i += 16; + length = (ushort)bytes[i++]; + _status = new byte[length]; + Array.Copy(bytes, i, _status, 0, length); i += length; + AgentCount = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _hostname = new byte[length]; + Array.Copy(bytes, i, _hostname, 0, length); i += length; + TimeToLive = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(X % 256); - bytes[i++] = (byte)((X >> 8) % 256); - bytes[i++] = (byte)((X >> 16) % 256); - bytes[i++] = (byte)((X >> 24) % 256); - bytes[i++] = (byte)(Y % 256); - bytes[i++] = (byte)((Y >> 8) % 256); - bytes[i++] = (byte)((Y >> 16) % 256); - bytes[i++] = (byte)((Y >> 24) % 256); - bytes[i++] = (byte)(PID % 256); - bytes[i++] = (byte)((PID >> 8) % 256); - bytes[i++] = (byte)((PID >> 16) % 256); - bytes[i++] = (byte)((PID >> 24) % 256); - if(RegionID == null) { Console.WriteLine("Warning: RegionID is null, in " + this.GetType()); } - Array.Copy(RegionID.GetBytes(), 0, bytes, i, 16); i += 16; - if(Status == null) { Console.WriteLine("Warning: Status is null, in " + this.GetType()); } - bytes[i++] = (byte)Status.Length; - Array.Copy(Status, 0, bytes, i, Status.Length); i += Status.Length; - bytes[i++] = (byte)(AgentCount % 256); - bytes[i++] = (byte)((AgentCount >> 8) % 256); - bytes[i++] = (byte)((AgentCount >> 16) % 256); - bytes[i++] = (byte)((AgentCount >> 24) % 256); - if(HostName == null) { Console.WriteLine("Warning: HostName is null, in " + this.GetType()); } - bytes[i++] = (byte)HostName.Length; - Array.Copy(HostName, 0, bytes, i, HostName.Length); i += HostName.Length; - bytes[i++] = (byte)(TimeToLive % 256); - bytes[i++] = (byte)((TimeToLive >> 8) % 256); - bytes[i++] = (byte)((TimeToLive >> 16) % 256); - bytes[i++] = (byte)((TimeToLive >> 24) % 256); + { + bytes[i++] = (byte)(X % 256); + bytes[i++] = (byte)((X >> 8) % 256); + bytes[i++] = (byte)((X >> 16) % 256); + bytes[i++] = (byte)((X >> 24) % 256); + bytes[i++] = (byte)(Y % 256); + bytes[i++] = (byte)((Y >> 8) % 256); + bytes[i++] = (byte)((Y >> 16) % 256); + bytes[i++] = (byte)((Y >> 24) % 256); + bytes[i++] = (byte)(PID % 256); + bytes[i++] = (byte)((PID >> 8) % 256); + bytes[i++] = (byte)((PID >> 16) % 256); + bytes[i++] = (byte)((PID >> 24) % 256); + if(RegionID == null) { Console.WriteLine("Warning: RegionID is null, in " + this.GetType()); } + Array.Copy(RegionID.GetBytes(), 0, bytes, i, 16); i += 16; + if(Status == null) { Console.WriteLine("Warning: Status is null, in " + this.GetType()); } + bytes[i++] = (byte)Status.Length; + Array.Copy(Status, 0, bytes, i, Status.Length); i += Status.Length; + bytes[i++] = (byte)(AgentCount % 256); + bytes[i++] = (byte)((AgentCount >> 8) % 256); + bytes[i++] = (byte)((AgentCount >> 16) % 256); + bytes[i++] = (byte)((AgentCount >> 24) % 256); + if(HostName == null) { Console.WriteLine("Warning: HostName is null, in " + this.GetType()); } + bytes[i++] = (byte)HostName.Length; + Array.Copy(HostName, 0, bytes, i, HostName.Length); i += HostName.Length; + bytes[i++] = (byte)(TimeToLive % 256); + bytes[i++] = (byte)((TimeToLive >> 8) % 256); + bytes[i++] = (byte)((TimeToLive >> 16) % 256); + bytes[i++] = (byte)((TimeToLive >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "X: " + X.ToString() + "\n"; - output += "Y: " + Y.ToString() + "\n"; - output += "PID: " + PID.ToString() + "\n"; - output += "RegionID: " + RegionID.ToString() + "\n"; - output += Helpers.FieldToString(Status, "Status") + "\n"; - output += "AgentCount: " + AgentCount.ToString() + "\n"; - output += Helpers.FieldToString(HostName, "HostName") + "\n"; - output += "TimeToLive: " + TimeToLive.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += "X: " + X.ToString() + "\n"; + output += "Y: " + Y.ToString() + "\n"; + output += "PID: " + PID.ToString() + "\n"; + output += "RegionID: " + RegionID.ToString() + "\n"; + output += Helpers.FieldToString(Status, "Status") + "\n"; + output += "AgentCount: " + AgentCount.ToString() + "\n"; + output += Helpers.FieldToString(HostName, "HostName") + "\n"; + output += "TimeToLive: " + TimeToLive.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.SetSimStatusInDatabase - public override PacketType Type { get { return PacketType.SetSimStatusInDatabase; } } - /// Data block - public DataBlock Data; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.SetSimStatusInDatabase + public override PacketType Type { get { return PacketType.SetSimStatusInDatabase; } } + /// Data block + public DataBlock Data; + + /// Default constructor public SetSimStatusInDatabasePacket() - { - Header = new LowHeader(); - Header.ID = 34; - Header.Reliable = true; - Data = new DataBlock(); + { + Header = new LowHeader(); + Header.ID = 34; + Header.Reliable = true; + Data = new DataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public SetSimStatusInDatabasePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Data = new DataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Data = new DataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public SetSimStatusInDatabasePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Data = new DataBlock(bytes, ref i); + { + Header = head; + Data = new DataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Data.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Data.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Data.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Data.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- SetSimStatusInDatabase ---\n"; - output += Data.ToString() + "\n"; + { + string output = "--- SetSimStatusInDatabase ---\n"; + output += Data.ToString() + "\n"; return output; } - + } - - /// SetSimPresenceInDatabase packet + + /// SetSimPresenceInDatabase packet public class SetSimPresenceInDatabasePacket : Packet - { - /// SimData block + { + /// SimData block public class SimDataBlock - { - /// PID field - public int PID; - /// RegionID field - public LLUUID RegionID; - private byte[] _status; - /// Status field + { + /// PID field + public int PID; + /// RegionID field + public LLUUID RegionID; + private byte[] _status; + /// Status field public byte[] Status - { - get { return _status; } + { + get { return _status; } set - { - if (value == null) { _status = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _status = new byte[value.Length]; Array.Copy(value, _status, value.Length); } + { + if (value == null) { _status = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _status = new byte[value.Length]; Array.Copy(value, _status, value.Length); } } - } - /// AgentCount field - public int AgentCount; - /// GridX field - public uint GridX; - /// GridY field - public uint GridY; - private byte[] _hostname; - /// HostName field + } + /// AgentCount field + public int AgentCount; + /// GridX field + public uint GridX; + /// GridY field + public uint GridY; + private byte[] _hostname; + /// HostName field public byte[] HostName - { - get { return _hostname; } + { + get { return _hostname; } set - { - if (value == null) { _hostname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _hostname = new byte[value.Length]; Array.Copy(value, _hostname, value.Length); } + { + if (value == null) { _hostname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _hostname = new byte[value.Length]; Array.Copy(value, _hostname, value.Length); } } - } - /// TimeToLive field - public int TimeToLive; - - /// Length of this block serialized in bytes + } + /// TimeToLive field + public int TimeToLive; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 36; - if (Status != null) { length += 1 + Status.Length; } - if (HostName != null) { length += 1 + HostName.Length; } - return length; + { + int length = 36; + if (Status != null) { length += 1 + Status.Length; } + if (HostName != null) { length += 1 + HostName.Length; } + return length; } } - - /// Default constructor - public SimDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public SimDataBlock() { } + /// Constructor for building the block from a byte array public SimDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - PID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - RegionID = new LLUUID(bytes, i); i += 16; - length = (ushort)bytes[i++]; - _status = new byte[length]; - Array.Copy(bytes, i, _status, 0, length); i += length; - AgentCount = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - GridX = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - GridY = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _hostname = new byte[length]; - Array.Copy(bytes, i, _hostname, 0, length); i += length; - TimeToLive = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + PID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + RegionID = new LLUUID(bytes, i); i += 16; + length = (ushort)bytes[i++]; + _status = new byte[length]; + Array.Copy(bytes, i, _status, 0, length); i += length; + AgentCount = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + GridX = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + GridY = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _hostname = new byte[length]; + Array.Copy(bytes, i, _hostname, 0, length); i += length; + TimeToLive = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(PID % 256); - bytes[i++] = (byte)((PID >> 8) % 256); - bytes[i++] = (byte)((PID >> 16) % 256); - bytes[i++] = (byte)((PID >> 24) % 256); - if(RegionID == null) { Console.WriteLine("Warning: RegionID is null, in " + this.GetType()); } - Array.Copy(RegionID.GetBytes(), 0, bytes, i, 16); i += 16; - if(Status == null) { Console.WriteLine("Warning: Status is null, in " + this.GetType()); } - bytes[i++] = (byte)Status.Length; - Array.Copy(Status, 0, bytes, i, Status.Length); i += Status.Length; - bytes[i++] = (byte)(AgentCount % 256); - bytes[i++] = (byte)((AgentCount >> 8) % 256); - bytes[i++] = (byte)((AgentCount >> 16) % 256); - bytes[i++] = (byte)((AgentCount >> 24) % 256); - bytes[i++] = (byte)(GridX % 256); - bytes[i++] = (byte)((GridX >> 8) % 256); - bytes[i++] = (byte)((GridX >> 16) % 256); - bytes[i++] = (byte)((GridX >> 24) % 256); - bytes[i++] = (byte)(GridY % 256); - bytes[i++] = (byte)((GridY >> 8) % 256); - bytes[i++] = (byte)((GridY >> 16) % 256); - bytes[i++] = (byte)((GridY >> 24) % 256); - if(HostName == null) { Console.WriteLine("Warning: HostName is null, in " + this.GetType()); } - bytes[i++] = (byte)HostName.Length; - Array.Copy(HostName, 0, bytes, i, HostName.Length); i += HostName.Length; - bytes[i++] = (byte)(TimeToLive % 256); - bytes[i++] = (byte)((TimeToLive >> 8) % 256); - bytes[i++] = (byte)((TimeToLive >> 16) % 256); - bytes[i++] = (byte)((TimeToLive >> 24) % 256); + { + bytes[i++] = (byte)(PID % 256); + bytes[i++] = (byte)((PID >> 8) % 256); + bytes[i++] = (byte)((PID >> 16) % 256); + bytes[i++] = (byte)((PID >> 24) % 256); + if(RegionID == null) { Console.WriteLine("Warning: RegionID is null, in " + this.GetType()); } + Array.Copy(RegionID.GetBytes(), 0, bytes, i, 16); i += 16; + if(Status == null) { Console.WriteLine("Warning: Status is null, in " + this.GetType()); } + bytes[i++] = (byte)Status.Length; + Array.Copy(Status, 0, bytes, i, Status.Length); i += Status.Length; + bytes[i++] = (byte)(AgentCount % 256); + bytes[i++] = (byte)((AgentCount >> 8) % 256); + bytes[i++] = (byte)((AgentCount >> 16) % 256); + bytes[i++] = (byte)((AgentCount >> 24) % 256); + bytes[i++] = (byte)(GridX % 256); + bytes[i++] = (byte)((GridX >> 8) % 256); + bytes[i++] = (byte)((GridX >> 16) % 256); + bytes[i++] = (byte)((GridX >> 24) % 256); + bytes[i++] = (byte)(GridY % 256); + bytes[i++] = (byte)((GridY >> 8) % 256); + bytes[i++] = (byte)((GridY >> 16) % 256); + bytes[i++] = (byte)((GridY >> 24) % 256); + if(HostName == null) { Console.WriteLine("Warning: HostName is null, in " + this.GetType()); } + bytes[i++] = (byte)HostName.Length; + Array.Copy(HostName, 0, bytes, i, HostName.Length); i += HostName.Length; + bytes[i++] = (byte)(TimeToLive % 256); + bytes[i++] = (byte)((TimeToLive >> 8) % 256); + bytes[i++] = (byte)((TimeToLive >> 16) % 256); + bytes[i++] = (byte)((TimeToLive >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- SimData --\n"; - output += "PID: " + PID.ToString() + "\n"; - output += "RegionID: " + RegionID.ToString() + "\n"; - output += Helpers.FieldToString(Status, "Status") + "\n"; - output += "AgentCount: " + AgentCount.ToString() + "\n"; - output += "GridX: " + GridX.ToString() + "\n"; - output += "GridY: " + GridY.ToString() + "\n"; - output += Helpers.FieldToString(HostName, "HostName") + "\n"; - output += "TimeToLive: " + TimeToLive.ToString() + "\n"; + { + string output = "-- SimData --\n"; + output += "PID: " + PID.ToString() + "\n"; + output += "RegionID: " + RegionID.ToString() + "\n"; + output += Helpers.FieldToString(Status, "Status") + "\n"; + output += "AgentCount: " + AgentCount.ToString() + "\n"; + output += "GridX: " + GridX.ToString() + "\n"; + output += "GridY: " + GridY.ToString() + "\n"; + output += Helpers.FieldToString(HostName, "HostName") + "\n"; + output += "TimeToLive: " + TimeToLive.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.SetSimPresenceInDatabase - public override PacketType Type { get { return PacketType.SetSimPresenceInDatabase; } } - /// SimData block - public SimDataBlock SimData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.SetSimPresenceInDatabase + public override PacketType Type { get { return PacketType.SetSimPresenceInDatabase; } } + /// SimData block + public SimDataBlock SimData; + + /// Default constructor public SetSimPresenceInDatabasePacket() - { - Header = new LowHeader(); - Header.ID = 35; - Header.Reliable = true; - SimData = new SimDataBlock(); + { + Header = new LowHeader(); + Header.ID = 35; + Header.Reliable = true; + SimData = new SimDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public SetSimPresenceInDatabasePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - SimData = new SimDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + SimData = new SimDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public SetSimPresenceInDatabasePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - SimData = new SimDataBlock(bytes, ref i); + { + Header = head; + SimData = new SimDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += SimData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - SimData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += SimData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + SimData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- SetSimPresenceInDatabase ---\n"; - output += SimData.ToString() + "\n"; + { + string output = "--- SetSimPresenceInDatabase ---\n"; + output += SimData.ToString() + "\n"; return output; } - + } - - /// EconomyDataRequest packet + + /// EconomyDataRequest packet public class EconomyDataRequestPacket : Packet - { - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.EconomyDataRequest - public override PacketType Type { get { return PacketType.EconomyDataRequest; } } - - /// Default constructor + { + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.EconomyDataRequest + public override PacketType Type { get { return PacketType.EconomyDataRequest; } } + + /// Default constructor public EconomyDataRequestPacket() - { - Header = new LowHeader(); - Header.ID = 36; - Header.Reliable = true; + { + Header = new LowHeader(); + Header.ID = 36; + Header.Reliable = true; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public EconomyDataRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public EconomyDataRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; + { + Header = head; } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; -; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; +; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- EconomyDataRequest ---\n"; + { + string output = "--- EconomyDataRequest ---\n"; return output; } - + } - - /// EconomyData packet + + /// EconomyData packet public class EconomyDataPacket : Packet - { - /// Info block + { + /// Info block public class InfoBlock - { - /// PriceParcelClaimFactor field - public float PriceParcelClaimFactor; - /// ObjectCapacity field - public int ObjectCapacity; - /// EnergyEfficiency field - public float EnergyEfficiency; - /// ObjectCount field - public int ObjectCount; - /// TeleportPriceExponent field - public float TeleportPriceExponent; - /// PriceGroupCreate field - public int PriceGroupCreate; - /// PriceObjectRent field - public float PriceObjectRent; - /// PricePublicObjectDelete field - public int PricePublicObjectDelete; - /// PriceEnergyUnit field - public int PriceEnergyUnit; - /// TeleportMinPrice field - public int TeleportMinPrice; - /// PricePublicObjectDecay field - public int PricePublicObjectDecay; - /// PriceObjectClaim field - public int PriceObjectClaim; - /// PriceParcelClaim field - public int PriceParcelClaim; - /// PriceObjectScaleFactor field - public float PriceObjectScaleFactor; - /// PriceRentLight field - public int PriceRentLight; - /// PriceParcelRent field - public int PriceParcelRent; - /// PriceUpload field - public int PriceUpload; - - /// Length of this block serialized in bytes + { + /// PriceParcelClaimFactor field + public float PriceParcelClaimFactor; + /// ObjectCapacity field + public int ObjectCapacity; + /// EnergyEfficiency field + public float EnergyEfficiency; + /// ObjectCount field + public int ObjectCount; + /// TeleportPriceExponent field + public float TeleportPriceExponent; + /// PriceGroupCreate field + public int PriceGroupCreate; + /// PriceObjectRent field + public float PriceObjectRent; + /// PricePublicObjectDelete field + public int PricePublicObjectDelete; + /// PriceEnergyUnit field + public int PriceEnergyUnit; + /// TeleportMinPrice field + public int TeleportMinPrice; + /// PricePublicObjectDecay field + public int PricePublicObjectDecay; + /// PriceObjectClaim field + public int PriceObjectClaim; + /// PriceParcelClaim field + public int PriceParcelClaim; + /// PriceObjectScaleFactor field + public float PriceObjectScaleFactor; + /// PriceRentLight field + public int PriceRentLight; + /// PriceParcelRent field + public int PriceParcelRent; + /// PriceUpload field + public int PriceUpload; + + /// Length of this block serialized in bytes public int Length { get - { - return 68; + { + return 68; } } - - /// Default constructor - public InfoBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public InfoBlock() { } + /// Constructor for building the block from a byte array public InfoBlock(byte[] bytes, ref int i) - { + { try - { - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - PriceParcelClaimFactor = BitConverter.ToSingle(bytes, i); i += 4; - ObjectCapacity = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - EnergyEfficiency = BitConverter.ToSingle(bytes, i); i += 4; - ObjectCount = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - TeleportPriceExponent = BitConverter.ToSingle(bytes, i); i += 4; - PriceGroupCreate = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - PriceObjectRent = BitConverter.ToSingle(bytes, i); i += 4; - PricePublicObjectDelete = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - PriceEnergyUnit = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - TeleportMinPrice = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - PricePublicObjectDecay = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - PriceObjectClaim = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - PriceParcelClaim = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - PriceObjectScaleFactor = BitConverter.ToSingle(bytes, i); i += 4; - PriceRentLight = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - PriceParcelRent = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - PriceUpload = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + PriceParcelClaimFactor = BitConverter.ToSingle(bytes, i); i += 4; + ObjectCapacity = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + EnergyEfficiency = BitConverter.ToSingle(bytes, i); i += 4; + ObjectCount = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + TeleportPriceExponent = BitConverter.ToSingle(bytes, i); i += 4; + PriceGroupCreate = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + PriceObjectRent = BitConverter.ToSingle(bytes, i); i += 4; + PricePublicObjectDelete = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + PriceEnergyUnit = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + TeleportMinPrice = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + PricePublicObjectDecay = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + PriceObjectClaim = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + PriceParcelClaim = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + PriceObjectScaleFactor = BitConverter.ToSingle(bytes, i); i += 4; + PriceRentLight = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + PriceParcelRent = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + PriceUpload = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; + { + byte[] ba; ba = BitConverter.GetBytes(PriceParcelClaimFactor); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - bytes[i++] = (byte)(ObjectCapacity % 256); - bytes[i++] = (byte)((ObjectCapacity >> 8) % 256); - bytes[i++] = (byte)((ObjectCapacity >> 16) % 256); - bytes[i++] = (byte)((ObjectCapacity >> 24) % 256); + Array.Copy(ba, 0, bytes, i, 4); i += 4; + bytes[i++] = (byte)(ObjectCapacity % 256); + bytes[i++] = (byte)((ObjectCapacity >> 8) % 256); + bytes[i++] = (byte)((ObjectCapacity >> 16) % 256); + bytes[i++] = (byte)((ObjectCapacity >> 24) % 256); ba = BitConverter.GetBytes(EnergyEfficiency); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - bytes[i++] = (byte)(ObjectCount % 256); - bytes[i++] = (byte)((ObjectCount >> 8) % 256); - bytes[i++] = (byte)((ObjectCount >> 16) % 256); - bytes[i++] = (byte)((ObjectCount >> 24) % 256); + Array.Copy(ba, 0, bytes, i, 4); i += 4; + bytes[i++] = (byte)(ObjectCount % 256); + bytes[i++] = (byte)((ObjectCount >> 8) % 256); + bytes[i++] = (byte)((ObjectCount >> 16) % 256); + bytes[i++] = (byte)((ObjectCount >> 24) % 256); ba = BitConverter.GetBytes(TeleportPriceExponent); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - bytes[i++] = (byte)(PriceGroupCreate % 256); - bytes[i++] = (byte)((PriceGroupCreate >> 8) % 256); - bytes[i++] = (byte)((PriceGroupCreate >> 16) % 256); - bytes[i++] = (byte)((PriceGroupCreate >> 24) % 256); + Array.Copy(ba, 0, bytes, i, 4); i += 4; + bytes[i++] = (byte)(PriceGroupCreate % 256); + bytes[i++] = (byte)((PriceGroupCreate >> 8) % 256); + bytes[i++] = (byte)((PriceGroupCreate >> 16) % 256); + bytes[i++] = (byte)((PriceGroupCreate >> 24) % 256); ba = BitConverter.GetBytes(PriceObjectRent); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - bytes[i++] = (byte)(PricePublicObjectDelete % 256); - bytes[i++] = (byte)((PricePublicObjectDelete >> 8) % 256); - bytes[i++] = (byte)((PricePublicObjectDelete >> 16) % 256); - bytes[i++] = (byte)((PricePublicObjectDelete >> 24) % 256); - bytes[i++] = (byte)(PriceEnergyUnit % 256); - bytes[i++] = (byte)((PriceEnergyUnit >> 8) % 256); - bytes[i++] = (byte)((PriceEnergyUnit >> 16) % 256); - bytes[i++] = (byte)((PriceEnergyUnit >> 24) % 256); - bytes[i++] = (byte)(TeleportMinPrice % 256); - bytes[i++] = (byte)((TeleportMinPrice >> 8) % 256); - bytes[i++] = (byte)((TeleportMinPrice >> 16) % 256); - bytes[i++] = (byte)((TeleportMinPrice >> 24) % 256); - bytes[i++] = (byte)(PricePublicObjectDecay % 256); - bytes[i++] = (byte)((PricePublicObjectDecay >> 8) % 256); - bytes[i++] = (byte)((PricePublicObjectDecay >> 16) % 256); - bytes[i++] = (byte)((PricePublicObjectDecay >> 24) % 256); - bytes[i++] = (byte)(PriceObjectClaim % 256); - bytes[i++] = (byte)((PriceObjectClaim >> 8) % 256); - bytes[i++] = (byte)((PriceObjectClaim >> 16) % 256); - bytes[i++] = (byte)((PriceObjectClaim >> 24) % 256); - bytes[i++] = (byte)(PriceParcelClaim % 256); - bytes[i++] = (byte)((PriceParcelClaim >> 8) % 256); - bytes[i++] = (byte)((PriceParcelClaim >> 16) % 256); - bytes[i++] = (byte)((PriceParcelClaim >> 24) % 256); + Array.Copy(ba, 0, bytes, i, 4); i += 4; + bytes[i++] = (byte)(PricePublicObjectDelete % 256); + bytes[i++] = (byte)((PricePublicObjectDelete >> 8) % 256); + bytes[i++] = (byte)((PricePublicObjectDelete >> 16) % 256); + bytes[i++] = (byte)((PricePublicObjectDelete >> 24) % 256); + bytes[i++] = (byte)(PriceEnergyUnit % 256); + bytes[i++] = (byte)((PriceEnergyUnit >> 8) % 256); + bytes[i++] = (byte)((PriceEnergyUnit >> 16) % 256); + bytes[i++] = (byte)((PriceEnergyUnit >> 24) % 256); + bytes[i++] = (byte)(TeleportMinPrice % 256); + bytes[i++] = (byte)((TeleportMinPrice >> 8) % 256); + bytes[i++] = (byte)((TeleportMinPrice >> 16) % 256); + bytes[i++] = (byte)((TeleportMinPrice >> 24) % 256); + bytes[i++] = (byte)(PricePublicObjectDecay % 256); + bytes[i++] = (byte)((PricePublicObjectDecay >> 8) % 256); + bytes[i++] = (byte)((PricePublicObjectDecay >> 16) % 256); + bytes[i++] = (byte)((PricePublicObjectDecay >> 24) % 256); + bytes[i++] = (byte)(PriceObjectClaim % 256); + bytes[i++] = (byte)((PriceObjectClaim >> 8) % 256); + bytes[i++] = (byte)((PriceObjectClaim >> 16) % 256); + bytes[i++] = (byte)((PriceObjectClaim >> 24) % 256); + bytes[i++] = (byte)(PriceParcelClaim % 256); + bytes[i++] = (byte)((PriceParcelClaim >> 8) % 256); + bytes[i++] = (byte)((PriceParcelClaim >> 16) % 256); + bytes[i++] = (byte)((PriceParcelClaim >> 24) % 256); ba = BitConverter.GetBytes(PriceObjectScaleFactor); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - bytes[i++] = (byte)(PriceRentLight % 256); - bytes[i++] = (byte)((PriceRentLight >> 8) % 256); - bytes[i++] = (byte)((PriceRentLight >> 16) % 256); - bytes[i++] = (byte)((PriceRentLight >> 24) % 256); - bytes[i++] = (byte)(PriceParcelRent % 256); - bytes[i++] = (byte)((PriceParcelRent >> 8) % 256); - bytes[i++] = (byte)((PriceParcelRent >> 16) % 256); - bytes[i++] = (byte)((PriceParcelRent >> 24) % 256); - bytes[i++] = (byte)(PriceUpload % 256); - bytes[i++] = (byte)((PriceUpload >> 8) % 256); - bytes[i++] = (byte)((PriceUpload >> 16) % 256); - bytes[i++] = (byte)((PriceUpload >> 24) % 256); + Array.Copy(ba, 0, bytes, i, 4); i += 4; + bytes[i++] = (byte)(PriceRentLight % 256); + bytes[i++] = (byte)((PriceRentLight >> 8) % 256); + bytes[i++] = (byte)((PriceRentLight >> 16) % 256); + bytes[i++] = (byte)((PriceRentLight >> 24) % 256); + bytes[i++] = (byte)(PriceParcelRent % 256); + bytes[i++] = (byte)((PriceParcelRent >> 8) % 256); + bytes[i++] = (byte)((PriceParcelRent >> 16) % 256); + bytes[i++] = (byte)((PriceParcelRent >> 24) % 256); + bytes[i++] = (byte)(PriceUpload % 256); + bytes[i++] = (byte)((PriceUpload >> 8) % 256); + bytes[i++] = (byte)((PriceUpload >> 16) % 256); + bytes[i++] = (byte)((PriceUpload >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Info --\n"; - output += "PriceParcelClaimFactor: " + PriceParcelClaimFactor.ToString() + "\n"; - output += "ObjectCapacity: " + ObjectCapacity.ToString() + "\n"; - output += "EnergyEfficiency: " + EnergyEfficiency.ToString() + "\n"; - output += "ObjectCount: " + ObjectCount.ToString() + "\n"; - output += "TeleportPriceExponent: " + TeleportPriceExponent.ToString() + "\n"; - output += "PriceGroupCreate: " + PriceGroupCreate.ToString() + "\n"; - output += "PriceObjectRent: " + PriceObjectRent.ToString() + "\n"; - output += "PricePublicObjectDelete: " + PricePublicObjectDelete.ToString() + "\n"; - output += "PriceEnergyUnit: " + PriceEnergyUnit.ToString() + "\n"; - output += "TeleportMinPrice: " + TeleportMinPrice.ToString() + "\n"; - output += "PricePublicObjectDecay: " + PricePublicObjectDecay.ToString() + "\n"; - output += "PriceObjectClaim: " + PriceObjectClaim.ToString() + "\n"; - output += "PriceParcelClaim: " + PriceParcelClaim.ToString() + "\n"; - output += "PriceObjectScaleFactor: " + PriceObjectScaleFactor.ToString() + "\n"; - output += "PriceRentLight: " + PriceRentLight.ToString() + "\n"; - output += "PriceParcelRent: " + PriceParcelRent.ToString() + "\n"; - output += "PriceUpload: " + PriceUpload.ToString() + "\n"; + { + string output = "-- Info --\n"; + output += "PriceParcelClaimFactor: " + PriceParcelClaimFactor.ToString() + "\n"; + output += "ObjectCapacity: " + ObjectCapacity.ToString() + "\n"; + output += "EnergyEfficiency: " + EnergyEfficiency.ToString() + "\n"; + output += "ObjectCount: " + ObjectCount.ToString() + "\n"; + output += "TeleportPriceExponent: " + TeleportPriceExponent.ToString() + "\n"; + output += "PriceGroupCreate: " + PriceGroupCreate.ToString() + "\n"; + output += "PriceObjectRent: " + PriceObjectRent.ToString() + "\n"; + output += "PricePublicObjectDelete: " + PricePublicObjectDelete.ToString() + "\n"; + output += "PriceEnergyUnit: " + PriceEnergyUnit.ToString() + "\n"; + output += "TeleportMinPrice: " + TeleportMinPrice.ToString() + "\n"; + output += "PricePublicObjectDecay: " + PricePublicObjectDecay.ToString() + "\n"; + output += "PriceObjectClaim: " + PriceObjectClaim.ToString() + "\n"; + output += "PriceParcelClaim: " + PriceParcelClaim.ToString() + "\n"; + output += "PriceObjectScaleFactor: " + PriceObjectScaleFactor.ToString() + "\n"; + output += "PriceRentLight: " + PriceRentLight.ToString() + "\n"; + output += "PriceParcelRent: " + PriceParcelRent.ToString() + "\n"; + output += "PriceUpload: " + PriceUpload.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.EconomyData - public override PacketType Type { get { return PacketType.EconomyData; } } - /// Info block - public InfoBlock Info; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.EconomyData + public override PacketType Type { get { return PacketType.EconomyData; } } + /// Info block + public InfoBlock Info; + + /// Default constructor public EconomyDataPacket() - { - Header = new LowHeader(); - Header.ID = 37; - Header.Reliable = true; - Header.Zerocoded = true; - Info = new InfoBlock(); + { + Header = new LowHeader(); + Header.ID = 37; + Header.Reliable = true; + Header.Zerocoded = true; + Info = new InfoBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public EconomyDataPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Info = new InfoBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Info = new InfoBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public EconomyDataPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Info = new InfoBlock(bytes, ref i); + { + Header = head; + Info = new InfoBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Info.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Info.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Info.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Info.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- EconomyData ---\n"; - output += Info.ToString() + "\n"; + { + string output = "--- EconomyData ---\n"; + output += Info.ToString() + "\n"; return output; } - + } - - /// AvatarPickerRequest packet + + /// AvatarPickerRequest packet public class AvatarPickerRequestPacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - private byte[] _name; - /// Name field + { + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 0; - if (Name != null) { length += 1 + Name.Length; } - return length; + { + int length = 0; + if (Name != null) { length += 1 + Name.Length; } + return length; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; + { + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + { + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; + { + string output = "-- Data --\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - /// QueryID field - public LLUUID QueryID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + /// QueryID field + public LLUUID QueryID; + + /// Length of this block serialized in bytes public int Length { get - { - return 48; + { + return 48; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; - QueryID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; + QueryID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } - Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } + Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "QueryID: " + QueryID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "QueryID: " + QueryID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AvatarPickerRequest - public override PacketType Type { get { return PacketType.AvatarPickerRequest; } } - /// Data block - public DataBlock Data; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AvatarPickerRequest + public override PacketType Type { get { return PacketType.AvatarPickerRequest; } } + /// Data block + public DataBlock Data; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public AvatarPickerRequestPacket() - { - Header = new LowHeader(); - Header.ID = 38; - Header.Reliable = true; - Data = new DataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 38; + Header.Reliable = true; + Data = new DataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AvatarPickerRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AvatarPickerRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Data.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Data.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Data.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Data.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AvatarPickerRequest ---\n"; - output += Data.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- AvatarPickerRequest ---\n"; + output += Data.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// AvatarPickerRequestBackend packet + + /// AvatarPickerRequestBackend packet public class AvatarPickerRequestBackendPacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - private byte[] _name; - /// Name field + { + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 0; - if (Name != null) { length += 1 + Name.Length; } - return length; + { + int length = 0; + if (Name != null) { length += 1 + Name.Length; } + return length; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; + { + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + { + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; + { + string output = "-- Data --\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - /// GodLevel field - public byte GodLevel; - /// QueryID field - public LLUUID QueryID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + /// GodLevel field + public byte GodLevel; + /// QueryID field + public LLUUID QueryID; + + /// Length of this block serialized in bytes public int Length { get - { - return 49; + { + return 49; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; - GodLevel = (byte)bytes[i++]; - QueryID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; + GodLevel = (byte)bytes[i++]; + QueryID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = GodLevel; - if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } - Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = GodLevel; + if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } + Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "GodLevel: " + GodLevel.ToString() + "\n"; - output += "QueryID: " + QueryID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "GodLevel: " + GodLevel.ToString() + "\n"; + output += "QueryID: " + QueryID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AvatarPickerRequestBackend - public override PacketType Type { get { return PacketType.AvatarPickerRequestBackend; } } - /// Data block - public DataBlock Data; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AvatarPickerRequestBackend + public override PacketType Type { get { return PacketType.AvatarPickerRequestBackend; } } + /// Data block + public DataBlock Data; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public AvatarPickerRequestBackendPacket() - { - Header = new LowHeader(); - Header.ID = 39; - Header.Reliable = true; - Data = new DataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 39; + Header.Reliable = true; + Data = new DataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AvatarPickerRequestBackendPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AvatarPickerRequestBackendPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Data.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Data.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Data.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Data.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AvatarPickerRequestBackend ---\n"; - output += Data.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- AvatarPickerRequestBackend ---\n"; + output += Data.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// AvatarPickerReply packet + + /// AvatarPickerReply packet public class AvatarPickerReplyPacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - private byte[] _lastname; - /// LastName field + { + private byte[] _lastname; + /// LastName field public byte[] LastName - { - get { return _lastname; } + { + get { return _lastname; } set - { - if (value == null) { _lastname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _lastname = new byte[value.Length]; Array.Copy(value, _lastname, value.Length); } + { + if (value == null) { _lastname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _lastname = new byte[value.Length]; Array.Copy(value, _lastname, value.Length); } } - } - private byte[] _firstname; - /// FirstName field + } + private byte[] _firstname; + /// FirstName field public byte[] FirstName - { - get { return _firstname; } + { + get { return _firstname; } set - { - if (value == null) { _firstname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _firstname = new byte[value.Length]; Array.Copy(value, _firstname, value.Length); } + { + if (value == null) { _firstname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _firstname = new byte[value.Length]; Array.Copy(value, _firstname, value.Length); } } - } - /// AvatarID field - public LLUUID AvatarID; - - /// Length of this block serialized in bytes + } + /// AvatarID field + public LLUUID AvatarID; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 16; - if (LastName != null) { length += 1 + LastName.Length; } - if (FirstName != null) { length += 1 + FirstName.Length; } - return length; + { + int length = 16; + if (LastName != null) { length += 1 + LastName.Length; } + if (FirstName != null) { length += 1 + FirstName.Length; } + return length; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _lastname = new byte[length]; - Array.Copy(bytes, i, _lastname, 0, length); i += length; - length = (ushort)bytes[i++]; - _firstname = new byte[length]; - Array.Copy(bytes, i, _firstname, 0, length); i += length; - AvatarID = new LLUUID(bytes, i); i += 16; + { + length = (ushort)bytes[i++]; + _lastname = new byte[length]; + Array.Copy(bytes, i, _lastname, 0, length); i += length; + length = (ushort)bytes[i++]; + _firstname = new byte[length]; + Array.Copy(bytes, i, _firstname, 0, length); i += length; + AvatarID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(LastName == null) { Console.WriteLine("Warning: LastName is null, in " + this.GetType()); } - bytes[i++] = (byte)LastName.Length; - Array.Copy(LastName, 0, bytes, i, LastName.Length); i += LastName.Length; - if(FirstName == null) { Console.WriteLine("Warning: FirstName is null, in " + this.GetType()); } - bytes[i++] = (byte)FirstName.Length; - Array.Copy(FirstName, 0, bytes, i, FirstName.Length); i += FirstName.Length; - if(AvatarID == null) { Console.WriteLine("Warning: AvatarID is null, in " + this.GetType()); } - Array.Copy(AvatarID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(LastName == null) { Console.WriteLine("Warning: LastName is null, in " + this.GetType()); } + bytes[i++] = (byte)LastName.Length; + Array.Copy(LastName, 0, bytes, i, LastName.Length); i += LastName.Length; + if(FirstName == null) { Console.WriteLine("Warning: FirstName is null, in " + this.GetType()); } + bytes[i++] = (byte)FirstName.Length; + Array.Copy(FirstName, 0, bytes, i, FirstName.Length); i += FirstName.Length; + if(AvatarID == null) { Console.WriteLine("Warning: AvatarID is null, in " + this.GetType()); } + Array.Copy(AvatarID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += Helpers.FieldToString(LastName, "LastName") + "\n"; - output += Helpers.FieldToString(FirstName, "FirstName") + "\n"; - output += "AvatarID: " + AvatarID.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += Helpers.FieldToString(LastName, "LastName") + "\n"; + output += Helpers.FieldToString(FirstName, "FirstName") + "\n"; + output += "AvatarID: " + AvatarID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// QueryID field - public LLUUID QueryID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// QueryID field + public LLUUID QueryID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - QueryID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + QueryID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } - Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } + Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "QueryID: " + QueryID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "QueryID: " + QueryID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AvatarPickerReply - public override PacketType Type { get { return PacketType.AvatarPickerReply; } } - /// Data block - public DataBlock[] Data; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AvatarPickerReply + public override PacketType Type { get { return PacketType.AvatarPickerReply; } } + /// Data block + public DataBlock[] Data; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public AvatarPickerReplyPacket() - { - Header = new LowHeader(); - Header.ID = 40; - Header.Reliable = true; - Data = new DataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 40; + Header.Reliable = true; + Data = new DataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AvatarPickerReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - Data = new DataBlock[count]; - for (int j = 0; j < count; j++) - { Data[j] = new DataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + Data = new DataBlock[count]; + for (int j = 0; j < count; j++) + { Data[j] = new DataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AvatarPickerReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - Data = new DataBlock[count]; - for (int j = 0; j < count; j++) - { Data[j] = new DataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + Data = new DataBlock[count]; + for (int j = 0; j < count; j++) + { Data[j] = new DataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < Data.Length; j++) { length += Data[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)Data.Length; - for (int j = 0; j < Data.Length; j++) { Data[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < Data.Length; j++) { length += Data[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)Data.Length; + for (int j = 0; j < Data.Length; j++) { Data[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AvatarPickerReply ---\n"; + { + string output = "--- AvatarPickerReply ---\n"; for (int j = 0; j < Data.Length; j++) - { + { output += Data[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// PlacesQuery packet + + /// PlacesQuery packet public class PlacesQueryPacket : Packet - { - /// QueryData block + { + /// QueryData block public class QueryDataBlock - { - private byte[] _simname; - /// SimName field + { + private byte[] _simname; + /// SimName field public byte[] SimName - { - get { return _simname; } + { + get { return _simname; } set - { - if (value == null) { _simname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _simname = new byte[value.Length]; Array.Copy(value, _simname, value.Length); } + { + if (value == null) { _simname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _simname = new byte[value.Length]; Array.Copy(value, _simname, value.Length); } } - } - /// Category field - public sbyte Category; - /// QueryFlags field - public uint QueryFlags; - private byte[] _querytext; - /// QueryText field + } + /// Category field + public sbyte Category; + /// QueryFlags field + public uint QueryFlags; + private byte[] _querytext; + /// QueryText field public byte[] QueryText - { - get { return _querytext; } + { + get { return _querytext; } set - { - if (value == null) { _querytext = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _querytext = new byte[value.Length]; Array.Copy(value, _querytext, value.Length); } + { + if (value == null) { _querytext = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _querytext = new byte[value.Length]; Array.Copy(value, _querytext, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 5; - if (SimName != null) { length += 1 + SimName.Length; } - if (QueryText != null) { length += 1 + QueryText.Length; } - return length; + { + int length = 5; + if (SimName != null) { length += 1 + SimName.Length; } + if (QueryText != null) { length += 1 + QueryText.Length; } + return length; } } - - /// Default constructor - public QueryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public QueryDataBlock() { } + /// Constructor for building the block from a byte array public QueryDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _simname = new byte[length]; - Array.Copy(bytes, i, _simname, 0, length); i += length; - Category = (sbyte)bytes[i++]; - QueryFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _querytext = new byte[length]; - Array.Copy(bytes, i, _querytext, 0, length); i += length; + { + length = (ushort)bytes[i++]; + _simname = new byte[length]; + Array.Copy(bytes, i, _simname, 0, length); i += length; + Category = (sbyte)bytes[i++]; + QueryFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _querytext = new byte[length]; + Array.Copy(bytes, i, _querytext, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(SimName == null) { Console.WriteLine("Warning: SimName is null, in " + this.GetType()); } - bytes[i++] = (byte)SimName.Length; - Array.Copy(SimName, 0, bytes, i, SimName.Length); i += SimName.Length; - bytes[i++] = (byte)Category; - bytes[i++] = (byte)(QueryFlags % 256); - bytes[i++] = (byte)((QueryFlags >> 8) % 256); - bytes[i++] = (byte)((QueryFlags >> 16) % 256); - bytes[i++] = (byte)((QueryFlags >> 24) % 256); - if(QueryText == null) { Console.WriteLine("Warning: QueryText is null, in " + this.GetType()); } - bytes[i++] = (byte)QueryText.Length; - Array.Copy(QueryText, 0, bytes, i, QueryText.Length); i += QueryText.Length; + { + if(SimName == null) { Console.WriteLine("Warning: SimName is null, in " + this.GetType()); } + bytes[i++] = (byte)SimName.Length; + Array.Copy(SimName, 0, bytes, i, SimName.Length); i += SimName.Length; + bytes[i++] = (byte)Category; + bytes[i++] = (byte)(QueryFlags % 256); + bytes[i++] = (byte)((QueryFlags >> 8) % 256); + bytes[i++] = (byte)((QueryFlags >> 16) % 256); + bytes[i++] = (byte)((QueryFlags >> 24) % 256); + if(QueryText == null) { Console.WriteLine("Warning: QueryText is null, in " + this.GetType()); } + bytes[i++] = (byte)QueryText.Length; + Array.Copy(QueryText, 0, bytes, i, QueryText.Length); i += QueryText.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- QueryData --\n"; - output += Helpers.FieldToString(SimName, "SimName") + "\n"; - output += "Category: " + Category.ToString() + "\n"; - output += "QueryFlags: " + QueryFlags.ToString() + "\n"; - output += Helpers.FieldToString(QueryText, "QueryText") + "\n"; + { + string output = "-- QueryData --\n"; + output += Helpers.FieldToString(SimName, "SimName") + "\n"; + output += "Category: " + Category.ToString() + "\n"; + output += "QueryFlags: " + QueryFlags.ToString() + "\n"; + output += Helpers.FieldToString(QueryText, "QueryText") + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - /// QueryID field - public LLUUID QueryID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + /// QueryID field + public LLUUID QueryID; + + /// Length of this block serialized in bytes public int Length { get - { - return 48; + { + return 48; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; - QueryID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; + QueryID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } - Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } + Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "QueryID: " + QueryID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "QueryID: " + QueryID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// TransactionData block + + /// TransactionData block public class TransactionDataBlock - { - /// TransactionID field - public LLUUID TransactionID; - - /// Length of this block serialized in bytes + { + /// TransactionID field + public LLUUID TransactionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public TransactionDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public TransactionDataBlock() { } + /// Constructor for building the block from a byte array public TransactionDataBlock(byte[] bytes, ref int i) - { + { try - { - TransactionID = new LLUUID(bytes, i); i += 16; + { + TransactionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } - Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } + Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- TransactionData --\n"; - output += "TransactionID: " + TransactionID.ToString() + "\n"; + { + string output = "-- TransactionData --\n"; + output += "TransactionID: " + TransactionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.PlacesQuery - public override PacketType Type { get { return PacketType.PlacesQuery; } } - /// QueryData block - public QueryDataBlock QueryData; - /// AgentData block - public AgentDataBlock AgentData; - /// TransactionData block - public TransactionDataBlock TransactionData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.PlacesQuery + public override PacketType Type { get { return PacketType.PlacesQuery; } } + /// QueryData block + public QueryDataBlock QueryData; + /// AgentData block + public AgentDataBlock AgentData; + /// TransactionData block + public TransactionDataBlock TransactionData; + + /// Default constructor public PlacesQueryPacket() - { - Header = new LowHeader(); - Header.ID = 41; - Header.Reliable = true; - Header.Zerocoded = true; - QueryData = new QueryDataBlock(); - AgentData = new AgentDataBlock(); - TransactionData = new TransactionDataBlock(); + { + Header = new LowHeader(); + Header.ID = 41; + Header.Reliable = true; + Header.Zerocoded = true; + QueryData = new QueryDataBlock(); + AgentData = new AgentDataBlock(); + TransactionData = new TransactionDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public PlacesQueryPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - QueryData = new QueryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); - TransactionData = new TransactionDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + QueryData = new QueryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); + TransactionData = new TransactionDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public PlacesQueryPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - QueryData = new QueryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); - TransactionData = new TransactionDataBlock(bytes, ref i); + { + Header = head; + QueryData = new QueryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); + TransactionData = new TransactionDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += QueryData.Length; length += AgentData.Length; length += TransactionData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - QueryData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - TransactionData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += QueryData.Length; length += AgentData.Length; length += TransactionData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + QueryData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + TransactionData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- PlacesQuery ---\n"; - output += QueryData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; - output += TransactionData.ToString() + "\n"; + { + string output = "--- PlacesQuery ---\n"; + output += QueryData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; + output += TransactionData.ToString() + "\n"; return output; } - + } - - /// PlacesReply packet + + /// PlacesReply packet public class PlacesReplyPacket : Packet - { - /// QueryData block + { + /// QueryData block public class QueryDataBlock - { - private byte[] _simname; - /// SimName field + { + private byte[] _simname; + /// SimName field public byte[] SimName - { - get { return _simname; } + { + get { return _simname; } set - { - if (value == null) { _simname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _simname = new byte[value.Length]; Array.Copy(value, _simname, value.Length); } + { + if (value == null) { _simname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _simname = new byte[value.Length]; Array.Copy(value, _simname, value.Length); } } - } - /// BillableArea field - public int BillableArea; - /// ActualArea field - public int ActualArea; - /// GlobalX field - public float GlobalX; - /// GlobalY field - public float GlobalY; - /// GlobalZ field - public float GlobalZ; - private byte[] _name; - /// Name field + } + /// BillableArea field + public int BillableArea; + /// ActualArea field + public int ActualArea; + /// GlobalX field + public float GlobalX; + /// GlobalY field + public float GlobalY; + /// GlobalZ field + public float GlobalZ; + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - private byte[] _desc; - /// Desc field + } + private byte[] _desc; + /// Desc field public byte[] Desc - { - get { return _desc; } + { + get { return _desc; } set - { - if (value == null) { _desc = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _desc = new byte[value.Length]; Array.Copy(value, _desc, value.Length); } + { + if (value == null) { _desc = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _desc = new byte[value.Length]; Array.Copy(value, _desc, value.Length); } } - } - /// OwnerID field - public LLUUID OwnerID; - /// SnapshotID field - public LLUUID SnapshotID; - /// Flags field - public byte Flags; - /// Price field - public int Price; - /// Dwell field - public float Dwell; - - /// Length of this block serialized in bytes + } + /// OwnerID field + public LLUUID OwnerID; + /// SnapshotID field + public LLUUID SnapshotID; + /// Flags field + public byte Flags; + /// Price field + public int Price; + /// Dwell field + public float Dwell; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 61; - if (SimName != null) { length += 1 + SimName.Length; } - if (Name != null) { length += 1 + Name.Length; } - if (Desc != null) { length += 1 + Desc.Length; } - return length; + { + int length = 61; + if (SimName != null) { length += 1 + SimName.Length; } + if (Name != null) { length += 1 + Name.Length; } + if (Desc != null) { length += 1 + Desc.Length; } + return length; } } - - /// Default constructor - public QueryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public QueryDataBlock() { } + /// Constructor for building the block from a byte array public QueryDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _simname = new byte[length]; - Array.Copy(bytes, i, _simname, 0, length); i += length; - BillableArea = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - ActualArea = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - GlobalX = BitConverter.ToSingle(bytes, i); i += 4; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - GlobalY = BitConverter.ToSingle(bytes, i); i += 4; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - GlobalZ = BitConverter.ToSingle(bytes, i); i += 4; - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; - length = (ushort)bytes[i++]; - _desc = new byte[length]; - Array.Copy(bytes, i, _desc, 0, length); i += length; - OwnerID = new LLUUID(bytes, i); i += 16; - SnapshotID = new LLUUID(bytes, i); i += 16; - Flags = (byte)bytes[i++]; - Price = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - Dwell = BitConverter.ToSingle(bytes, i); i += 4; + { + length = (ushort)bytes[i++]; + _simname = new byte[length]; + Array.Copy(bytes, i, _simname, 0, length); i += length; + BillableArea = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + ActualArea = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + GlobalX = BitConverter.ToSingle(bytes, i); i += 4; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + GlobalY = BitConverter.ToSingle(bytes, i); i += 4; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + GlobalZ = BitConverter.ToSingle(bytes, i); i += 4; + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; + length = (ushort)bytes[i++]; + _desc = new byte[length]; + Array.Copy(bytes, i, _desc, 0, length); i += length; + OwnerID = new LLUUID(bytes, i); i += 16; + SnapshotID = new LLUUID(bytes, i); i += 16; + Flags = (byte)bytes[i++]; + Price = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + Dwell = BitConverter.ToSingle(bytes, i); i += 4; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; - if(SimName == null) { Console.WriteLine("Warning: SimName is null, in " + this.GetType()); } - bytes[i++] = (byte)SimName.Length; - Array.Copy(SimName, 0, bytes, i, SimName.Length); i += SimName.Length; - bytes[i++] = (byte)(BillableArea % 256); - bytes[i++] = (byte)((BillableArea >> 8) % 256); - bytes[i++] = (byte)((BillableArea >> 16) % 256); - bytes[i++] = (byte)((BillableArea >> 24) % 256); - bytes[i++] = (byte)(ActualArea % 256); - bytes[i++] = (byte)((ActualArea >> 8) % 256); - bytes[i++] = (byte)((ActualArea >> 16) % 256); - bytes[i++] = (byte)((ActualArea >> 24) % 256); + { + byte[] ba; + if(SimName == null) { Console.WriteLine("Warning: SimName is null, in " + this.GetType()); } + bytes[i++] = (byte)SimName.Length; + Array.Copy(SimName, 0, bytes, i, SimName.Length); i += SimName.Length; + bytes[i++] = (byte)(BillableArea % 256); + bytes[i++] = (byte)((BillableArea >> 8) % 256); + bytes[i++] = (byte)((BillableArea >> 16) % 256); + bytes[i++] = (byte)((BillableArea >> 24) % 256); + bytes[i++] = (byte)(ActualArea % 256); + bytes[i++] = (byte)((ActualArea >> 8) % 256); + bytes[i++] = (byte)((ActualArea >> 16) % 256); + bytes[i++] = (byte)((ActualArea >> 24) % 256); ba = BitConverter.GetBytes(GlobalX); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; ba = BitConverter.GetBytes(GlobalY); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; ba = BitConverter.GetBytes(GlobalZ); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; - if(Desc == null) { Console.WriteLine("Warning: Desc is null, in " + this.GetType()); } - bytes[i++] = (byte)Desc.Length; - Array.Copy(Desc, 0, bytes, i, Desc.Length); i += Desc.Length; - if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } - Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SnapshotID == null) { Console.WriteLine("Warning: SnapshotID is null, in " + this.GetType()); } - Array.Copy(SnapshotID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = Flags; - bytes[i++] = (byte)(Price % 256); - bytes[i++] = (byte)((Price >> 8) % 256); - bytes[i++] = (byte)((Price >> 16) % 256); - bytes[i++] = (byte)((Price >> 24) % 256); + Array.Copy(ba, 0, bytes, i, 4); i += 4; + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + if(Desc == null) { Console.WriteLine("Warning: Desc is null, in " + this.GetType()); } + bytes[i++] = (byte)Desc.Length; + Array.Copy(Desc, 0, bytes, i, Desc.Length); i += Desc.Length; + if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } + Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SnapshotID == null) { Console.WriteLine("Warning: SnapshotID is null, in " + this.GetType()); } + Array.Copy(SnapshotID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = Flags; + bytes[i++] = (byte)(Price % 256); + bytes[i++] = (byte)((Price >> 8) % 256); + bytes[i++] = (byte)((Price >> 16) % 256); + bytes[i++] = (byte)((Price >> 24) % 256); ba = BitConverter.GetBytes(Dwell); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- QueryData --\n"; - output += Helpers.FieldToString(SimName, "SimName") + "\n"; - output += "BillableArea: " + BillableArea.ToString() + "\n"; - output += "ActualArea: " + ActualArea.ToString() + "\n"; - output += "GlobalX: " + GlobalX.ToString() + "\n"; - output += "GlobalY: " + GlobalY.ToString() + "\n"; - output += "GlobalZ: " + GlobalZ.ToString() + "\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; - output += Helpers.FieldToString(Desc, "Desc") + "\n"; - output += "OwnerID: " + OwnerID.ToString() + "\n"; - output += "SnapshotID: " + SnapshotID.ToString() + "\n"; - output += "Flags: " + Flags.ToString() + "\n"; - output += "Price: " + Price.ToString() + "\n"; - output += "Dwell: " + Dwell.ToString() + "\n"; + { + string output = "-- QueryData --\n"; + output += Helpers.FieldToString(SimName, "SimName") + "\n"; + output += "BillableArea: " + BillableArea.ToString() + "\n"; + output += "ActualArea: " + ActualArea.ToString() + "\n"; + output += "GlobalX: " + GlobalX.ToString() + "\n"; + output += "GlobalY: " + GlobalY.ToString() + "\n"; + output += "GlobalZ: " + GlobalZ.ToString() + "\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; + output += Helpers.FieldToString(Desc, "Desc") + "\n"; + output += "OwnerID: " + OwnerID.ToString() + "\n"; + output += "SnapshotID: " + SnapshotID.ToString() + "\n"; + output += "Flags: " + Flags.ToString() + "\n"; + output += "Price: " + Price.ToString() + "\n"; + output += "Dwell: " + Dwell.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// QueryID field - public LLUUID QueryID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// QueryID field + public LLUUID QueryID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - QueryID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + QueryID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } - Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } + Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "QueryID: " + QueryID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "QueryID: " + QueryID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// TransactionData block + + /// TransactionData block public class TransactionDataBlock - { - /// TransactionID field - public LLUUID TransactionID; - - /// Length of this block serialized in bytes + { + /// TransactionID field + public LLUUID TransactionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public TransactionDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public TransactionDataBlock() { } + /// Constructor for building the block from a byte array public TransactionDataBlock(byte[] bytes, ref int i) - { + { try - { - TransactionID = new LLUUID(bytes, i); i += 16; + { + TransactionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } - Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } + Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- TransactionData --\n"; - output += "TransactionID: " + TransactionID.ToString() + "\n"; + { + string output = "-- TransactionData --\n"; + output += "TransactionID: " + TransactionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.PlacesReply - public override PacketType Type { get { return PacketType.PlacesReply; } } - /// QueryData block - public QueryDataBlock[] QueryData; - /// AgentData block - public AgentDataBlock AgentData; - /// TransactionData block - public TransactionDataBlock TransactionData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.PlacesReply + public override PacketType Type { get { return PacketType.PlacesReply; } } + /// QueryData block + public QueryDataBlock[] QueryData; + /// AgentData block + public AgentDataBlock AgentData; + /// TransactionData block + public TransactionDataBlock TransactionData; + + /// Default constructor public PlacesReplyPacket() - { - Header = new LowHeader(); - Header.ID = 42; - Header.Reliable = true; - Header.Zerocoded = true; - QueryData = new QueryDataBlock[0]; - AgentData = new AgentDataBlock(); - TransactionData = new TransactionDataBlock(); + { + Header = new LowHeader(); + Header.ID = 42; + Header.Reliable = true; + Header.Zerocoded = true; + QueryData = new QueryDataBlock[0]; + AgentData = new AgentDataBlock(); + TransactionData = new TransactionDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public PlacesReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - QueryData = new QueryDataBlock[count]; - for (int j = 0; j < count; j++) - { QueryData[j] = new QueryDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); - TransactionData = new TransactionDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + QueryData = new QueryDataBlock[count]; + for (int j = 0; j < count; j++) + { QueryData[j] = new QueryDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); + TransactionData = new TransactionDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public PlacesReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - QueryData = new QueryDataBlock[count]; - for (int j = 0; j < count; j++) - { QueryData[j] = new QueryDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); - TransactionData = new TransactionDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + QueryData = new QueryDataBlock[count]; + for (int j = 0; j < count; j++) + { QueryData[j] = new QueryDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); + TransactionData = new TransactionDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length; length += TransactionData.Length;; - length++; - for (int j = 0; j < QueryData.Length; j++) { length += QueryData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)QueryData.Length; - for (int j = 0; j < QueryData.Length; j++) { QueryData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - TransactionData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length; length += TransactionData.Length;; + length++; + for (int j = 0; j < QueryData.Length; j++) { length += QueryData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)QueryData.Length; + for (int j = 0; j < QueryData.Length; j++) { QueryData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + TransactionData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- PlacesReply ---\n"; + { + string output = "--- PlacesReply ---\n"; for (int j = 0; j < QueryData.Length; j++) - { + { output += QueryData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; - output += TransactionData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; + output += TransactionData.ToString() + "\n"; return output; } - + } - - /// DirFindQuery packet + + /// DirFindQuery packet public class DirFindQueryPacket : Packet - { - /// QueryData block + { + /// QueryData block public class QueryDataBlock - { - /// QueryID field - public LLUUID QueryID; - /// QueryFlags field - public uint QueryFlags; - /// QueryStart field - public int QueryStart; - private byte[] _querytext; - /// QueryText field + { + /// QueryID field + public LLUUID QueryID; + /// QueryFlags field + public uint QueryFlags; + /// QueryStart field + public int QueryStart; + private byte[] _querytext; + /// QueryText field public byte[] QueryText - { - get { return _querytext; } + { + get { return _querytext; } set - { - if (value == null) { _querytext = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _querytext = new byte[value.Length]; Array.Copy(value, _querytext, value.Length); } + { + if (value == null) { _querytext = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _querytext = new byte[value.Length]; Array.Copy(value, _querytext, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 24; - if (QueryText != null) { length += 1 + QueryText.Length; } - return length; + { + int length = 24; + if (QueryText != null) { length += 1 + QueryText.Length; } + return length; } } - - /// Default constructor - public QueryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public QueryDataBlock() { } + /// Constructor for building the block from a byte array public QueryDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - QueryID = new LLUUID(bytes, i); i += 16; - QueryFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - QueryStart = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _querytext = new byte[length]; - Array.Copy(bytes, i, _querytext, 0, length); i += length; + { + QueryID = new LLUUID(bytes, i); i += 16; + QueryFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + QueryStart = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _querytext = new byte[length]; + Array.Copy(bytes, i, _querytext, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } - Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(QueryFlags % 256); - bytes[i++] = (byte)((QueryFlags >> 8) % 256); - bytes[i++] = (byte)((QueryFlags >> 16) % 256); - bytes[i++] = (byte)((QueryFlags >> 24) % 256); - bytes[i++] = (byte)(QueryStart % 256); - bytes[i++] = (byte)((QueryStart >> 8) % 256); - bytes[i++] = (byte)((QueryStart >> 16) % 256); - bytes[i++] = (byte)((QueryStart >> 24) % 256); - if(QueryText == null) { Console.WriteLine("Warning: QueryText is null, in " + this.GetType()); } - bytes[i++] = (byte)QueryText.Length; - Array.Copy(QueryText, 0, bytes, i, QueryText.Length); i += QueryText.Length; + { + if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } + Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(QueryFlags % 256); + bytes[i++] = (byte)((QueryFlags >> 8) % 256); + bytes[i++] = (byte)((QueryFlags >> 16) % 256); + bytes[i++] = (byte)((QueryFlags >> 24) % 256); + bytes[i++] = (byte)(QueryStart % 256); + bytes[i++] = (byte)((QueryStart >> 8) % 256); + bytes[i++] = (byte)((QueryStart >> 16) % 256); + bytes[i++] = (byte)((QueryStart >> 24) % 256); + if(QueryText == null) { Console.WriteLine("Warning: QueryText is null, in " + this.GetType()); } + bytes[i++] = (byte)QueryText.Length; + Array.Copy(QueryText, 0, bytes, i, QueryText.Length); i += QueryText.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- QueryData --\n"; - output += "QueryID: " + QueryID.ToString() + "\n"; - output += "QueryFlags: " + QueryFlags.ToString() + "\n"; - output += "QueryStart: " + QueryStart.ToString() + "\n"; - output += Helpers.FieldToString(QueryText, "QueryText") + "\n"; + { + string output = "-- QueryData --\n"; + output += "QueryID: " + QueryID.ToString() + "\n"; + output += "QueryFlags: " + QueryFlags.ToString() + "\n"; + output += "QueryStart: " + QueryStart.ToString() + "\n"; + output += Helpers.FieldToString(QueryText, "QueryText") + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.DirFindQuery - public override PacketType Type { get { return PacketType.DirFindQuery; } } - /// QueryData block - public QueryDataBlock QueryData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.DirFindQuery + public override PacketType Type { get { return PacketType.DirFindQuery; } } + /// QueryData block + public QueryDataBlock QueryData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public DirFindQueryPacket() - { - Header = new LowHeader(); - Header.ID = 43; - Header.Reliable = true; - Header.Zerocoded = true; - QueryData = new QueryDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 43; + Header.Reliable = true; + Header.Zerocoded = true; + QueryData = new QueryDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public DirFindQueryPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - QueryData = new QueryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + QueryData = new QueryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public DirFindQueryPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - QueryData = new QueryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + QueryData = new QueryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += QueryData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - QueryData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += QueryData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + QueryData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- DirFindQuery ---\n"; - output += QueryData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- DirFindQuery ---\n"; + output += QueryData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// DirFindQueryBackend packet + + /// DirFindQueryBackend packet public class DirFindQueryBackendPacket : Packet - { - /// QueryData block + { + /// QueryData block public class QueryDataBlock - { - /// SpaceIP field - public uint SpaceIP; - /// Godlike field - public bool Godlike; - /// QueryID field - public LLUUID QueryID; - /// QueryFlags field - public uint QueryFlags; - /// QueryStart field - public int QueryStart; - private byte[] _querytext; - /// QueryText field + { + /// SpaceIP field + public uint SpaceIP; + /// Godlike field + public bool Godlike; + /// QueryID field + public LLUUID QueryID; + /// QueryFlags field + public uint QueryFlags; + /// QueryStart field + public int QueryStart; + private byte[] _querytext; + /// QueryText field public byte[] QueryText - { - get { return _querytext; } + { + get { return _querytext; } set - { - if (value == null) { _querytext = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _querytext = new byte[value.Length]; Array.Copy(value, _querytext, value.Length); } + { + if (value == null) { _querytext = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _querytext = new byte[value.Length]; Array.Copy(value, _querytext, value.Length); } } - } - /// EstateID field - public uint EstateID; - - /// Length of this block serialized in bytes + } + /// EstateID field + public uint EstateID; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 33; - if (QueryText != null) { length += 1 + QueryText.Length; } - return length; + { + int length = 33; + if (QueryText != null) { length += 1 + QueryText.Length; } + return length; } } - - /// Default constructor - public QueryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public QueryDataBlock() { } + /// Constructor for building the block from a byte array public QueryDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - SpaceIP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Godlike = (bytes[i++] != 0) ? (bool)true : (bool)false; - QueryID = new LLUUID(bytes, i); i += 16; - QueryFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - QueryStart = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _querytext = new byte[length]; - Array.Copy(bytes, i, _querytext, 0, length); i += length; - EstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + SpaceIP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Godlike = (bytes[i++] != 0) ? (bool)true : (bool)false; + QueryID = new LLUUID(bytes, i); i += 16; + QueryFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + QueryStart = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _querytext = new byte[length]; + Array.Copy(bytes, i, _querytext, 0, length); i += length; + EstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(SpaceIP % 256); - bytes[i++] = (byte)((SpaceIP >> 8) % 256); - bytes[i++] = (byte)((SpaceIP >> 16) % 256); - bytes[i++] = (byte)((SpaceIP >> 24) % 256); - bytes[i++] = (byte)((Godlike) ? 1 : 0); - if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } - Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(QueryFlags % 256); - bytes[i++] = (byte)((QueryFlags >> 8) % 256); - bytes[i++] = (byte)((QueryFlags >> 16) % 256); - bytes[i++] = (byte)((QueryFlags >> 24) % 256); - bytes[i++] = (byte)(QueryStart % 256); - bytes[i++] = (byte)((QueryStart >> 8) % 256); - bytes[i++] = (byte)((QueryStart >> 16) % 256); - bytes[i++] = (byte)((QueryStart >> 24) % 256); - if(QueryText == null) { Console.WriteLine("Warning: QueryText is null, in " + this.GetType()); } - bytes[i++] = (byte)QueryText.Length; - Array.Copy(QueryText, 0, bytes, i, QueryText.Length); i += QueryText.Length; - bytes[i++] = (byte)(EstateID % 256); - bytes[i++] = (byte)((EstateID >> 8) % 256); - bytes[i++] = (byte)((EstateID >> 16) % 256); - bytes[i++] = (byte)((EstateID >> 24) % 256); + { + bytes[i++] = (byte)(SpaceIP % 256); + bytes[i++] = (byte)((SpaceIP >> 8) % 256); + bytes[i++] = (byte)((SpaceIP >> 16) % 256); + bytes[i++] = (byte)((SpaceIP >> 24) % 256); + bytes[i++] = (byte)((Godlike) ? 1 : 0); + if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } + Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(QueryFlags % 256); + bytes[i++] = (byte)((QueryFlags >> 8) % 256); + bytes[i++] = (byte)((QueryFlags >> 16) % 256); + bytes[i++] = (byte)((QueryFlags >> 24) % 256); + bytes[i++] = (byte)(QueryStart % 256); + bytes[i++] = (byte)((QueryStart >> 8) % 256); + bytes[i++] = (byte)((QueryStart >> 16) % 256); + bytes[i++] = (byte)((QueryStart >> 24) % 256); + if(QueryText == null) { Console.WriteLine("Warning: QueryText is null, in " + this.GetType()); } + bytes[i++] = (byte)QueryText.Length; + Array.Copy(QueryText, 0, bytes, i, QueryText.Length); i += QueryText.Length; + bytes[i++] = (byte)(EstateID % 256); + bytes[i++] = (byte)((EstateID >> 8) % 256); + bytes[i++] = (byte)((EstateID >> 16) % 256); + bytes[i++] = (byte)((EstateID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- QueryData --\n"; - output += "SpaceIP: " + SpaceIP.ToString() + "\n"; - output += "Godlike: " + Godlike.ToString() + "\n"; - output += "QueryID: " + QueryID.ToString() + "\n"; - output += "QueryFlags: " + QueryFlags.ToString() + "\n"; - output += "QueryStart: " + QueryStart.ToString() + "\n"; - output += Helpers.FieldToString(QueryText, "QueryText") + "\n"; - output += "EstateID: " + EstateID.ToString() + "\n"; + { + string output = "-- QueryData --\n"; + output += "SpaceIP: " + SpaceIP.ToString() + "\n"; + output += "Godlike: " + Godlike.ToString() + "\n"; + output += "QueryID: " + QueryID.ToString() + "\n"; + output += "QueryFlags: " + QueryFlags.ToString() + "\n"; + output += "QueryStart: " + QueryStart.ToString() + "\n"; + output += Helpers.FieldToString(QueryText, "QueryText") + "\n"; + output += "EstateID: " + EstateID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.DirFindQueryBackend - public override PacketType Type { get { return PacketType.DirFindQueryBackend; } } - /// QueryData block - public QueryDataBlock QueryData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.DirFindQueryBackend + public override PacketType Type { get { return PacketType.DirFindQueryBackend; } } + /// QueryData block + public QueryDataBlock QueryData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public DirFindQueryBackendPacket() - { - Header = new LowHeader(); - Header.ID = 44; - Header.Reliable = true; - Header.Zerocoded = true; - QueryData = new QueryDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 44; + Header.Reliable = true; + Header.Zerocoded = true; + QueryData = new QueryDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public DirFindQueryBackendPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - QueryData = new QueryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + QueryData = new QueryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public DirFindQueryBackendPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - QueryData = new QueryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + QueryData = new QueryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += QueryData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - QueryData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += QueryData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + QueryData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- DirFindQueryBackend ---\n"; - output += QueryData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- DirFindQueryBackend ---\n"; + output += QueryData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// DirPlacesQuery packet + + /// DirPlacesQuery packet public class DirPlacesQueryPacket : Packet - { - /// QueryData block + { + /// QueryData block public class QueryDataBlock - { - private byte[] _simname; - /// SimName field + { + private byte[] _simname; + /// SimName field public byte[] SimName - { - get { return _simname; } + { + get { return _simname; } set - { - if (value == null) { _simname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _simname = new byte[value.Length]; Array.Copy(value, _simname, value.Length); } + { + if (value == null) { _simname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _simname = new byte[value.Length]; Array.Copy(value, _simname, value.Length); } } - } - /// QueryID field - public LLUUID QueryID; - /// Category field - public sbyte Category; - /// QueryFlags field - public uint QueryFlags; - /// QueryStart field - public int QueryStart; - private byte[] _querytext; - /// QueryText field + } + /// QueryID field + public LLUUID QueryID; + /// Category field + public sbyte Category; + /// QueryFlags field + public uint QueryFlags; + /// QueryStart field + public int QueryStart; + private byte[] _querytext; + /// QueryText field public byte[] QueryText - { - get { return _querytext; } + { + get { return _querytext; } set - { - if (value == null) { _querytext = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _querytext = new byte[value.Length]; Array.Copy(value, _querytext, value.Length); } + { + if (value == null) { _querytext = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _querytext = new byte[value.Length]; Array.Copy(value, _querytext, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 25; - if (SimName != null) { length += 1 + SimName.Length; } - if (QueryText != null) { length += 1 + QueryText.Length; } - return length; + { + int length = 25; + if (SimName != null) { length += 1 + SimName.Length; } + if (QueryText != null) { length += 1 + QueryText.Length; } + return length; } } - - /// Default constructor - public QueryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public QueryDataBlock() { } + /// Constructor for building the block from a byte array public QueryDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _simname = new byte[length]; - Array.Copy(bytes, i, _simname, 0, length); i += length; - QueryID = new LLUUID(bytes, i); i += 16; - Category = (sbyte)bytes[i++]; - QueryFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - QueryStart = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _querytext = new byte[length]; - Array.Copy(bytes, i, _querytext, 0, length); i += length; + { + length = (ushort)bytes[i++]; + _simname = new byte[length]; + Array.Copy(bytes, i, _simname, 0, length); i += length; + QueryID = new LLUUID(bytes, i); i += 16; + Category = (sbyte)bytes[i++]; + QueryFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + QueryStart = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _querytext = new byte[length]; + Array.Copy(bytes, i, _querytext, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(SimName == null) { Console.WriteLine("Warning: SimName is null, in " + this.GetType()); } - bytes[i++] = (byte)SimName.Length; - Array.Copy(SimName, 0, bytes, i, SimName.Length); i += SimName.Length; - if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } - Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)Category; - bytes[i++] = (byte)(QueryFlags % 256); - bytes[i++] = (byte)((QueryFlags >> 8) % 256); - bytes[i++] = (byte)((QueryFlags >> 16) % 256); - bytes[i++] = (byte)((QueryFlags >> 24) % 256); - bytes[i++] = (byte)(QueryStart % 256); - bytes[i++] = (byte)((QueryStart >> 8) % 256); - bytes[i++] = (byte)((QueryStart >> 16) % 256); - bytes[i++] = (byte)((QueryStart >> 24) % 256); - if(QueryText == null) { Console.WriteLine("Warning: QueryText is null, in " + this.GetType()); } - bytes[i++] = (byte)QueryText.Length; - Array.Copy(QueryText, 0, bytes, i, QueryText.Length); i += QueryText.Length; + { + if(SimName == null) { Console.WriteLine("Warning: SimName is null, in " + this.GetType()); } + bytes[i++] = (byte)SimName.Length; + Array.Copy(SimName, 0, bytes, i, SimName.Length); i += SimName.Length; + if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } + Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)Category; + bytes[i++] = (byte)(QueryFlags % 256); + bytes[i++] = (byte)((QueryFlags >> 8) % 256); + bytes[i++] = (byte)((QueryFlags >> 16) % 256); + bytes[i++] = (byte)((QueryFlags >> 24) % 256); + bytes[i++] = (byte)(QueryStart % 256); + bytes[i++] = (byte)((QueryStart >> 8) % 256); + bytes[i++] = (byte)((QueryStart >> 16) % 256); + bytes[i++] = (byte)((QueryStart >> 24) % 256); + if(QueryText == null) { Console.WriteLine("Warning: QueryText is null, in " + this.GetType()); } + bytes[i++] = (byte)QueryText.Length; + Array.Copy(QueryText, 0, bytes, i, QueryText.Length); i += QueryText.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- QueryData --\n"; - output += Helpers.FieldToString(SimName, "SimName") + "\n"; - output += "QueryID: " + QueryID.ToString() + "\n"; - output += "Category: " + Category.ToString() + "\n"; - output += "QueryFlags: " + QueryFlags.ToString() + "\n"; - output += "QueryStart: " + QueryStart.ToString() + "\n"; - output += Helpers.FieldToString(QueryText, "QueryText") + "\n"; + { + string output = "-- QueryData --\n"; + output += Helpers.FieldToString(SimName, "SimName") + "\n"; + output += "QueryID: " + QueryID.ToString() + "\n"; + output += "Category: " + Category.ToString() + "\n"; + output += "QueryFlags: " + QueryFlags.ToString() + "\n"; + output += "QueryStart: " + QueryStart.ToString() + "\n"; + output += Helpers.FieldToString(QueryText, "QueryText") + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.DirPlacesQuery - public override PacketType Type { get { return PacketType.DirPlacesQuery; } } - /// QueryData block - public QueryDataBlock QueryData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.DirPlacesQuery + public override PacketType Type { get { return PacketType.DirPlacesQuery; } } + /// QueryData block + public QueryDataBlock QueryData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public DirPlacesQueryPacket() - { - Header = new LowHeader(); - Header.ID = 45; - Header.Reliable = true; - Header.Zerocoded = true; - QueryData = new QueryDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 45; + Header.Reliable = true; + Header.Zerocoded = true; + QueryData = new QueryDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public DirPlacesQueryPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - QueryData = new QueryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + QueryData = new QueryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public DirPlacesQueryPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - QueryData = new QueryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + QueryData = new QueryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += QueryData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - QueryData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += QueryData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + QueryData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- DirPlacesQuery ---\n"; - output += QueryData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- DirPlacesQuery ---\n"; + output += QueryData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// DirPlacesQueryBackend packet + + /// DirPlacesQueryBackend packet public class DirPlacesQueryBackendPacket : Packet - { - /// QueryData block + { + /// QueryData block public class QueryDataBlock - { - private byte[] _simname; - /// SimName field + { + private byte[] _simname; + /// SimName field public byte[] SimName - { - get { return _simname; } + { + get { return _simname; } set - { - if (value == null) { _simname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _simname = new byte[value.Length]; Array.Copy(value, _simname, value.Length); } + { + if (value == null) { _simname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _simname = new byte[value.Length]; Array.Copy(value, _simname, value.Length); } } - } - /// Godlike field - public bool Godlike; - /// QueryID field - public LLUUID QueryID; - /// Category field - public sbyte Category; - /// QueryFlags field - public uint QueryFlags; - /// QueryStart field - public int QueryStart; - private byte[] _querytext; - /// QueryText field + } + /// Godlike field + public bool Godlike; + /// QueryID field + public LLUUID QueryID; + /// Category field + public sbyte Category; + /// QueryFlags field + public uint QueryFlags; + /// QueryStart field + public int QueryStart; + private byte[] _querytext; + /// QueryText field public byte[] QueryText - { - get { return _querytext; } + { + get { return _querytext; } set - { - if (value == null) { _querytext = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _querytext = new byte[value.Length]; Array.Copy(value, _querytext, value.Length); } + { + if (value == null) { _querytext = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _querytext = new byte[value.Length]; Array.Copy(value, _querytext, value.Length); } } - } - /// EstateID field - public uint EstateID; - - /// Length of this block serialized in bytes + } + /// EstateID field + public uint EstateID; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 30; - if (SimName != null) { length += 1 + SimName.Length; } - if (QueryText != null) { length += 1 + QueryText.Length; } - return length; + { + int length = 30; + if (SimName != null) { length += 1 + SimName.Length; } + if (QueryText != null) { length += 1 + QueryText.Length; } + return length; } } - - /// Default constructor - public QueryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public QueryDataBlock() { } + /// Constructor for building the block from a byte array public QueryDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _simname = new byte[length]; - Array.Copy(bytes, i, _simname, 0, length); i += length; - Godlike = (bytes[i++] != 0) ? (bool)true : (bool)false; - QueryID = new LLUUID(bytes, i); i += 16; - Category = (sbyte)bytes[i++]; - QueryFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - QueryStart = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _querytext = new byte[length]; - Array.Copy(bytes, i, _querytext, 0, length); i += length; - EstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + length = (ushort)bytes[i++]; + _simname = new byte[length]; + Array.Copy(bytes, i, _simname, 0, length); i += length; + Godlike = (bytes[i++] != 0) ? (bool)true : (bool)false; + QueryID = new LLUUID(bytes, i); i += 16; + Category = (sbyte)bytes[i++]; + QueryFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + QueryStart = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _querytext = new byte[length]; + Array.Copy(bytes, i, _querytext, 0, length); i += length; + EstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(SimName == null) { Console.WriteLine("Warning: SimName is null, in " + this.GetType()); } - bytes[i++] = (byte)SimName.Length; - Array.Copy(SimName, 0, bytes, i, SimName.Length); i += SimName.Length; - bytes[i++] = (byte)((Godlike) ? 1 : 0); - if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } - Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)Category; - bytes[i++] = (byte)(QueryFlags % 256); - bytes[i++] = (byte)((QueryFlags >> 8) % 256); - bytes[i++] = (byte)((QueryFlags >> 16) % 256); - bytes[i++] = (byte)((QueryFlags >> 24) % 256); - bytes[i++] = (byte)(QueryStart % 256); - bytes[i++] = (byte)((QueryStart >> 8) % 256); - bytes[i++] = (byte)((QueryStart >> 16) % 256); - bytes[i++] = (byte)((QueryStart >> 24) % 256); - if(QueryText == null) { Console.WriteLine("Warning: QueryText is null, in " + this.GetType()); } - bytes[i++] = (byte)QueryText.Length; - Array.Copy(QueryText, 0, bytes, i, QueryText.Length); i += QueryText.Length; - bytes[i++] = (byte)(EstateID % 256); - bytes[i++] = (byte)((EstateID >> 8) % 256); - bytes[i++] = (byte)((EstateID >> 16) % 256); - bytes[i++] = (byte)((EstateID >> 24) % 256); + { + if(SimName == null) { Console.WriteLine("Warning: SimName is null, in " + this.GetType()); } + bytes[i++] = (byte)SimName.Length; + Array.Copy(SimName, 0, bytes, i, SimName.Length); i += SimName.Length; + bytes[i++] = (byte)((Godlike) ? 1 : 0); + if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } + Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)Category; + bytes[i++] = (byte)(QueryFlags % 256); + bytes[i++] = (byte)((QueryFlags >> 8) % 256); + bytes[i++] = (byte)((QueryFlags >> 16) % 256); + bytes[i++] = (byte)((QueryFlags >> 24) % 256); + bytes[i++] = (byte)(QueryStart % 256); + bytes[i++] = (byte)((QueryStart >> 8) % 256); + bytes[i++] = (byte)((QueryStart >> 16) % 256); + bytes[i++] = (byte)((QueryStart >> 24) % 256); + if(QueryText == null) { Console.WriteLine("Warning: QueryText is null, in " + this.GetType()); } + bytes[i++] = (byte)QueryText.Length; + Array.Copy(QueryText, 0, bytes, i, QueryText.Length); i += QueryText.Length; + bytes[i++] = (byte)(EstateID % 256); + bytes[i++] = (byte)((EstateID >> 8) % 256); + bytes[i++] = (byte)((EstateID >> 16) % 256); + bytes[i++] = (byte)((EstateID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- QueryData --\n"; - output += Helpers.FieldToString(SimName, "SimName") + "\n"; - output += "Godlike: " + Godlike.ToString() + "\n"; - output += "QueryID: " + QueryID.ToString() + "\n"; - output += "Category: " + Category.ToString() + "\n"; - output += "QueryFlags: " + QueryFlags.ToString() + "\n"; - output += "QueryStart: " + QueryStart.ToString() + "\n"; - output += Helpers.FieldToString(QueryText, "QueryText") + "\n"; - output += "EstateID: " + EstateID.ToString() + "\n"; + { + string output = "-- QueryData --\n"; + output += Helpers.FieldToString(SimName, "SimName") + "\n"; + output += "Godlike: " + Godlike.ToString() + "\n"; + output += "QueryID: " + QueryID.ToString() + "\n"; + output += "Category: " + Category.ToString() + "\n"; + output += "QueryFlags: " + QueryFlags.ToString() + "\n"; + output += "QueryStart: " + QueryStart.ToString() + "\n"; + output += Helpers.FieldToString(QueryText, "QueryText") + "\n"; + output += "EstateID: " + EstateID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.DirPlacesQueryBackend - public override PacketType Type { get { return PacketType.DirPlacesQueryBackend; } } - /// QueryData block - public QueryDataBlock QueryData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.DirPlacesQueryBackend + public override PacketType Type { get { return PacketType.DirPlacesQueryBackend; } } + /// QueryData block + public QueryDataBlock QueryData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public DirPlacesQueryBackendPacket() - { - Header = new LowHeader(); - Header.ID = 46; - Header.Reliable = true; - Header.Zerocoded = true; - QueryData = new QueryDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 46; + Header.Reliable = true; + Header.Zerocoded = true; + QueryData = new QueryDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public DirPlacesQueryBackendPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - QueryData = new QueryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + QueryData = new QueryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public DirPlacesQueryBackendPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - QueryData = new QueryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + QueryData = new QueryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += QueryData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - QueryData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += QueryData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + QueryData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- DirPlacesQueryBackend ---\n"; - output += QueryData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- DirPlacesQueryBackend ---\n"; + output += QueryData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// DirPlacesReply packet + + /// DirPlacesReply packet public class DirPlacesReplyPacket : Packet - { - /// QueryReplies block + { + /// QueryReplies block public class QueryRepliesBlock - { - /// ReservedNewbie field - public bool ReservedNewbie; - /// ForSale field - public bool ForSale; - /// ParcelID field - public LLUUID ParcelID; - private byte[] _name; - /// Name field + { + /// ReservedNewbie field + public bool ReservedNewbie; + /// ForSale field + public bool ForSale; + /// ParcelID field + public LLUUID ParcelID; + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - /// Auction field - public bool Auction; - /// Dwell field - public float Dwell; - - /// Length of this block serialized in bytes + } + /// Auction field + public bool Auction; + /// Dwell field + public float Dwell; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 23; - if (Name != null) { length += 1 + Name.Length; } - return length; + { + int length = 23; + if (Name != null) { length += 1 + Name.Length; } + return length; } } - - /// Default constructor - public QueryRepliesBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public QueryRepliesBlock() { } + /// Constructor for building the block from a byte array public QueryRepliesBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - ReservedNewbie = (bytes[i++] != 0) ? (bool)true : (bool)false; - ForSale = (bytes[i++] != 0) ? (bool)true : (bool)false; - ParcelID = new LLUUID(bytes, i); i += 16; - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; - Auction = (bytes[i++] != 0) ? (bool)true : (bool)false; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - Dwell = BitConverter.ToSingle(bytes, i); i += 4; + { + ReservedNewbie = (bytes[i++] != 0) ? (bool)true : (bool)false; + ForSale = (bytes[i++] != 0) ? (bool)true : (bool)false; + ParcelID = new LLUUID(bytes, i); i += 16; + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; + Auction = (bytes[i++] != 0) ? (bool)true : (bool)false; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + Dwell = BitConverter.ToSingle(bytes, i); i += 4; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; - bytes[i++] = (byte)((ReservedNewbie) ? 1 : 0); - bytes[i++] = (byte)((ForSale) ? 1 : 0); - if(ParcelID == null) { Console.WriteLine("Warning: ParcelID is null, in " + this.GetType()); } - Array.Copy(ParcelID.GetBytes(), 0, bytes, i, 16); i += 16; - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; - bytes[i++] = (byte)((Auction) ? 1 : 0); + { + byte[] ba; + bytes[i++] = (byte)((ReservedNewbie) ? 1 : 0); + bytes[i++] = (byte)((ForSale) ? 1 : 0); + if(ParcelID == null) { Console.WriteLine("Warning: ParcelID is null, in " + this.GetType()); } + Array.Copy(ParcelID.GetBytes(), 0, bytes, i, 16); i += 16; + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + bytes[i++] = (byte)((Auction) ? 1 : 0); ba = BitConverter.GetBytes(Dwell); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- QueryReplies --\n"; - output += "ReservedNewbie: " + ReservedNewbie.ToString() + "\n"; - output += "ForSale: " + ForSale.ToString() + "\n"; - output += "ParcelID: " + ParcelID.ToString() + "\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; - output += "Auction: " + Auction.ToString() + "\n"; - output += "Dwell: " + Dwell.ToString() + "\n"; + { + string output = "-- QueryReplies --\n"; + output += "ReservedNewbie: " + ReservedNewbie.ToString() + "\n"; + output += "ForSale: " + ForSale.ToString() + "\n"; + output += "ParcelID: " + ParcelID.ToString() + "\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; + output += "Auction: " + Auction.ToString() + "\n"; + output += "Dwell: " + Dwell.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// QueryData block + + /// QueryData block public class QueryDataBlock - { - /// QueryID field - public LLUUID QueryID; - - /// Length of this block serialized in bytes + { + /// QueryID field + public LLUUID QueryID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public QueryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public QueryDataBlock() { } + /// Constructor for building the block from a byte array public QueryDataBlock(byte[] bytes, ref int i) - { + { try - { - QueryID = new LLUUID(bytes, i); i += 16; + { + QueryID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } - Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } + Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- QueryData --\n"; - output += "QueryID: " + QueryID.ToString() + "\n"; + { + string output = "-- QueryData --\n"; + output += "QueryID: " + QueryID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.DirPlacesReply - public override PacketType Type { get { return PacketType.DirPlacesReply; } } - /// QueryReplies block - public QueryRepliesBlock[] QueryReplies; - /// QueryData block - public QueryDataBlock[] QueryData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.DirPlacesReply + public override PacketType Type { get { return PacketType.DirPlacesReply; } } + /// QueryReplies block + public QueryRepliesBlock[] QueryReplies; + /// QueryData block + public QueryDataBlock[] QueryData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public DirPlacesReplyPacket() - { - Header = new LowHeader(); - Header.ID = 47; - Header.Reliable = true; - Header.Zerocoded = true; - QueryReplies = new QueryRepliesBlock[0]; - QueryData = new QueryDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 47; + Header.Reliable = true; + Header.Zerocoded = true; + QueryReplies = new QueryRepliesBlock[0]; + QueryData = new QueryDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public DirPlacesReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - QueryReplies = new QueryRepliesBlock[count]; - for (int j = 0; j < count; j++) - { QueryReplies[j] = new QueryRepliesBlock(bytes, ref i); } - count = (int)bytes[i++]; - QueryData = new QueryDataBlock[count]; - for (int j = 0; j < count; j++) - { QueryData[j] = new QueryDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + QueryReplies = new QueryRepliesBlock[count]; + for (int j = 0; j < count; j++) + { QueryReplies[j] = new QueryRepliesBlock(bytes, ref i); } + count = (int)bytes[i++]; + QueryData = new QueryDataBlock[count]; + for (int j = 0; j < count; j++) + { QueryData[j] = new QueryDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public DirPlacesReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - QueryReplies = new QueryRepliesBlock[count]; - for (int j = 0; j < count; j++) - { QueryReplies[j] = new QueryRepliesBlock(bytes, ref i); } - count = (int)bytes[i++]; - QueryData = new QueryDataBlock[count]; - for (int j = 0; j < count; j++) - { QueryData[j] = new QueryDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + QueryReplies = new QueryRepliesBlock[count]; + for (int j = 0; j < count; j++) + { QueryReplies[j] = new QueryRepliesBlock(bytes, ref i); } + count = (int)bytes[i++]; + QueryData = new QueryDataBlock[count]; + for (int j = 0; j < count; j++) + { QueryData[j] = new QueryDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < QueryReplies.Length; j++) { length += QueryReplies[j].Length; } - length++; - for (int j = 0; j < QueryData.Length; j++) { length += QueryData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)QueryReplies.Length; - for (int j = 0; j < QueryReplies.Length; j++) { QueryReplies[j].ToBytes(bytes, ref i); } - bytes[i++] = (byte)QueryData.Length; - for (int j = 0; j < QueryData.Length; j++) { QueryData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < QueryReplies.Length; j++) { length += QueryReplies[j].Length; } + length++; + for (int j = 0; j < QueryData.Length; j++) { length += QueryData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)QueryReplies.Length; + for (int j = 0; j < QueryReplies.Length; j++) { QueryReplies[j].ToBytes(bytes, ref i); } + bytes[i++] = (byte)QueryData.Length; + for (int j = 0; j < QueryData.Length; j++) { QueryData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- DirPlacesReply ---\n"; + { + string output = "--- DirPlacesReply ---\n"; for (int j = 0; j < QueryReplies.Length; j++) - { + { output += QueryReplies[j].ToString() + "\n"; - } + } for (int j = 0; j < QueryData.Length; j++) - { + { output += QueryData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// DirPeopleQuery packet + + /// DirPeopleQuery packet public class DirPeopleQueryPacket : Packet - { - /// QueryData block + { + /// QueryData block public class QueryDataBlock - { - /// SkillFlags field - public uint SkillFlags; - private byte[] _name; - /// Name field + { + /// SkillFlags field + public uint SkillFlags; + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - /// QueryID field - public LLUUID QueryID; - /// Online field - public byte Online; - private byte[] _reputation; - /// Reputation field + } + /// QueryID field + public LLUUID QueryID; + /// Online field + public byte Online; + private byte[] _reputation; + /// Reputation field public byte[] Reputation - { - get { return _reputation; } + { + get { return _reputation; } set - { - if (value == null) { _reputation = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _reputation = new byte[value.Length]; Array.Copy(value, _reputation, value.Length); } + { + if (value == null) { _reputation = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _reputation = new byte[value.Length]; Array.Copy(value, _reputation, value.Length); } } - } - private byte[] _distance; - /// Distance field + } + private byte[] _distance; + /// Distance field public byte[] Distance - { - get { return _distance; } + { + get { return _distance; } set - { - if (value == null) { _distance = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _distance = new byte[value.Length]; Array.Copy(value, _distance, value.Length); } + { + if (value == null) { _distance = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _distance = new byte[value.Length]; Array.Copy(value, _distance, value.Length); } } - } - private byte[] _group; - /// Group field + } + private byte[] _group; + /// Group field public byte[] Group - { - get { return _group; } + { + get { return _group; } set - { - if (value == null) { _group = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _group = new byte[value.Length]; Array.Copy(value, _group, value.Length); } + { + if (value == null) { _group = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _group = new byte[value.Length]; Array.Copy(value, _group, value.Length); } } - } - private byte[] _querytext; - /// QueryText field + } + private byte[] _querytext; + /// QueryText field public byte[] QueryText - { - get { return _querytext; } + { + get { return _querytext; } set - { - if (value == null) { _querytext = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _querytext = new byte[value.Length]; Array.Copy(value, _querytext, value.Length); } + { + if (value == null) { _querytext = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _querytext = new byte[value.Length]; Array.Copy(value, _querytext, value.Length); } } - } - /// WantToFlags field - public uint WantToFlags; - - /// Length of this block serialized in bytes + } + /// WantToFlags field + public uint WantToFlags; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 25; - if (Name != null) { length += 1 + Name.Length; } - if (Reputation != null) { length += 1 + Reputation.Length; } - if (Distance != null) { length += 1 + Distance.Length; } - if (Group != null) { length += 1 + Group.Length; } - if (QueryText != null) { length += 1 + QueryText.Length; } - return length; + { + int length = 25; + if (Name != null) { length += 1 + Name.Length; } + if (Reputation != null) { length += 1 + Reputation.Length; } + if (Distance != null) { length += 1 + Distance.Length; } + if (Group != null) { length += 1 + Group.Length; } + if (QueryText != null) { length += 1 + QueryText.Length; } + return length; } } - - /// Default constructor - public QueryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public QueryDataBlock() { } + /// Constructor for building the block from a byte array public QueryDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - SkillFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; - QueryID = new LLUUID(bytes, i); i += 16; - Online = (byte)bytes[i++]; - length = (ushort)bytes[i++]; - _reputation = new byte[length]; - Array.Copy(bytes, i, _reputation, 0, length); i += length; - length = (ushort)bytes[i++]; - _distance = new byte[length]; - Array.Copy(bytes, i, _distance, 0, length); i += length; - length = (ushort)bytes[i++]; - _group = new byte[length]; - Array.Copy(bytes, i, _group, 0, length); i += length; - length = (ushort)bytes[i++]; - _querytext = new byte[length]; - Array.Copy(bytes, i, _querytext, 0, length); i += length; - WantToFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + SkillFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; + QueryID = new LLUUID(bytes, i); i += 16; + Online = (byte)bytes[i++]; + length = (ushort)bytes[i++]; + _reputation = new byte[length]; + Array.Copy(bytes, i, _reputation, 0, length); i += length; + length = (ushort)bytes[i++]; + _distance = new byte[length]; + Array.Copy(bytes, i, _distance, 0, length); i += length; + length = (ushort)bytes[i++]; + _group = new byte[length]; + Array.Copy(bytes, i, _group, 0, length); i += length; + length = (ushort)bytes[i++]; + _querytext = new byte[length]; + Array.Copy(bytes, i, _querytext, 0, length); i += length; + WantToFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(SkillFlags % 256); - bytes[i++] = (byte)((SkillFlags >> 8) % 256); - bytes[i++] = (byte)((SkillFlags >> 16) % 256); - bytes[i++] = (byte)((SkillFlags >> 24) % 256); - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; - if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } - Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = Online; - if(Reputation == null) { Console.WriteLine("Warning: Reputation is null, in " + this.GetType()); } - bytes[i++] = (byte)Reputation.Length; - Array.Copy(Reputation, 0, bytes, i, Reputation.Length); i += Reputation.Length; - if(Distance == null) { Console.WriteLine("Warning: Distance is null, in " + this.GetType()); } - bytes[i++] = (byte)Distance.Length; - Array.Copy(Distance, 0, bytes, i, Distance.Length); i += Distance.Length; - if(Group == null) { Console.WriteLine("Warning: Group is null, in " + this.GetType()); } - bytes[i++] = (byte)Group.Length; - Array.Copy(Group, 0, bytes, i, Group.Length); i += Group.Length; - if(QueryText == null) { Console.WriteLine("Warning: QueryText is null, in " + this.GetType()); } - bytes[i++] = (byte)QueryText.Length; - Array.Copy(QueryText, 0, bytes, i, QueryText.Length); i += QueryText.Length; - bytes[i++] = (byte)(WantToFlags % 256); - bytes[i++] = (byte)((WantToFlags >> 8) % 256); - bytes[i++] = (byte)((WantToFlags >> 16) % 256); - bytes[i++] = (byte)((WantToFlags >> 24) % 256); + { + bytes[i++] = (byte)(SkillFlags % 256); + bytes[i++] = (byte)((SkillFlags >> 8) % 256); + bytes[i++] = (byte)((SkillFlags >> 16) % 256); + bytes[i++] = (byte)((SkillFlags >> 24) % 256); + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } + Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = Online; + if(Reputation == null) { Console.WriteLine("Warning: Reputation is null, in " + this.GetType()); } + bytes[i++] = (byte)Reputation.Length; + Array.Copy(Reputation, 0, bytes, i, Reputation.Length); i += Reputation.Length; + if(Distance == null) { Console.WriteLine("Warning: Distance is null, in " + this.GetType()); } + bytes[i++] = (byte)Distance.Length; + Array.Copy(Distance, 0, bytes, i, Distance.Length); i += Distance.Length; + if(Group == null) { Console.WriteLine("Warning: Group is null, in " + this.GetType()); } + bytes[i++] = (byte)Group.Length; + Array.Copy(Group, 0, bytes, i, Group.Length); i += Group.Length; + if(QueryText == null) { Console.WriteLine("Warning: QueryText is null, in " + this.GetType()); } + bytes[i++] = (byte)QueryText.Length; + Array.Copy(QueryText, 0, bytes, i, QueryText.Length); i += QueryText.Length; + bytes[i++] = (byte)(WantToFlags % 256); + bytes[i++] = (byte)((WantToFlags >> 8) % 256); + bytes[i++] = (byte)((WantToFlags >> 16) % 256); + bytes[i++] = (byte)((WantToFlags >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- QueryData --\n"; - output += "SkillFlags: " + SkillFlags.ToString() + "\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; - output += "QueryID: " + QueryID.ToString() + "\n"; - output += "Online: " + Online.ToString() + "\n"; - output += Helpers.FieldToString(Reputation, "Reputation") + "\n"; - output += Helpers.FieldToString(Distance, "Distance") + "\n"; - output += Helpers.FieldToString(Group, "Group") + "\n"; - output += Helpers.FieldToString(QueryText, "QueryText") + "\n"; - output += "WantToFlags: " + WantToFlags.ToString() + "\n"; + { + string output = "-- QueryData --\n"; + output += "SkillFlags: " + SkillFlags.ToString() + "\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; + output += "QueryID: " + QueryID.ToString() + "\n"; + output += "Online: " + Online.ToString() + "\n"; + output += Helpers.FieldToString(Reputation, "Reputation") + "\n"; + output += Helpers.FieldToString(Distance, "Distance") + "\n"; + output += Helpers.FieldToString(Group, "Group") + "\n"; + output += Helpers.FieldToString(QueryText, "QueryText") + "\n"; + output += "WantToFlags: " + WantToFlags.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.DirPeopleQuery - public override PacketType Type { get { return PacketType.DirPeopleQuery; } } - /// QueryData block - public QueryDataBlock QueryData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.DirPeopleQuery + public override PacketType Type { get { return PacketType.DirPeopleQuery; } } + /// QueryData block + public QueryDataBlock QueryData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public DirPeopleQueryPacket() - { - Header = new LowHeader(); - Header.ID = 48; - Header.Reliable = true; - Header.Zerocoded = true; - QueryData = new QueryDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 48; + Header.Reliable = true; + Header.Zerocoded = true; + QueryData = new QueryDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public DirPeopleQueryPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - QueryData = new QueryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + QueryData = new QueryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public DirPeopleQueryPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - QueryData = new QueryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + QueryData = new QueryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += QueryData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - QueryData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += QueryData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + QueryData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- DirPeopleQuery ---\n"; - output += QueryData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- DirPeopleQuery ---\n"; + output += QueryData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// DirPeopleQueryBackend packet + + /// DirPeopleQueryBackend packet public class DirPeopleQueryBackendPacket : Packet - { - /// QueryData block + { + /// QueryData block public class QueryDataBlock - { - /// SpaceIP field - public uint SpaceIP; - /// Godlike field - public bool Godlike; - /// SkillFlags field - public uint SkillFlags; - private byte[] _name; - /// Name field + { + /// SpaceIP field + public uint SpaceIP; + /// Godlike field + public bool Godlike; + /// SkillFlags field + public uint SkillFlags; + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - /// QueryID field - public LLUUID QueryID; - /// Online field - public byte Online; - private byte[] _reputation; - /// Reputation field + } + /// QueryID field + public LLUUID QueryID; + /// Online field + public byte Online; + private byte[] _reputation; + /// Reputation field public byte[] Reputation - { - get { return _reputation; } + { + get { return _reputation; } set - { - if (value == null) { _reputation = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _reputation = new byte[value.Length]; Array.Copy(value, _reputation, value.Length); } + { + if (value == null) { _reputation = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _reputation = new byte[value.Length]; Array.Copy(value, _reputation, value.Length); } } - } - private byte[] _distance; - /// Distance field + } + private byte[] _distance; + /// Distance field public byte[] Distance - { - get { return _distance; } + { + get { return _distance; } set - { - if (value == null) { _distance = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _distance = new byte[value.Length]; Array.Copy(value, _distance, value.Length); } + { + if (value == null) { _distance = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _distance = new byte[value.Length]; Array.Copy(value, _distance, value.Length); } } - } - private byte[] _group; - /// Group field + } + private byte[] _group; + /// Group field public byte[] Group - { - get { return _group; } + { + get { return _group; } set - { - if (value == null) { _group = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _group = new byte[value.Length]; Array.Copy(value, _group, value.Length); } + { + if (value == null) { _group = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _group = new byte[value.Length]; Array.Copy(value, _group, value.Length); } } - } - private byte[] _querytext; - /// QueryText field + } + private byte[] _querytext; + /// QueryText field public byte[] QueryText - { - get { return _querytext; } + { + get { return _querytext; } set - { - if (value == null) { _querytext = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _querytext = new byte[value.Length]; Array.Copy(value, _querytext, value.Length); } + { + if (value == null) { _querytext = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _querytext = new byte[value.Length]; Array.Copy(value, _querytext, value.Length); } } - } - /// EstateID field - public uint EstateID; - /// WantToFlags field - public uint WantToFlags; - - /// Length of this block serialized in bytes + } + /// EstateID field + public uint EstateID; + /// WantToFlags field + public uint WantToFlags; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 34; - if (Name != null) { length += 1 + Name.Length; } - if (Reputation != null) { length += 1 + Reputation.Length; } - if (Distance != null) { length += 1 + Distance.Length; } - if (Group != null) { length += 1 + Group.Length; } - if (QueryText != null) { length += 1 + QueryText.Length; } - return length; + { + int length = 34; + if (Name != null) { length += 1 + Name.Length; } + if (Reputation != null) { length += 1 + Reputation.Length; } + if (Distance != null) { length += 1 + Distance.Length; } + if (Group != null) { length += 1 + Group.Length; } + if (QueryText != null) { length += 1 + QueryText.Length; } + return length; } } - - /// Default constructor - public QueryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public QueryDataBlock() { } + /// Constructor for building the block from a byte array public QueryDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - SpaceIP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Godlike = (bytes[i++] != 0) ? (bool)true : (bool)false; - SkillFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; - QueryID = new LLUUID(bytes, i); i += 16; - Online = (byte)bytes[i++]; - length = (ushort)bytes[i++]; - _reputation = new byte[length]; - Array.Copy(bytes, i, _reputation, 0, length); i += length; - length = (ushort)bytes[i++]; - _distance = new byte[length]; - Array.Copy(bytes, i, _distance, 0, length); i += length; - length = (ushort)bytes[i++]; - _group = new byte[length]; - Array.Copy(bytes, i, _group, 0, length); i += length; - length = (ushort)bytes[i++]; - _querytext = new byte[length]; - Array.Copy(bytes, i, _querytext, 0, length); i += length; - EstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - WantToFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + SpaceIP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Godlike = (bytes[i++] != 0) ? (bool)true : (bool)false; + SkillFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; + QueryID = new LLUUID(bytes, i); i += 16; + Online = (byte)bytes[i++]; + length = (ushort)bytes[i++]; + _reputation = new byte[length]; + Array.Copy(bytes, i, _reputation, 0, length); i += length; + length = (ushort)bytes[i++]; + _distance = new byte[length]; + Array.Copy(bytes, i, _distance, 0, length); i += length; + length = (ushort)bytes[i++]; + _group = new byte[length]; + Array.Copy(bytes, i, _group, 0, length); i += length; + length = (ushort)bytes[i++]; + _querytext = new byte[length]; + Array.Copy(bytes, i, _querytext, 0, length); i += length; + EstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + WantToFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(SpaceIP % 256); - bytes[i++] = (byte)((SpaceIP >> 8) % 256); - bytes[i++] = (byte)((SpaceIP >> 16) % 256); - bytes[i++] = (byte)((SpaceIP >> 24) % 256); - bytes[i++] = (byte)((Godlike) ? 1 : 0); - bytes[i++] = (byte)(SkillFlags % 256); - bytes[i++] = (byte)((SkillFlags >> 8) % 256); - bytes[i++] = (byte)((SkillFlags >> 16) % 256); - bytes[i++] = (byte)((SkillFlags >> 24) % 256); - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; - if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } - Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = Online; - if(Reputation == null) { Console.WriteLine("Warning: Reputation is null, in " + this.GetType()); } - bytes[i++] = (byte)Reputation.Length; - Array.Copy(Reputation, 0, bytes, i, Reputation.Length); i += Reputation.Length; - if(Distance == null) { Console.WriteLine("Warning: Distance is null, in " + this.GetType()); } - bytes[i++] = (byte)Distance.Length; - Array.Copy(Distance, 0, bytes, i, Distance.Length); i += Distance.Length; - if(Group == null) { Console.WriteLine("Warning: Group is null, in " + this.GetType()); } - bytes[i++] = (byte)Group.Length; - Array.Copy(Group, 0, bytes, i, Group.Length); i += Group.Length; - if(QueryText == null) { Console.WriteLine("Warning: QueryText is null, in " + this.GetType()); } - bytes[i++] = (byte)QueryText.Length; - Array.Copy(QueryText, 0, bytes, i, QueryText.Length); i += QueryText.Length; - bytes[i++] = (byte)(EstateID % 256); - bytes[i++] = (byte)((EstateID >> 8) % 256); - bytes[i++] = (byte)((EstateID >> 16) % 256); - bytes[i++] = (byte)((EstateID >> 24) % 256); - bytes[i++] = (byte)(WantToFlags % 256); - bytes[i++] = (byte)((WantToFlags >> 8) % 256); - bytes[i++] = (byte)((WantToFlags >> 16) % 256); - bytes[i++] = (byte)((WantToFlags >> 24) % 256); + { + bytes[i++] = (byte)(SpaceIP % 256); + bytes[i++] = (byte)((SpaceIP >> 8) % 256); + bytes[i++] = (byte)((SpaceIP >> 16) % 256); + bytes[i++] = (byte)((SpaceIP >> 24) % 256); + bytes[i++] = (byte)((Godlike) ? 1 : 0); + bytes[i++] = (byte)(SkillFlags % 256); + bytes[i++] = (byte)((SkillFlags >> 8) % 256); + bytes[i++] = (byte)((SkillFlags >> 16) % 256); + bytes[i++] = (byte)((SkillFlags >> 24) % 256); + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } + Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = Online; + if(Reputation == null) { Console.WriteLine("Warning: Reputation is null, in " + this.GetType()); } + bytes[i++] = (byte)Reputation.Length; + Array.Copy(Reputation, 0, bytes, i, Reputation.Length); i += Reputation.Length; + if(Distance == null) { Console.WriteLine("Warning: Distance is null, in " + this.GetType()); } + bytes[i++] = (byte)Distance.Length; + Array.Copy(Distance, 0, bytes, i, Distance.Length); i += Distance.Length; + if(Group == null) { Console.WriteLine("Warning: Group is null, in " + this.GetType()); } + bytes[i++] = (byte)Group.Length; + Array.Copy(Group, 0, bytes, i, Group.Length); i += Group.Length; + if(QueryText == null) { Console.WriteLine("Warning: QueryText is null, in " + this.GetType()); } + bytes[i++] = (byte)QueryText.Length; + Array.Copy(QueryText, 0, bytes, i, QueryText.Length); i += QueryText.Length; + bytes[i++] = (byte)(EstateID % 256); + bytes[i++] = (byte)((EstateID >> 8) % 256); + bytes[i++] = (byte)((EstateID >> 16) % 256); + bytes[i++] = (byte)((EstateID >> 24) % 256); + bytes[i++] = (byte)(WantToFlags % 256); + bytes[i++] = (byte)((WantToFlags >> 8) % 256); + bytes[i++] = (byte)((WantToFlags >> 16) % 256); + bytes[i++] = (byte)((WantToFlags >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- QueryData --\n"; - output += "SpaceIP: " + SpaceIP.ToString() + "\n"; - output += "Godlike: " + Godlike.ToString() + "\n"; - output += "SkillFlags: " + SkillFlags.ToString() + "\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; - output += "QueryID: " + QueryID.ToString() + "\n"; - output += "Online: " + Online.ToString() + "\n"; - output += Helpers.FieldToString(Reputation, "Reputation") + "\n"; - output += Helpers.FieldToString(Distance, "Distance") + "\n"; - output += Helpers.FieldToString(Group, "Group") + "\n"; - output += Helpers.FieldToString(QueryText, "QueryText") + "\n"; - output += "EstateID: " + EstateID.ToString() + "\n"; - output += "WantToFlags: " + WantToFlags.ToString() + "\n"; + { + string output = "-- QueryData --\n"; + output += "SpaceIP: " + SpaceIP.ToString() + "\n"; + output += "Godlike: " + Godlike.ToString() + "\n"; + output += "SkillFlags: " + SkillFlags.ToString() + "\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; + output += "QueryID: " + QueryID.ToString() + "\n"; + output += "Online: " + Online.ToString() + "\n"; + output += Helpers.FieldToString(Reputation, "Reputation") + "\n"; + output += Helpers.FieldToString(Distance, "Distance") + "\n"; + output += Helpers.FieldToString(Group, "Group") + "\n"; + output += Helpers.FieldToString(QueryText, "QueryText") + "\n"; + output += "EstateID: " + EstateID.ToString() + "\n"; + output += "WantToFlags: " + WantToFlags.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.DirPeopleQueryBackend - public override PacketType Type { get { return PacketType.DirPeopleQueryBackend; } } - /// QueryData block - public QueryDataBlock QueryData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.DirPeopleQueryBackend + public override PacketType Type { get { return PacketType.DirPeopleQueryBackend; } } + /// QueryData block + public QueryDataBlock QueryData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public DirPeopleQueryBackendPacket() - { - Header = new LowHeader(); - Header.ID = 49; - Header.Reliable = true; - Header.Zerocoded = true; - QueryData = new QueryDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 49; + Header.Reliable = true; + Header.Zerocoded = true; + QueryData = new QueryDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public DirPeopleQueryBackendPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - QueryData = new QueryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + QueryData = new QueryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public DirPeopleQueryBackendPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - QueryData = new QueryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + QueryData = new QueryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += QueryData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - QueryData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += QueryData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + QueryData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- DirPeopleQueryBackend ---\n"; - output += QueryData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- DirPeopleQueryBackend ---\n"; + output += QueryData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// DirPeopleReply packet + + /// DirPeopleReply packet public class DirPeopleReplyPacket : Packet - { - /// QueryReplies block + { + /// QueryReplies block public class QueryRepliesBlock - { - /// AgentID field - public LLUUID AgentID; - private byte[] _lastname; - /// LastName field + { + /// AgentID field + public LLUUID AgentID; + private byte[] _lastname; + /// LastName field public byte[] LastName - { - get { return _lastname; } + { + get { return _lastname; } set - { - if (value == null) { _lastname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _lastname = new byte[value.Length]; Array.Copy(value, _lastname, value.Length); } + { + if (value == null) { _lastname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _lastname = new byte[value.Length]; Array.Copy(value, _lastname, value.Length); } } - } - private byte[] _firstname; - /// FirstName field + } + private byte[] _firstname; + /// FirstName field public byte[] FirstName - { - get { return _firstname; } + { + get { return _firstname; } set - { - if (value == null) { _firstname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _firstname = new byte[value.Length]; Array.Copy(value, _firstname, value.Length); } + { + if (value == null) { _firstname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _firstname = new byte[value.Length]; Array.Copy(value, _firstname, value.Length); } } - } - /// Online field - public bool Online; - /// Reputation field - public int Reputation; - private byte[] _group; - /// Group field + } + /// Online field + public bool Online; + /// Reputation field + public int Reputation; + private byte[] _group; + /// Group field public byte[] Group - { - get { return _group; } + { + get { return _group; } set - { - if (value == null) { _group = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _group = new byte[value.Length]; Array.Copy(value, _group, value.Length); } + { + if (value == null) { _group = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _group = new byte[value.Length]; Array.Copy(value, _group, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 21; - if (LastName != null) { length += 1 + LastName.Length; } - if (FirstName != null) { length += 1 + FirstName.Length; } - if (Group != null) { length += 1 + Group.Length; } - return length; + { + int length = 21; + if (LastName != null) { length += 1 + LastName.Length; } + if (FirstName != null) { length += 1 + FirstName.Length; } + if (Group != null) { length += 1 + Group.Length; } + return length; } } - - /// Default constructor - public QueryRepliesBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public QueryRepliesBlock() { } + /// Constructor for building the block from a byte array public QueryRepliesBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - AgentID = new LLUUID(bytes, i); i += 16; - length = (ushort)bytes[i++]; - _lastname = new byte[length]; - Array.Copy(bytes, i, _lastname, 0, length); i += length; - length = (ushort)bytes[i++]; - _firstname = new byte[length]; - Array.Copy(bytes, i, _firstname, 0, length); i += length; - Online = (bytes[i++] != 0) ? (bool)true : (bool)false; - Reputation = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _group = new byte[length]; - Array.Copy(bytes, i, _group, 0, length); i += length; + { + AgentID = new LLUUID(bytes, i); i += 16; + length = (ushort)bytes[i++]; + _lastname = new byte[length]; + Array.Copy(bytes, i, _lastname, 0, length); i += length; + length = (ushort)bytes[i++]; + _firstname = new byte[length]; + Array.Copy(bytes, i, _firstname, 0, length); i += length; + Online = (bytes[i++] != 0) ? (bool)true : (bool)false; + Reputation = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _group = new byte[length]; + Array.Copy(bytes, i, _group, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(LastName == null) { Console.WriteLine("Warning: LastName is null, in " + this.GetType()); } - bytes[i++] = (byte)LastName.Length; - Array.Copy(LastName, 0, bytes, i, LastName.Length); i += LastName.Length; - if(FirstName == null) { Console.WriteLine("Warning: FirstName is null, in " + this.GetType()); } - bytes[i++] = (byte)FirstName.Length; - Array.Copy(FirstName, 0, bytes, i, FirstName.Length); i += FirstName.Length; - bytes[i++] = (byte)((Online) ? 1 : 0); - bytes[i++] = (byte)(Reputation % 256); - bytes[i++] = (byte)((Reputation >> 8) % 256); - bytes[i++] = (byte)((Reputation >> 16) % 256); - bytes[i++] = (byte)((Reputation >> 24) % 256); - if(Group == null) { Console.WriteLine("Warning: Group is null, in " + this.GetType()); } - bytes[i++] = (byte)Group.Length; - Array.Copy(Group, 0, bytes, i, Group.Length); i += Group.Length; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(LastName == null) { Console.WriteLine("Warning: LastName is null, in " + this.GetType()); } + bytes[i++] = (byte)LastName.Length; + Array.Copy(LastName, 0, bytes, i, LastName.Length); i += LastName.Length; + if(FirstName == null) { Console.WriteLine("Warning: FirstName is null, in " + this.GetType()); } + bytes[i++] = (byte)FirstName.Length; + Array.Copy(FirstName, 0, bytes, i, FirstName.Length); i += FirstName.Length; + bytes[i++] = (byte)((Online) ? 1 : 0); + bytes[i++] = (byte)(Reputation % 256); + bytes[i++] = (byte)((Reputation >> 8) % 256); + bytes[i++] = (byte)((Reputation >> 16) % 256); + bytes[i++] = (byte)((Reputation >> 24) % 256); + if(Group == null) { Console.WriteLine("Warning: Group is null, in " + this.GetType()); } + bytes[i++] = (byte)Group.Length; + Array.Copy(Group, 0, bytes, i, Group.Length); i += Group.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- QueryReplies --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += Helpers.FieldToString(LastName, "LastName") + "\n"; - output += Helpers.FieldToString(FirstName, "FirstName") + "\n"; - output += "Online: " + Online.ToString() + "\n"; - output += "Reputation: " + Reputation.ToString() + "\n"; - output += Helpers.FieldToString(Group, "Group") + "\n"; + { + string output = "-- QueryReplies --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += Helpers.FieldToString(LastName, "LastName") + "\n"; + output += Helpers.FieldToString(FirstName, "FirstName") + "\n"; + output += "Online: " + Online.ToString() + "\n"; + output += "Reputation: " + Reputation.ToString() + "\n"; + output += Helpers.FieldToString(Group, "Group") + "\n"; output = output.Trim(); return output; - } + } } - - /// QueryData block + + /// QueryData block public class QueryDataBlock - { - /// QueryID field - public LLUUID QueryID; - - /// Length of this block serialized in bytes + { + /// QueryID field + public LLUUID QueryID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public QueryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public QueryDataBlock() { } + /// Constructor for building the block from a byte array public QueryDataBlock(byte[] bytes, ref int i) - { + { try - { - QueryID = new LLUUID(bytes, i); i += 16; + { + QueryID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } - Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } + Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- QueryData --\n"; - output += "QueryID: " + QueryID.ToString() + "\n"; + { + string output = "-- QueryData --\n"; + output += "QueryID: " + QueryID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.DirPeopleReply - public override PacketType Type { get { return PacketType.DirPeopleReply; } } - /// QueryReplies block - public QueryRepliesBlock[] QueryReplies; - /// QueryData block - public QueryDataBlock QueryData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.DirPeopleReply + public override PacketType Type { get { return PacketType.DirPeopleReply; } } + /// QueryReplies block + public QueryRepliesBlock[] QueryReplies; + /// QueryData block + public QueryDataBlock QueryData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public DirPeopleReplyPacket() - { - Header = new LowHeader(); - Header.ID = 50; - Header.Reliable = true; - Header.Zerocoded = true; - QueryReplies = new QueryRepliesBlock[0]; - QueryData = new QueryDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 50; + Header.Reliable = true; + Header.Zerocoded = true; + QueryReplies = new QueryRepliesBlock[0]; + QueryData = new QueryDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public DirPeopleReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - QueryReplies = new QueryRepliesBlock[count]; - for (int j = 0; j < count; j++) - { QueryReplies[j] = new QueryRepliesBlock(bytes, ref i); } - QueryData = new QueryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + QueryReplies = new QueryRepliesBlock[count]; + for (int j = 0; j < count; j++) + { QueryReplies[j] = new QueryRepliesBlock(bytes, ref i); } + QueryData = new QueryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public DirPeopleReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - QueryReplies = new QueryRepliesBlock[count]; - for (int j = 0; j < count; j++) - { QueryReplies[j] = new QueryRepliesBlock(bytes, ref i); } - QueryData = new QueryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + QueryReplies = new QueryRepliesBlock[count]; + for (int j = 0; j < count; j++) + { QueryReplies[j] = new QueryRepliesBlock(bytes, ref i); } + QueryData = new QueryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += QueryData.Length; length += AgentData.Length;; - length++; - for (int j = 0; j < QueryReplies.Length; j++) { length += QueryReplies[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)QueryReplies.Length; - for (int j = 0; j < QueryReplies.Length; j++) { QueryReplies[j].ToBytes(bytes, ref i); } - QueryData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += QueryData.Length; length += AgentData.Length;; + length++; + for (int j = 0; j < QueryReplies.Length; j++) { length += QueryReplies[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)QueryReplies.Length; + for (int j = 0; j < QueryReplies.Length; j++) { QueryReplies[j].ToBytes(bytes, ref i); } + QueryData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- DirPeopleReply ---\n"; + { + string output = "--- DirPeopleReply ---\n"; for (int j = 0; j < QueryReplies.Length; j++) - { + { output += QueryReplies[j].ToString() + "\n"; - } - output += QueryData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + } + output += QueryData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// DirEventsReply packet + + /// DirEventsReply packet public class DirEventsReplyPacket : Packet - { - /// QueryReplies block + { + /// QueryReplies block public class QueryRepliesBlock - { - private byte[] _name; - /// Name field + { + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - private byte[] _date; - /// Date field + } + private byte[] _date; + /// Date field public byte[] Date - { - get { return _date; } + { + get { return _date; } set - { - if (value == null) { _date = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _date = new byte[value.Length]; Array.Copy(value, _date, value.Length); } + { + if (value == null) { _date = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _date = new byte[value.Length]; Array.Copy(value, _date, value.Length); } } - } - /// EventID field - public uint EventID; - /// OwnerID field - public LLUUID OwnerID; - /// EventFlags field - public uint EventFlags; - /// UnixTime field - public uint UnixTime; - - /// Length of this block serialized in bytes + } + /// EventID field + public uint EventID; + /// OwnerID field + public LLUUID OwnerID; + /// EventFlags field + public uint EventFlags; + /// UnixTime field + public uint UnixTime; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 28; - if (Name != null) { length += 1 + Name.Length; } - if (Date != null) { length += 1 + Date.Length; } - return length; + { + int length = 28; + if (Name != null) { length += 1 + Name.Length; } + if (Date != null) { length += 1 + Date.Length; } + return length; } } - - /// Default constructor - public QueryRepliesBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public QueryRepliesBlock() { } + /// Constructor for building the block from a byte array public QueryRepliesBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; - length = (ushort)bytes[i++]; - _date = new byte[length]; - Array.Copy(bytes, i, _date, 0, length); i += length; - EventID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - OwnerID = new LLUUID(bytes, i); i += 16; - EventFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - UnixTime = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; + length = (ushort)bytes[i++]; + _date = new byte[length]; + Array.Copy(bytes, i, _date, 0, length); i += length; + EventID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + OwnerID = new LLUUID(bytes, i); i += 16; + EventFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + UnixTime = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; - if(Date == null) { Console.WriteLine("Warning: Date is null, in " + this.GetType()); } - bytes[i++] = (byte)Date.Length; - Array.Copy(Date, 0, bytes, i, Date.Length); i += Date.Length; - bytes[i++] = (byte)(EventID % 256); - bytes[i++] = (byte)((EventID >> 8) % 256); - bytes[i++] = (byte)((EventID >> 16) % 256); - bytes[i++] = (byte)((EventID >> 24) % 256); - if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } - Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(EventFlags % 256); - bytes[i++] = (byte)((EventFlags >> 8) % 256); - bytes[i++] = (byte)((EventFlags >> 16) % 256); - bytes[i++] = (byte)((EventFlags >> 24) % 256); - bytes[i++] = (byte)(UnixTime % 256); - bytes[i++] = (byte)((UnixTime >> 8) % 256); - bytes[i++] = (byte)((UnixTime >> 16) % 256); - bytes[i++] = (byte)((UnixTime >> 24) % 256); + { + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + if(Date == null) { Console.WriteLine("Warning: Date is null, in " + this.GetType()); } + bytes[i++] = (byte)Date.Length; + Array.Copy(Date, 0, bytes, i, Date.Length); i += Date.Length; + bytes[i++] = (byte)(EventID % 256); + bytes[i++] = (byte)((EventID >> 8) % 256); + bytes[i++] = (byte)((EventID >> 16) % 256); + bytes[i++] = (byte)((EventID >> 24) % 256); + if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } + Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(EventFlags % 256); + bytes[i++] = (byte)((EventFlags >> 8) % 256); + bytes[i++] = (byte)((EventFlags >> 16) % 256); + bytes[i++] = (byte)((EventFlags >> 24) % 256); + bytes[i++] = (byte)(UnixTime % 256); + bytes[i++] = (byte)((UnixTime >> 8) % 256); + bytes[i++] = (byte)((UnixTime >> 16) % 256); + bytes[i++] = (byte)((UnixTime >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- QueryReplies --\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; - output += Helpers.FieldToString(Date, "Date") + "\n"; - output += "EventID: " + EventID.ToString() + "\n"; - output += "OwnerID: " + OwnerID.ToString() + "\n"; - output += "EventFlags: " + EventFlags.ToString() + "\n"; - output += "UnixTime: " + UnixTime.ToString() + "\n"; + { + string output = "-- QueryReplies --\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; + output += Helpers.FieldToString(Date, "Date") + "\n"; + output += "EventID: " + EventID.ToString() + "\n"; + output += "OwnerID: " + OwnerID.ToString() + "\n"; + output += "EventFlags: " + EventFlags.ToString() + "\n"; + output += "UnixTime: " + UnixTime.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// QueryData block + + /// QueryData block public class QueryDataBlock - { - /// QueryID field - public LLUUID QueryID; - - /// Length of this block serialized in bytes + { + /// QueryID field + public LLUUID QueryID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public QueryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public QueryDataBlock() { } + /// Constructor for building the block from a byte array public QueryDataBlock(byte[] bytes, ref int i) - { + { try - { - QueryID = new LLUUID(bytes, i); i += 16; + { + QueryID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } - Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } + Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- QueryData --\n"; - output += "QueryID: " + QueryID.ToString() + "\n"; + { + string output = "-- QueryData --\n"; + output += "QueryID: " + QueryID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.DirEventsReply - public override PacketType Type { get { return PacketType.DirEventsReply; } } - /// QueryReplies block - public QueryRepliesBlock[] QueryReplies; - /// QueryData block - public QueryDataBlock QueryData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.DirEventsReply + public override PacketType Type { get { return PacketType.DirEventsReply; } } + /// QueryReplies block + public QueryRepliesBlock[] QueryReplies; + /// QueryData block + public QueryDataBlock QueryData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public DirEventsReplyPacket() - { - Header = new LowHeader(); - Header.ID = 51; - Header.Reliable = true; - Header.Zerocoded = true; - QueryReplies = new QueryRepliesBlock[0]; - QueryData = new QueryDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 51; + Header.Reliable = true; + Header.Zerocoded = true; + QueryReplies = new QueryRepliesBlock[0]; + QueryData = new QueryDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public DirEventsReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - QueryReplies = new QueryRepliesBlock[count]; - for (int j = 0; j < count; j++) - { QueryReplies[j] = new QueryRepliesBlock(bytes, ref i); } - QueryData = new QueryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + QueryReplies = new QueryRepliesBlock[count]; + for (int j = 0; j < count; j++) + { QueryReplies[j] = new QueryRepliesBlock(bytes, ref i); } + QueryData = new QueryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public DirEventsReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - QueryReplies = new QueryRepliesBlock[count]; - for (int j = 0; j < count; j++) - { QueryReplies[j] = new QueryRepliesBlock(bytes, ref i); } - QueryData = new QueryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + QueryReplies = new QueryRepliesBlock[count]; + for (int j = 0; j < count; j++) + { QueryReplies[j] = new QueryRepliesBlock(bytes, ref i); } + QueryData = new QueryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += QueryData.Length; length += AgentData.Length;; - length++; - for (int j = 0; j < QueryReplies.Length; j++) { length += QueryReplies[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)QueryReplies.Length; - for (int j = 0; j < QueryReplies.Length; j++) { QueryReplies[j].ToBytes(bytes, ref i); } - QueryData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += QueryData.Length; length += AgentData.Length;; + length++; + for (int j = 0; j < QueryReplies.Length; j++) { length += QueryReplies[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)QueryReplies.Length; + for (int j = 0; j < QueryReplies.Length; j++) { QueryReplies[j].ToBytes(bytes, ref i); } + QueryData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- DirEventsReply ---\n"; + { + string output = "--- DirEventsReply ---\n"; for (int j = 0; j < QueryReplies.Length; j++) - { + { output += QueryReplies[j].ToString() + "\n"; - } - output += QueryData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + } + output += QueryData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// DirGroupsQuery packet + + /// DirGroupsQuery packet public class DirGroupsQueryPacket : Packet - { - /// QueryData block + { + /// QueryData block public class QueryDataBlock - { - /// QueryID field - public LLUUID QueryID; - private byte[] _querytext; - /// QueryText field + { + /// QueryID field + public LLUUID QueryID; + private byte[] _querytext; + /// QueryText field public byte[] QueryText - { - get { return _querytext; } + { + get { return _querytext; } set - { - if (value == null) { _querytext = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _querytext = new byte[value.Length]; Array.Copy(value, _querytext, value.Length); } + { + if (value == null) { _querytext = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _querytext = new byte[value.Length]; Array.Copy(value, _querytext, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 16; - if (QueryText != null) { length += 1 + QueryText.Length; } - return length; + { + int length = 16; + if (QueryText != null) { length += 1 + QueryText.Length; } + return length; } } - - /// Default constructor - public QueryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public QueryDataBlock() { } + /// Constructor for building the block from a byte array public QueryDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - QueryID = new LLUUID(bytes, i); i += 16; - length = (ushort)bytes[i++]; - _querytext = new byte[length]; - Array.Copy(bytes, i, _querytext, 0, length); i += length; + { + QueryID = new LLUUID(bytes, i); i += 16; + length = (ushort)bytes[i++]; + _querytext = new byte[length]; + Array.Copy(bytes, i, _querytext, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } - Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; - if(QueryText == null) { Console.WriteLine("Warning: QueryText is null, in " + this.GetType()); } - bytes[i++] = (byte)QueryText.Length; - Array.Copy(QueryText, 0, bytes, i, QueryText.Length); i += QueryText.Length; + { + if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } + Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; + if(QueryText == null) { Console.WriteLine("Warning: QueryText is null, in " + this.GetType()); } + bytes[i++] = (byte)QueryText.Length; + Array.Copy(QueryText, 0, bytes, i, QueryText.Length); i += QueryText.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- QueryData --\n"; - output += "QueryID: " + QueryID.ToString() + "\n"; - output += Helpers.FieldToString(QueryText, "QueryText") + "\n"; + { + string output = "-- QueryData --\n"; + output += "QueryID: " + QueryID.ToString() + "\n"; + output += Helpers.FieldToString(QueryText, "QueryText") + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.DirGroupsQuery - public override PacketType Type { get { return PacketType.DirGroupsQuery; } } - /// QueryData block - public QueryDataBlock QueryData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.DirGroupsQuery + public override PacketType Type { get { return PacketType.DirGroupsQuery; } } + /// QueryData block + public QueryDataBlock QueryData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public DirGroupsQueryPacket() - { - Header = new LowHeader(); - Header.ID = 52; - Header.Reliable = true; - Header.Zerocoded = true; - QueryData = new QueryDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 52; + Header.Reliable = true; + Header.Zerocoded = true; + QueryData = new QueryDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public DirGroupsQueryPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - QueryData = new QueryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + QueryData = new QueryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public DirGroupsQueryPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - QueryData = new QueryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + QueryData = new QueryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += QueryData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - QueryData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += QueryData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + QueryData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- DirGroupsQuery ---\n"; - output += QueryData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- DirGroupsQuery ---\n"; + output += QueryData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// DirGroupsQueryBackend packet + + /// DirGroupsQueryBackend packet public class DirGroupsQueryBackendPacket : Packet - { - /// QueryData block + { + /// QueryData block public class QueryDataBlock - { - /// Godlike field - public bool Godlike; - /// QueryID field - public LLUUID QueryID; - private byte[] _querytext; - /// QueryText field + { + /// Godlike field + public bool Godlike; + /// QueryID field + public LLUUID QueryID; + private byte[] _querytext; + /// QueryText field public byte[] QueryText - { - get { return _querytext; } + { + get { return _querytext; } set - { - if (value == null) { _querytext = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _querytext = new byte[value.Length]; Array.Copy(value, _querytext, value.Length); } + { + if (value == null) { _querytext = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _querytext = new byte[value.Length]; Array.Copy(value, _querytext, value.Length); } } - } - /// EstateID field - public uint EstateID; - - /// Length of this block serialized in bytes + } + /// EstateID field + public uint EstateID; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 21; - if (QueryText != null) { length += 1 + QueryText.Length; } - return length; + { + int length = 21; + if (QueryText != null) { length += 1 + QueryText.Length; } + return length; } } - - /// Default constructor - public QueryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public QueryDataBlock() { } + /// Constructor for building the block from a byte array public QueryDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - Godlike = (bytes[i++] != 0) ? (bool)true : (bool)false; - QueryID = new LLUUID(bytes, i); i += 16; - length = (ushort)bytes[i++]; - _querytext = new byte[length]; - Array.Copy(bytes, i, _querytext, 0, length); i += length; - EstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + Godlike = (bytes[i++] != 0) ? (bool)true : (bool)false; + QueryID = new LLUUID(bytes, i); i += 16; + length = (ushort)bytes[i++]; + _querytext = new byte[length]; + Array.Copy(bytes, i, _querytext, 0, length); i += length; + EstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)((Godlike) ? 1 : 0); - if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } - Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; - if(QueryText == null) { Console.WriteLine("Warning: QueryText is null, in " + this.GetType()); } - bytes[i++] = (byte)QueryText.Length; - Array.Copy(QueryText, 0, bytes, i, QueryText.Length); i += QueryText.Length; - bytes[i++] = (byte)(EstateID % 256); - bytes[i++] = (byte)((EstateID >> 8) % 256); - bytes[i++] = (byte)((EstateID >> 16) % 256); - bytes[i++] = (byte)((EstateID >> 24) % 256); + { + bytes[i++] = (byte)((Godlike) ? 1 : 0); + if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } + Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; + if(QueryText == null) { Console.WriteLine("Warning: QueryText is null, in " + this.GetType()); } + bytes[i++] = (byte)QueryText.Length; + Array.Copy(QueryText, 0, bytes, i, QueryText.Length); i += QueryText.Length; + bytes[i++] = (byte)(EstateID % 256); + bytes[i++] = (byte)((EstateID >> 8) % 256); + bytes[i++] = (byte)((EstateID >> 16) % 256); + bytes[i++] = (byte)((EstateID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- QueryData --\n"; - output += "Godlike: " + Godlike.ToString() + "\n"; - output += "QueryID: " + QueryID.ToString() + "\n"; - output += Helpers.FieldToString(QueryText, "QueryText") + "\n"; - output += "EstateID: " + EstateID.ToString() + "\n"; + { + string output = "-- QueryData --\n"; + output += "Godlike: " + Godlike.ToString() + "\n"; + output += "QueryID: " + QueryID.ToString() + "\n"; + output += Helpers.FieldToString(QueryText, "QueryText") + "\n"; + output += "EstateID: " + EstateID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.DirGroupsQueryBackend - public override PacketType Type { get { return PacketType.DirGroupsQueryBackend; } } - /// QueryData block - public QueryDataBlock QueryData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.DirGroupsQueryBackend + public override PacketType Type { get { return PacketType.DirGroupsQueryBackend; } } + /// QueryData block + public QueryDataBlock QueryData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public DirGroupsQueryBackendPacket() - { - Header = new LowHeader(); - Header.ID = 53; - Header.Reliable = true; - Header.Zerocoded = true; - QueryData = new QueryDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 53; + Header.Reliable = true; + Header.Zerocoded = true; + QueryData = new QueryDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public DirGroupsQueryBackendPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - QueryData = new QueryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + QueryData = new QueryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public DirGroupsQueryBackendPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - QueryData = new QueryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + QueryData = new QueryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += QueryData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - QueryData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += QueryData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + QueryData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- DirGroupsQueryBackend ---\n"; - output += QueryData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- DirGroupsQueryBackend ---\n"; + output += QueryData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// DirGroupsReply packet + + /// DirGroupsReply packet public class DirGroupsReplyPacket : Packet - { - /// QueryReplies block + { + /// QueryReplies block public class QueryRepliesBlock - { - /// Members field - public int Members; - /// GroupID field - public LLUUID GroupID; - /// MembershipFee field - public int MembershipFee; - /// OpenEnrollment field - public bool OpenEnrollment; - private byte[] _groupname; - /// GroupName field + { + /// Members field + public int Members; + /// GroupID field + public LLUUID GroupID; + /// MembershipFee field + public int MembershipFee; + /// OpenEnrollment field + public bool OpenEnrollment; + private byte[] _groupname; + /// GroupName field public byte[] GroupName - { - get { return _groupname; } + { + get { return _groupname; } set - { - if (value == null) { _groupname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _groupname = new byte[value.Length]; Array.Copy(value, _groupname, value.Length); } + { + if (value == null) { _groupname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _groupname = new byte[value.Length]; Array.Copy(value, _groupname, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 25; - if (GroupName != null) { length += 1 + GroupName.Length; } - return length; + { + int length = 25; + if (GroupName != null) { length += 1 + GroupName.Length; } + return length; } } - - /// Default constructor - public QueryRepliesBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public QueryRepliesBlock() { } + /// Constructor for building the block from a byte array public QueryRepliesBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - Members = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - GroupID = new LLUUID(bytes, i); i += 16; - MembershipFee = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - OpenEnrollment = (bytes[i++] != 0) ? (bool)true : (bool)false; - length = (ushort)bytes[i++]; - _groupname = new byte[length]; - Array.Copy(bytes, i, _groupname, 0, length); i += length; + { + Members = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + GroupID = new LLUUID(bytes, i); i += 16; + MembershipFee = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + OpenEnrollment = (bytes[i++] != 0) ? (bool)true : (bool)false; + length = (ushort)bytes[i++]; + _groupname = new byte[length]; + Array.Copy(bytes, i, _groupname, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(Members % 256); - bytes[i++] = (byte)((Members >> 8) % 256); - bytes[i++] = (byte)((Members >> 16) % 256); - bytes[i++] = (byte)((Members >> 24) % 256); - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(MembershipFee % 256); - bytes[i++] = (byte)((MembershipFee >> 8) % 256); - bytes[i++] = (byte)((MembershipFee >> 16) % 256); - bytes[i++] = (byte)((MembershipFee >> 24) % 256); - bytes[i++] = (byte)((OpenEnrollment) ? 1 : 0); - if(GroupName == null) { Console.WriteLine("Warning: GroupName is null, in " + this.GetType()); } - bytes[i++] = (byte)GroupName.Length; - Array.Copy(GroupName, 0, bytes, i, GroupName.Length); i += GroupName.Length; + { + bytes[i++] = (byte)(Members % 256); + bytes[i++] = (byte)((Members >> 8) % 256); + bytes[i++] = (byte)((Members >> 16) % 256); + bytes[i++] = (byte)((Members >> 24) % 256); + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(MembershipFee % 256); + bytes[i++] = (byte)((MembershipFee >> 8) % 256); + bytes[i++] = (byte)((MembershipFee >> 16) % 256); + bytes[i++] = (byte)((MembershipFee >> 24) % 256); + bytes[i++] = (byte)((OpenEnrollment) ? 1 : 0); + if(GroupName == null) { Console.WriteLine("Warning: GroupName is null, in " + this.GetType()); } + bytes[i++] = (byte)GroupName.Length; + Array.Copy(GroupName, 0, bytes, i, GroupName.Length); i += GroupName.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- QueryReplies --\n"; - output += "Members: " + Members.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; - output += "MembershipFee: " + MembershipFee.ToString() + "\n"; - output += "OpenEnrollment: " + OpenEnrollment.ToString() + "\n"; - output += Helpers.FieldToString(GroupName, "GroupName") + "\n"; + { + string output = "-- QueryReplies --\n"; + output += "Members: " + Members.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; + output += "MembershipFee: " + MembershipFee.ToString() + "\n"; + output += "OpenEnrollment: " + OpenEnrollment.ToString() + "\n"; + output += Helpers.FieldToString(GroupName, "GroupName") + "\n"; output = output.Trim(); return output; - } + } } - - /// QueryData block + + /// QueryData block public class QueryDataBlock - { - /// QueryID field - public LLUUID QueryID; - - /// Length of this block serialized in bytes + { + /// QueryID field + public LLUUID QueryID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public QueryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public QueryDataBlock() { } + /// Constructor for building the block from a byte array public QueryDataBlock(byte[] bytes, ref int i) - { + { try - { - QueryID = new LLUUID(bytes, i); i += 16; + { + QueryID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } - Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } + Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- QueryData --\n"; - output += "QueryID: " + QueryID.ToString() + "\n"; + { + string output = "-- QueryData --\n"; + output += "QueryID: " + QueryID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.DirGroupsReply - public override PacketType Type { get { return PacketType.DirGroupsReply; } } - /// QueryReplies block - public QueryRepliesBlock[] QueryReplies; - /// QueryData block - public QueryDataBlock QueryData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.DirGroupsReply + public override PacketType Type { get { return PacketType.DirGroupsReply; } } + /// QueryReplies block + public QueryRepliesBlock[] QueryReplies; + /// QueryData block + public QueryDataBlock QueryData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public DirGroupsReplyPacket() - { - Header = new LowHeader(); - Header.ID = 54; - Header.Reliable = true; - Header.Zerocoded = true; - QueryReplies = new QueryRepliesBlock[0]; - QueryData = new QueryDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 54; + Header.Reliable = true; + Header.Zerocoded = true; + QueryReplies = new QueryRepliesBlock[0]; + QueryData = new QueryDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public DirGroupsReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - QueryReplies = new QueryRepliesBlock[count]; - for (int j = 0; j < count; j++) - { QueryReplies[j] = new QueryRepliesBlock(bytes, ref i); } - QueryData = new QueryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + QueryReplies = new QueryRepliesBlock[count]; + for (int j = 0; j < count; j++) + { QueryReplies[j] = new QueryRepliesBlock(bytes, ref i); } + QueryData = new QueryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public DirGroupsReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - QueryReplies = new QueryRepliesBlock[count]; - for (int j = 0; j < count; j++) - { QueryReplies[j] = new QueryRepliesBlock(bytes, ref i); } - QueryData = new QueryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + QueryReplies = new QueryRepliesBlock[count]; + for (int j = 0; j < count; j++) + { QueryReplies[j] = new QueryRepliesBlock(bytes, ref i); } + QueryData = new QueryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += QueryData.Length; length += AgentData.Length;; - length++; - for (int j = 0; j < QueryReplies.Length; j++) { length += QueryReplies[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)QueryReplies.Length; - for (int j = 0; j < QueryReplies.Length; j++) { QueryReplies[j].ToBytes(bytes, ref i); } - QueryData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += QueryData.Length; length += AgentData.Length;; + length++; + for (int j = 0; j < QueryReplies.Length; j++) { length += QueryReplies[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)QueryReplies.Length; + for (int j = 0; j < QueryReplies.Length; j++) { QueryReplies[j].ToBytes(bytes, ref i); } + QueryData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- DirGroupsReply ---\n"; + { + string output = "--- DirGroupsReply ---\n"; for (int j = 0; j < QueryReplies.Length; j++) - { + { output += QueryReplies[j].ToString() + "\n"; - } - output += QueryData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + } + output += QueryData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// DirClassifiedQuery packet + + /// DirClassifiedQuery packet public class DirClassifiedQueryPacket : Packet - { - /// QueryData block + { + /// QueryData block public class QueryDataBlock - { - /// QueryID field - public LLUUID QueryID; - /// Category field - public uint Category; - /// QueryFlags field - public uint QueryFlags; - private byte[] _querytext; - /// QueryText field + { + /// QueryID field + public LLUUID QueryID; + /// Category field + public uint Category; + /// QueryFlags field + public uint QueryFlags; + private byte[] _querytext; + /// QueryText field public byte[] QueryText - { - get { return _querytext; } + { + get { return _querytext; } set - { - if (value == null) { _querytext = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _querytext = new byte[value.Length]; Array.Copy(value, _querytext, value.Length); } + { + if (value == null) { _querytext = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _querytext = new byte[value.Length]; Array.Copy(value, _querytext, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 24; - if (QueryText != null) { length += 1 + QueryText.Length; } - return length; + { + int length = 24; + if (QueryText != null) { length += 1 + QueryText.Length; } + return length; } } - - /// Default constructor - public QueryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public QueryDataBlock() { } + /// Constructor for building the block from a byte array public QueryDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - QueryID = new LLUUID(bytes, i); i += 16; - Category = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - QueryFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _querytext = new byte[length]; - Array.Copy(bytes, i, _querytext, 0, length); i += length; + { + QueryID = new LLUUID(bytes, i); i += 16; + Category = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + QueryFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _querytext = new byte[length]; + Array.Copy(bytes, i, _querytext, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } - Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(Category % 256); - bytes[i++] = (byte)((Category >> 8) % 256); - bytes[i++] = (byte)((Category >> 16) % 256); - bytes[i++] = (byte)((Category >> 24) % 256); - bytes[i++] = (byte)(QueryFlags % 256); - bytes[i++] = (byte)((QueryFlags >> 8) % 256); - bytes[i++] = (byte)((QueryFlags >> 16) % 256); - bytes[i++] = (byte)((QueryFlags >> 24) % 256); - if(QueryText == null) { Console.WriteLine("Warning: QueryText is null, in " + this.GetType()); } - bytes[i++] = (byte)QueryText.Length; - Array.Copy(QueryText, 0, bytes, i, QueryText.Length); i += QueryText.Length; + { + if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } + Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(Category % 256); + bytes[i++] = (byte)((Category >> 8) % 256); + bytes[i++] = (byte)((Category >> 16) % 256); + bytes[i++] = (byte)((Category >> 24) % 256); + bytes[i++] = (byte)(QueryFlags % 256); + bytes[i++] = (byte)((QueryFlags >> 8) % 256); + bytes[i++] = (byte)((QueryFlags >> 16) % 256); + bytes[i++] = (byte)((QueryFlags >> 24) % 256); + if(QueryText == null) { Console.WriteLine("Warning: QueryText is null, in " + this.GetType()); } + bytes[i++] = (byte)QueryText.Length; + Array.Copy(QueryText, 0, bytes, i, QueryText.Length); i += QueryText.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- QueryData --\n"; - output += "QueryID: " + QueryID.ToString() + "\n"; - output += "Category: " + Category.ToString() + "\n"; - output += "QueryFlags: " + QueryFlags.ToString() + "\n"; - output += Helpers.FieldToString(QueryText, "QueryText") + "\n"; + { + string output = "-- QueryData --\n"; + output += "QueryID: " + QueryID.ToString() + "\n"; + output += "Category: " + Category.ToString() + "\n"; + output += "QueryFlags: " + QueryFlags.ToString() + "\n"; + output += Helpers.FieldToString(QueryText, "QueryText") + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.DirClassifiedQuery - public override PacketType Type { get { return PacketType.DirClassifiedQuery; } } - /// QueryData block - public QueryDataBlock QueryData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.DirClassifiedQuery + public override PacketType Type { get { return PacketType.DirClassifiedQuery; } } + /// QueryData block + public QueryDataBlock QueryData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public DirClassifiedQueryPacket() - { - Header = new LowHeader(); - Header.ID = 55; - Header.Reliable = true; - Header.Zerocoded = true; - QueryData = new QueryDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 55; + Header.Reliable = true; + Header.Zerocoded = true; + QueryData = new QueryDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public DirClassifiedQueryPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - QueryData = new QueryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + QueryData = new QueryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public DirClassifiedQueryPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - QueryData = new QueryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + QueryData = new QueryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += QueryData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - QueryData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += QueryData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + QueryData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- DirClassifiedQuery ---\n"; - output += QueryData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- DirClassifiedQuery ---\n"; + output += QueryData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// DirClassifiedQueryBackend packet + + /// DirClassifiedQueryBackend packet public class DirClassifiedQueryBackendPacket : Packet - { - /// QueryData block + { + /// QueryData block public class QueryDataBlock - { - /// Godlike field - public bool Godlike; - /// QueryID field - public LLUUID QueryID; - /// Category field - public uint Category; - /// QueryFlags field - public uint QueryFlags; - private byte[] _querytext; - /// QueryText field + { + /// Godlike field + public bool Godlike; + /// QueryID field + public LLUUID QueryID; + /// Category field + public uint Category; + /// QueryFlags field + public uint QueryFlags; + private byte[] _querytext; + /// QueryText field public byte[] QueryText - { - get { return _querytext; } + { + get { return _querytext; } set - { - if (value == null) { _querytext = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _querytext = new byte[value.Length]; Array.Copy(value, _querytext, value.Length); } + { + if (value == null) { _querytext = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _querytext = new byte[value.Length]; Array.Copy(value, _querytext, value.Length); } } - } - /// EstateID field - public uint EstateID; - - /// Length of this block serialized in bytes + } + /// EstateID field + public uint EstateID; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 29; - if (QueryText != null) { length += 1 + QueryText.Length; } - return length; + { + int length = 29; + if (QueryText != null) { length += 1 + QueryText.Length; } + return length; } } - - /// Default constructor - public QueryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public QueryDataBlock() { } + /// Constructor for building the block from a byte array public QueryDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - Godlike = (bytes[i++] != 0) ? (bool)true : (bool)false; - QueryID = new LLUUID(bytes, i); i += 16; - Category = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - QueryFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _querytext = new byte[length]; - Array.Copy(bytes, i, _querytext, 0, length); i += length; - EstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + Godlike = (bytes[i++] != 0) ? (bool)true : (bool)false; + QueryID = new LLUUID(bytes, i); i += 16; + Category = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + QueryFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _querytext = new byte[length]; + Array.Copy(bytes, i, _querytext, 0, length); i += length; + EstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)((Godlike) ? 1 : 0); - if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } - Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(Category % 256); - bytes[i++] = (byte)((Category >> 8) % 256); - bytes[i++] = (byte)((Category >> 16) % 256); - bytes[i++] = (byte)((Category >> 24) % 256); - bytes[i++] = (byte)(QueryFlags % 256); - bytes[i++] = (byte)((QueryFlags >> 8) % 256); - bytes[i++] = (byte)((QueryFlags >> 16) % 256); - bytes[i++] = (byte)((QueryFlags >> 24) % 256); - if(QueryText == null) { Console.WriteLine("Warning: QueryText is null, in " + this.GetType()); } - bytes[i++] = (byte)QueryText.Length; - Array.Copy(QueryText, 0, bytes, i, QueryText.Length); i += QueryText.Length; - bytes[i++] = (byte)(EstateID % 256); - bytes[i++] = (byte)((EstateID >> 8) % 256); - bytes[i++] = (byte)((EstateID >> 16) % 256); - bytes[i++] = (byte)((EstateID >> 24) % 256); + { + bytes[i++] = (byte)((Godlike) ? 1 : 0); + if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } + Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(Category % 256); + bytes[i++] = (byte)((Category >> 8) % 256); + bytes[i++] = (byte)((Category >> 16) % 256); + bytes[i++] = (byte)((Category >> 24) % 256); + bytes[i++] = (byte)(QueryFlags % 256); + bytes[i++] = (byte)((QueryFlags >> 8) % 256); + bytes[i++] = (byte)((QueryFlags >> 16) % 256); + bytes[i++] = (byte)((QueryFlags >> 24) % 256); + if(QueryText == null) { Console.WriteLine("Warning: QueryText is null, in " + this.GetType()); } + bytes[i++] = (byte)QueryText.Length; + Array.Copy(QueryText, 0, bytes, i, QueryText.Length); i += QueryText.Length; + bytes[i++] = (byte)(EstateID % 256); + bytes[i++] = (byte)((EstateID >> 8) % 256); + bytes[i++] = (byte)((EstateID >> 16) % 256); + bytes[i++] = (byte)((EstateID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- QueryData --\n"; - output += "Godlike: " + Godlike.ToString() + "\n"; - output += "QueryID: " + QueryID.ToString() + "\n"; - output += "Category: " + Category.ToString() + "\n"; - output += "QueryFlags: " + QueryFlags.ToString() + "\n"; - output += Helpers.FieldToString(QueryText, "QueryText") + "\n"; - output += "EstateID: " + EstateID.ToString() + "\n"; + { + string output = "-- QueryData --\n"; + output += "Godlike: " + Godlike.ToString() + "\n"; + output += "QueryID: " + QueryID.ToString() + "\n"; + output += "Category: " + Category.ToString() + "\n"; + output += "QueryFlags: " + QueryFlags.ToString() + "\n"; + output += Helpers.FieldToString(QueryText, "QueryText") + "\n"; + output += "EstateID: " + EstateID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.DirClassifiedQueryBackend - public override PacketType Type { get { return PacketType.DirClassifiedQueryBackend; } } - /// QueryData block - public QueryDataBlock QueryData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.DirClassifiedQueryBackend + public override PacketType Type { get { return PacketType.DirClassifiedQueryBackend; } } + /// QueryData block + public QueryDataBlock QueryData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public DirClassifiedQueryBackendPacket() - { - Header = new LowHeader(); - Header.ID = 56; - Header.Reliable = true; - Header.Zerocoded = true; - QueryData = new QueryDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 56; + Header.Reliable = true; + Header.Zerocoded = true; + QueryData = new QueryDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public DirClassifiedQueryBackendPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - QueryData = new QueryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + QueryData = new QueryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public DirClassifiedQueryBackendPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - QueryData = new QueryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + QueryData = new QueryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += QueryData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - QueryData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += QueryData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + QueryData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- DirClassifiedQueryBackend ---\n"; - output += QueryData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- DirClassifiedQueryBackend ---\n"; + output += QueryData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// DirClassifiedReply packet + + /// DirClassifiedReply packet public class DirClassifiedReplyPacket : Packet - { - /// QueryReplies block + { + /// QueryReplies block public class QueryRepliesBlock - { - /// ClassifiedFlags field - public byte ClassifiedFlags; - /// CreationDate field - public uint CreationDate; - /// ClassifiedID field - public LLUUID ClassifiedID; - private byte[] _name; - /// Name field + { + /// ClassifiedFlags field + public byte ClassifiedFlags; + /// CreationDate field + public uint CreationDate; + /// ClassifiedID field + public LLUUID ClassifiedID; + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - /// PriceForListing field - public int PriceForListing; - /// ExpirationDate field - public uint ExpirationDate; - - /// Length of this block serialized in bytes + } + /// PriceForListing field + public int PriceForListing; + /// ExpirationDate field + public uint ExpirationDate; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 29; - if (Name != null) { length += 1 + Name.Length; } - return length; + { + int length = 29; + if (Name != null) { length += 1 + Name.Length; } + return length; } } - - /// Default constructor - public QueryRepliesBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public QueryRepliesBlock() { } + /// Constructor for building the block from a byte array public QueryRepliesBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - ClassifiedFlags = (byte)bytes[i++]; - CreationDate = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - ClassifiedID = new LLUUID(bytes, i); i += 16; - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; - PriceForListing = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - ExpirationDate = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + ClassifiedFlags = (byte)bytes[i++]; + CreationDate = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + ClassifiedID = new LLUUID(bytes, i); i += 16; + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; + PriceForListing = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + ExpirationDate = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = ClassifiedFlags; - bytes[i++] = (byte)(CreationDate % 256); - bytes[i++] = (byte)((CreationDate >> 8) % 256); - bytes[i++] = (byte)((CreationDate >> 16) % 256); - bytes[i++] = (byte)((CreationDate >> 24) % 256); - if(ClassifiedID == null) { Console.WriteLine("Warning: ClassifiedID is null, in " + this.GetType()); } - Array.Copy(ClassifiedID.GetBytes(), 0, bytes, i, 16); i += 16; - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; - bytes[i++] = (byte)(PriceForListing % 256); - bytes[i++] = (byte)((PriceForListing >> 8) % 256); - bytes[i++] = (byte)((PriceForListing >> 16) % 256); - bytes[i++] = (byte)((PriceForListing >> 24) % 256); - bytes[i++] = (byte)(ExpirationDate % 256); - bytes[i++] = (byte)((ExpirationDate >> 8) % 256); - bytes[i++] = (byte)((ExpirationDate >> 16) % 256); - bytes[i++] = (byte)((ExpirationDate >> 24) % 256); + { + bytes[i++] = ClassifiedFlags; + bytes[i++] = (byte)(CreationDate % 256); + bytes[i++] = (byte)((CreationDate >> 8) % 256); + bytes[i++] = (byte)((CreationDate >> 16) % 256); + bytes[i++] = (byte)((CreationDate >> 24) % 256); + if(ClassifiedID == null) { Console.WriteLine("Warning: ClassifiedID is null, in " + this.GetType()); } + Array.Copy(ClassifiedID.GetBytes(), 0, bytes, i, 16); i += 16; + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + bytes[i++] = (byte)(PriceForListing % 256); + bytes[i++] = (byte)((PriceForListing >> 8) % 256); + bytes[i++] = (byte)((PriceForListing >> 16) % 256); + bytes[i++] = (byte)((PriceForListing >> 24) % 256); + bytes[i++] = (byte)(ExpirationDate % 256); + bytes[i++] = (byte)((ExpirationDate >> 8) % 256); + bytes[i++] = (byte)((ExpirationDate >> 16) % 256); + bytes[i++] = (byte)((ExpirationDate >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- QueryReplies --\n"; - output += "ClassifiedFlags: " + ClassifiedFlags.ToString() + "\n"; - output += "CreationDate: " + CreationDate.ToString() + "\n"; - output += "ClassifiedID: " + ClassifiedID.ToString() + "\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; - output += "PriceForListing: " + PriceForListing.ToString() + "\n"; - output += "ExpirationDate: " + ExpirationDate.ToString() + "\n"; + { + string output = "-- QueryReplies --\n"; + output += "ClassifiedFlags: " + ClassifiedFlags.ToString() + "\n"; + output += "CreationDate: " + CreationDate.ToString() + "\n"; + output += "ClassifiedID: " + ClassifiedID.ToString() + "\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; + output += "PriceForListing: " + PriceForListing.ToString() + "\n"; + output += "ExpirationDate: " + ExpirationDate.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// QueryData block + + /// QueryData block public class QueryDataBlock - { - /// QueryID field - public LLUUID QueryID; - - /// Length of this block serialized in bytes + { + /// QueryID field + public LLUUID QueryID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public QueryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public QueryDataBlock() { } + /// Constructor for building the block from a byte array public QueryDataBlock(byte[] bytes, ref int i) - { + { try - { - QueryID = new LLUUID(bytes, i); i += 16; + { + QueryID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } - Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } + Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- QueryData --\n"; - output += "QueryID: " + QueryID.ToString() + "\n"; + { + string output = "-- QueryData --\n"; + output += "QueryID: " + QueryID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.DirClassifiedReply - public override PacketType Type { get { return PacketType.DirClassifiedReply; } } - /// QueryReplies block - public QueryRepliesBlock[] QueryReplies; - /// QueryData block - public QueryDataBlock QueryData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.DirClassifiedReply + public override PacketType Type { get { return PacketType.DirClassifiedReply; } } + /// QueryReplies block + public QueryRepliesBlock[] QueryReplies; + /// QueryData block + public QueryDataBlock QueryData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public DirClassifiedReplyPacket() - { - Header = new LowHeader(); - Header.ID = 57; - Header.Reliable = true; - Header.Zerocoded = true; - QueryReplies = new QueryRepliesBlock[0]; - QueryData = new QueryDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 57; + Header.Reliable = true; + Header.Zerocoded = true; + QueryReplies = new QueryRepliesBlock[0]; + QueryData = new QueryDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public DirClassifiedReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - QueryReplies = new QueryRepliesBlock[count]; - for (int j = 0; j < count; j++) - { QueryReplies[j] = new QueryRepliesBlock(bytes, ref i); } - QueryData = new QueryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + QueryReplies = new QueryRepliesBlock[count]; + for (int j = 0; j < count; j++) + { QueryReplies[j] = new QueryRepliesBlock(bytes, ref i); } + QueryData = new QueryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public DirClassifiedReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - QueryReplies = new QueryRepliesBlock[count]; - for (int j = 0; j < count; j++) - { QueryReplies[j] = new QueryRepliesBlock(bytes, ref i); } - QueryData = new QueryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + QueryReplies = new QueryRepliesBlock[count]; + for (int j = 0; j < count; j++) + { QueryReplies[j] = new QueryRepliesBlock(bytes, ref i); } + QueryData = new QueryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += QueryData.Length; length += AgentData.Length;; - length++; - for (int j = 0; j < QueryReplies.Length; j++) { length += QueryReplies[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)QueryReplies.Length; - for (int j = 0; j < QueryReplies.Length; j++) { QueryReplies[j].ToBytes(bytes, ref i); } - QueryData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += QueryData.Length; length += AgentData.Length;; + length++; + for (int j = 0; j < QueryReplies.Length; j++) { length += QueryReplies[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)QueryReplies.Length; + for (int j = 0; j < QueryReplies.Length; j++) { QueryReplies[j].ToBytes(bytes, ref i); } + QueryData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- DirClassifiedReply ---\n"; + { + string output = "--- DirClassifiedReply ---\n"; for (int j = 0; j < QueryReplies.Length; j++) - { + { output += QueryReplies[j].ToString() + "\n"; - } - output += QueryData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + } + output += QueryData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// AvatarClassifiedReply packet + + /// AvatarClassifiedReply packet public class AvatarClassifiedReplyPacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - /// ClassifiedID field - public LLUUID ClassifiedID; - private byte[] _name; - /// Name field + { + /// ClassifiedID field + public LLUUID ClassifiedID; + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 16; - if (Name != null) { length += 1 + Name.Length; } - return length; + { + int length = 16; + if (Name != null) { length += 1 + Name.Length; } + return length; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - ClassifiedID = new LLUUID(bytes, i); i += 16; - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; + { + ClassifiedID = new LLUUID(bytes, i); i += 16; + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ClassifiedID == null) { Console.WriteLine("Warning: ClassifiedID is null, in " + this.GetType()); } - Array.Copy(ClassifiedID.GetBytes(), 0, bytes, i, 16); i += 16; - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + { + if(ClassifiedID == null) { Console.WriteLine("Warning: ClassifiedID is null, in " + this.GetType()); } + Array.Copy(ClassifiedID.GetBytes(), 0, bytes, i, 16); i += 16; + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "ClassifiedID: " + ClassifiedID.ToString() + "\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; + { + string output = "-- Data --\n"; + output += "ClassifiedID: " + ClassifiedID.ToString() + "\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// TargetID field - public LLUUID TargetID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// TargetID field + public LLUUID TargetID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - TargetID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + TargetID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(TargetID == null) { Console.WriteLine("Warning: TargetID is null, in " + this.GetType()); } - Array.Copy(TargetID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(TargetID == null) { Console.WriteLine("Warning: TargetID is null, in " + this.GetType()); } + Array.Copy(TargetID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "TargetID: " + TargetID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "TargetID: " + TargetID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AvatarClassifiedReply - public override PacketType Type { get { return PacketType.AvatarClassifiedReply; } } - /// Data block - public DataBlock[] Data; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AvatarClassifiedReply + public override PacketType Type { get { return PacketType.AvatarClassifiedReply; } } + /// Data block + public DataBlock[] Data; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public AvatarClassifiedReplyPacket() - { - Header = new LowHeader(); - Header.ID = 58; - Header.Reliable = true; - Data = new DataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 58; + Header.Reliable = true; + Data = new DataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AvatarClassifiedReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - Data = new DataBlock[count]; - for (int j = 0; j < count; j++) - { Data[j] = new DataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + Data = new DataBlock[count]; + for (int j = 0; j < count; j++) + { Data[j] = new DataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AvatarClassifiedReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - Data = new DataBlock[count]; - for (int j = 0; j < count; j++) - { Data[j] = new DataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + Data = new DataBlock[count]; + for (int j = 0; j < count; j++) + { Data[j] = new DataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < Data.Length; j++) { length += Data[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)Data.Length; - for (int j = 0; j < Data.Length; j++) { Data[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < Data.Length; j++) { length += Data[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)Data.Length; + for (int j = 0; j < Data.Length; j++) { Data[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AvatarClassifiedReply ---\n"; + { + string output = "--- AvatarClassifiedReply ---\n"; for (int j = 0; j < Data.Length; j++) - { + { output += Data[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ClassifiedInfoRequest packet + + /// ClassifiedInfoRequest packet public class ClassifiedInfoRequestPacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - /// ClassifiedID field - public LLUUID ClassifiedID; - - /// Length of this block serialized in bytes + { + /// ClassifiedID field + public LLUUID ClassifiedID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { + { try - { - ClassifiedID = new LLUUID(bytes, i); i += 16; + { + ClassifiedID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ClassifiedID == null) { Console.WriteLine("Warning: ClassifiedID is null, in " + this.GetType()); } - Array.Copy(ClassifiedID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(ClassifiedID == null) { Console.WriteLine("Warning: ClassifiedID is null, in " + this.GetType()); } + Array.Copy(ClassifiedID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "ClassifiedID: " + ClassifiedID.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += "ClassifiedID: " + ClassifiedID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ClassifiedInfoRequest - public override PacketType Type { get { return PacketType.ClassifiedInfoRequest; } } - /// Data block - public DataBlock Data; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ClassifiedInfoRequest + public override PacketType Type { get { return PacketType.ClassifiedInfoRequest; } } + /// Data block + public DataBlock Data; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ClassifiedInfoRequestPacket() - { - Header = new LowHeader(); - Header.ID = 59; - Header.Reliable = true; - Header.Zerocoded = true; - Data = new DataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 59; + Header.Reliable = true; + Header.Zerocoded = true; + Data = new DataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ClassifiedInfoRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ClassifiedInfoRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Data.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Data.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Data.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Data.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ClassifiedInfoRequest ---\n"; - output += Data.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- ClassifiedInfoRequest ---\n"; + output += Data.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ClassifiedInfoReply packet + + /// ClassifiedInfoReply packet public class ClassifiedInfoReplyPacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - /// ClassifiedFlags field - public byte ClassifiedFlags; - /// CreationDate field - public uint CreationDate; - private byte[] _simname; - /// SimName field + { + /// ClassifiedFlags field + public byte ClassifiedFlags; + /// CreationDate field + public uint CreationDate; + private byte[] _simname; + /// SimName field public byte[] SimName - { - get { return _simname; } + { + get { return _simname; } set - { - if (value == null) { _simname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _simname = new byte[value.Length]; Array.Copy(value, _simname, value.Length); } + { + if (value == null) { _simname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _simname = new byte[value.Length]; Array.Copy(value, _simname, value.Length); } } - } - /// ClassifiedID field - public LLUUID ClassifiedID; - /// PosGlobal field - public LLVector3d PosGlobal; - /// ParcelID field - public LLUUID ParcelID; - private byte[] _name; - /// Name field + } + /// ClassifiedID field + public LLUUID ClassifiedID; + /// PosGlobal field + public LLVector3d PosGlobal; + /// ParcelID field + public LLUUID ParcelID; + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - private byte[] _desc; - /// Desc field + } + private byte[] _desc; + /// Desc field public byte[] Desc - { - get { return _desc; } + { + get { return _desc; } set - { - if (value == null) { _desc = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _desc = new byte[value.Length]; Array.Copy(value, _desc, value.Length); } + { + if (value == null) { _desc = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _desc = new byte[value.Length]; Array.Copy(value, _desc, value.Length); } } - } - private byte[] _parcelname; - /// ParcelName field + } + private byte[] _parcelname; + /// ParcelName field public byte[] ParcelName - { - get { return _parcelname; } + { + get { return _parcelname; } set - { - if (value == null) { _parcelname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _parcelname = new byte[value.Length]; Array.Copy(value, _parcelname, value.Length); } + { + if (value == null) { _parcelname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _parcelname = new byte[value.Length]; Array.Copy(value, _parcelname, value.Length); } } - } - /// Category field - public uint Category; - /// CreatorID field - public LLUUID CreatorID; - /// SnapshotID field - public LLUUID SnapshotID; - /// PriceForListing field - public int PriceForListing; - /// ExpirationDate field - public uint ExpirationDate; - /// ParentEstate field - public uint ParentEstate; - - /// Length of this block serialized in bytes + } + /// Category field + public uint Category; + /// CreatorID field + public LLUUID CreatorID; + /// SnapshotID field + public LLUUID SnapshotID; + /// PriceForListing field + public int PriceForListing; + /// ExpirationDate field + public uint ExpirationDate; + /// ParentEstate field + public uint ParentEstate; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 109; - if (SimName != null) { length += 1 + SimName.Length; } - if (Name != null) { length += 1 + Name.Length; } - if (Desc != null) { length += 2 + Desc.Length; } - if (ParcelName != null) { length += 1 + ParcelName.Length; } - return length; + { + int length = 109; + if (SimName != null) { length += 1 + SimName.Length; } + if (Name != null) { length += 1 + Name.Length; } + if (Desc != null) { length += 2 + Desc.Length; } + if (ParcelName != null) { length += 1 + ParcelName.Length; } + return length; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - ClassifiedFlags = (byte)bytes[i++]; - CreationDate = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _simname = new byte[length]; - Array.Copy(bytes, i, _simname, 0, length); i += length; - ClassifiedID = new LLUUID(bytes, i); i += 16; - PosGlobal = new LLVector3d(bytes, i); i += 24; - ParcelID = new LLUUID(bytes, i); i += 16; - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _desc = new byte[length]; - Array.Copy(bytes, i, _desc, 0, length); i += length; - length = (ushort)bytes[i++]; - _parcelname = new byte[length]; - Array.Copy(bytes, i, _parcelname, 0, length); i += length; - Category = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - CreatorID = new LLUUID(bytes, i); i += 16; - SnapshotID = new LLUUID(bytes, i); i += 16; - PriceForListing = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - ExpirationDate = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - ParentEstate = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + ClassifiedFlags = (byte)bytes[i++]; + CreationDate = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _simname = new byte[length]; + Array.Copy(bytes, i, _simname, 0, length); i += length; + ClassifiedID = new LLUUID(bytes, i); i += 16; + PosGlobal = new LLVector3d(bytes, i); i += 24; + ParcelID = new LLUUID(bytes, i); i += 16; + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _desc = new byte[length]; + Array.Copy(bytes, i, _desc, 0, length); i += length; + length = (ushort)bytes[i++]; + _parcelname = new byte[length]; + Array.Copy(bytes, i, _parcelname, 0, length); i += length; + Category = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + CreatorID = new LLUUID(bytes, i); i += 16; + SnapshotID = new LLUUID(bytes, i); i += 16; + PriceForListing = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + ExpirationDate = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + ParentEstate = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = ClassifiedFlags; - bytes[i++] = (byte)(CreationDate % 256); - bytes[i++] = (byte)((CreationDate >> 8) % 256); - bytes[i++] = (byte)((CreationDate >> 16) % 256); - bytes[i++] = (byte)((CreationDate >> 24) % 256); - if(SimName == null) { Console.WriteLine("Warning: SimName is null, in " + this.GetType()); } - bytes[i++] = (byte)SimName.Length; - Array.Copy(SimName, 0, bytes, i, SimName.Length); i += SimName.Length; - if(ClassifiedID == null) { Console.WriteLine("Warning: ClassifiedID is null, in " + this.GetType()); } - Array.Copy(ClassifiedID.GetBytes(), 0, bytes, i, 16); i += 16; - if(PosGlobal == null) { Console.WriteLine("Warning: PosGlobal is null, in " + this.GetType()); } - Array.Copy(PosGlobal.GetBytes(), 0, bytes, i, 24); i += 24; - if(ParcelID == null) { Console.WriteLine("Warning: ParcelID is null, in " + this.GetType()); } - Array.Copy(ParcelID.GetBytes(), 0, bytes, i, 16); i += 16; - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; - if(Desc == null) { Console.WriteLine("Warning: Desc is null, in " + this.GetType()); } - bytes[i++] = (byte)(Desc.Length % 256); - bytes[i++] = (byte)((Desc.Length >> 8) % 256); - Array.Copy(Desc, 0, bytes, i, Desc.Length); i += Desc.Length; - if(ParcelName == null) { Console.WriteLine("Warning: ParcelName is null, in " + this.GetType()); } - bytes[i++] = (byte)ParcelName.Length; - Array.Copy(ParcelName, 0, bytes, i, ParcelName.Length); i += ParcelName.Length; - bytes[i++] = (byte)(Category % 256); - bytes[i++] = (byte)((Category >> 8) % 256); - bytes[i++] = (byte)((Category >> 16) % 256); - bytes[i++] = (byte)((Category >> 24) % 256); - if(CreatorID == null) { Console.WriteLine("Warning: CreatorID is null, in " + this.GetType()); } - Array.Copy(CreatorID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SnapshotID == null) { Console.WriteLine("Warning: SnapshotID is null, in " + this.GetType()); } - Array.Copy(SnapshotID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(PriceForListing % 256); - bytes[i++] = (byte)((PriceForListing >> 8) % 256); - bytes[i++] = (byte)((PriceForListing >> 16) % 256); - bytes[i++] = (byte)((PriceForListing >> 24) % 256); - bytes[i++] = (byte)(ExpirationDate % 256); - bytes[i++] = (byte)((ExpirationDate >> 8) % 256); - bytes[i++] = (byte)((ExpirationDate >> 16) % 256); - bytes[i++] = (byte)((ExpirationDate >> 24) % 256); - bytes[i++] = (byte)(ParentEstate % 256); - bytes[i++] = (byte)((ParentEstate >> 8) % 256); - bytes[i++] = (byte)((ParentEstate >> 16) % 256); - bytes[i++] = (byte)((ParentEstate >> 24) % 256); + { + bytes[i++] = ClassifiedFlags; + bytes[i++] = (byte)(CreationDate % 256); + bytes[i++] = (byte)((CreationDate >> 8) % 256); + bytes[i++] = (byte)((CreationDate >> 16) % 256); + bytes[i++] = (byte)((CreationDate >> 24) % 256); + if(SimName == null) { Console.WriteLine("Warning: SimName is null, in " + this.GetType()); } + bytes[i++] = (byte)SimName.Length; + Array.Copy(SimName, 0, bytes, i, SimName.Length); i += SimName.Length; + if(ClassifiedID == null) { Console.WriteLine("Warning: ClassifiedID is null, in " + this.GetType()); } + Array.Copy(ClassifiedID.GetBytes(), 0, bytes, i, 16); i += 16; + if(PosGlobal == null) { Console.WriteLine("Warning: PosGlobal is null, in " + this.GetType()); } + Array.Copy(PosGlobal.GetBytes(), 0, bytes, i, 24); i += 24; + if(ParcelID == null) { Console.WriteLine("Warning: ParcelID is null, in " + this.GetType()); } + Array.Copy(ParcelID.GetBytes(), 0, bytes, i, 16); i += 16; + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + if(Desc == null) { Console.WriteLine("Warning: Desc is null, in " + this.GetType()); } + bytes[i++] = (byte)(Desc.Length % 256); + bytes[i++] = (byte)((Desc.Length >> 8) % 256); + Array.Copy(Desc, 0, bytes, i, Desc.Length); i += Desc.Length; + if(ParcelName == null) { Console.WriteLine("Warning: ParcelName is null, in " + this.GetType()); } + bytes[i++] = (byte)ParcelName.Length; + Array.Copy(ParcelName, 0, bytes, i, ParcelName.Length); i += ParcelName.Length; + bytes[i++] = (byte)(Category % 256); + bytes[i++] = (byte)((Category >> 8) % 256); + bytes[i++] = (byte)((Category >> 16) % 256); + bytes[i++] = (byte)((Category >> 24) % 256); + if(CreatorID == null) { Console.WriteLine("Warning: CreatorID is null, in " + this.GetType()); } + Array.Copy(CreatorID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SnapshotID == null) { Console.WriteLine("Warning: SnapshotID is null, in " + this.GetType()); } + Array.Copy(SnapshotID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(PriceForListing % 256); + bytes[i++] = (byte)((PriceForListing >> 8) % 256); + bytes[i++] = (byte)((PriceForListing >> 16) % 256); + bytes[i++] = (byte)((PriceForListing >> 24) % 256); + bytes[i++] = (byte)(ExpirationDate % 256); + bytes[i++] = (byte)((ExpirationDate >> 8) % 256); + bytes[i++] = (byte)((ExpirationDate >> 16) % 256); + bytes[i++] = (byte)((ExpirationDate >> 24) % 256); + bytes[i++] = (byte)(ParentEstate % 256); + bytes[i++] = (byte)((ParentEstate >> 8) % 256); + bytes[i++] = (byte)((ParentEstate >> 16) % 256); + bytes[i++] = (byte)((ParentEstate >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "ClassifiedFlags: " + ClassifiedFlags.ToString() + "\n"; - output += "CreationDate: " + CreationDate.ToString() + "\n"; - output += Helpers.FieldToString(SimName, "SimName") + "\n"; - output += "ClassifiedID: " + ClassifiedID.ToString() + "\n"; - output += "PosGlobal: " + PosGlobal.ToString() + "\n"; - output += "ParcelID: " + ParcelID.ToString() + "\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; - output += Helpers.FieldToString(Desc, "Desc") + "\n"; - output += Helpers.FieldToString(ParcelName, "ParcelName") + "\n"; - output += "Category: " + Category.ToString() + "\n"; - output += "CreatorID: " + CreatorID.ToString() + "\n"; - output += "SnapshotID: " + SnapshotID.ToString() + "\n"; - output += "PriceForListing: " + PriceForListing.ToString() + "\n"; - output += "ExpirationDate: " + ExpirationDate.ToString() + "\n"; - output += "ParentEstate: " + ParentEstate.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += "ClassifiedFlags: " + ClassifiedFlags.ToString() + "\n"; + output += "CreationDate: " + CreationDate.ToString() + "\n"; + output += Helpers.FieldToString(SimName, "SimName") + "\n"; + output += "ClassifiedID: " + ClassifiedID.ToString() + "\n"; + output += "PosGlobal: " + PosGlobal.ToString() + "\n"; + output += "ParcelID: " + ParcelID.ToString() + "\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; + output += Helpers.FieldToString(Desc, "Desc") + "\n"; + output += Helpers.FieldToString(ParcelName, "ParcelName") + "\n"; + output += "Category: " + Category.ToString() + "\n"; + output += "CreatorID: " + CreatorID.ToString() + "\n"; + output += "SnapshotID: " + SnapshotID.ToString() + "\n"; + output += "PriceForListing: " + PriceForListing.ToString() + "\n"; + output += "ExpirationDate: " + ExpirationDate.ToString() + "\n"; + output += "ParentEstate: " + ParentEstate.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ClassifiedInfoReply - public override PacketType Type { get { return PacketType.ClassifiedInfoReply; } } - /// Data block - public DataBlock Data; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ClassifiedInfoReply + public override PacketType Type { get { return PacketType.ClassifiedInfoReply; } } + /// Data block + public DataBlock Data; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ClassifiedInfoReplyPacket() - { - Header = new LowHeader(); - Header.ID = 60; - Header.Reliable = true; - Data = new DataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 60; + Header.Reliable = true; + Data = new DataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ClassifiedInfoReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ClassifiedInfoReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Data.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Data.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Data.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Data.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ClassifiedInfoReply ---\n"; - output += Data.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- ClassifiedInfoReply ---\n"; + output += Data.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ClassifiedInfoUpdate packet + + /// ClassifiedInfoUpdate packet public class ClassifiedInfoUpdatePacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - /// ClassifiedFlags field - public byte ClassifiedFlags; - /// ClassifiedID field - public LLUUID ClassifiedID; - /// PosGlobal field - public LLVector3d PosGlobal; - /// ParcelID field - public LLUUID ParcelID; - private byte[] _name; - /// Name field + { + /// ClassifiedFlags field + public byte ClassifiedFlags; + /// ClassifiedID field + public LLUUID ClassifiedID; + /// PosGlobal field + public LLVector3d PosGlobal; + /// ParcelID field + public LLUUID ParcelID; + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - private byte[] _desc; - /// Desc field + } + private byte[] _desc; + /// Desc field public byte[] Desc - { - get { return _desc; } + { + get { return _desc; } set - { - if (value == null) { _desc = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _desc = new byte[value.Length]; Array.Copy(value, _desc, value.Length); } + { + if (value == null) { _desc = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _desc = new byte[value.Length]; Array.Copy(value, _desc, value.Length); } } - } - /// Category field - public uint Category; - /// SnapshotID field - public LLUUID SnapshotID; - /// PriceForListing field - public int PriceForListing; - /// ParentEstate field - public uint ParentEstate; - - /// Length of this block serialized in bytes + } + /// Category field + public uint Category; + /// SnapshotID field + public LLUUID SnapshotID; + /// PriceForListing field + public int PriceForListing; + /// ParentEstate field + public uint ParentEstate; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 85; - if (Name != null) { length += 1 + Name.Length; } - if (Desc != null) { length += 2 + Desc.Length; } - return length; + { + int length = 85; + if (Name != null) { length += 1 + Name.Length; } + if (Desc != null) { length += 2 + Desc.Length; } + return length; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - ClassifiedFlags = (byte)bytes[i++]; - ClassifiedID = new LLUUID(bytes, i); i += 16; - PosGlobal = new LLVector3d(bytes, i); i += 24; - ParcelID = new LLUUID(bytes, i); i += 16; - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _desc = new byte[length]; - Array.Copy(bytes, i, _desc, 0, length); i += length; - Category = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - SnapshotID = new LLUUID(bytes, i); i += 16; - PriceForListing = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - ParentEstate = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + ClassifiedFlags = (byte)bytes[i++]; + ClassifiedID = new LLUUID(bytes, i); i += 16; + PosGlobal = new LLVector3d(bytes, i); i += 24; + ParcelID = new LLUUID(bytes, i); i += 16; + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _desc = new byte[length]; + Array.Copy(bytes, i, _desc, 0, length); i += length; + Category = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + SnapshotID = new LLUUID(bytes, i); i += 16; + PriceForListing = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + ParentEstate = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = ClassifiedFlags; - if(ClassifiedID == null) { Console.WriteLine("Warning: ClassifiedID is null, in " + this.GetType()); } - Array.Copy(ClassifiedID.GetBytes(), 0, bytes, i, 16); i += 16; - if(PosGlobal == null) { Console.WriteLine("Warning: PosGlobal is null, in " + this.GetType()); } - Array.Copy(PosGlobal.GetBytes(), 0, bytes, i, 24); i += 24; - if(ParcelID == null) { Console.WriteLine("Warning: ParcelID is null, in " + this.GetType()); } - Array.Copy(ParcelID.GetBytes(), 0, bytes, i, 16); i += 16; - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; - if(Desc == null) { Console.WriteLine("Warning: Desc is null, in " + this.GetType()); } - bytes[i++] = (byte)(Desc.Length % 256); - bytes[i++] = (byte)((Desc.Length >> 8) % 256); - Array.Copy(Desc, 0, bytes, i, Desc.Length); i += Desc.Length; - bytes[i++] = (byte)(Category % 256); - bytes[i++] = (byte)((Category >> 8) % 256); - bytes[i++] = (byte)((Category >> 16) % 256); - bytes[i++] = (byte)((Category >> 24) % 256); - if(SnapshotID == null) { Console.WriteLine("Warning: SnapshotID is null, in " + this.GetType()); } - Array.Copy(SnapshotID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(PriceForListing % 256); - bytes[i++] = (byte)((PriceForListing >> 8) % 256); - bytes[i++] = (byte)((PriceForListing >> 16) % 256); - bytes[i++] = (byte)((PriceForListing >> 24) % 256); - bytes[i++] = (byte)(ParentEstate % 256); - bytes[i++] = (byte)((ParentEstate >> 8) % 256); - bytes[i++] = (byte)((ParentEstate >> 16) % 256); - bytes[i++] = (byte)((ParentEstate >> 24) % 256); + { + bytes[i++] = ClassifiedFlags; + if(ClassifiedID == null) { Console.WriteLine("Warning: ClassifiedID is null, in " + this.GetType()); } + Array.Copy(ClassifiedID.GetBytes(), 0, bytes, i, 16); i += 16; + if(PosGlobal == null) { Console.WriteLine("Warning: PosGlobal is null, in " + this.GetType()); } + Array.Copy(PosGlobal.GetBytes(), 0, bytes, i, 24); i += 24; + if(ParcelID == null) { Console.WriteLine("Warning: ParcelID is null, in " + this.GetType()); } + Array.Copy(ParcelID.GetBytes(), 0, bytes, i, 16); i += 16; + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + if(Desc == null) { Console.WriteLine("Warning: Desc is null, in " + this.GetType()); } + bytes[i++] = (byte)(Desc.Length % 256); + bytes[i++] = (byte)((Desc.Length >> 8) % 256); + Array.Copy(Desc, 0, bytes, i, Desc.Length); i += Desc.Length; + bytes[i++] = (byte)(Category % 256); + bytes[i++] = (byte)((Category >> 8) % 256); + bytes[i++] = (byte)((Category >> 16) % 256); + bytes[i++] = (byte)((Category >> 24) % 256); + if(SnapshotID == null) { Console.WriteLine("Warning: SnapshotID is null, in " + this.GetType()); } + Array.Copy(SnapshotID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(PriceForListing % 256); + bytes[i++] = (byte)((PriceForListing >> 8) % 256); + bytes[i++] = (byte)((PriceForListing >> 16) % 256); + bytes[i++] = (byte)((PriceForListing >> 24) % 256); + bytes[i++] = (byte)(ParentEstate % 256); + bytes[i++] = (byte)((ParentEstate >> 8) % 256); + bytes[i++] = (byte)((ParentEstate >> 16) % 256); + bytes[i++] = (byte)((ParentEstate >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "ClassifiedFlags: " + ClassifiedFlags.ToString() + "\n"; - output += "ClassifiedID: " + ClassifiedID.ToString() + "\n"; - output += "PosGlobal: " + PosGlobal.ToString() + "\n"; - output += "ParcelID: " + ParcelID.ToString() + "\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; - output += Helpers.FieldToString(Desc, "Desc") + "\n"; - output += "Category: " + Category.ToString() + "\n"; - output += "SnapshotID: " + SnapshotID.ToString() + "\n"; - output += "PriceForListing: " + PriceForListing.ToString() + "\n"; - output += "ParentEstate: " + ParentEstate.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += "ClassifiedFlags: " + ClassifiedFlags.ToString() + "\n"; + output += "ClassifiedID: " + ClassifiedID.ToString() + "\n"; + output += "PosGlobal: " + PosGlobal.ToString() + "\n"; + output += "ParcelID: " + ParcelID.ToString() + "\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; + output += Helpers.FieldToString(Desc, "Desc") + "\n"; + output += "Category: " + Category.ToString() + "\n"; + output += "SnapshotID: " + SnapshotID.ToString() + "\n"; + output += "PriceForListing: " + PriceForListing.ToString() + "\n"; + output += "ParentEstate: " + ParentEstate.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ClassifiedInfoUpdate - public override PacketType Type { get { return PacketType.ClassifiedInfoUpdate; } } - /// Data block - public DataBlock Data; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ClassifiedInfoUpdate + public override PacketType Type { get { return PacketType.ClassifiedInfoUpdate; } } + /// Data block + public DataBlock Data; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ClassifiedInfoUpdatePacket() - { - Header = new LowHeader(); - Header.ID = 61; - Header.Reliable = true; - Data = new DataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 61; + Header.Reliable = true; + Data = new DataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ClassifiedInfoUpdatePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ClassifiedInfoUpdatePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Data.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Data.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Data.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Data.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ClassifiedInfoUpdate ---\n"; - output += Data.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- ClassifiedInfoUpdate ---\n"; + output += Data.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ClassifiedDelete packet + + /// ClassifiedDelete packet public class ClassifiedDeletePacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - /// ClassifiedID field - public LLUUID ClassifiedID; - - /// Length of this block serialized in bytes + { + /// ClassifiedID field + public LLUUID ClassifiedID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { + { try - { - ClassifiedID = new LLUUID(bytes, i); i += 16; + { + ClassifiedID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ClassifiedID == null) { Console.WriteLine("Warning: ClassifiedID is null, in " + this.GetType()); } - Array.Copy(ClassifiedID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(ClassifiedID == null) { Console.WriteLine("Warning: ClassifiedID is null, in " + this.GetType()); } + Array.Copy(ClassifiedID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "ClassifiedID: " + ClassifiedID.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += "ClassifiedID: " + ClassifiedID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ClassifiedDelete - public override PacketType Type { get { return PacketType.ClassifiedDelete; } } - /// Data block - public DataBlock Data; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ClassifiedDelete + public override PacketType Type { get { return PacketType.ClassifiedDelete; } } + /// Data block + public DataBlock Data; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ClassifiedDeletePacket() - { - Header = new LowHeader(); - Header.ID = 62; - Header.Reliable = true; - Data = new DataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 62; + Header.Reliable = true; + Data = new DataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ClassifiedDeletePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ClassifiedDeletePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Data.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Data.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Data.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Data.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ClassifiedDelete ---\n"; - output += Data.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- ClassifiedDelete ---\n"; + output += Data.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ClassifiedGodDelete packet + + /// ClassifiedGodDelete packet public class ClassifiedGodDeletePacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - /// ClassifiedID field - public LLUUID ClassifiedID; - /// QueryID field - public LLUUID QueryID; - - /// Length of this block serialized in bytes + { + /// ClassifiedID field + public LLUUID ClassifiedID; + /// QueryID field + public LLUUID QueryID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { + { try - { - ClassifiedID = new LLUUID(bytes, i); i += 16; - QueryID = new LLUUID(bytes, i); i += 16; + { + ClassifiedID = new LLUUID(bytes, i); i += 16; + QueryID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ClassifiedID == null) { Console.WriteLine("Warning: ClassifiedID is null, in " + this.GetType()); } - Array.Copy(ClassifiedID.GetBytes(), 0, bytes, i, 16); i += 16; - if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } - Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(ClassifiedID == null) { Console.WriteLine("Warning: ClassifiedID is null, in " + this.GetType()); } + Array.Copy(ClassifiedID.GetBytes(), 0, bytes, i, 16); i += 16; + if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } + Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "ClassifiedID: " + ClassifiedID.ToString() + "\n"; - output += "QueryID: " + QueryID.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += "ClassifiedID: " + ClassifiedID.ToString() + "\n"; + output += "QueryID: " + QueryID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ClassifiedGodDelete - public override PacketType Type { get { return PacketType.ClassifiedGodDelete; } } - /// Data block - public DataBlock Data; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ClassifiedGodDelete + public override PacketType Type { get { return PacketType.ClassifiedGodDelete; } } + /// Data block + public DataBlock Data; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ClassifiedGodDeletePacket() - { - Header = new LowHeader(); - Header.ID = 63; - Header.Reliable = true; - Data = new DataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 63; + Header.Reliable = true; + Data = new DataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ClassifiedGodDeletePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ClassifiedGodDeletePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Data.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Data.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Data.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Data.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ClassifiedGodDelete ---\n"; - output += Data.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- ClassifiedGodDelete ---\n"; + output += Data.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// DirPicksQuery packet + + /// DirPicksQuery packet public class DirPicksQueryPacket : Packet - { - /// QueryData block + { + /// QueryData block public class QueryDataBlock - { - /// QueryID field - public LLUUID QueryID; - /// QueryFlags field - public uint QueryFlags; - - /// Length of this block serialized in bytes + { + /// QueryID field + public LLUUID QueryID; + /// QueryFlags field + public uint QueryFlags; + + /// Length of this block serialized in bytes public int Length { get - { - return 20; + { + return 20; } } - - /// Default constructor - public QueryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public QueryDataBlock() { } + /// Constructor for building the block from a byte array public QueryDataBlock(byte[] bytes, ref int i) - { + { try - { - QueryID = new LLUUID(bytes, i); i += 16; - QueryFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + QueryID = new LLUUID(bytes, i); i += 16; + QueryFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } - Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(QueryFlags % 256); - bytes[i++] = (byte)((QueryFlags >> 8) % 256); - bytes[i++] = (byte)((QueryFlags >> 16) % 256); - bytes[i++] = (byte)((QueryFlags >> 24) % 256); + { + if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } + Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(QueryFlags % 256); + bytes[i++] = (byte)((QueryFlags >> 8) % 256); + bytes[i++] = (byte)((QueryFlags >> 16) % 256); + bytes[i++] = (byte)((QueryFlags >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- QueryData --\n"; - output += "QueryID: " + QueryID.ToString() + "\n"; - output += "QueryFlags: " + QueryFlags.ToString() + "\n"; + { + string output = "-- QueryData --\n"; + output += "QueryID: " + QueryID.ToString() + "\n"; + output += "QueryFlags: " + QueryFlags.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.DirPicksQuery - public override PacketType Type { get { return PacketType.DirPicksQuery; } } - /// QueryData block - public QueryDataBlock QueryData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.DirPicksQuery + public override PacketType Type { get { return PacketType.DirPicksQuery; } } + /// QueryData block + public QueryDataBlock QueryData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public DirPicksQueryPacket() - { - Header = new LowHeader(); - Header.ID = 64; - Header.Reliable = true; - Header.Zerocoded = true; - QueryData = new QueryDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 64; + Header.Reliable = true; + Header.Zerocoded = true; + QueryData = new QueryDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public DirPicksQueryPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - QueryData = new QueryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + QueryData = new QueryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public DirPicksQueryPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - QueryData = new QueryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + QueryData = new QueryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += QueryData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - QueryData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += QueryData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + QueryData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- DirPicksQuery ---\n"; - output += QueryData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- DirPicksQuery ---\n"; + output += QueryData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// DirPicksQueryBackend packet + + /// DirPicksQueryBackend packet public class DirPicksQueryBackendPacket : Packet - { - /// QueryData block + { + /// QueryData block public class QueryDataBlock - { - /// Godlike field - public bool Godlike; - /// QueryID field - public LLUUID QueryID; - /// QueryFlags field - public uint QueryFlags; - /// EstateID field - public uint EstateID; - - /// Length of this block serialized in bytes + { + /// Godlike field + public bool Godlike; + /// QueryID field + public LLUUID QueryID; + /// QueryFlags field + public uint QueryFlags; + /// EstateID field + public uint EstateID; + + /// Length of this block serialized in bytes public int Length { get - { - return 25; + { + return 25; } } - - /// Default constructor - public QueryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public QueryDataBlock() { } + /// Constructor for building the block from a byte array public QueryDataBlock(byte[] bytes, ref int i) - { + { try - { - Godlike = (bytes[i++] != 0) ? (bool)true : (bool)false; - QueryID = new LLUUID(bytes, i); i += 16; - QueryFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - EstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + Godlike = (bytes[i++] != 0) ? (bool)true : (bool)false; + QueryID = new LLUUID(bytes, i); i += 16; + QueryFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + EstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)((Godlike) ? 1 : 0); - if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } - Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(QueryFlags % 256); - bytes[i++] = (byte)((QueryFlags >> 8) % 256); - bytes[i++] = (byte)((QueryFlags >> 16) % 256); - bytes[i++] = (byte)((QueryFlags >> 24) % 256); - bytes[i++] = (byte)(EstateID % 256); - bytes[i++] = (byte)((EstateID >> 8) % 256); - bytes[i++] = (byte)((EstateID >> 16) % 256); - bytes[i++] = (byte)((EstateID >> 24) % 256); + { + bytes[i++] = (byte)((Godlike) ? 1 : 0); + if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } + Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(QueryFlags % 256); + bytes[i++] = (byte)((QueryFlags >> 8) % 256); + bytes[i++] = (byte)((QueryFlags >> 16) % 256); + bytes[i++] = (byte)((QueryFlags >> 24) % 256); + bytes[i++] = (byte)(EstateID % 256); + bytes[i++] = (byte)((EstateID >> 8) % 256); + bytes[i++] = (byte)((EstateID >> 16) % 256); + bytes[i++] = (byte)((EstateID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- QueryData --\n"; - output += "Godlike: " + Godlike.ToString() + "\n"; - output += "QueryID: " + QueryID.ToString() + "\n"; - output += "QueryFlags: " + QueryFlags.ToString() + "\n"; - output += "EstateID: " + EstateID.ToString() + "\n"; + { + string output = "-- QueryData --\n"; + output += "Godlike: " + Godlike.ToString() + "\n"; + output += "QueryID: " + QueryID.ToString() + "\n"; + output += "QueryFlags: " + QueryFlags.ToString() + "\n"; + output += "EstateID: " + EstateID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.DirPicksQueryBackend - public override PacketType Type { get { return PacketType.DirPicksQueryBackend; } } - /// QueryData block - public QueryDataBlock QueryData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.DirPicksQueryBackend + public override PacketType Type { get { return PacketType.DirPicksQueryBackend; } } + /// QueryData block + public QueryDataBlock QueryData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public DirPicksQueryBackendPacket() - { - Header = new LowHeader(); - Header.ID = 65; - Header.Reliable = true; - Header.Zerocoded = true; - QueryData = new QueryDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 65; + Header.Reliable = true; + Header.Zerocoded = true; + QueryData = new QueryDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public DirPicksQueryBackendPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - QueryData = new QueryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + QueryData = new QueryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public DirPicksQueryBackendPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - QueryData = new QueryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + QueryData = new QueryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += QueryData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - QueryData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += QueryData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + QueryData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- DirPicksQueryBackend ---\n"; - output += QueryData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- DirPicksQueryBackend ---\n"; + output += QueryData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// DirPicksReply packet + + /// DirPicksReply packet public class DirPicksReplyPacket : Packet - { - /// QueryReplies block + { + /// QueryReplies block public class QueryRepliesBlock - { - /// Enabled field - public bool Enabled; - private byte[] _name; - /// Name field + { + /// Enabled field + public bool Enabled; + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - /// PickID field - public LLUUID PickID; - - /// Length of this block serialized in bytes + } + /// PickID field + public LLUUID PickID; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 17; - if (Name != null) { length += 1 + Name.Length; } - return length; + { + int length = 17; + if (Name != null) { length += 1 + Name.Length; } + return length; } } - - /// Default constructor - public QueryRepliesBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public QueryRepliesBlock() { } + /// Constructor for building the block from a byte array public QueryRepliesBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - Enabled = (bytes[i++] != 0) ? (bool)true : (bool)false; - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; - PickID = new LLUUID(bytes, i); i += 16; + { + Enabled = (bytes[i++] != 0) ? (bool)true : (bool)false; + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; + PickID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)((Enabled) ? 1 : 0); - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; - if(PickID == null) { Console.WriteLine("Warning: PickID is null, in " + this.GetType()); } - Array.Copy(PickID.GetBytes(), 0, bytes, i, 16); i += 16; + { + bytes[i++] = (byte)((Enabled) ? 1 : 0); + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + if(PickID == null) { Console.WriteLine("Warning: PickID is null, in " + this.GetType()); } + Array.Copy(PickID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- QueryReplies --\n"; - output += "Enabled: " + Enabled.ToString() + "\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; - output += "PickID: " + PickID.ToString() + "\n"; + { + string output = "-- QueryReplies --\n"; + output += "Enabled: " + Enabled.ToString() + "\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; + output += "PickID: " + PickID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// QueryData block + + /// QueryData block public class QueryDataBlock - { - /// QueryID field - public LLUUID QueryID; - - /// Length of this block serialized in bytes + { + /// QueryID field + public LLUUID QueryID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public QueryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public QueryDataBlock() { } + /// Constructor for building the block from a byte array public QueryDataBlock(byte[] bytes, ref int i) - { + { try - { - QueryID = new LLUUID(bytes, i); i += 16; + { + QueryID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } - Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } + Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- QueryData --\n"; - output += "QueryID: " + QueryID.ToString() + "\n"; + { + string output = "-- QueryData --\n"; + output += "QueryID: " + QueryID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.DirPicksReply - public override PacketType Type { get { return PacketType.DirPicksReply; } } - /// QueryReplies block - public QueryRepliesBlock[] QueryReplies; - /// QueryData block - public QueryDataBlock QueryData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.DirPicksReply + public override PacketType Type { get { return PacketType.DirPicksReply; } } + /// QueryReplies block + public QueryRepliesBlock[] QueryReplies; + /// QueryData block + public QueryDataBlock QueryData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public DirPicksReplyPacket() - { - Header = new LowHeader(); - Header.ID = 66; - Header.Reliable = true; - Header.Zerocoded = true; - QueryReplies = new QueryRepliesBlock[0]; - QueryData = new QueryDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 66; + Header.Reliable = true; + Header.Zerocoded = true; + QueryReplies = new QueryRepliesBlock[0]; + QueryData = new QueryDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public DirPicksReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - QueryReplies = new QueryRepliesBlock[count]; - for (int j = 0; j < count; j++) - { QueryReplies[j] = new QueryRepliesBlock(bytes, ref i); } - QueryData = new QueryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + QueryReplies = new QueryRepliesBlock[count]; + for (int j = 0; j < count; j++) + { QueryReplies[j] = new QueryRepliesBlock(bytes, ref i); } + QueryData = new QueryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public DirPicksReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - QueryReplies = new QueryRepliesBlock[count]; - for (int j = 0; j < count; j++) - { QueryReplies[j] = new QueryRepliesBlock(bytes, ref i); } - QueryData = new QueryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + QueryReplies = new QueryRepliesBlock[count]; + for (int j = 0; j < count; j++) + { QueryReplies[j] = new QueryRepliesBlock(bytes, ref i); } + QueryData = new QueryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += QueryData.Length; length += AgentData.Length;; - length++; - for (int j = 0; j < QueryReplies.Length; j++) { length += QueryReplies[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)QueryReplies.Length; - for (int j = 0; j < QueryReplies.Length; j++) { QueryReplies[j].ToBytes(bytes, ref i); } - QueryData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += QueryData.Length; length += AgentData.Length;; + length++; + for (int j = 0; j < QueryReplies.Length; j++) { length += QueryReplies[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)QueryReplies.Length; + for (int j = 0; j < QueryReplies.Length; j++) { QueryReplies[j].ToBytes(bytes, ref i); } + QueryData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- DirPicksReply ---\n"; + { + string output = "--- DirPicksReply ---\n"; for (int j = 0; j < QueryReplies.Length; j++) - { + { output += QueryReplies[j].ToString() + "\n"; - } - output += QueryData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + } + output += QueryData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// DirLandQuery packet + + /// DirLandQuery packet public class DirLandQueryPacket : Packet - { - /// QueryData block + { + /// QueryData block public class QueryDataBlock - { - /// ReservedNewbie field - public bool ReservedNewbie; - /// ForSale field - public bool ForSale; - /// QueryID field - public LLUUID QueryID; - /// Auction field - public bool Auction; - /// QueryFlags field - public uint QueryFlags; - - /// Length of this block serialized in bytes + { + /// ReservedNewbie field + public bool ReservedNewbie; + /// ForSale field + public bool ForSale; + /// QueryID field + public LLUUID QueryID; + /// Auction field + public bool Auction; + /// QueryFlags field + public uint QueryFlags; + + /// Length of this block serialized in bytes public int Length { get - { - return 23; + { + return 23; } } - - /// Default constructor - public QueryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public QueryDataBlock() { } + /// Constructor for building the block from a byte array public QueryDataBlock(byte[] bytes, ref int i) - { + { try - { - ReservedNewbie = (bytes[i++] != 0) ? (bool)true : (bool)false; - ForSale = (bytes[i++] != 0) ? (bool)true : (bool)false; - QueryID = new LLUUID(bytes, i); i += 16; - Auction = (bytes[i++] != 0) ? (bool)true : (bool)false; - QueryFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + ReservedNewbie = (bytes[i++] != 0) ? (bool)true : (bool)false; + ForSale = (bytes[i++] != 0) ? (bool)true : (bool)false; + QueryID = new LLUUID(bytes, i); i += 16; + Auction = (bytes[i++] != 0) ? (bool)true : (bool)false; + QueryFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)((ReservedNewbie) ? 1 : 0); - bytes[i++] = (byte)((ForSale) ? 1 : 0); - if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } - Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((Auction) ? 1 : 0); - bytes[i++] = (byte)(QueryFlags % 256); - bytes[i++] = (byte)((QueryFlags >> 8) % 256); - bytes[i++] = (byte)((QueryFlags >> 16) % 256); - bytes[i++] = (byte)((QueryFlags >> 24) % 256); + { + bytes[i++] = (byte)((ReservedNewbie) ? 1 : 0); + bytes[i++] = (byte)((ForSale) ? 1 : 0); + if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } + Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((Auction) ? 1 : 0); + bytes[i++] = (byte)(QueryFlags % 256); + bytes[i++] = (byte)((QueryFlags >> 8) % 256); + bytes[i++] = (byte)((QueryFlags >> 16) % 256); + bytes[i++] = (byte)((QueryFlags >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- QueryData --\n"; - output += "ReservedNewbie: " + ReservedNewbie.ToString() + "\n"; - output += "ForSale: " + ForSale.ToString() + "\n"; - output += "QueryID: " + QueryID.ToString() + "\n"; - output += "Auction: " + Auction.ToString() + "\n"; - output += "QueryFlags: " + QueryFlags.ToString() + "\n"; + { + string output = "-- QueryData --\n"; + output += "ReservedNewbie: " + ReservedNewbie.ToString() + "\n"; + output += "ForSale: " + ForSale.ToString() + "\n"; + output += "QueryID: " + QueryID.ToString() + "\n"; + output += "Auction: " + Auction.ToString() + "\n"; + output += "QueryFlags: " + QueryFlags.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.DirLandQuery - public override PacketType Type { get { return PacketType.DirLandQuery; } } - /// QueryData block - public QueryDataBlock QueryData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.DirLandQuery + public override PacketType Type { get { return PacketType.DirLandQuery; } } + /// QueryData block + public QueryDataBlock QueryData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public DirLandQueryPacket() - { - Header = new LowHeader(); - Header.ID = 67; - Header.Reliable = true; - Header.Zerocoded = true; - QueryData = new QueryDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 67; + Header.Reliable = true; + Header.Zerocoded = true; + QueryData = new QueryDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public DirLandQueryPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - QueryData = new QueryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + QueryData = new QueryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public DirLandQueryPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - QueryData = new QueryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + QueryData = new QueryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += QueryData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - QueryData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += QueryData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + QueryData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- DirLandQuery ---\n"; - output += QueryData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- DirLandQuery ---\n"; + output += QueryData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// DirLandQueryBackend packet + + /// DirLandQueryBackend packet public class DirLandQueryBackendPacket : Packet - { - /// QueryData block + { + /// QueryData block public class QueryDataBlock - { - /// ReservedNewbie field - public bool ReservedNewbie; - /// ForSale field - public bool ForSale; - /// Godlike field - public bool Godlike; - /// QueryID field - public LLUUID QueryID; - /// Auction field - public bool Auction; - /// QueryFlags field - public uint QueryFlags; - /// EstateID field - public uint EstateID; - - /// Length of this block serialized in bytes + { + /// ReservedNewbie field + public bool ReservedNewbie; + /// ForSale field + public bool ForSale; + /// Godlike field + public bool Godlike; + /// QueryID field + public LLUUID QueryID; + /// Auction field + public bool Auction; + /// QueryFlags field + public uint QueryFlags; + /// EstateID field + public uint EstateID; + + /// Length of this block serialized in bytes public int Length { get - { - return 28; + { + return 28; } } - - /// Default constructor - public QueryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public QueryDataBlock() { } + /// Constructor for building the block from a byte array public QueryDataBlock(byte[] bytes, ref int i) - { + { try - { - ReservedNewbie = (bytes[i++] != 0) ? (bool)true : (bool)false; - ForSale = (bytes[i++] != 0) ? (bool)true : (bool)false; - Godlike = (bytes[i++] != 0) ? (bool)true : (bool)false; - QueryID = new LLUUID(bytes, i); i += 16; - Auction = (bytes[i++] != 0) ? (bool)true : (bool)false; - QueryFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - EstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + ReservedNewbie = (bytes[i++] != 0) ? (bool)true : (bool)false; + ForSale = (bytes[i++] != 0) ? (bool)true : (bool)false; + Godlike = (bytes[i++] != 0) ? (bool)true : (bool)false; + QueryID = new LLUUID(bytes, i); i += 16; + Auction = (bytes[i++] != 0) ? (bool)true : (bool)false; + QueryFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + EstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)((ReservedNewbie) ? 1 : 0); - bytes[i++] = (byte)((ForSale) ? 1 : 0); - bytes[i++] = (byte)((Godlike) ? 1 : 0); - if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } - Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((Auction) ? 1 : 0); - bytes[i++] = (byte)(QueryFlags % 256); - bytes[i++] = (byte)((QueryFlags >> 8) % 256); - bytes[i++] = (byte)((QueryFlags >> 16) % 256); - bytes[i++] = (byte)((QueryFlags >> 24) % 256); - bytes[i++] = (byte)(EstateID % 256); - bytes[i++] = (byte)((EstateID >> 8) % 256); - bytes[i++] = (byte)((EstateID >> 16) % 256); - bytes[i++] = (byte)((EstateID >> 24) % 256); + { + bytes[i++] = (byte)((ReservedNewbie) ? 1 : 0); + bytes[i++] = (byte)((ForSale) ? 1 : 0); + bytes[i++] = (byte)((Godlike) ? 1 : 0); + if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } + Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((Auction) ? 1 : 0); + bytes[i++] = (byte)(QueryFlags % 256); + bytes[i++] = (byte)((QueryFlags >> 8) % 256); + bytes[i++] = (byte)((QueryFlags >> 16) % 256); + bytes[i++] = (byte)((QueryFlags >> 24) % 256); + bytes[i++] = (byte)(EstateID % 256); + bytes[i++] = (byte)((EstateID >> 8) % 256); + bytes[i++] = (byte)((EstateID >> 16) % 256); + bytes[i++] = (byte)((EstateID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- QueryData --\n"; - output += "ReservedNewbie: " + ReservedNewbie.ToString() + "\n"; - output += "ForSale: " + ForSale.ToString() + "\n"; - output += "Godlike: " + Godlike.ToString() + "\n"; - output += "QueryID: " + QueryID.ToString() + "\n"; - output += "Auction: " + Auction.ToString() + "\n"; - output += "QueryFlags: " + QueryFlags.ToString() + "\n"; - output += "EstateID: " + EstateID.ToString() + "\n"; + { + string output = "-- QueryData --\n"; + output += "ReservedNewbie: " + ReservedNewbie.ToString() + "\n"; + output += "ForSale: " + ForSale.ToString() + "\n"; + output += "Godlike: " + Godlike.ToString() + "\n"; + output += "QueryID: " + QueryID.ToString() + "\n"; + output += "Auction: " + Auction.ToString() + "\n"; + output += "QueryFlags: " + QueryFlags.ToString() + "\n"; + output += "EstateID: " + EstateID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.DirLandQueryBackend - public override PacketType Type { get { return PacketType.DirLandQueryBackend; } } - /// QueryData block - public QueryDataBlock QueryData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.DirLandQueryBackend + public override PacketType Type { get { return PacketType.DirLandQueryBackend; } } + /// QueryData block + public QueryDataBlock QueryData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public DirLandQueryBackendPacket() - { - Header = new LowHeader(); - Header.ID = 68; - Header.Reliable = true; - Header.Zerocoded = true; - QueryData = new QueryDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 68; + Header.Reliable = true; + Header.Zerocoded = true; + QueryData = new QueryDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public DirLandQueryBackendPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - QueryData = new QueryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + QueryData = new QueryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public DirLandQueryBackendPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - QueryData = new QueryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + QueryData = new QueryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += QueryData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - QueryData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += QueryData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + QueryData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- DirLandQueryBackend ---\n"; - output += QueryData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- DirLandQueryBackend ---\n"; + output += QueryData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// DirLandReply packet + + /// DirLandReply packet public class DirLandReplyPacket : Packet - { - /// QueryReplies block + { + /// QueryReplies block public class QueryRepliesBlock - { - /// ReservedNewbie field - public bool ReservedNewbie; - /// ActualArea field - public int ActualArea; - /// ForSale field - public bool ForSale; - /// ParcelID field - public LLUUID ParcelID; - private byte[] _name; - /// Name field + { + /// ReservedNewbie field + public bool ReservedNewbie; + /// ActualArea field + public int ActualArea; + /// ForSale field + public bool ForSale; + /// ParcelID field + public LLUUID ParcelID; + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - /// Auction field - public bool Auction; - /// SalePrice field - public int SalePrice; - - /// Length of this block serialized in bytes + } + /// Auction field + public bool Auction; + /// SalePrice field + public int SalePrice; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 27; - if (Name != null) { length += 1 + Name.Length; } - return length; + { + int length = 27; + if (Name != null) { length += 1 + Name.Length; } + return length; } } - - /// Default constructor - public QueryRepliesBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public QueryRepliesBlock() { } + /// Constructor for building the block from a byte array public QueryRepliesBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - ReservedNewbie = (bytes[i++] != 0) ? (bool)true : (bool)false; - ActualArea = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - ForSale = (bytes[i++] != 0) ? (bool)true : (bool)false; - ParcelID = new LLUUID(bytes, i); i += 16; - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; - Auction = (bytes[i++] != 0) ? (bool)true : (bool)false; - SalePrice = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + ReservedNewbie = (bytes[i++] != 0) ? (bool)true : (bool)false; + ActualArea = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + ForSale = (bytes[i++] != 0) ? (bool)true : (bool)false; + ParcelID = new LLUUID(bytes, i); i += 16; + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; + Auction = (bytes[i++] != 0) ? (bool)true : (bool)false; + SalePrice = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)((ReservedNewbie) ? 1 : 0); - bytes[i++] = (byte)(ActualArea % 256); - bytes[i++] = (byte)((ActualArea >> 8) % 256); - bytes[i++] = (byte)((ActualArea >> 16) % 256); - bytes[i++] = (byte)((ActualArea >> 24) % 256); - bytes[i++] = (byte)((ForSale) ? 1 : 0); - if(ParcelID == null) { Console.WriteLine("Warning: ParcelID is null, in " + this.GetType()); } - Array.Copy(ParcelID.GetBytes(), 0, bytes, i, 16); i += 16; - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; - bytes[i++] = (byte)((Auction) ? 1 : 0); - bytes[i++] = (byte)(SalePrice % 256); - bytes[i++] = (byte)((SalePrice >> 8) % 256); - bytes[i++] = (byte)((SalePrice >> 16) % 256); - bytes[i++] = (byte)((SalePrice >> 24) % 256); + { + bytes[i++] = (byte)((ReservedNewbie) ? 1 : 0); + bytes[i++] = (byte)(ActualArea % 256); + bytes[i++] = (byte)((ActualArea >> 8) % 256); + bytes[i++] = (byte)((ActualArea >> 16) % 256); + bytes[i++] = (byte)((ActualArea >> 24) % 256); + bytes[i++] = (byte)((ForSale) ? 1 : 0); + if(ParcelID == null) { Console.WriteLine("Warning: ParcelID is null, in " + this.GetType()); } + Array.Copy(ParcelID.GetBytes(), 0, bytes, i, 16); i += 16; + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + bytes[i++] = (byte)((Auction) ? 1 : 0); + bytes[i++] = (byte)(SalePrice % 256); + bytes[i++] = (byte)((SalePrice >> 8) % 256); + bytes[i++] = (byte)((SalePrice >> 16) % 256); + bytes[i++] = (byte)((SalePrice >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- QueryReplies --\n"; - output += "ReservedNewbie: " + ReservedNewbie.ToString() + "\n"; - output += "ActualArea: " + ActualArea.ToString() + "\n"; - output += "ForSale: " + ForSale.ToString() + "\n"; - output += "ParcelID: " + ParcelID.ToString() + "\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; - output += "Auction: " + Auction.ToString() + "\n"; - output += "SalePrice: " + SalePrice.ToString() + "\n"; + { + string output = "-- QueryReplies --\n"; + output += "ReservedNewbie: " + ReservedNewbie.ToString() + "\n"; + output += "ActualArea: " + ActualArea.ToString() + "\n"; + output += "ForSale: " + ForSale.ToString() + "\n"; + output += "ParcelID: " + ParcelID.ToString() + "\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; + output += "Auction: " + Auction.ToString() + "\n"; + output += "SalePrice: " + SalePrice.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// QueryData block + + /// QueryData block public class QueryDataBlock - { - /// QueryID field - public LLUUID QueryID; - - /// Length of this block serialized in bytes + { + /// QueryID field + public LLUUID QueryID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public QueryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public QueryDataBlock() { } + /// Constructor for building the block from a byte array public QueryDataBlock(byte[] bytes, ref int i) - { + { try - { - QueryID = new LLUUID(bytes, i); i += 16; + { + QueryID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } - Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } + Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- QueryData --\n"; - output += "QueryID: " + QueryID.ToString() + "\n"; + { + string output = "-- QueryData --\n"; + output += "QueryID: " + QueryID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.DirLandReply - public override PacketType Type { get { return PacketType.DirLandReply; } } - /// QueryReplies block - public QueryRepliesBlock[] QueryReplies; - /// QueryData block - public QueryDataBlock QueryData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.DirLandReply + public override PacketType Type { get { return PacketType.DirLandReply; } } + /// QueryReplies block + public QueryRepliesBlock[] QueryReplies; + /// QueryData block + public QueryDataBlock QueryData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public DirLandReplyPacket() - { - Header = new LowHeader(); - Header.ID = 69; - Header.Reliable = true; - Header.Zerocoded = true; - QueryReplies = new QueryRepliesBlock[0]; - QueryData = new QueryDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 69; + Header.Reliable = true; + Header.Zerocoded = true; + QueryReplies = new QueryRepliesBlock[0]; + QueryData = new QueryDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public DirLandReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - QueryReplies = new QueryRepliesBlock[count]; - for (int j = 0; j < count; j++) - { QueryReplies[j] = new QueryRepliesBlock(bytes, ref i); } - QueryData = new QueryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + QueryReplies = new QueryRepliesBlock[count]; + for (int j = 0; j < count; j++) + { QueryReplies[j] = new QueryRepliesBlock(bytes, ref i); } + QueryData = new QueryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public DirLandReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - QueryReplies = new QueryRepliesBlock[count]; - for (int j = 0; j < count; j++) - { QueryReplies[j] = new QueryRepliesBlock(bytes, ref i); } - QueryData = new QueryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + QueryReplies = new QueryRepliesBlock[count]; + for (int j = 0; j < count; j++) + { QueryReplies[j] = new QueryRepliesBlock(bytes, ref i); } + QueryData = new QueryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += QueryData.Length; length += AgentData.Length;; - length++; - for (int j = 0; j < QueryReplies.Length; j++) { length += QueryReplies[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)QueryReplies.Length; - for (int j = 0; j < QueryReplies.Length; j++) { QueryReplies[j].ToBytes(bytes, ref i); } - QueryData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += QueryData.Length; length += AgentData.Length;; + length++; + for (int j = 0; j < QueryReplies.Length; j++) { length += QueryReplies[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)QueryReplies.Length; + for (int j = 0; j < QueryReplies.Length; j++) { QueryReplies[j].ToBytes(bytes, ref i); } + QueryData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- DirLandReply ---\n"; + { + string output = "--- DirLandReply ---\n"; for (int j = 0; j < QueryReplies.Length; j++) - { + { output += QueryReplies[j].ToString() + "\n"; - } - output += QueryData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + } + output += QueryData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// DirPopularQuery packet + + /// DirPopularQuery packet public class DirPopularQueryPacket : Packet - { - /// QueryData block + { + /// QueryData block public class QueryDataBlock - { - /// QueryID field - public LLUUID QueryID; - /// QueryFlags field - public uint QueryFlags; - - /// Length of this block serialized in bytes + { + /// QueryID field + public LLUUID QueryID; + /// QueryFlags field + public uint QueryFlags; + + /// Length of this block serialized in bytes public int Length { get - { - return 20; + { + return 20; } } - - /// Default constructor - public QueryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public QueryDataBlock() { } + /// Constructor for building the block from a byte array public QueryDataBlock(byte[] bytes, ref int i) - { + { try - { - QueryID = new LLUUID(bytes, i); i += 16; - QueryFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + QueryID = new LLUUID(bytes, i); i += 16; + QueryFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } - Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(QueryFlags % 256); - bytes[i++] = (byte)((QueryFlags >> 8) % 256); - bytes[i++] = (byte)((QueryFlags >> 16) % 256); - bytes[i++] = (byte)((QueryFlags >> 24) % 256); + { + if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } + Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(QueryFlags % 256); + bytes[i++] = (byte)((QueryFlags >> 8) % 256); + bytes[i++] = (byte)((QueryFlags >> 16) % 256); + bytes[i++] = (byte)((QueryFlags >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- QueryData --\n"; - output += "QueryID: " + QueryID.ToString() + "\n"; - output += "QueryFlags: " + QueryFlags.ToString() + "\n"; + { + string output = "-- QueryData --\n"; + output += "QueryID: " + QueryID.ToString() + "\n"; + output += "QueryFlags: " + QueryFlags.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.DirPopularQuery - public override PacketType Type { get { return PacketType.DirPopularQuery; } } - /// QueryData block - public QueryDataBlock QueryData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.DirPopularQuery + public override PacketType Type { get { return PacketType.DirPopularQuery; } } + /// QueryData block + public QueryDataBlock QueryData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public DirPopularQueryPacket() - { - Header = new LowHeader(); - Header.ID = 70; - Header.Reliable = true; - Header.Zerocoded = true; - QueryData = new QueryDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 70; + Header.Reliable = true; + Header.Zerocoded = true; + QueryData = new QueryDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public DirPopularQueryPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - QueryData = new QueryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + QueryData = new QueryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public DirPopularQueryPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - QueryData = new QueryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + QueryData = new QueryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += QueryData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - QueryData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += QueryData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + QueryData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- DirPopularQuery ---\n"; - output += QueryData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- DirPopularQuery ---\n"; + output += QueryData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// DirPopularQueryBackend packet + + /// DirPopularQueryBackend packet public class DirPopularQueryBackendPacket : Packet - { - /// QueryData block + { + /// QueryData block public class QueryDataBlock - { - /// Godlike field - public bool Godlike; - /// QueryID field - public LLUUID QueryID; - /// QueryFlags field - public uint QueryFlags; - /// EstateID field - public uint EstateID; - - /// Length of this block serialized in bytes + { + /// Godlike field + public bool Godlike; + /// QueryID field + public LLUUID QueryID; + /// QueryFlags field + public uint QueryFlags; + /// EstateID field + public uint EstateID; + + /// Length of this block serialized in bytes public int Length { get - { - return 25; + { + return 25; } } - - /// Default constructor - public QueryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public QueryDataBlock() { } + /// Constructor for building the block from a byte array public QueryDataBlock(byte[] bytes, ref int i) - { + { try - { - Godlike = (bytes[i++] != 0) ? (bool)true : (bool)false; - QueryID = new LLUUID(bytes, i); i += 16; - QueryFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - EstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + Godlike = (bytes[i++] != 0) ? (bool)true : (bool)false; + QueryID = new LLUUID(bytes, i); i += 16; + QueryFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + EstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)((Godlike) ? 1 : 0); - if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } - Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(QueryFlags % 256); - bytes[i++] = (byte)((QueryFlags >> 8) % 256); - bytes[i++] = (byte)((QueryFlags >> 16) % 256); - bytes[i++] = (byte)((QueryFlags >> 24) % 256); - bytes[i++] = (byte)(EstateID % 256); - bytes[i++] = (byte)((EstateID >> 8) % 256); - bytes[i++] = (byte)((EstateID >> 16) % 256); - bytes[i++] = (byte)((EstateID >> 24) % 256); + { + bytes[i++] = (byte)((Godlike) ? 1 : 0); + if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } + Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(QueryFlags % 256); + bytes[i++] = (byte)((QueryFlags >> 8) % 256); + bytes[i++] = (byte)((QueryFlags >> 16) % 256); + bytes[i++] = (byte)((QueryFlags >> 24) % 256); + bytes[i++] = (byte)(EstateID % 256); + bytes[i++] = (byte)((EstateID >> 8) % 256); + bytes[i++] = (byte)((EstateID >> 16) % 256); + bytes[i++] = (byte)((EstateID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- QueryData --\n"; - output += "Godlike: " + Godlike.ToString() + "\n"; - output += "QueryID: " + QueryID.ToString() + "\n"; - output += "QueryFlags: " + QueryFlags.ToString() + "\n"; - output += "EstateID: " + EstateID.ToString() + "\n"; + { + string output = "-- QueryData --\n"; + output += "Godlike: " + Godlike.ToString() + "\n"; + output += "QueryID: " + QueryID.ToString() + "\n"; + output += "QueryFlags: " + QueryFlags.ToString() + "\n"; + output += "EstateID: " + EstateID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.DirPopularQueryBackend - public override PacketType Type { get { return PacketType.DirPopularQueryBackend; } } - /// QueryData block - public QueryDataBlock QueryData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.DirPopularQueryBackend + public override PacketType Type { get { return PacketType.DirPopularQueryBackend; } } + /// QueryData block + public QueryDataBlock QueryData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public DirPopularQueryBackendPacket() - { - Header = new LowHeader(); - Header.ID = 71; - Header.Reliable = true; - Header.Zerocoded = true; - QueryData = new QueryDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 71; + Header.Reliable = true; + Header.Zerocoded = true; + QueryData = new QueryDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public DirPopularQueryBackendPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - QueryData = new QueryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + QueryData = new QueryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public DirPopularQueryBackendPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - QueryData = new QueryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + QueryData = new QueryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += QueryData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - QueryData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += QueryData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + QueryData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- DirPopularQueryBackend ---\n"; - output += QueryData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- DirPopularQueryBackend ---\n"; + output += QueryData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// DirPopularReply packet + + /// DirPopularReply packet public class DirPopularReplyPacket : Packet - { - /// QueryReplies block + { + /// QueryReplies block public class QueryRepliesBlock - { - /// ParcelID field - public LLUUID ParcelID; - private byte[] _name; - /// Name field + { + /// ParcelID field + public LLUUID ParcelID; + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - /// Dwell field - public float Dwell; - - /// Length of this block serialized in bytes + } + /// Dwell field + public float Dwell; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 20; - if (Name != null) { length += 1 + Name.Length; } - return length; + { + int length = 20; + if (Name != null) { length += 1 + Name.Length; } + return length; } } - - /// Default constructor - public QueryRepliesBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public QueryRepliesBlock() { } + /// Constructor for building the block from a byte array public QueryRepliesBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - ParcelID = new LLUUID(bytes, i); i += 16; - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - Dwell = BitConverter.ToSingle(bytes, i); i += 4; + { + ParcelID = new LLUUID(bytes, i); i += 16; + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + Dwell = BitConverter.ToSingle(bytes, i); i += 4; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; - if(ParcelID == null) { Console.WriteLine("Warning: ParcelID is null, in " + this.GetType()); } - Array.Copy(ParcelID.GetBytes(), 0, bytes, i, 16); i += 16; - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + { + byte[] ba; + if(ParcelID == null) { Console.WriteLine("Warning: ParcelID is null, in " + this.GetType()); } + Array.Copy(ParcelID.GetBytes(), 0, bytes, i, 16); i += 16; + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; ba = BitConverter.GetBytes(Dwell); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- QueryReplies --\n"; - output += "ParcelID: " + ParcelID.ToString() + "\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; - output += "Dwell: " + Dwell.ToString() + "\n"; + { + string output = "-- QueryReplies --\n"; + output += "ParcelID: " + ParcelID.ToString() + "\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; + output += "Dwell: " + Dwell.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// QueryData block + + /// QueryData block public class QueryDataBlock - { - /// QueryID field - public LLUUID QueryID; - - /// Length of this block serialized in bytes + { + /// QueryID field + public LLUUID QueryID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public QueryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public QueryDataBlock() { } + /// Constructor for building the block from a byte array public QueryDataBlock(byte[] bytes, ref int i) - { + { try - { - QueryID = new LLUUID(bytes, i); i += 16; + { + QueryID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } - Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } + Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- QueryData --\n"; - output += "QueryID: " + QueryID.ToString() + "\n"; + { + string output = "-- QueryData --\n"; + output += "QueryID: " + QueryID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.DirPopularReply - public override PacketType Type { get { return PacketType.DirPopularReply; } } - /// QueryReplies block - public QueryRepliesBlock[] QueryReplies; - /// QueryData block - public QueryDataBlock QueryData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.DirPopularReply + public override PacketType Type { get { return PacketType.DirPopularReply; } } + /// QueryReplies block + public QueryRepliesBlock[] QueryReplies; + /// QueryData block + public QueryDataBlock QueryData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public DirPopularReplyPacket() - { - Header = new LowHeader(); - Header.ID = 72; - Header.Reliable = true; - Header.Zerocoded = true; - QueryReplies = new QueryRepliesBlock[0]; - QueryData = new QueryDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 72; + Header.Reliable = true; + Header.Zerocoded = true; + QueryReplies = new QueryRepliesBlock[0]; + QueryData = new QueryDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public DirPopularReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - QueryReplies = new QueryRepliesBlock[count]; - for (int j = 0; j < count; j++) - { QueryReplies[j] = new QueryRepliesBlock(bytes, ref i); } - QueryData = new QueryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + QueryReplies = new QueryRepliesBlock[count]; + for (int j = 0; j < count; j++) + { QueryReplies[j] = new QueryRepliesBlock(bytes, ref i); } + QueryData = new QueryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public DirPopularReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - QueryReplies = new QueryRepliesBlock[count]; - for (int j = 0; j < count; j++) - { QueryReplies[j] = new QueryRepliesBlock(bytes, ref i); } - QueryData = new QueryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + QueryReplies = new QueryRepliesBlock[count]; + for (int j = 0; j < count; j++) + { QueryReplies[j] = new QueryRepliesBlock(bytes, ref i); } + QueryData = new QueryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += QueryData.Length; length += AgentData.Length;; - length++; - for (int j = 0; j < QueryReplies.Length; j++) { length += QueryReplies[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)QueryReplies.Length; - for (int j = 0; j < QueryReplies.Length; j++) { QueryReplies[j].ToBytes(bytes, ref i); } - QueryData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += QueryData.Length; length += AgentData.Length;; + length++; + for (int j = 0; j < QueryReplies.Length; j++) { length += QueryReplies[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)QueryReplies.Length; + for (int j = 0; j < QueryReplies.Length; j++) { QueryReplies[j].ToBytes(bytes, ref i); } + QueryData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- DirPopularReply ---\n"; + { + string output = "--- DirPopularReply ---\n"; for (int j = 0; j < QueryReplies.Length; j++) - { + { output += QueryReplies[j].ToString() + "\n"; - } - output += QueryData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + } + output += QueryData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ParcelInfoRequest packet + + /// ParcelInfoRequest packet public class ParcelInfoRequestPacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - /// ParcelID field - public LLUUID ParcelID; - - /// Length of this block serialized in bytes + { + /// ParcelID field + public LLUUID ParcelID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { + { try - { - ParcelID = new LLUUID(bytes, i); i += 16; + { + ParcelID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ParcelID == null) { Console.WriteLine("Warning: ParcelID is null, in " + this.GetType()); } - Array.Copy(ParcelID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(ParcelID == null) { Console.WriteLine("Warning: ParcelID is null, in " + this.GetType()); } + Array.Copy(ParcelID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "ParcelID: " + ParcelID.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += "ParcelID: " + ParcelID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ParcelInfoRequest - public override PacketType Type { get { return PacketType.ParcelInfoRequest; } } - /// Data block - public DataBlock Data; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ParcelInfoRequest + public override PacketType Type { get { return PacketType.ParcelInfoRequest; } } + /// Data block + public DataBlock Data; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ParcelInfoRequestPacket() - { - Header = new LowHeader(); - Header.ID = 73; - Header.Reliable = true; - Data = new DataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 73; + Header.Reliable = true; + Data = new DataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ParcelInfoRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ParcelInfoRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Data.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Data.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Data.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Data.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ParcelInfoRequest ---\n"; - output += Data.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- ParcelInfoRequest ---\n"; + output += Data.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ParcelInfoReply packet + + /// ParcelInfoReply packet public class ParcelInfoReplyPacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - private byte[] _simname; - /// SimName field + { + private byte[] _simname; + /// SimName field public byte[] SimName - { - get { return _simname; } + { + get { return _simname; } set - { - if (value == null) { _simname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _simname = new byte[value.Length]; Array.Copy(value, _simname, value.Length); } + { + if (value == null) { _simname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _simname = new byte[value.Length]; Array.Copy(value, _simname, value.Length); } } - } - /// BillableArea field - public int BillableArea; - /// ActualArea field - public int ActualArea; - /// GlobalX field - public float GlobalX; - /// GlobalY field - public float GlobalY; - /// GlobalZ field - public float GlobalZ; - /// ParcelID field - public LLUUID ParcelID; - private byte[] _name; - /// Name field + } + /// BillableArea field + public int BillableArea; + /// ActualArea field + public int ActualArea; + /// GlobalX field + public float GlobalX; + /// GlobalY field + public float GlobalY; + /// GlobalZ field + public float GlobalZ; + /// ParcelID field + public LLUUID ParcelID; + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - private byte[] _desc; - /// Desc field + } + private byte[] _desc; + /// Desc field public byte[] Desc - { - get { return _desc; } + { + get { return _desc; } set - { - if (value == null) { _desc = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _desc = new byte[value.Length]; Array.Copy(value, _desc, value.Length); } + { + if (value == null) { _desc = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _desc = new byte[value.Length]; Array.Copy(value, _desc, value.Length); } } - } - /// SalePrice field - public int SalePrice; - /// OwnerID field - public LLUUID OwnerID; - /// SnapshotID field - public LLUUID SnapshotID; - /// Flags field - public byte Flags; - /// AuctionID field - public int AuctionID; - /// Dwell field - public float Dwell; - - /// Length of this block serialized in bytes + } + /// SalePrice field + public int SalePrice; + /// OwnerID field + public LLUUID OwnerID; + /// SnapshotID field + public LLUUID SnapshotID; + /// Flags field + public byte Flags; + /// AuctionID field + public int AuctionID; + /// Dwell field + public float Dwell; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 81; - if (SimName != null) { length += 1 + SimName.Length; } - if (Name != null) { length += 1 + Name.Length; } - if (Desc != null) { length += 1 + Desc.Length; } - return length; + { + int length = 81; + if (SimName != null) { length += 1 + SimName.Length; } + if (Name != null) { length += 1 + Name.Length; } + if (Desc != null) { length += 1 + Desc.Length; } + return length; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _simname = new byte[length]; - Array.Copy(bytes, i, _simname, 0, length); i += length; - BillableArea = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - ActualArea = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - GlobalX = BitConverter.ToSingle(bytes, i); i += 4; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - GlobalY = BitConverter.ToSingle(bytes, i); i += 4; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - GlobalZ = BitConverter.ToSingle(bytes, i); i += 4; - ParcelID = new LLUUID(bytes, i); i += 16; - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; - length = (ushort)bytes[i++]; - _desc = new byte[length]; - Array.Copy(bytes, i, _desc, 0, length); i += length; - SalePrice = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - OwnerID = new LLUUID(bytes, i); i += 16; - SnapshotID = new LLUUID(bytes, i); i += 16; - Flags = (byte)bytes[i++]; - AuctionID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - Dwell = BitConverter.ToSingle(bytes, i); i += 4; + { + length = (ushort)bytes[i++]; + _simname = new byte[length]; + Array.Copy(bytes, i, _simname, 0, length); i += length; + BillableArea = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + ActualArea = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + GlobalX = BitConverter.ToSingle(bytes, i); i += 4; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + GlobalY = BitConverter.ToSingle(bytes, i); i += 4; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + GlobalZ = BitConverter.ToSingle(bytes, i); i += 4; + ParcelID = new LLUUID(bytes, i); i += 16; + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; + length = (ushort)bytes[i++]; + _desc = new byte[length]; + Array.Copy(bytes, i, _desc, 0, length); i += length; + SalePrice = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + OwnerID = new LLUUID(bytes, i); i += 16; + SnapshotID = new LLUUID(bytes, i); i += 16; + Flags = (byte)bytes[i++]; + AuctionID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + Dwell = BitConverter.ToSingle(bytes, i); i += 4; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; - if(SimName == null) { Console.WriteLine("Warning: SimName is null, in " + this.GetType()); } - bytes[i++] = (byte)SimName.Length; - Array.Copy(SimName, 0, bytes, i, SimName.Length); i += SimName.Length; - bytes[i++] = (byte)(BillableArea % 256); - bytes[i++] = (byte)((BillableArea >> 8) % 256); - bytes[i++] = (byte)((BillableArea >> 16) % 256); - bytes[i++] = (byte)((BillableArea >> 24) % 256); - bytes[i++] = (byte)(ActualArea % 256); - bytes[i++] = (byte)((ActualArea >> 8) % 256); - bytes[i++] = (byte)((ActualArea >> 16) % 256); - bytes[i++] = (byte)((ActualArea >> 24) % 256); + { + byte[] ba; + if(SimName == null) { Console.WriteLine("Warning: SimName is null, in " + this.GetType()); } + bytes[i++] = (byte)SimName.Length; + Array.Copy(SimName, 0, bytes, i, SimName.Length); i += SimName.Length; + bytes[i++] = (byte)(BillableArea % 256); + bytes[i++] = (byte)((BillableArea >> 8) % 256); + bytes[i++] = (byte)((BillableArea >> 16) % 256); + bytes[i++] = (byte)((BillableArea >> 24) % 256); + bytes[i++] = (byte)(ActualArea % 256); + bytes[i++] = (byte)((ActualArea >> 8) % 256); + bytes[i++] = (byte)((ActualArea >> 16) % 256); + bytes[i++] = (byte)((ActualArea >> 24) % 256); ba = BitConverter.GetBytes(GlobalX); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; ba = BitConverter.GetBytes(GlobalY); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; ba = BitConverter.GetBytes(GlobalZ); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - if(ParcelID == null) { Console.WriteLine("Warning: ParcelID is null, in " + this.GetType()); } - Array.Copy(ParcelID.GetBytes(), 0, bytes, i, 16); i += 16; - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; - if(Desc == null) { Console.WriteLine("Warning: Desc is null, in " + this.GetType()); } - bytes[i++] = (byte)Desc.Length; - Array.Copy(Desc, 0, bytes, i, Desc.Length); i += Desc.Length; - bytes[i++] = (byte)(SalePrice % 256); - bytes[i++] = (byte)((SalePrice >> 8) % 256); - bytes[i++] = (byte)((SalePrice >> 16) % 256); - bytes[i++] = (byte)((SalePrice >> 24) % 256); - if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } - Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SnapshotID == null) { Console.WriteLine("Warning: SnapshotID is null, in " + this.GetType()); } - Array.Copy(SnapshotID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = Flags; - bytes[i++] = (byte)(AuctionID % 256); - bytes[i++] = (byte)((AuctionID >> 8) % 256); - bytes[i++] = (byte)((AuctionID >> 16) % 256); - bytes[i++] = (byte)((AuctionID >> 24) % 256); + Array.Copy(ba, 0, bytes, i, 4); i += 4; + if(ParcelID == null) { Console.WriteLine("Warning: ParcelID is null, in " + this.GetType()); } + Array.Copy(ParcelID.GetBytes(), 0, bytes, i, 16); i += 16; + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + if(Desc == null) { Console.WriteLine("Warning: Desc is null, in " + this.GetType()); } + bytes[i++] = (byte)Desc.Length; + Array.Copy(Desc, 0, bytes, i, Desc.Length); i += Desc.Length; + bytes[i++] = (byte)(SalePrice % 256); + bytes[i++] = (byte)((SalePrice >> 8) % 256); + bytes[i++] = (byte)((SalePrice >> 16) % 256); + bytes[i++] = (byte)((SalePrice >> 24) % 256); + if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } + Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SnapshotID == null) { Console.WriteLine("Warning: SnapshotID is null, in " + this.GetType()); } + Array.Copy(SnapshotID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = Flags; + bytes[i++] = (byte)(AuctionID % 256); + bytes[i++] = (byte)((AuctionID >> 8) % 256); + bytes[i++] = (byte)((AuctionID >> 16) % 256); + bytes[i++] = (byte)((AuctionID >> 24) % 256); ba = BitConverter.GetBytes(Dwell); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += Helpers.FieldToString(SimName, "SimName") + "\n"; - output += "BillableArea: " + BillableArea.ToString() + "\n"; - output += "ActualArea: " + ActualArea.ToString() + "\n"; - output += "GlobalX: " + GlobalX.ToString() + "\n"; - output += "GlobalY: " + GlobalY.ToString() + "\n"; - output += "GlobalZ: " + GlobalZ.ToString() + "\n"; - output += "ParcelID: " + ParcelID.ToString() + "\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; - output += Helpers.FieldToString(Desc, "Desc") + "\n"; - output += "SalePrice: " + SalePrice.ToString() + "\n"; - output += "OwnerID: " + OwnerID.ToString() + "\n"; - output += "SnapshotID: " + SnapshotID.ToString() + "\n"; - output += "Flags: " + Flags.ToString() + "\n"; - output += "AuctionID: " + AuctionID.ToString() + "\n"; - output += "Dwell: " + Dwell.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += Helpers.FieldToString(SimName, "SimName") + "\n"; + output += "BillableArea: " + BillableArea.ToString() + "\n"; + output += "ActualArea: " + ActualArea.ToString() + "\n"; + output += "GlobalX: " + GlobalX.ToString() + "\n"; + output += "GlobalY: " + GlobalY.ToString() + "\n"; + output += "GlobalZ: " + GlobalZ.ToString() + "\n"; + output += "ParcelID: " + ParcelID.ToString() + "\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; + output += Helpers.FieldToString(Desc, "Desc") + "\n"; + output += "SalePrice: " + SalePrice.ToString() + "\n"; + output += "OwnerID: " + OwnerID.ToString() + "\n"; + output += "SnapshotID: " + SnapshotID.ToString() + "\n"; + output += "Flags: " + Flags.ToString() + "\n"; + output += "AuctionID: " + AuctionID.ToString() + "\n"; + output += "Dwell: " + Dwell.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ParcelInfoReply - public override PacketType Type { get { return PacketType.ParcelInfoReply; } } - /// Data block - public DataBlock Data; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ParcelInfoReply + public override PacketType Type { get { return PacketType.ParcelInfoReply; } } + /// Data block + public DataBlock Data; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ParcelInfoReplyPacket() - { - Header = new LowHeader(); - Header.ID = 74; - Header.Reliable = true; - Header.Zerocoded = true; - Data = new DataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 74; + Header.Reliable = true; + Header.Zerocoded = true; + Data = new DataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ParcelInfoReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ParcelInfoReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Data.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Data.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Data.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Data.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ParcelInfoReply ---\n"; - output += Data.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- ParcelInfoReply ---\n"; + output += Data.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ParcelObjectOwnersRequest packet + + /// ParcelObjectOwnersRequest packet public class ParcelObjectOwnersRequestPacket : Packet - { - /// ParcelData block + { + /// ParcelData block public class ParcelDataBlock - { - /// LocalID field - public int LocalID; - - /// Length of this block serialized in bytes + { + /// LocalID field + public int LocalID; + + /// Length of this block serialized in bytes public int Length { get - { - return 4; + { + return 4; } } - - /// Default constructor - public ParcelDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ParcelDataBlock() { } + /// Constructor for building the block from a byte array public ParcelDataBlock(byte[] bytes, ref int i) - { + { try - { - LocalID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + LocalID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(LocalID % 256); - bytes[i++] = (byte)((LocalID >> 8) % 256); - bytes[i++] = (byte)((LocalID >> 16) % 256); - bytes[i++] = (byte)((LocalID >> 24) % 256); + { + bytes[i++] = (byte)(LocalID % 256); + bytes[i++] = (byte)((LocalID >> 8) % 256); + bytes[i++] = (byte)((LocalID >> 16) % 256); + bytes[i++] = (byte)((LocalID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ParcelData --\n"; - output += "LocalID: " + LocalID.ToString() + "\n"; + { + string output = "-- ParcelData --\n"; + output += "LocalID: " + LocalID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ParcelObjectOwnersRequest - public override PacketType Type { get { return PacketType.ParcelObjectOwnersRequest; } } - /// ParcelData block - public ParcelDataBlock ParcelData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ParcelObjectOwnersRequest + public override PacketType Type { get { return PacketType.ParcelObjectOwnersRequest; } } + /// ParcelData block + public ParcelDataBlock ParcelData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ParcelObjectOwnersRequestPacket() - { - Header = new LowHeader(); - Header.ID = 75; - Header.Reliable = true; - ParcelData = new ParcelDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 75; + Header.Reliable = true; + ParcelData = new ParcelDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ParcelObjectOwnersRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - ParcelData = new ParcelDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + ParcelData = new ParcelDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ParcelObjectOwnersRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - ParcelData = new ParcelDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + ParcelData = new ParcelDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += ParcelData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - ParcelData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += ParcelData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + ParcelData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ParcelObjectOwnersRequest ---\n"; - output += ParcelData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- ParcelObjectOwnersRequest ---\n"; + output += ParcelData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// OnlineStatusRequest packet + + /// OnlineStatusRequest packet public class OnlineStatusRequestPacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - /// ID field - public LLUUID ID; - - /// Length of this block serialized in bytes + { + /// ID field + public LLUUID ID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { + { try - { - ID = new LLUUID(bytes, i); i += 16; + { + ID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } - Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } + Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "ID: " + ID.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += "ID: " + ID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SpaceIP field - public uint SpaceIP; - /// Godlike field - public bool Godlike; - /// QueryID field - public LLUUID QueryID; - /// EstateID field - public uint EstateID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SpaceIP field + public uint SpaceIP; + /// Godlike field + public bool Godlike; + /// QueryID field + public LLUUID QueryID; + /// EstateID field + public uint EstateID; + + /// Length of this block serialized in bytes public int Length { get - { - return 41; + { + return 41; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SpaceIP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Godlike = (bytes[i++] != 0) ? (bool)true : (bool)false; - QueryID = new LLUUID(bytes, i); i += 16; - EstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + AgentID = new LLUUID(bytes, i); i += 16; + SpaceIP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Godlike = (bytes[i++] != 0) ? (bool)true : (bool)false; + QueryID = new LLUUID(bytes, i); i += 16; + EstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(SpaceIP % 256); - bytes[i++] = (byte)((SpaceIP >> 8) % 256); - bytes[i++] = (byte)((SpaceIP >> 16) % 256); - bytes[i++] = (byte)((SpaceIP >> 24) % 256); - bytes[i++] = (byte)((Godlike) ? 1 : 0); - if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } - Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(EstateID % 256); - bytes[i++] = (byte)((EstateID >> 8) % 256); - bytes[i++] = (byte)((EstateID >> 16) % 256); - bytes[i++] = (byte)((EstateID >> 24) % 256); + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(SpaceIP % 256); + bytes[i++] = (byte)((SpaceIP >> 8) % 256); + bytes[i++] = (byte)((SpaceIP >> 16) % 256); + bytes[i++] = (byte)((SpaceIP >> 24) % 256); + bytes[i++] = (byte)((Godlike) ? 1 : 0); + if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } + Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(EstateID % 256); + bytes[i++] = (byte)((EstateID >> 8) % 256); + bytes[i++] = (byte)((EstateID >> 16) % 256); + bytes[i++] = (byte)((EstateID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SpaceIP: " + SpaceIP.ToString() + "\n"; - output += "Godlike: " + Godlike.ToString() + "\n"; - output += "QueryID: " + QueryID.ToString() + "\n"; - output += "EstateID: " + EstateID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SpaceIP: " + SpaceIP.ToString() + "\n"; + output += "Godlike: " + Godlike.ToString() + "\n"; + output += "QueryID: " + QueryID.ToString() + "\n"; + output += "EstateID: " + EstateID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.OnlineStatusRequest - public override PacketType Type { get { return PacketType.OnlineStatusRequest; } } - /// Data block - public DataBlock[] Data; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.OnlineStatusRequest + public override PacketType Type { get { return PacketType.OnlineStatusRequest; } } + /// Data block + public DataBlock[] Data; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public OnlineStatusRequestPacket() - { - Header = new LowHeader(); - Header.ID = 76; - Header.Reliable = true; - Data = new DataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 76; + Header.Reliable = true; + Data = new DataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public OnlineStatusRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - Data = new DataBlock[count]; - for (int j = 0; j < count; j++) - { Data[j] = new DataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + Data = new DataBlock[count]; + for (int j = 0; j < count; j++) + { Data[j] = new DataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public OnlineStatusRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - Data = new DataBlock[count]; - for (int j = 0; j < count; j++) - { Data[j] = new DataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + Data = new DataBlock[count]; + for (int j = 0; j < count; j++) + { Data[j] = new DataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < Data.Length; j++) { length += Data[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)Data.Length; - for (int j = 0; j < Data.Length; j++) { Data[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < Data.Length; j++) { length += Data[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)Data.Length; + for (int j = 0; j < Data.Length; j++) { Data[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- OnlineStatusRequest ---\n"; + { + string output = "--- OnlineStatusRequest ---\n"; for (int j = 0; j < Data.Length; j++) - { + { output += Data[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// OnlineStatusReply packet + + /// OnlineStatusReply packet public class OnlineStatusReplyPacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - /// ID field - public LLUUID ID; - - /// Length of this block serialized in bytes + { + /// ID field + public LLUUID ID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { + { try - { - ID = new LLUUID(bytes, i); i += 16; + { + ID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } - Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } + Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "ID: " + ID.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += "ID: " + ID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// QueryID field - public LLUUID QueryID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// QueryID field + public LLUUID QueryID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - QueryID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + QueryID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } - Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } + Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "QueryID: " + QueryID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "QueryID: " + QueryID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.OnlineStatusReply - public override PacketType Type { get { return PacketType.OnlineStatusReply; } } - /// Data block - public DataBlock[] Data; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.OnlineStatusReply + public override PacketType Type { get { return PacketType.OnlineStatusReply; } } + /// Data block + public DataBlock[] Data; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public OnlineStatusReplyPacket() - { - Header = new LowHeader(); - Header.ID = 77; - Header.Reliable = true; - Header.Zerocoded = true; - Data = new DataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 77; + Header.Reliable = true; + Header.Zerocoded = true; + Data = new DataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public OnlineStatusReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - Data = new DataBlock[count]; - for (int j = 0; j < count; j++) - { Data[j] = new DataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + Data = new DataBlock[count]; + for (int j = 0; j < count; j++) + { Data[j] = new DataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public OnlineStatusReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - Data = new DataBlock[count]; - for (int j = 0; j < count; j++) - { Data[j] = new DataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + Data = new DataBlock[count]; + for (int j = 0; j < count; j++) + { Data[j] = new DataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < Data.Length; j++) { length += Data[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)Data.Length; - for (int j = 0; j < Data.Length; j++) { Data[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < Data.Length; j++) { length += Data[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)Data.Length; + for (int j = 0; j < Data.Length; j++) { Data[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- OnlineStatusReply ---\n"; + { + string output = "--- OnlineStatusReply ---\n"; for (int j = 0; j < Data.Length; j++) - { + { output += Data[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ParcelObjectOwnersReply packet + + /// ParcelObjectOwnersReply packet public class ParcelObjectOwnersReplyPacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - /// OnlineStatus field - public bool OnlineStatus; - /// IsGroupOwned field - public bool IsGroupOwned; - /// OwnerID field - public LLUUID OwnerID; - /// Count field - public int Count; - - /// Length of this block serialized in bytes + { + /// OnlineStatus field + public bool OnlineStatus; + /// IsGroupOwned field + public bool IsGroupOwned; + /// OwnerID field + public LLUUID OwnerID; + /// Count field + public int Count; + + /// Length of this block serialized in bytes public int Length { get - { - return 22; + { + return 22; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { + { try - { - OnlineStatus = (bytes[i++] != 0) ? (bool)true : (bool)false; - IsGroupOwned = (bytes[i++] != 0) ? (bool)true : (bool)false; - OwnerID = new LLUUID(bytes, i); i += 16; - Count = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + OnlineStatus = (bytes[i++] != 0) ? (bool)true : (bool)false; + IsGroupOwned = (bytes[i++] != 0) ? (bool)true : (bool)false; + OwnerID = new LLUUID(bytes, i); i += 16; + Count = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)((OnlineStatus) ? 1 : 0); - bytes[i++] = (byte)((IsGroupOwned) ? 1 : 0); - if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } - Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(Count % 256); - bytes[i++] = (byte)((Count >> 8) % 256); - bytes[i++] = (byte)((Count >> 16) % 256); - bytes[i++] = (byte)((Count >> 24) % 256); + { + bytes[i++] = (byte)((OnlineStatus) ? 1 : 0); + bytes[i++] = (byte)((IsGroupOwned) ? 1 : 0); + if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } + Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(Count % 256); + bytes[i++] = (byte)((Count >> 8) % 256); + bytes[i++] = (byte)((Count >> 16) % 256); + bytes[i++] = (byte)((Count >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "OnlineStatus: " + OnlineStatus.ToString() + "\n"; - output += "IsGroupOwned: " + IsGroupOwned.ToString() + "\n"; - output += "OwnerID: " + OwnerID.ToString() + "\n"; - output += "Count: " + Count.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += "OnlineStatus: " + OnlineStatus.ToString() + "\n"; + output += "IsGroupOwned: " + IsGroupOwned.ToString() + "\n"; + output += "OwnerID: " + OwnerID.ToString() + "\n"; + output += "Count: " + Count.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ParcelObjectOwnersReply - public override PacketType Type { get { return PacketType.ParcelObjectOwnersReply; } } - /// Data block - public DataBlock[] Data; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ParcelObjectOwnersReply + public override PacketType Type { get { return PacketType.ParcelObjectOwnersReply; } } + /// Data block + public DataBlock[] Data; + + /// Default constructor public ParcelObjectOwnersReplyPacket() - { - Header = new LowHeader(); - Header.ID = 78; - Header.Reliable = true; - Header.Zerocoded = true; - Data = new DataBlock[0]; + { + Header = new LowHeader(); + Header.ID = 78; + Header.Reliable = true; + Header.Zerocoded = true; + Data = new DataBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ParcelObjectOwnersReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - Data = new DataBlock[count]; - for (int j = 0; j < count; j++) - { Data[j] = new DataBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + Data = new DataBlock[count]; + for (int j = 0; j < count; j++) + { Data[j] = new DataBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ParcelObjectOwnersReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - Data = new DataBlock[count]; - for (int j = 0; j < count; j++) - { Data[j] = new DataBlock(bytes, ref i); } + { + Header = head; + int count = (int)bytes[i++]; + Data = new DataBlock[count]; + for (int j = 0; j < count; j++) + { Data[j] = new DataBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; -; - length++; - for (int j = 0; j < Data.Length; j++) { length += Data[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)Data.Length; - for (int j = 0; j < Data.Length; j++) { Data[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; +; + length++; + for (int j = 0; j < Data.Length; j++) { length += Data[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)Data.Length; + for (int j = 0; j < Data.Length; j++) { Data[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ParcelObjectOwnersReply ---\n"; + { + string output = "--- ParcelObjectOwnersReply ---\n"; for (int j = 0; j < Data.Length; j++) - { + { output += Data[j].ToString() + "\n"; - } + } return output; } - + } - - /// GroupNoticesListRequest packet + + /// GroupNoticesListRequest packet public class GroupNoticesListRequestPacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - /// GroupID field - public LLUUID GroupID; - - /// Length of this block serialized in bytes + { + /// GroupID field + public LLUUID GroupID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { + { try - { - GroupID = new LLUUID(bytes, i); i += 16; + { + GroupID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.GroupNoticesListRequest - public override PacketType Type { get { return PacketType.GroupNoticesListRequest; } } - /// Data block - public DataBlock Data; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.GroupNoticesListRequest + public override PacketType Type { get { return PacketType.GroupNoticesListRequest; } } + /// Data block + public DataBlock Data; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public GroupNoticesListRequestPacket() - { - Header = new LowHeader(); - Header.ID = 79; - Header.Reliable = true; - Data = new DataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 79; + Header.Reliable = true; + Data = new DataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public GroupNoticesListRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public GroupNoticesListRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Data.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Data.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Data.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Data.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- GroupNoticesListRequest ---\n"; - output += Data.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- GroupNoticesListRequest ---\n"; + output += Data.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// GroupNoticesListReply packet + + /// GroupNoticesListReply packet public class GroupNoticesListReplyPacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - /// Timestamp field - public uint Timestamp; - private byte[] _subject; - /// Subject field + { + /// Timestamp field + public uint Timestamp; + private byte[] _subject; + /// Subject field public byte[] Subject - { - get { return _subject; } + { + get { return _subject; } set - { - if (value == null) { _subject = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _subject = new byte[value.Length]; Array.Copy(value, _subject, value.Length); } + { + if (value == null) { _subject = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _subject = new byte[value.Length]; Array.Copy(value, _subject, value.Length); } } - } - /// HasAttachment field - public bool HasAttachment; - /// NoticeID field - public LLUUID NoticeID; - private byte[] _fromname; - /// FromName field + } + /// HasAttachment field + public bool HasAttachment; + /// NoticeID field + public LLUUID NoticeID; + private byte[] _fromname; + /// FromName field public byte[] FromName - { - get { return _fromname; } + { + get { return _fromname; } set - { - if (value == null) { _fromname = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _fromname = new byte[value.Length]; Array.Copy(value, _fromname, value.Length); } + { + if (value == null) { _fromname = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _fromname = new byte[value.Length]; Array.Copy(value, _fromname, value.Length); } } - } - /// AssetType field - public byte AssetType; - - /// Length of this block serialized in bytes + } + /// AssetType field + public byte AssetType; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 22; - if (Subject != null) { length += 2 + Subject.Length; } - if (FromName != null) { length += 2 + FromName.Length; } - return length; + { + int length = 22; + if (Subject != null) { length += 2 + Subject.Length; } + if (FromName != null) { length += 2 + FromName.Length; } + return length; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - Timestamp = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _subject = new byte[length]; - Array.Copy(bytes, i, _subject, 0, length); i += length; - HasAttachment = (bytes[i++] != 0) ? (bool)true : (bool)false; - NoticeID = new LLUUID(bytes, i); i += 16; - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _fromname = new byte[length]; - Array.Copy(bytes, i, _fromname, 0, length); i += length; - AssetType = (byte)bytes[i++]; + { + Timestamp = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _subject = new byte[length]; + Array.Copy(bytes, i, _subject, 0, length); i += length; + HasAttachment = (bytes[i++] != 0) ? (bool)true : (bool)false; + NoticeID = new LLUUID(bytes, i); i += 16; + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _fromname = new byte[length]; + Array.Copy(bytes, i, _fromname, 0, length); i += length; + AssetType = (byte)bytes[i++]; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(Timestamp % 256); - bytes[i++] = (byte)((Timestamp >> 8) % 256); - bytes[i++] = (byte)((Timestamp >> 16) % 256); - bytes[i++] = (byte)((Timestamp >> 24) % 256); - if(Subject == null) { Console.WriteLine("Warning: Subject is null, in " + this.GetType()); } - bytes[i++] = (byte)(Subject.Length % 256); - bytes[i++] = (byte)((Subject.Length >> 8) % 256); - Array.Copy(Subject, 0, bytes, i, Subject.Length); i += Subject.Length; - bytes[i++] = (byte)((HasAttachment) ? 1 : 0); - if(NoticeID == null) { Console.WriteLine("Warning: NoticeID is null, in " + this.GetType()); } - Array.Copy(NoticeID.GetBytes(), 0, bytes, i, 16); i += 16; - if(FromName == null) { Console.WriteLine("Warning: FromName is null, in " + this.GetType()); } - bytes[i++] = (byte)(FromName.Length % 256); - bytes[i++] = (byte)((FromName.Length >> 8) % 256); - Array.Copy(FromName, 0, bytes, i, FromName.Length); i += FromName.Length; - bytes[i++] = AssetType; + { + bytes[i++] = (byte)(Timestamp % 256); + bytes[i++] = (byte)((Timestamp >> 8) % 256); + bytes[i++] = (byte)((Timestamp >> 16) % 256); + bytes[i++] = (byte)((Timestamp >> 24) % 256); + if(Subject == null) { Console.WriteLine("Warning: Subject is null, in " + this.GetType()); } + bytes[i++] = (byte)(Subject.Length % 256); + bytes[i++] = (byte)((Subject.Length >> 8) % 256); + Array.Copy(Subject, 0, bytes, i, Subject.Length); i += Subject.Length; + bytes[i++] = (byte)((HasAttachment) ? 1 : 0); + if(NoticeID == null) { Console.WriteLine("Warning: NoticeID is null, in " + this.GetType()); } + Array.Copy(NoticeID.GetBytes(), 0, bytes, i, 16); i += 16; + if(FromName == null) { Console.WriteLine("Warning: FromName is null, in " + this.GetType()); } + bytes[i++] = (byte)(FromName.Length % 256); + bytes[i++] = (byte)((FromName.Length >> 8) % 256); + Array.Copy(FromName, 0, bytes, i, FromName.Length); i += FromName.Length; + bytes[i++] = AssetType; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "Timestamp: " + Timestamp.ToString() + "\n"; - output += Helpers.FieldToString(Subject, "Subject") + "\n"; - output += "HasAttachment: " + HasAttachment.ToString() + "\n"; - output += "NoticeID: " + NoticeID.ToString() + "\n"; - output += Helpers.FieldToString(FromName, "FromName") + "\n"; - output += "AssetType: " + AssetType.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += "Timestamp: " + Timestamp.ToString() + "\n"; + output += Helpers.FieldToString(Subject, "Subject") + "\n"; + output += "HasAttachment: " + HasAttachment.ToString() + "\n"; + output += "NoticeID: " + NoticeID.ToString() + "\n"; + output += Helpers.FieldToString(FromName, "FromName") + "\n"; + output += "AssetType: " + AssetType.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// GroupID field - public LLUUID GroupID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// GroupID field + public LLUUID GroupID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - GroupID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + GroupID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.GroupNoticesListReply - public override PacketType Type { get { return PacketType.GroupNoticesListReply; } } - /// Data block - public DataBlock[] Data; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.GroupNoticesListReply + public override PacketType Type { get { return PacketType.GroupNoticesListReply; } } + /// Data block + public DataBlock[] Data; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public GroupNoticesListReplyPacket() - { - Header = new LowHeader(); - Header.ID = 80; - Header.Reliable = true; - Data = new DataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 80; + Header.Reliable = true; + Data = new DataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public GroupNoticesListReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - Data = new DataBlock[count]; - for (int j = 0; j < count; j++) - { Data[j] = new DataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + Data = new DataBlock[count]; + for (int j = 0; j < count; j++) + { Data[j] = new DataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public GroupNoticesListReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - Data = new DataBlock[count]; - for (int j = 0; j < count; j++) - { Data[j] = new DataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + Data = new DataBlock[count]; + for (int j = 0; j < count; j++) + { Data[j] = new DataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < Data.Length; j++) { length += Data[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)Data.Length; - for (int j = 0; j < Data.Length; j++) { Data[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < Data.Length; j++) { length += Data[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)Data.Length; + for (int j = 0; j < Data.Length; j++) { Data[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- GroupNoticesListReply ---\n"; + { + string output = "--- GroupNoticesListReply ---\n"; for (int j = 0; j < Data.Length; j++) - { + { output += Data[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// GroupNoticeRequest packet + + /// GroupNoticeRequest packet public class GroupNoticeRequestPacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - /// GroupNoticeID field - public LLUUID GroupNoticeID; - - /// Length of this block serialized in bytes + { + /// GroupNoticeID field + public LLUUID GroupNoticeID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { + { try - { - GroupNoticeID = new LLUUID(bytes, i); i += 16; + { + GroupNoticeID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(GroupNoticeID == null) { Console.WriteLine("Warning: GroupNoticeID is null, in " + this.GetType()); } - Array.Copy(GroupNoticeID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(GroupNoticeID == null) { Console.WriteLine("Warning: GroupNoticeID is null, in " + this.GetType()); } + Array.Copy(GroupNoticeID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "GroupNoticeID: " + GroupNoticeID.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += "GroupNoticeID: " + GroupNoticeID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.GroupNoticeRequest - public override PacketType Type { get { return PacketType.GroupNoticeRequest; } } - /// Data block - public DataBlock Data; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.GroupNoticeRequest + public override PacketType Type { get { return PacketType.GroupNoticeRequest; } } + /// Data block + public DataBlock Data; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public GroupNoticeRequestPacket() - { - Header = new LowHeader(); - Header.ID = 81; - Header.Reliable = true; - Data = new DataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 81; + Header.Reliable = true; + Data = new DataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public GroupNoticeRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public GroupNoticeRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Data.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Data.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Data.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Data.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- GroupNoticeRequest ---\n"; - output += Data.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- GroupNoticeRequest ---\n"; + output += Data.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// GroupNoticeAdd packet + + /// GroupNoticeAdd packet public class GroupNoticeAddPacket : Packet - { - /// MessageBlock block + { + /// MessageBlock block public class MessageBlockBlock - { - /// ID field - public LLUUID ID; - private byte[] _message; - /// Message field + { + /// ID field + public LLUUID ID; + private byte[] _message; + /// Message field public byte[] Message - { - get { return _message; } + { + get { return _message; } set - { - if (value == null) { _message = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _message = new byte[value.Length]; Array.Copy(value, _message, value.Length); } + { + if (value == null) { _message = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _message = new byte[value.Length]; Array.Copy(value, _message, value.Length); } } - } - /// Dialog field - public byte Dialog; - /// ToGroupID field - public LLUUID ToGroupID; - private byte[] _binarybucket; - /// BinaryBucket field + } + /// Dialog field + public byte Dialog; + /// ToGroupID field + public LLUUID ToGroupID; + private byte[] _binarybucket; + /// BinaryBucket field public byte[] BinaryBucket - { - get { return _binarybucket; } + { + get { return _binarybucket; } set - { - if (value == null) { _binarybucket = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _binarybucket = new byte[value.Length]; Array.Copy(value, _binarybucket, value.Length); } + { + if (value == null) { _binarybucket = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _binarybucket = new byte[value.Length]; Array.Copy(value, _binarybucket, value.Length); } } - } - private byte[] _fromagentname; - /// FromAgentName field + } + private byte[] _fromagentname; + /// FromAgentName field public byte[] FromAgentName - { - get { return _fromagentname; } + { + get { return _fromagentname; } set - { - if (value == null) { _fromagentname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _fromagentname = new byte[value.Length]; Array.Copy(value, _fromagentname, value.Length); } + { + if (value == null) { _fromagentname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _fromagentname = new byte[value.Length]; Array.Copy(value, _fromagentname, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 33; - if (Message != null) { length += 2 + Message.Length; } - if (BinaryBucket != null) { length += 2 + BinaryBucket.Length; } - if (FromAgentName != null) { length += 1 + FromAgentName.Length; } - return length; + { + int length = 33; + if (Message != null) { length += 2 + Message.Length; } + if (BinaryBucket != null) { length += 2 + BinaryBucket.Length; } + if (FromAgentName != null) { length += 1 + FromAgentName.Length; } + return length; } } - - /// Default constructor - public MessageBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public MessageBlockBlock() { } + /// Constructor for building the block from a byte array public MessageBlockBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - ID = new LLUUID(bytes, i); i += 16; - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _message = new byte[length]; - Array.Copy(bytes, i, _message, 0, length); i += length; - Dialog = (byte)bytes[i++]; - ToGroupID = new LLUUID(bytes, i); i += 16; - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _binarybucket = new byte[length]; - Array.Copy(bytes, i, _binarybucket, 0, length); i += length; - length = (ushort)bytes[i++]; - _fromagentname = new byte[length]; - Array.Copy(bytes, i, _fromagentname, 0, length); i += length; + { + ID = new LLUUID(bytes, i); i += 16; + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _message = new byte[length]; + Array.Copy(bytes, i, _message, 0, length); i += length; + Dialog = (byte)bytes[i++]; + ToGroupID = new LLUUID(bytes, i); i += 16; + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _binarybucket = new byte[length]; + Array.Copy(bytes, i, _binarybucket, 0, length); i += length; + length = (ushort)bytes[i++]; + _fromagentname = new byte[length]; + Array.Copy(bytes, i, _fromagentname, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } - Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; - if(Message == null) { Console.WriteLine("Warning: Message is null, in " + this.GetType()); } - bytes[i++] = (byte)(Message.Length % 256); - bytes[i++] = (byte)((Message.Length >> 8) % 256); - Array.Copy(Message, 0, bytes, i, Message.Length); i += Message.Length; - bytes[i++] = Dialog; - if(ToGroupID == null) { Console.WriteLine("Warning: ToGroupID is null, in " + this.GetType()); } - Array.Copy(ToGroupID.GetBytes(), 0, bytes, i, 16); i += 16; - if(BinaryBucket == null) { Console.WriteLine("Warning: BinaryBucket is null, in " + this.GetType()); } - bytes[i++] = (byte)(BinaryBucket.Length % 256); - bytes[i++] = (byte)((BinaryBucket.Length >> 8) % 256); - Array.Copy(BinaryBucket, 0, bytes, i, BinaryBucket.Length); i += BinaryBucket.Length; - if(FromAgentName == null) { Console.WriteLine("Warning: FromAgentName is null, in " + this.GetType()); } - bytes[i++] = (byte)FromAgentName.Length; - Array.Copy(FromAgentName, 0, bytes, i, FromAgentName.Length); i += FromAgentName.Length; + { + if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } + Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; + if(Message == null) { Console.WriteLine("Warning: Message is null, in " + this.GetType()); } + bytes[i++] = (byte)(Message.Length % 256); + bytes[i++] = (byte)((Message.Length >> 8) % 256); + Array.Copy(Message, 0, bytes, i, Message.Length); i += Message.Length; + bytes[i++] = Dialog; + if(ToGroupID == null) { Console.WriteLine("Warning: ToGroupID is null, in " + this.GetType()); } + Array.Copy(ToGroupID.GetBytes(), 0, bytes, i, 16); i += 16; + if(BinaryBucket == null) { Console.WriteLine("Warning: BinaryBucket is null, in " + this.GetType()); } + bytes[i++] = (byte)(BinaryBucket.Length % 256); + bytes[i++] = (byte)((BinaryBucket.Length >> 8) % 256); + Array.Copy(BinaryBucket, 0, bytes, i, BinaryBucket.Length); i += BinaryBucket.Length; + if(FromAgentName == null) { Console.WriteLine("Warning: FromAgentName is null, in " + this.GetType()); } + bytes[i++] = (byte)FromAgentName.Length; + Array.Copy(FromAgentName, 0, bytes, i, FromAgentName.Length); i += FromAgentName.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- MessageBlock --\n"; - output += "ID: " + ID.ToString() + "\n"; - output += Helpers.FieldToString(Message, "Message") + "\n"; - output += "Dialog: " + Dialog.ToString() + "\n"; - output += "ToGroupID: " + ToGroupID.ToString() + "\n"; - output += Helpers.FieldToString(BinaryBucket, "BinaryBucket") + "\n"; - output += Helpers.FieldToString(FromAgentName, "FromAgentName") + "\n"; + { + string output = "-- MessageBlock --\n"; + output += "ID: " + ID.ToString() + "\n"; + output += Helpers.FieldToString(Message, "Message") + "\n"; + output += "Dialog: " + Dialog.ToString() + "\n"; + output += "ToGroupID: " + ToGroupID.ToString() + "\n"; + output += Helpers.FieldToString(BinaryBucket, "BinaryBucket") + "\n"; + output += Helpers.FieldToString(FromAgentName, "FromAgentName") + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.GroupNoticeAdd - public override PacketType Type { get { return PacketType.GroupNoticeAdd; } } - /// MessageBlock block - public MessageBlockBlock MessageBlock; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.GroupNoticeAdd + public override PacketType Type { get { return PacketType.GroupNoticeAdd; } } + /// MessageBlock block + public MessageBlockBlock MessageBlock; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public GroupNoticeAddPacket() - { - Header = new LowHeader(); - Header.ID = 82; - Header.Reliable = true; - MessageBlock = new MessageBlockBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 82; + Header.Reliable = true; + MessageBlock = new MessageBlockBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public GroupNoticeAddPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - MessageBlock = new MessageBlockBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + MessageBlock = new MessageBlockBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public GroupNoticeAddPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - MessageBlock = new MessageBlockBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + MessageBlock = new MessageBlockBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += MessageBlock.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - MessageBlock.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += MessageBlock.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + MessageBlock.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- GroupNoticeAdd ---\n"; - output += MessageBlock.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- GroupNoticeAdd ---\n"; + output += MessageBlock.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// GroupNoticeDelete packet + + /// GroupNoticeDelete packet public class GroupNoticeDeletePacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - /// GroupNoticeID field - public LLUUID GroupNoticeID; - /// GroupID field - public LLUUID GroupID; - - /// Length of this block serialized in bytes + { + /// GroupNoticeID field + public LLUUID GroupNoticeID; + /// GroupID field + public LLUUID GroupID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { + { try - { - GroupNoticeID = new LLUUID(bytes, i); i += 16; - GroupID = new LLUUID(bytes, i); i += 16; + { + GroupNoticeID = new LLUUID(bytes, i); i += 16; + GroupID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(GroupNoticeID == null) { Console.WriteLine("Warning: GroupNoticeID is null, in " + this.GetType()); } - Array.Copy(GroupNoticeID.GetBytes(), 0, bytes, i, 16); i += 16; - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(GroupNoticeID == null) { Console.WriteLine("Warning: GroupNoticeID is null, in " + this.GetType()); } + Array.Copy(GroupNoticeID.GetBytes(), 0, bytes, i, 16); i += 16; + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "GroupNoticeID: " + GroupNoticeID.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += "GroupNoticeID: " + GroupNoticeID.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.GroupNoticeDelete - public override PacketType Type { get { return PacketType.GroupNoticeDelete; } } - /// Data block - public DataBlock Data; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.GroupNoticeDelete + public override PacketType Type { get { return PacketType.GroupNoticeDelete; } } + /// Data block + public DataBlock Data; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public GroupNoticeDeletePacket() - { - Header = new LowHeader(); - Header.ID = 83; - Header.Reliable = true; - Data = new DataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 83; + Header.Reliable = true; + Data = new DataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public GroupNoticeDeletePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public GroupNoticeDeletePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Data.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Data.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Data.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Data.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- GroupNoticeDelete ---\n"; - output += Data.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- GroupNoticeDelete ---\n"; + output += Data.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// TeleportRequest packet + + /// TeleportRequest packet public class TeleportRequestPacket : Packet - { - /// Info block + { + /// Info block public class InfoBlock - { - /// RegionID field - public LLUUID RegionID; - /// LookAt field - public LLVector3 LookAt; - /// Position field - public LLVector3 Position; - - /// Length of this block serialized in bytes + { + /// RegionID field + public LLUUID RegionID; + /// LookAt field + public LLVector3 LookAt; + /// Position field + public LLVector3 Position; + + /// Length of this block serialized in bytes public int Length { get - { - return 40; + { + return 40; } } - - /// Default constructor - public InfoBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public InfoBlock() { } + /// Constructor for building the block from a byte array public InfoBlock(byte[] bytes, ref int i) - { + { try - { - RegionID = new LLUUID(bytes, i); i += 16; - LookAt = new LLVector3(bytes, i); i += 12; - Position = new LLVector3(bytes, i); i += 12; + { + RegionID = new LLUUID(bytes, i); i += 16; + LookAt = new LLVector3(bytes, i); i += 12; + Position = new LLVector3(bytes, i); i += 12; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(RegionID == null) { Console.WriteLine("Warning: RegionID is null, in " + this.GetType()); } - Array.Copy(RegionID.GetBytes(), 0, bytes, i, 16); i += 16; - if(LookAt == null) { Console.WriteLine("Warning: LookAt is null, in " + this.GetType()); } - Array.Copy(LookAt.GetBytes(), 0, bytes, i, 12); i += 12; - if(Position == null) { Console.WriteLine("Warning: Position is null, in " + this.GetType()); } - Array.Copy(Position.GetBytes(), 0, bytes, i, 12); i += 12; + { + if(RegionID == null) { Console.WriteLine("Warning: RegionID is null, in " + this.GetType()); } + Array.Copy(RegionID.GetBytes(), 0, bytes, i, 16); i += 16; + if(LookAt == null) { Console.WriteLine("Warning: LookAt is null, in " + this.GetType()); } + Array.Copy(LookAt.GetBytes(), 0, bytes, i, 12); i += 12; + if(Position == null) { Console.WriteLine("Warning: Position is null, in " + this.GetType()); } + Array.Copy(Position.GetBytes(), 0, bytes, i, 12); i += 12; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Info --\n"; - output += "RegionID: " + RegionID.ToString() + "\n"; - output += "LookAt: " + LookAt.ToString() + "\n"; - output += "Position: " + Position.ToString() + "\n"; + { + string output = "-- Info --\n"; + output += "RegionID: " + RegionID.ToString() + "\n"; + output += "LookAt: " + LookAt.ToString() + "\n"; + output += "Position: " + Position.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.TeleportRequest - public override PacketType Type { get { return PacketType.TeleportRequest; } } - /// Info block - public InfoBlock Info; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.TeleportRequest + public override PacketType Type { get { return PacketType.TeleportRequest; } } + /// Info block + public InfoBlock Info; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public TeleportRequestPacket() - { - Header = new LowHeader(); - Header.ID = 84; - Header.Reliable = true; - Info = new InfoBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 84; + Header.Reliable = true; + Info = new InfoBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public TeleportRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Info = new InfoBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Info = new InfoBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public TeleportRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Info = new InfoBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + Info = new InfoBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Info.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Info.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Info.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Info.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- TeleportRequest ---\n"; - output += Info.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- TeleportRequest ---\n"; + output += Info.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// TeleportLocationRequest packet + + /// TeleportLocationRequest packet public class TeleportLocationRequestPacket : Packet - { - /// Info block + { + /// Info block public class InfoBlock - { - /// RegionHandle field - public ulong RegionHandle; - /// LookAt field - public LLVector3 LookAt; - /// Position field - public LLVector3 Position; - - /// Length of this block serialized in bytes + { + /// RegionHandle field + public ulong RegionHandle; + /// LookAt field + public LLVector3 LookAt; + /// Position field + public LLVector3 Position; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public InfoBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public InfoBlock() { } + /// Constructor for building the block from a byte array public InfoBlock(byte[] bytes, ref int i) - { + { try - { - RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); - LookAt = new LLVector3(bytes, i); i += 12; - Position = new LLVector3(bytes, i); i += 12; + { + RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + LookAt = new LLVector3(bytes, i); i += 12; + Position = new LLVector3(bytes, i); i += 12; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(RegionHandle % 256); - bytes[i++] = (byte)((RegionHandle >> 8) % 256); - bytes[i++] = (byte)((RegionHandle >> 16) % 256); - bytes[i++] = (byte)((RegionHandle >> 24) % 256); - bytes[i++] = (byte)((RegionHandle >> 32) % 256); - bytes[i++] = (byte)((RegionHandle >> 40) % 256); - bytes[i++] = (byte)((RegionHandle >> 48) % 256); - bytes[i++] = (byte)((RegionHandle >> 56) % 256); - if(LookAt == null) { Console.WriteLine("Warning: LookAt is null, in " + this.GetType()); } - Array.Copy(LookAt.GetBytes(), 0, bytes, i, 12); i += 12; - if(Position == null) { Console.WriteLine("Warning: Position is null, in " + this.GetType()); } - Array.Copy(Position.GetBytes(), 0, bytes, i, 12); i += 12; + { + bytes[i++] = (byte)(RegionHandle % 256); + bytes[i++] = (byte)((RegionHandle >> 8) % 256); + bytes[i++] = (byte)((RegionHandle >> 16) % 256); + bytes[i++] = (byte)((RegionHandle >> 24) % 256); + bytes[i++] = (byte)((RegionHandle >> 32) % 256); + bytes[i++] = (byte)((RegionHandle >> 40) % 256); + bytes[i++] = (byte)((RegionHandle >> 48) % 256); + bytes[i++] = (byte)((RegionHandle >> 56) % 256); + if(LookAt == null) { Console.WriteLine("Warning: LookAt is null, in " + this.GetType()); } + Array.Copy(LookAt.GetBytes(), 0, bytes, i, 12); i += 12; + if(Position == null) { Console.WriteLine("Warning: Position is null, in " + this.GetType()); } + Array.Copy(Position.GetBytes(), 0, bytes, i, 12); i += 12; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Info --\n"; - output += "RegionHandle: " + RegionHandle.ToString() + "\n"; - output += "LookAt: " + LookAt.ToString() + "\n"; - output += "Position: " + Position.ToString() + "\n"; + { + string output = "-- Info --\n"; + output += "RegionHandle: " + RegionHandle.ToString() + "\n"; + output += "LookAt: " + LookAt.ToString() + "\n"; + output += "Position: " + Position.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.TeleportLocationRequest - public override PacketType Type { get { return PacketType.TeleportLocationRequest; } } - /// Info block - public InfoBlock Info; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.TeleportLocationRequest + public override PacketType Type { get { return PacketType.TeleportLocationRequest; } } + /// Info block + public InfoBlock Info; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public TeleportLocationRequestPacket() - { - Header = new LowHeader(); - Header.ID = 85; - Header.Reliable = true; - Info = new InfoBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 85; + Header.Reliable = true; + Info = new InfoBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public TeleportLocationRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Info = new InfoBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Info = new InfoBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public TeleportLocationRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Info = new InfoBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + Info = new InfoBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Info.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Info.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Info.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Info.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- TeleportLocationRequest ---\n"; - output += Info.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- TeleportLocationRequest ---\n"; + output += Info.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// TeleportLocal packet + + /// TeleportLocal packet public class TeleportLocalPacket : Packet - { - /// Info block + { + /// Info block public class InfoBlock - { - /// AgentID field - public LLUUID AgentID; - /// LocationID field - public uint LocationID; - /// LookAt field - public LLVector3 LookAt; - /// TeleportFlags field - public uint TeleportFlags; - /// Position field - public LLVector3 Position; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// LocationID field + public uint LocationID; + /// LookAt field + public LLVector3 LookAt; + /// TeleportFlags field + public uint TeleportFlags; + /// Position field + public LLVector3 Position; + + /// Length of this block serialized in bytes public int Length { get - { - return 48; + { + return 48; } } - - /// Default constructor - public InfoBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public InfoBlock() { } + /// Constructor for building the block from a byte array public InfoBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - LocationID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - LookAt = new LLVector3(bytes, i); i += 12; - TeleportFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Position = new LLVector3(bytes, i); i += 12; + { + AgentID = new LLUUID(bytes, i); i += 16; + LocationID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + LookAt = new LLVector3(bytes, i); i += 12; + TeleportFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Position = new LLVector3(bytes, i); i += 12; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(LocationID % 256); - bytes[i++] = (byte)((LocationID >> 8) % 256); - bytes[i++] = (byte)((LocationID >> 16) % 256); - bytes[i++] = (byte)((LocationID >> 24) % 256); - if(LookAt == null) { Console.WriteLine("Warning: LookAt is null, in " + this.GetType()); } - Array.Copy(LookAt.GetBytes(), 0, bytes, i, 12); i += 12; - bytes[i++] = (byte)(TeleportFlags % 256); - bytes[i++] = (byte)((TeleportFlags >> 8) % 256); - bytes[i++] = (byte)((TeleportFlags >> 16) % 256); - bytes[i++] = (byte)((TeleportFlags >> 24) % 256); - if(Position == null) { Console.WriteLine("Warning: Position is null, in " + this.GetType()); } - Array.Copy(Position.GetBytes(), 0, bytes, i, 12); i += 12; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(LocationID % 256); + bytes[i++] = (byte)((LocationID >> 8) % 256); + bytes[i++] = (byte)((LocationID >> 16) % 256); + bytes[i++] = (byte)((LocationID >> 24) % 256); + if(LookAt == null) { Console.WriteLine("Warning: LookAt is null, in " + this.GetType()); } + Array.Copy(LookAt.GetBytes(), 0, bytes, i, 12); i += 12; + bytes[i++] = (byte)(TeleportFlags % 256); + bytes[i++] = (byte)((TeleportFlags >> 8) % 256); + bytes[i++] = (byte)((TeleportFlags >> 16) % 256); + bytes[i++] = (byte)((TeleportFlags >> 24) % 256); + if(Position == null) { Console.WriteLine("Warning: Position is null, in " + this.GetType()); } + Array.Copy(Position.GetBytes(), 0, bytes, i, 12); i += 12; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Info --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "LocationID: " + LocationID.ToString() + "\n"; - output += "LookAt: " + LookAt.ToString() + "\n"; - output += "TeleportFlags: " + TeleportFlags.ToString() + "\n"; - output += "Position: " + Position.ToString() + "\n"; + { + string output = "-- Info --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "LocationID: " + LocationID.ToString() + "\n"; + output += "LookAt: " + LookAt.ToString() + "\n"; + output += "TeleportFlags: " + TeleportFlags.ToString() + "\n"; + output += "Position: " + Position.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.TeleportLocal - public override PacketType Type { get { return PacketType.TeleportLocal; } } - /// Info block - public InfoBlock Info; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.TeleportLocal + public override PacketType Type { get { return PacketType.TeleportLocal; } } + /// Info block + public InfoBlock Info; + + /// Default constructor public TeleportLocalPacket() - { - Header = new LowHeader(); - Header.ID = 86; - Header.Reliable = true; - Info = new InfoBlock(); + { + Header = new LowHeader(); + Header.ID = 86; + Header.Reliable = true; + Info = new InfoBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public TeleportLocalPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Info = new InfoBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Info = new InfoBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public TeleportLocalPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Info = new InfoBlock(bytes, ref i); + { + Header = head; + Info = new InfoBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Info.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Info.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Info.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Info.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- TeleportLocal ---\n"; - output += Info.ToString() + "\n"; + { + string output = "--- TeleportLocal ---\n"; + output += Info.ToString() + "\n"; return output; } - + } - - /// TeleportLandmarkRequest packet + + /// TeleportLandmarkRequest packet public class TeleportLandmarkRequestPacket : Packet - { - /// Info block + { + /// Info block public class InfoBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - /// LandmarkID field - public LLUUID LandmarkID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + /// LandmarkID field + public LLUUID LandmarkID; + + /// Length of this block serialized in bytes public int Length { get - { - return 48; + { + return 48; } } - - /// Default constructor - public InfoBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public InfoBlock() { } + /// Constructor for building the block from a byte array public InfoBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; - LandmarkID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; + LandmarkID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - if(LandmarkID == null) { Console.WriteLine("Warning: LandmarkID is null, in " + this.GetType()); } - Array.Copy(LandmarkID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + if(LandmarkID == null) { Console.WriteLine("Warning: LandmarkID is null, in " + this.GetType()); } + Array.Copy(LandmarkID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Info --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "LandmarkID: " + LandmarkID.ToString() + "\n"; + { + string output = "-- Info --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "LandmarkID: " + LandmarkID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.TeleportLandmarkRequest - public override PacketType Type { get { return PacketType.TeleportLandmarkRequest; } } - /// Info block - public InfoBlock Info; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.TeleportLandmarkRequest + public override PacketType Type { get { return PacketType.TeleportLandmarkRequest; } } + /// Info block + public InfoBlock Info; + + /// Default constructor public TeleportLandmarkRequestPacket() - { - Header = new LowHeader(); - Header.ID = 87; - Header.Reliable = true; - Header.Zerocoded = true; - Info = new InfoBlock(); + { + Header = new LowHeader(); + Header.ID = 87; + Header.Reliable = true; + Header.Zerocoded = true; + Info = new InfoBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public TeleportLandmarkRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Info = new InfoBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Info = new InfoBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public TeleportLandmarkRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Info = new InfoBlock(bytes, ref i); + { + Header = head; + Info = new InfoBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Info.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Info.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Info.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Info.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- TeleportLandmarkRequest ---\n"; - output += Info.ToString() + "\n"; + { + string output = "--- TeleportLandmarkRequest ---\n"; + output += Info.ToString() + "\n"; return output; } - + } - - /// TeleportProgress packet + + /// TeleportProgress packet public class TeleportProgressPacket : Packet - { - /// Info block + { + /// Info block public class InfoBlock - { - private byte[] _message; - /// Message field + { + private byte[] _message; + /// Message field public byte[] Message - { - get { return _message; } + { + get { return _message; } set - { - if (value == null) { _message = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _message = new byte[value.Length]; Array.Copy(value, _message, value.Length); } + { + if (value == null) { _message = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _message = new byte[value.Length]; Array.Copy(value, _message, value.Length); } } - } - /// TeleportFlags field - public uint TeleportFlags; - - /// Length of this block serialized in bytes + } + /// TeleportFlags field + public uint TeleportFlags; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 4; - if (Message != null) { length += 1 + Message.Length; } - return length; + { + int length = 4; + if (Message != null) { length += 1 + Message.Length; } + return length; } } - - /// Default constructor - public InfoBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public InfoBlock() { } + /// Constructor for building the block from a byte array public InfoBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _message = new byte[length]; - Array.Copy(bytes, i, _message, 0, length); i += length; - TeleportFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + length = (ushort)bytes[i++]; + _message = new byte[length]; + Array.Copy(bytes, i, _message, 0, length); i += length; + TeleportFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(Message == null) { Console.WriteLine("Warning: Message is null, in " + this.GetType()); } - bytes[i++] = (byte)Message.Length; - Array.Copy(Message, 0, bytes, i, Message.Length); i += Message.Length; - bytes[i++] = (byte)(TeleportFlags % 256); - bytes[i++] = (byte)((TeleportFlags >> 8) % 256); - bytes[i++] = (byte)((TeleportFlags >> 16) % 256); - bytes[i++] = (byte)((TeleportFlags >> 24) % 256); + { + if(Message == null) { Console.WriteLine("Warning: Message is null, in " + this.GetType()); } + bytes[i++] = (byte)Message.Length; + Array.Copy(Message, 0, bytes, i, Message.Length); i += Message.Length; + bytes[i++] = (byte)(TeleportFlags % 256); + bytes[i++] = (byte)((TeleportFlags >> 8) % 256); + bytes[i++] = (byte)((TeleportFlags >> 16) % 256); + bytes[i++] = (byte)((TeleportFlags >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Info --\n"; - output += Helpers.FieldToString(Message, "Message") + "\n"; - output += "TeleportFlags: " + TeleportFlags.ToString() + "\n"; + { + string output = "-- Info --\n"; + output += Helpers.FieldToString(Message, "Message") + "\n"; + output += "TeleportFlags: " + TeleportFlags.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.TeleportProgress - public override PacketType Type { get { return PacketType.TeleportProgress; } } - /// Info block - public InfoBlock Info; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.TeleportProgress + public override PacketType Type { get { return PacketType.TeleportProgress; } } + /// Info block + public InfoBlock Info; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public TeleportProgressPacket() - { - Header = new LowHeader(); - Header.ID = 88; - Header.Reliable = true; - Info = new InfoBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 88; + Header.Reliable = true; + Info = new InfoBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public TeleportProgressPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Info = new InfoBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Info = new InfoBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public TeleportProgressPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Info = new InfoBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + Info = new InfoBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Info.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Info.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Info.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Info.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- TeleportProgress ---\n"; - output += Info.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- TeleportProgress ---\n"; + output += Info.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// DataAgentAccessRequest packet + + /// DataAgentAccessRequest packet public class DataAgentAccessRequestPacket : Packet - { - /// Info block + { + /// Info block public class InfoBlock - { - /// LocationPos field - public LLVector3 LocationPos; - /// AgentID field - public LLUUID AgentID; - /// RegionHandle field - public ulong RegionHandle; - /// LocationID field - public uint LocationID; - /// LocationLookAt field - public LLVector3 LocationLookAt; - /// EstateID field - public uint EstateID; - - /// Length of this block serialized in bytes + { + /// LocationPos field + public LLVector3 LocationPos; + /// AgentID field + public LLUUID AgentID; + /// RegionHandle field + public ulong RegionHandle; + /// LocationID field + public uint LocationID; + /// LocationLookAt field + public LLVector3 LocationLookAt; + /// EstateID field + public uint EstateID; + + /// Length of this block serialized in bytes public int Length { get - { - return 56; + { + return 56; } } - - /// Default constructor - public InfoBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public InfoBlock() { } + /// Constructor for building the block from a byte array public InfoBlock(byte[] bytes, ref int i) - { + { try - { - LocationPos = new LLVector3(bytes, i); i += 12; - AgentID = new LLUUID(bytes, i); i += 16; - RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); - LocationID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - LocationLookAt = new LLVector3(bytes, i); i += 12; - EstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + LocationPos = new LLVector3(bytes, i); i += 12; + AgentID = new LLUUID(bytes, i); i += 16; + RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + LocationID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + LocationLookAt = new LLVector3(bytes, i); i += 12; + EstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(LocationPos == null) { Console.WriteLine("Warning: LocationPos is null, in " + this.GetType()); } - Array.Copy(LocationPos.GetBytes(), 0, bytes, i, 12); i += 12; - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(RegionHandle % 256); - bytes[i++] = (byte)((RegionHandle >> 8) % 256); - bytes[i++] = (byte)((RegionHandle >> 16) % 256); - bytes[i++] = (byte)((RegionHandle >> 24) % 256); - bytes[i++] = (byte)((RegionHandle >> 32) % 256); - bytes[i++] = (byte)((RegionHandle >> 40) % 256); - bytes[i++] = (byte)((RegionHandle >> 48) % 256); - bytes[i++] = (byte)((RegionHandle >> 56) % 256); - bytes[i++] = (byte)(LocationID % 256); - bytes[i++] = (byte)((LocationID >> 8) % 256); - bytes[i++] = (byte)((LocationID >> 16) % 256); - bytes[i++] = (byte)((LocationID >> 24) % 256); - if(LocationLookAt == null) { Console.WriteLine("Warning: LocationLookAt is null, in " + this.GetType()); } - Array.Copy(LocationLookAt.GetBytes(), 0, bytes, i, 12); i += 12; - bytes[i++] = (byte)(EstateID % 256); - bytes[i++] = (byte)((EstateID >> 8) % 256); - bytes[i++] = (byte)((EstateID >> 16) % 256); - bytes[i++] = (byte)((EstateID >> 24) % 256); + { + if(LocationPos == null) { Console.WriteLine("Warning: LocationPos is null, in " + this.GetType()); } + Array.Copy(LocationPos.GetBytes(), 0, bytes, i, 12); i += 12; + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(RegionHandle % 256); + bytes[i++] = (byte)((RegionHandle >> 8) % 256); + bytes[i++] = (byte)((RegionHandle >> 16) % 256); + bytes[i++] = (byte)((RegionHandle >> 24) % 256); + bytes[i++] = (byte)((RegionHandle >> 32) % 256); + bytes[i++] = (byte)((RegionHandle >> 40) % 256); + bytes[i++] = (byte)((RegionHandle >> 48) % 256); + bytes[i++] = (byte)((RegionHandle >> 56) % 256); + bytes[i++] = (byte)(LocationID % 256); + bytes[i++] = (byte)((LocationID >> 8) % 256); + bytes[i++] = (byte)((LocationID >> 16) % 256); + bytes[i++] = (byte)((LocationID >> 24) % 256); + if(LocationLookAt == null) { Console.WriteLine("Warning: LocationLookAt is null, in " + this.GetType()); } + Array.Copy(LocationLookAt.GetBytes(), 0, bytes, i, 12); i += 12; + bytes[i++] = (byte)(EstateID % 256); + bytes[i++] = (byte)((EstateID >> 8) % 256); + bytes[i++] = (byte)((EstateID >> 16) % 256); + bytes[i++] = (byte)((EstateID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Info --\n"; - output += "LocationPos: " + LocationPos.ToString() + "\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "RegionHandle: " + RegionHandle.ToString() + "\n"; - output += "LocationID: " + LocationID.ToString() + "\n"; - output += "LocationLookAt: " + LocationLookAt.ToString() + "\n"; - output += "EstateID: " + EstateID.ToString() + "\n"; + { + string output = "-- Info --\n"; + output += "LocationPos: " + LocationPos.ToString() + "\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "RegionHandle: " + RegionHandle.ToString() + "\n"; + output += "LocationID: " + LocationID.ToString() + "\n"; + output += "LocationLookAt: " + LocationLookAt.ToString() + "\n"; + output += "EstateID: " + EstateID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.DataAgentAccessRequest - public override PacketType Type { get { return PacketType.DataAgentAccessRequest; } } - /// Info block - public InfoBlock Info; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.DataAgentAccessRequest + public override PacketType Type { get { return PacketType.DataAgentAccessRequest; } } + /// Info block + public InfoBlock Info; + + /// Default constructor public DataAgentAccessRequestPacket() - { - Header = new LowHeader(); - Header.ID = 89; - Header.Reliable = true; - Info = new InfoBlock(); + { + Header = new LowHeader(); + Header.ID = 89; + Header.Reliable = true; + Info = new InfoBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public DataAgentAccessRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Info = new InfoBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Info = new InfoBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public DataAgentAccessRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Info = new InfoBlock(bytes, ref i); + { + Header = head; + Info = new InfoBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Info.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Info.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Info.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Info.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- DataAgentAccessRequest ---\n"; - output += Info.ToString() + "\n"; + { + string output = "--- DataAgentAccessRequest ---\n"; + output += Info.ToString() + "\n"; return output; } - + } - - /// DataAgentAccessReply packet + + /// DataAgentAccessReply packet public class DataAgentAccessReplyPacket : Packet - { - /// Info block + { + /// Info block public class InfoBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public InfoBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public InfoBlock() { } + /// Constructor for building the block from a byte array public InfoBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Info --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- Info --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.DataAgentAccessReply - public override PacketType Type { get { return PacketType.DataAgentAccessReply; } } - /// Info block - public InfoBlock Info; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.DataAgentAccessReply + public override PacketType Type { get { return PacketType.DataAgentAccessReply; } } + /// Info block + public InfoBlock Info; + + /// Default constructor public DataAgentAccessReplyPacket() - { - Header = new LowHeader(); - Header.ID = 90; - Header.Reliable = true; - Info = new InfoBlock(); + { + Header = new LowHeader(); + Header.ID = 90; + Header.Reliable = true; + Info = new InfoBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public DataAgentAccessReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Info = new InfoBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Info = new InfoBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public DataAgentAccessReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Info = new InfoBlock(bytes, ref i); + { + Header = head; + Info = new InfoBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Info.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Info.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Info.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Info.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- DataAgentAccessReply ---\n"; - output += Info.ToString() + "\n"; + { + string output = "--- DataAgentAccessReply ---\n"; + output += Info.ToString() + "\n"; return output; } - + } - - /// DataHomeLocationRequest packet + + /// DataHomeLocationRequest packet public class DataHomeLocationRequestPacket : Packet - { - /// Info block + { + /// Info block public class InfoBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public InfoBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public InfoBlock() { } + /// Constructor for building the block from a byte array public InfoBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Info --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- Info --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.DataHomeLocationRequest - public override PacketType Type { get { return PacketType.DataHomeLocationRequest; } } - /// Info block - public InfoBlock Info; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.DataHomeLocationRequest + public override PacketType Type { get { return PacketType.DataHomeLocationRequest; } } + /// Info block + public InfoBlock Info; + + /// Default constructor public DataHomeLocationRequestPacket() - { - Header = new LowHeader(); - Header.ID = 91; - Header.Reliable = true; - Header.Zerocoded = true; - Info = new InfoBlock(); + { + Header = new LowHeader(); + Header.ID = 91; + Header.Reliable = true; + Header.Zerocoded = true; + Info = new InfoBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public DataHomeLocationRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Info = new InfoBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Info = new InfoBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public DataHomeLocationRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Info = new InfoBlock(bytes, ref i); + { + Header = head; + Info = new InfoBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Info.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Info.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Info.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Info.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- DataHomeLocationRequest ---\n"; - output += Info.ToString() + "\n"; + { + string output = "--- DataHomeLocationRequest ---\n"; + output += Info.ToString() + "\n"; return output; } - + } - - /// DataHomeLocationReply packet + + /// DataHomeLocationReply packet public class DataHomeLocationReplyPacket : Packet - { - /// Info block + { + /// Info block public class InfoBlock - { - /// AgentID field - public LLUUID AgentID; - /// RegionHandle field - public ulong RegionHandle; - /// LookAt field - public LLVector3 LookAt; - /// Position field - public LLVector3 Position; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// RegionHandle field + public ulong RegionHandle; + /// LookAt field + public LLVector3 LookAt; + /// Position field + public LLVector3 Position; + + /// Length of this block serialized in bytes public int Length { get - { - return 48; + { + return 48; } } - - /// Default constructor - public InfoBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public InfoBlock() { } + /// Constructor for building the block from a byte array public InfoBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); - LookAt = new LLVector3(bytes, i); i += 12; - Position = new LLVector3(bytes, i); i += 12; + { + AgentID = new LLUUID(bytes, i); i += 16; + RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + LookAt = new LLVector3(bytes, i); i += 12; + Position = new LLVector3(bytes, i); i += 12; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(RegionHandle % 256); - bytes[i++] = (byte)((RegionHandle >> 8) % 256); - bytes[i++] = (byte)((RegionHandle >> 16) % 256); - bytes[i++] = (byte)((RegionHandle >> 24) % 256); - bytes[i++] = (byte)((RegionHandle >> 32) % 256); - bytes[i++] = (byte)((RegionHandle >> 40) % 256); - bytes[i++] = (byte)((RegionHandle >> 48) % 256); - bytes[i++] = (byte)((RegionHandle >> 56) % 256); - if(LookAt == null) { Console.WriteLine("Warning: LookAt is null, in " + this.GetType()); } - Array.Copy(LookAt.GetBytes(), 0, bytes, i, 12); i += 12; - if(Position == null) { Console.WriteLine("Warning: Position is null, in " + this.GetType()); } - Array.Copy(Position.GetBytes(), 0, bytes, i, 12); i += 12; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(RegionHandle % 256); + bytes[i++] = (byte)((RegionHandle >> 8) % 256); + bytes[i++] = (byte)((RegionHandle >> 16) % 256); + bytes[i++] = (byte)((RegionHandle >> 24) % 256); + bytes[i++] = (byte)((RegionHandle >> 32) % 256); + bytes[i++] = (byte)((RegionHandle >> 40) % 256); + bytes[i++] = (byte)((RegionHandle >> 48) % 256); + bytes[i++] = (byte)((RegionHandle >> 56) % 256); + if(LookAt == null) { Console.WriteLine("Warning: LookAt is null, in " + this.GetType()); } + Array.Copy(LookAt.GetBytes(), 0, bytes, i, 12); i += 12; + if(Position == null) { Console.WriteLine("Warning: Position is null, in " + this.GetType()); } + Array.Copy(Position.GetBytes(), 0, bytes, i, 12); i += 12; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Info --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "RegionHandle: " + RegionHandle.ToString() + "\n"; - output += "LookAt: " + LookAt.ToString() + "\n"; - output += "Position: " + Position.ToString() + "\n"; + { + string output = "-- Info --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "RegionHandle: " + RegionHandle.ToString() + "\n"; + output += "LookAt: " + LookAt.ToString() + "\n"; + output += "Position: " + Position.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.DataHomeLocationReply - public override PacketType Type { get { return PacketType.DataHomeLocationReply; } } - /// Info block - public InfoBlock Info; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.DataHomeLocationReply + public override PacketType Type { get { return PacketType.DataHomeLocationReply; } } + /// Info block + public InfoBlock Info; + + /// Default constructor public DataHomeLocationReplyPacket() - { - Header = new LowHeader(); - Header.ID = 92; - Header.Reliable = true; - Info = new InfoBlock(); + { + Header = new LowHeader(); + Header.ID = 92; + Header.Reliable = true; + Info = new InfoBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public DataHomeLocationReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Info = new InfoBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Info = new InfoBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public DataHomeLocationReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Info = new InfoBlock(bytes, ref i); + { + Header = head; + Info = new InfoBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Info.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Info.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Info.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Info.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- DataHomeLocationReply ---\n"; - output += Info.ToString() + "\n"; + { + string output = "--- DataHomeLocationReply ---\n"; + output += Info.ToString() + "\n"; return output; } - + } - - /// SpaceLocationTeleportRequest packet + + /// SpaceLocationTeleportRequest packet public class SpaceLocationTeleportRequestPacket : Packet - { - /// Info block + { + /// Info block public class InfoBlock - { - /// AgentID field - public LLUUID AgentID; - /// TravelAccess field - public byte TravelAccess; - /// SessionID field - public LLUUID SessionID; - /// RegionHandle field - public ulong RegionHandle; - /// CircuitCode field - public uint CircuitCode; - /// LookAt field - public LLVector3 LookAt; - /// ParentEstateID field - public uint ParentEstateID; - /// TeleportFlags field - public uint TeleportFlags; - /// Position field - public LLVector3 Position; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// TravelAccess field + public byte TravelAccess; + /// SessionID field + public LLUUID SessionID; + /// RegionHandle field + public ulong RegionHandle; + /// CircuitCode field + public uint CircuitCode; + /// LookAt field + public LLVector3 LookAt; + /// ParentEstateID field + public uint ParentEstateID; + /// TeleportFlags field + public uint TeleportFlags; + /// Position field + public LLVector3 Position; + + /// Length of this block serialized in bytes public int Length { get - { - return 77; + { + return 77; } } - - /// Default constructor - public InfoBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public InfoBlock() { } + /// Constructor for building the block from a byte array public InfoBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - TravelAccess = (byte)bytes[i++]; - SessionID = new LLUUID(bytes, i); i += 16; - RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); - CircuitCode = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - LookAt = new LLVector3(bytes, i); i += 12; - ParentEstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - TeleportFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Position = new LLVector3(bytes, i); i += 12; + { + AgentID = new LLUUID(bytes, i); i += 16; + TravelAccess = (byte)bytes[i++]; + SessionID = new LLUUID(bytes, i); i += 16; + RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + CircuitCode = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + LookAt = new LLVector3(bytes, i); i += 12; + ParentEstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + TeleportFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Position = new LLVector3(bytes, i); i += 12; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = TravelAccess; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(RegionHandle % 256); - bytes[i++] = (byte)((RegionHandle >> 8) % 256); - bytes[i++] = (byte)((RegionHandle >> 16) % 256); - bytes[i++] = (byte)((RegionHandle >> 24) % 256); - bytes[i++] = (byte)((RegionHandle >> 32) % 256); - bytes[i++] = (byte)((RegionHandle >> 40) % 256); - bytes[i++] = (byte)((RegionHandle >> 48) % 256); - bytes[i++] = (byte)((RegionHandle >> 56) % 256); - bytes[i++] = (byte)(CircuitCode % 256); - bytes[i++] = (byte)((CircuitCode >> 8) % 256); - bytes[i++] = (byte)((CircuitCode >> 16) % 256); - bytes[i++] = (byte)((CircuitCode >> 24) % 256); - if(LookAt == null) { Console.WriteLine("Warning: LookAt is null, in " + this.GetType()); } - Array.Copy(LookAt.GetBytes(), 0, bytes, i, 12); i += 12; - bytes[i++] = (byte)(ParentEstateID % 256); - bytes[i++] = (byte)((ParentEstateID >> 8) % 256); - bytes[i++] = (byte)((ParentEstateID >> 16) % 256); - bytes[i++] = (byte)((ParentEstateID >> 24) % 256); - bytes[i++] = (byte)(TeleportFlags % 256); - bytes[i++] = (byte)((TeleportFlags >> 8) % 256); - bytes[i++] = (byte)((TeleportFlags >> 16) % 256); - bytes[i++] = (byte)((TeleportFlags >> 24) % 256); - if(Position == null) { Console.WriteLine("Warning: Position is null, in " + this.GetType()); } - Array.Copy(Position.GetBytes(), 0, bytes, i, 12); i += 12; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = TravelAccess; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(RegionHandle % 256); + bytes[i++] = (byte)((RegionHandle >> 8) % 256); + bytes[i++] = (byte)((RegionHandle >> 16) % 256); + bytes[i++] = (byte)((RegionHandle >> 24) % 256); + bytes[i++] = (byte)((RegionHandle >> 32) % 256); + bytes[i++] = (byte)((RegionHandle >> 40) % 256); + bytes[i++] = (byte)((RegionHandle >> 48) % 256); + bytes[i++] = (byte)((RegionHandle >> 56) % 256); + bytes[i++] = (byte)(CircuitCode % 256); + bytes[i++] = (byte)((CircuitCode >> 8) % 256); + bytes[i++] = (byte)((CircuitCode >> 16) % 256); + bytes[i++] = (byte)((CircuitCode >> 24) % 256); + if(LookAt == null) { Console.WriteLine("Warning: LookAt is null, in " + this.GetType()); } + Array.Copy(LookAt.GetBytes(), 0, bytes, i, 12); i += 12; + bytes[i++] = (byte)(ParentEstateID % 256); + bytes[i++] = (byte)((ParentEstateID >> 8) % 256); + bytes[i++] = (byte)((ParentEstateID >> 16) % 256); + bytes[i++] = (byte)((ParentEstateID >> 24) % 256); + bytes[i++] = (byte)(TeleportFlags % 256); + bytes[i++] = (byte)((TeleportFlags >> 8) % 256); + bytes[i++] = (byte)((TeleportFlags >> 16) % 256); + bytes[i++] = (byte)((TeleportFlags >> 24) % 256); + if(Position == null) { Console.WriteLine("Warning: Position is null, in " + this.GetType()); } + Array.Copy(Position.GetBytes(), 0, bytes, i, 12); i += 12; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Info --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "TravelAccess: " + TravelAccess.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "RegionHandle: " + RegionHandle.ToString() + "\n"; - output += "CircuitCode: " + CircuitCode.ToString() + "\n"; - output += "LookAt: " + LookAt.ToString() + "\n"; - output += "ParentEstateID: " + ParentEstateID.ToString() + "\n"; - output += "TeleportFlags: " + TeleportFlags.ToString() + "\n"; - output += "Position: " + Position.ToString() + "\n"; + { + string output = "-- Info --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "TravelAccess: " + TravelAccess.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "RegionHandle: " + RegionHandle.ToString() + "\n"; + output += "CircuitCode: " + CircuitCode.ToString() + "\n"; + output += "LookAt: " + LookAt.ToString() + "\n"; + output += "ParentEstateID: " + ParentEstateID.ToString() + "\n"; + output += "TeleportFlags: " + TeleportFlags.ToString() + "\n"; + output += "Position: " + Position.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.SpaceLocationTeleportRequest - public override PacketType Type { get { return PacketType.SpaceLocationTeleportRequest; } } - /// Info block - public InfoBlock Info; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.SpaceLocationTeleportRequest + public override PacketType Type { get { return PacketType.SpaceLocationTeleportRequest; } } + /// Info block + public InfoBlock Info; + + /// Default constructor public SpaceLocationTeleportRequestPacket() - { - Header = new LowHeader(); - Header.ID = 93; - Header.Reliable = true; - Info = new InfoBlock(); + { + Header = new LowHeader(); + Header.ID = 93; + Header.Reliable = true; + Info = new InfoBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public SpaceLocationTeleportRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Info = new InfoBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Info = new InfoBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public SpaceLocationTeleportRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Info = new InfoBlock(bytes, ref i); + { + Header = head; + Info = new InfoBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Info.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Info.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Info.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Info.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- SpaceLocationTeleportRequest ---\n"; - output += Info.ToString() + "\n"; + { + string output = "--- SpaceLocationTeleportRequest ---\n"; + output += Info.ToString() + "\n"; return output; } - + } - - /// SpaceLocationTeleportReply packet + + /// SpaceLocationTeleportReply packet public class SpaceLocationTeleportReplyPacket : Packet - { - /// Info block + { + /// Info block public class InfoBlock - { - private byte[] _simname; - /// SimName field + { + private byte[] _simname; + /// SimName field public byte[] SimName - { - get { return _simname; } + { + get { return _simname; } set - { - if (value == null) { _simname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _simname = new byte[value.Length]; Array.Copy(value, _simname, value.Length); } + { + if (value == null) { _simname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _simname = new byte[value.Length]; Array.Copy(value, _simname, value.Length); } } - } - /// AgentID field - public LLUUID AgentID; - /// SimPort field - public ushort SimPort; - /// RegionHandle field - public ulong RegionHandle; - /// LocationID field - public uint LocationID; - /// SimAccess field - public byte SimAccess; - /// LookAt field - public LLVector3 LookAt; - /// SimIP field - public uint SimIP; - /// TeleportFlags field - public uint TeleportFlags; - /// Position field - public LLVector3 Position; - - /// Length of this block serialized in bytes + } + /// AgentID field + public LLUUID AgentID; + /// SimPort field + public ushort SimPort; + /// RegionHandle field + public ulong RegionHandle; + /// LocationID field + public uint LocationID; + /// SimAccess field + public byte SimAccess; + /// LookAt field + public LLVector3 LookAt; + /// SimIP field + public uint SimIP; + /// TeleportFlags field + public uint TeleportFlags; + /// Position field + public LLVector3 Position; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 63; - if (SimName != null) { length += 1 + SimName.Length; } - return length; + { + int length = 63; + if (SimName != null) { length += 1 + SimName.Length; } + return length; } } - - /// Default constructor - public InfoBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public InfoBlock() { } + /// Constructor for building the block from a byte array public InfoBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _simname = new byte[length]; - Array.Copy(bytes, i, _simname, 0, length); i += length; - AgentID = new LLUUID(bytes, i); i += 16; - SimPort = (ushort)((bytes[i++] << 8) + bytes[i++]); - RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); - LocationID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - SimAccess = (byte)bytes[i++]; - LookAt = new LLVector3(bytes, i); i += 12; - SimIP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - TeleportFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Position = new LLVector3(bytes, i); i += 12; + { + length = (ushort)bytes[i++]; + _simname = new byte[length]; + Array.Copy(bytes, i, _simname, 0, length); i += length; + AgentID = new LLUUID(bytes, i); i += 16; + SimPort = (ushort)((bytes[i++] << 8) + bytes[i++]); + RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + LocationID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + SimAccess = (byte)bytes[i++]; + LookAt = new LLVector3(bytes, i); i += 12; + SimIP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + TeleportFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Position = new LLVector3(bytes, i); i += 12; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(SimName == null) { Console.WriteLine("Warning: SimName is null, in " + this.GetType()); } - bytes[i++] = (byte)SimName.Length; - Array.Copy(SimName, 0, bytes, i, SimName.Length); i += SimName.Length; - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((SimPort >> 8) % 256); - bytes[i++] = (byte)(SimPort % 256); - bytes[i++] = (byte)(RegionHandle % 256); - bytes[i++] = (byte)((RegionHandle >> 8) % 256); - bytes[i++] = (byte)((RegionHandle >> 16) % 256); - bytes[i++] = (byte)((RegionHandle >> 24) % 256); - bytes[i++] = (byte)((RegionHandle >> 32) % 256); - bytes[i++] = (byte)((RegionHandle >> 40) % 256); - bytes[i++] = (byte)((RegionHandle >> 48) % 256); - bytes[i++] = (byte)((RegionHandle >> 56) % 256); - bytes[i++] = (byte)(LocationID % 256); - bytes[i++] = (byte)((LocationID >> 8) % 256); - bytes[i++] = (byte)((LocationID >> 16) % 256); - bytes[i++] = (byte)((LocationID >> 24) % 256); - bytes[i++] = SimAccess; - if(LookAt == null) { Console.WriteLine("Warning: LookAt is null, in " + this.GetType()); } - Array.Copy(LookAt.GetBytes(), 0, bytes, i, 12); i += 12; - bytes[i++] = (byte)(SimIP % 256); - bytes[i++] = (byte)((SimIP >> 8) % 256); - bytes[i++] = (byte)((SimIP >> 16) % 256); - bytes[i++] = (byte)((SimIP >> 24) % 256); - bytes[i++] = (byte)(TeleportFlags % 256); - bytes[i++] = (byte)((TeleportFlags >> 8) % 256); - bytes[i++] = (byte)((TeleportFlags >> 16) % 256); - bytes[i++] = (byte)((TeleportFlags >> 24) % 256); - if(Position == null) { Console.WriteLine("Warning: Position is null, in " + this.GetType()); } - Array.Copy(Position.GetBytes(), 0, bytes, i, 12); i += 12; + { + if(SimName == null) { Console.WriteLine("Warning: SimName is null, in " + this.GetType()); } + bytes[i++] = (byte)SimName.Length; + Array.Copy(SimName, 0, bytes, i, SimName.Length); i += SimName.Length; + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((SimPort >> 8) % 256); + bytes[i++] = (byte)(SimPort % 256); + bytes[i++] = (byte)(RegionHandle % 256); + bytes[i++] = (byte)((RegionHandle >> 8) % 256); + bytes[i++] = (byte)((RegionHandle >> 16) % 256); + bytes[i++] = (byte)((RegionHandle >> 24) % 256); + bytes[i++] = (byte)((RegionHandle >> 32) % 256); + bytes[i++] = (byte)((RegionHandle >> 40) % 256); + bytes[i++] = (byte)((RegionHandle >> 48) % 256); + bytes[i++] = (byte)((RegionHandle >> 56) % 256); + bytes[i++] = (byte)(LocationID % 256); + bytes[i++] = (byte)((LocationID >> 8) % 256); + bytes[i++] = (byte)((LocationID >> 16) % 256); + bytes[i++] = (byte)((LocationID >> 24) % 256); + bytes[i++] = SimAccess; + if(LookAt == null) { Console.WriteLine("Warning: LookAt is null, in " + this.GetType()); } + Array.Copy(LookAt.GetBytes(), 0, bytes, i, 12); i += 12; + bytes[i++] = (byte)(SimIP % 256); + bytes[i++] = (byte)((SimIP >> 8) % 256); + bytes[i++] = (byte)((SimIP >> 16) % 256); + bytes[i++] = (byte)((SimIP >> 24) % 256); + bytes[i++] = (byte)(TeleportFlags % 256); + bytes[i++] = (byte)((TeleportFlags >> 8) % 256); + bytes[i++] = (byte)((TeleportFlags >> 16) % 256); + bytes[i++] = (byte)((TeleportFlags >> 24) % 256); + if(Position == null) { Console.WriteLine("Warning: Position is null, in " + this.GetType()); } + Array.Copy(Position.GetBytes(), 0, bytes, i, 12); i += 12; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Info --\n"; - output += Helpers.FieldToString(SimName, "SimName") + "\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SimPort: " + SimPort.ToString() + "\n"; - output += "RegionHandle: " + RegionHandle.ToString() + "\n"; - output += "LocationID: " + LocationID.ToString() + "\n"; - output += "SimAccess: " + SimAccess.ToString() + "\n"; - output += "LookAt: " + LookAt.ToString() + "\n"; - output += "SimIP: " + SimIP.ToString() + "\n"; - output += "TeleportFlags: " + TeleportFlags.ToString() + "\n"; - output += "Position: " + Position.ToString() + "\n"; + { + string output = "-- Info --\n"; + output += Helpers.FieldToString(SimName, "SimName") + "\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SimPort: " + SimPort.ToString() + "\n"; + output += "RegionHandle: " + RegionHandle.ToString() + "\n"; + output += "LocationID: " + LocationID.ToString() + "\n"; + output += "SimAccess: " + SimAccess.ToString() + "\n"; + output += "LookAt: " + LookAt.ToString() + "\n"; + output += "SimIP: " + SimIP.ToString() + "\n"; + output += "TeleportFlags: " + TeleportFlags.ToString() + "\n"; + output += "Position: " + Position.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.SpaceLocationTeleportReply - public override PacketType Type { get { return PacketType.SpaceLocationTeleportReply; } } - /// Info block - public InfoBlock Info; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.SpaceLocationTeleportReply + public override PacketType Type { get { return PacketType.SpaceLocationTeleportReply; } } + /// Info block + public InfoBlock Info; + + /// Default constructor public SpaceLocationTeleportReplyPacket() - { - Header = new LowHeader(); - Header.ID = 94; - Header.Reliable = true; - Info = new InfoBlock(); + { + Header = new LowHeader(); + Header.ID = 94; + Header.Reliable = true; + Info = new InfoBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public SpaceLocationTeleportReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Info = new InfoBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Info = new InfoBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public SpaceLocationTeleportReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Info = new InfoBlock(bytes, ref i); + { + Header = head; + Info = new InfoBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Info.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Info.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Info.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Info.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- SpaceLocationTeleportReply ---\n"; - output += Info.ToString() + "\n"; + { + string output = "--- SpaceLocationTeleportReply ---\n"; + output += Info.ToString() + "\n"; return output; } - + } - - /// TeleportFinish packet + + /// TeleportFinish packet public class TeleportFinishPacket : Packet - { - /// Info block + { + /// Info block public class InfoBlock - { - private byte[] _seedcapability; - /// SeedCapability field + { + private byte[] _seedcapability; + /// SeedCapability field public byte[] SeedCapability - { - get { return _seedcapability; } + { + get { return _seedcapability; } set - { - if (value == null) { _seedcapability = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _seedcapability = new byte[value.Length]; Array.Copy(value, _seedcapability, value.Length); } + { + if (value == null) { _seedcapability = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _seedcapability = new byte[value.Length]; Array.Copy(value, _seedcapability, value.Length); } } - } - /// AgentID field - public LLUUID AgentID; - /// SimPort field - public ushort SimPort; - /// RegionHandle field - public ulong RegionHandle; - /// LocationID field - public uint LocationID; - /// SimAccess field - public byte SimAccess; - /// SimIP field - public uint SimIP; - /// TeleportFlags field - public uint TeleportFlags; - - /// Length of this block serialized in bytes + } + /// AgentID field + public LLUUID AgentID; + /// SimPort field + public ushort SimPort; + /// RegionHandle field + public ulong RegionHandle; + /// LocationID field + public uint LocationID; + /// SimAccess field + public byte SimAccess; + /// SimIP field + public uint SimIP; + /// TeleportFlags field + public uint TeleportFlags; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 39; - if (SeedCapability != null) { length += 2 + SeedCapability.Length; } - return length; + { + int length = 39; + if (SeedCapability != null) { length += 2 + SeedCapability.Length; } + return length; } } - - /// Default constructor - public InfoBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public InfoBlock() { } + /// Constructor for building the block from a byte array public InfoBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _seedcapability = new byte[length]; - Array.Copy(bytes, i, _seedcapability, 0, length); i += length; - AgentID = new LLUUID(bytes, i); i += 16; - SimPort = (ushort)((bytes[i++] << 8) + bytes[i++]); - RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); - LocationID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - SimAccess = (byte)bytes[i++]; - SimIP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - TeleportFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _seedcapability = new byte[length]; + Array.Copy(bytes, i, _seedcapability, 0, length); i += length; + AgentID = new LLUUID(bytes, i); i += 16; + SimPort = (ushort)((bytes[i++] << 8) + bytes[i++]); + RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + LocationID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + SimAccess = (byte)bytes[i++]; + SimIP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + TeleportFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(SeedCapability == null) { Console.WriteLine("Warning: SeedCapability is null, in " + this.GetType()); } - bytes[i++] = (byte)(SeedCapability.Length % 256); - bytes[i++] = (byte)((SeedCapability.Length >> 8) % 256); - Array.Copy(SeedCapability, 0, bytes, i, SeedCapability.Length); i += SeedCapability.Length; - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((SimPort >> 8) % 256); - bytes[i++] = (byte)(SimPort % 256); - bytes[i++] = (byte)(RegionHandle % 256); - bytes[i++] = (byte)((RegionHandle >> 8) % 256); - bytes[i++] = (byte)((RegionHandle >> 16) % 256); - bytes[i++] = (byte)((RegionHandle >> 24) % 256); - bytes[i++] = (byte)((RegionHandle >> 32) % 256); - bytes[i++] = (byte)((RegionHandle >> 40) % 256); - bytes[i++] = (byte)((RegionHandle >> 48) % 256); - bytes[i++] = (byte)((RegionHandle >> 56) % 256); - bytes[i++] = (byte)(LocationID % 256); - bytes[i++] = (byte)((LocationID >> 8) % 256); - bytes[i++] = (byte)((LocationID >> 16) % 256); - bytes[i++] = (byte)((LocationID >> 24) % 256); - bytes[i++] = SimAccess; - bytes[i++] = (byte)(SimIP % 256); - bytes[i++] = (byte)((SimIP >> 8) % 256); - bytes[i++] = (byte)((SimIP >> 16) % 256); - bytes[i++] = (byte)((SimIP >> 24) % 256); - bytes[i++] = (byte)(TeleportFlags % 256); - bytes[i++] = (byte)((TeleportFlags >> 8) % 256); - bytes[i++] = (byte)((TeleportFlags >> 16) % 256); - bytes[i++] = (byte)((TeleportFlags >> 24) % 256); + { + if(SeedCapability == null) { Console.WriteLine("Warning: SeedCapability is null, in " + this.GetType()); } + bytes[i++] = (byte)(SeedCapability.Length % 256); + bytes[i++] = (byte)((SeedCapability.Length >> 8) % 256); + Array.Copy(SeedCapability, 0, bytes, i, SeedCapability.Length); i += SeedCapability.Length; + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((SimPort >> 8) % 256); + bytes[i++] = (byte)(SimPort % 256); + bytes[i++] = (byte)(RegionHandle % 256); + bytes[i++] = (byte)((RegionHandle >> 8) % 256); + bytes[i++] = (byte)((RegionHandle >> 16) % 256); + bytes[i++] = (byte)((RegionHandle >> 24) % 256); + bytes[i++] = (byte)((RegionHandle >> 32) % 256); + bytes[i++] = (byte)((RegionHandle >> 40) % 256); + bytes[i++] = (byte)((RegionHandle >> 48) % 256); + bytes[i++] = (byte)((RegionHandle >> 56) % 256); + bytes[i++] = (byte)(LocationID % 256); + bytes[i++] = (byte)((LocationID >> 8) % 256); + bytes[i++] = (byte)((LocationID >> 16) % 256); + bytes[i++] = (byte)((LocationID >> 24) % 256); + bytes[i++] = SimAccess; + bytes[i++] = (byte)(SimIP % 256); + bytes[i++] = (byte)((SimIP >> 8) % 256); + bytes[i++] = (byte)((SimIP >> 16) % 256); + bytes[i++] = (byte)((SimIP >> 24) % 256); + bytes[i++] = (byte)(TeleportFlags % 256); + bytes[i++] = (byte)((TeleportFlags >> 8) % 256); + bytes[i++] = (byte)((TeleportFlags >> 16) % 256); + bytes[i++] = (byte)((TeleportFlags >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Info --\n"; - output += Helpers.FieldToString(SeedCapability, "SeedCapability") + "\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SimPort: " + SimPort.ToString() + "\n"; - output += "RegionHandle: " + RegionHandle.ToString() + "\n"; - output += "LocationID: " + LocationID.ToString() + "\n"; - output += "SimAccess: " + SimAccess.ToString() + "\n"; - output += "SimIP: " + SimIP.ToString() + "\n"; - output += "TeleportFlags: " + TeleportFlags.ToString() + "\n"; + { + string output = "-- Info --\n"; + output += Helpers.FieldToString(SeedCapability, "SeedCapability") + "\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SimPort: " + SimPort.ToString() + "\n"; + output += "RegionHandle: " + RegionHandle.ToString() + "\n"; + output += "LocationID: " + LocationID.ToString() + "\n"; + output += "SimAccess: " + SimAccess.ToString() + "\n"; + output += "SimIP: " + SimIP.ToString() + "\n"; + output += "TeleportFlags: " + TeleportFlags.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.TeleportFinish - public override PacketType Type { get { return PacketType.TeleportFinish; } } - /// Info block - public InfoBlock Info; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.TeleportFinish + public override PacketType Type { get { return PacketType.TeleportFinish; } } + /// Info block + public InfoBlock Info; + + /// Default constructor public TeleportFinishPacket() - { - Header = new LowHeader(); - Header.ID = 95; - Header.Reliable = true; - Info = new InfoBlock(); + { + Header = new LowHeader(); + Header.ID = 95; + Header.Reliable = true; + Info = new InfoBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public TeleportFinishPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Info = new InfoBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Info = new InfoBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public TeleportFinishPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Info = new InfoBlock(bytes, ref i); + { + Header = head; + Info = new InfoBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Info.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Info.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Info.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Info.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- TeleportFinish ---\n"; - output += Info.ToString() + "\n"; + { + string output = "--- TeleportFinish ---\n"; + output += Info.ToString() + "\n"; return output; } - + } - - /// StartLure packet + + /// StartLure packet public class StartLurePacket : Packet - { - /// Info block + { + /// Info block public class InfoBlock - { - private byte[] _message; - /// Message field + { + private byte[] _message; + /// Message field public byte[] Message - { - get { return _message; } + { + get { return _message; } set - { - if (value == null) { _message = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _message = new byte[value.Length]; Array.Copy(value, _message, value.Length); } + { + if (value == null) { _message = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _message = new byte[value.Length]; Array.Copy(value, _message, value.Length); } } - } - /// TargetID field - public LLUUID TargetID; - /// LureType field - public byte LureType; - - /// Length of this block serialized in bytes + } + /// TargetID field + public LLUUID TargetID; + /// LureType field + public byte LureType; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 17; - if (Message != null) { length += 1 + Message.Length; } - return length; + { + int length = 17; + if (Message != null) { length += 1 + Message.Length; } + return length; } } - - /// Default constructor - public InfoBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public InfoBlock() { } + /// Constructor for building the block from a byte array public InfoBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _message = new byte[length]; - Array.Copy(bytes, i, _message, 0, length); i += length; - TargetID = new LLUUID(bytes, i); i += 16; - LureType = (byte)bytes[i++]; + { + length = (ushort)bytes[i++]; + _message = new byte[length]; + Array.Copy(bytes, i, _message, 0, length); i += length; + TargetID = new LLUUID(bytes, i); i += 16; + LureType = (byte)bytes[i++]; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(Message == null) { Console.WriteLine("Warning: Message is null, in " + this.GetType()); } - bytes[i++] = (byte)Message.Length; - Array.Copy(Message, 0, bytes, i, Message.Length); i += Message.Length; - if(TargetID == null) { Console.WriteLine("Warning: TargetID is null, in " + this.GetType()); } - Array.Copy(TargetID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = LureType; + { + if(Message == null) { Console.WriteLine("Warning: Message is null, in " + this.GetType()); } + bytes[i++] = (byte)Message.Length; + Array.Copy(Message, 0, bytes, i, Message.Length); i += Message.Length; + if(TargetID == null) { Console.WriteLine("Warning: TargetID is null, in " + this.GetType()); } + Array.Copy(TargetID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = LureType; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Info --\n"; - output += Helpers.FieldToString(Message, "Message") + "\n"; - output += "TargetID: " + TargetID.ToString() + "\n"; - output += "LureType: " + LureType.ToString() + "\n"; + { + string output = "-- Info --\n"; + output += Helpers.FieldToString(Message, "Message") + "\n"; + output += "TargetID: " + TargetID.ToString() + "\n"; + output += "LureType: " + LureType.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.StartLure - public override PacketType Type { get { return PacketType.StartLure; } } - /// Info block - public InfoBlock Info; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.StartLure + public override PacketType Type { get { return PacketType.StartLure; } } + /// Info block + public InfoBlock Info; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public StartLurePacket() - { - Header = new LowHeader(); - Header.ID = 96; - Header.Reliable = true; - Info = new InfoBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 96; + Header.Reliable = true; + Info = new InfoBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public StartLurePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Info = new InfoBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Info = new InfoBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public StartLurePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Info = new InfoBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + Info = new InfoBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Info.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Info.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Info.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Info.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- StartLure ---\n"; - output += Info.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- StartLure ---\n"; + output += Info.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// TeleportLureRequest packet + + /// TeleportLureRequest packet public class TeleportLureRequestPacket : Packet - { - /// Info block + { + /// Info block public class InfoBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - /// LureID field - public LLUUID LureID; - /// TeleportFlags field - public uint TeleportFlags; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + /// LureID field + public LLUUID LureID; + /// TeleportFlags field + public uint TeleportFlags; + + /// Length of this block serialized in bytes public int Length { get - { - return 52; + { + return 52; } } - - /// Default constructor - public InfoBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public InfoBlock() { } + /// Constructor for building the block from a byte array public InfoBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; - LureID = new LLUUID(bytes, i); i += 16; - TeleportFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; + LureID = new LLUUID(bytes, i); i += 16; + TeleportFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - if(LureID == null) { Console.WriteLine("Warning: LureID is null, in " + this.GetType()); } - Array.Copy(LureID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(TeleportFlags % 256); - bytes[i++] = (byte)((TeleportFlags >> 8) % 256); - bytes[i++] = (byte)((TeleportFlags >> 16) % 256); - bytes[i++] = (byte)((TeleportFlags >> 24) % 256); + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + if(LureID == null) { Console.WriteLine("Warning: LureID is null, in " + this.GetType()); } + Array.Copy(LureID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(TeleportFlags % 256); + bytes[i++] = (byte)((TeleportFlags >> 8) % 256); + bytes[i++] = (byte)((TeleportFlags >> 16) % 256); + bytes[i++] = (byte)((TeleportFlags >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Info --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "LureID: " + LureID.ToString() + "\n"; - output += "TeleportFlags: " + TeleportFlags.ToString() + "\n"; + { + string output = "-- Info --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "LureID: " + LureID.ToString() + "\n"; + output += "TeleportFlags: " + TeleportFlags.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.TeleportLureRequest - public override PacketType Type { get { return PacketType.TeleportLureRequest; } } - /// Info block - public InfoBlock Info; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.TeleportLureRequest + public override PacketType Type { get { return PacketType.TeleportLureRequest; } } + /// Info block + public InfoBlock Info; + + /// Default constructor public TeleportLureRequestPacket() - { - Header = new LowHeader(); - Header.ID = 97; - Header.Reliable = true; - Info = new InfoBlock(); + { + Header = new LowHeader(); + Header.ID = 97; + Header.Reliable = true; + Info = new InfoBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public TeleportLureRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Info = new InfoBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Info = new InfoBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public TeleportLureRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Info = new InfoBlock(bytes, ref i); + { + Header = head; + Info = new InfoBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Info.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Info.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Info.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Info.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- TeleportLureRequest ---\n"; - output += Info.ToString() + "\n"; + { + string output = "--- TeleportLureRequest ---\n"; + output += Info.ToString() + "\n"; return output; } - + } - - /// TeleportCancel packet + + /// TeleportCancel packet public class TeleportCancelPacket : Packet - { - /// Info block + { + /// Info block public class InfoBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public InfoBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public InfoBlock() { } + /// Constructor for building the block from a byte array public InfoBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Info --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- Info --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.TeleportCancel - public override PacketType Type { get { return PacketType.TeleportCancel; } } - /// Info block - public InfoBlock Info; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.TeleportCancel + public override PacketType Type { get { return PacketType.TeleportCancel; } } + /// Info block + public InfoBlock Info; + + /// Default constructor public TeleportCancelPacket() - { - Header = new LowHeader(); - Header.ID = 98; - Header.Reliable = true; - Info = new InfoBlock(); + { + Header = new LowHeader(); + Header.ID = 98; + Header.Reliable = true; + Info = new InfoBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public TeleportCancelPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Info = new InfoBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Info = new InfoBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public TeleportCancelPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Info = new InfoBlock(bytes, ref i); + { + Header = head; + Info = new InfoBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Info.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Info.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Info.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Info.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- TeleportCancel ---\n"; - output += Info.ToString() + "\n"; + { + string output = "--- TeleportCancel ---\n"; + output += Info.ToString() + "\n"; return output; } - + } - - /// CompleteLure packet + + /// CompleteLure packet public class CompleteLurePacket : Packet - { - /// Info block + { + /// Info block public class InfoBlock - { - /// AgentID field - public LLUUID AgentID; - /// TravelAccess field - public byte TravelAccess; - /// SessionID field - public LLUUID SessionID; - /// CircuitCode field - public uint CircuitCode; - /// LureID field - public LLUUID LureID; - /// ParentEstateID field - public uint ParentEstateID; - /// TeleportFlags field - public uint TeleportFlags; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// TravelAccess field + public byte TravelAccess; + /// SessionID field + public LLUUID SessionID; + /// CircuitCode field + public uint CircuitCode; + /// LureID field + public LLUUID LureID; + /// ParentEstateID field + public uint ParentEstateID; + /// TeleportFlags field + public uint TeleportFlags; + + /// Length of this block serialized in bytes public int Length { get - { - return 61; + { + return 61; } } - - /// Default constructor - public InfoBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public InfoBlock() { } + /// Constructor for building the block from a byte array public InfoBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - TravelAccess = (byte)bytes[i++]; - SessionID = new LLUUID(bytes, i); i += 16; - CircuitCode = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - LureID = new LLUUID(bytes, i); i += 16; - ParentEstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - TeleportFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + AgentID = new LLUUID(bytes, i); i += 16; + TravelAccess = (byte)bytes[i++]; + SessionID = new LLUUID(bytes, i); i += 16; + CircuitCode = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + LureID = new LLUUID(bytes, i); i += 16; + ParentEstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + TeleportFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = TravelAccess; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(CircuitCode % 256); - bytes[i++] = (byte)((CircuitCode >> 8) % 256); - bytes[i++] = (byte)((CircuitCode >> 16) % 256); - bytes[i++] = (byte)((CircuitCode >> 24) % 256); - if(LureID == null) { Console.WriteLine("Warning: LureID is null, in " + this.GetType()); } - Array.Copy(LureID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(ParentEstateID % 256); - bytes[i++] = (byte)((ParentEstateID >> 8) % 256); - bytes[i++] = (byte)((ParentEstateID >> 16) % 256); - bytes[i++] = (byte)((ParentEstateID >> 24) % 256); - bytes[i++] = (byte)(TeleportFlags % 256); - bytes[i++] = (byte)((TeleportFlags >> 8) % 256); - bytes[i++] = (byte)((TeleportFlags >> 16) % 256); - bytes[i++] = (byte)((TeleportFlags >> 24) % 256); + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = TravelAccess; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(CircuitCode % 256); + bytes[i++] = (byte)((CircuitCode >> 8) % 256); + bytes[i++] = (byte)((CircuitCode >> 16) % 256); + bytes[i++] = (byte)((CircuitCode >> 24) % 256); + if(LureID == null) { Console.WriteLine("Warning: LureID is null, in " + this.GetType()); } + Array.Copy(LureID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(ParentEstateID % 256); + bytes[i++] = (byte)((ParentEstateID >> 8) % 256); + bytes[i++] = (byte)((ParentEstateID >> 16) % 256); + bytes[i++] = (byte)((ParentEstateID >> 24) % 256); + bytes[i++] = (byte)(TeleportFlags % 256); + bytes[i++] = (byte)((TeleportFlags >> 8) % 256); + bytes[i++] = (byte)((TeleportFlags >> 16) % 256); + bytes[i++] = (byte)((TeleportFlags >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Info --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "TravelAccess: " + TravelAccess.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "CircuitCode: " + CircuitCode.ToString() + "\n"; - output += "LureID: " + LureID.ToString() + "\n"; - output += "ParentEstateID: " + ParentEstateID.ToString() + "\n"; - output += "TeleportFlags: " + TeleportFlags.ToString() + "\n"; + { + string output = "-- Info --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "TravelAccess: " + TravelAccess.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "CircuitCode: " + CircuitCode.ToString() + "\n"; + output += "LureID: " + LureID.ToString() + "\n"; + output += "ParentEstateID: " + ParentEstateID.ToString() + "\n"; + output += "TeleportFlags: " + TeleportFlags.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.CompleteLure - public override PacketType Type { get { return PacketType.CompleteLure; } } - /// Info block - public InfoBlock Info; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.CompleteLure + public override PacketType Type { get { return PacketType.CompleteLure; } } + /// Info block + public InfoBlock Info; + + /// Default constructor public CompleteLurePacket() - { - Header = new LowHeader(); - Header.ID = 99; - Header.Reliable = true; - Info = new InfoBlock(); + { + Header = new LowHeader(); + Header.ID = 99; + Header.Reliable = true; + Info = new InfoBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public CompleteLurePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Info = new InfoBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Info = new InfoBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public CompleteLurePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Info = new InfoBlock(bytes, ref i); + { + Header = head; + Info = new InfoBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Info.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Info.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Info.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Info.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- CompleteLure ---\n"; - output += Info.ToString() + "\n"; + { + string output = "--- CompleteLure ---\n"; + output += Info.ToString() + "\n"; return output; } - + } - - /// TeleportStart packet + + /// TeleportStart packet public class TeleportStartPacket : Packet - { - /// Info block + { + /// Info block public class InfoBlock - { - /// TeleportFlags field - public uint TeleportFlags; - - /// Length of this block serialized in bytes + { + /// TeleportFlags field + public uint TeleportFlags; + + /// Length of this block serialized in bytes public int Length { get - { - return 4; + { + return 4; } } - - /// Default constructor - public InfoBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public InfoBlock() { } + /// Constructor for building the block from a byte array public InfoBlock(byte[] bytes, ref int i) - { + { try - { - TeleportFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + TeleportFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(TeleportFlags % 256); - bytes[i++] = (byte)((TeleportFlags >> 8) % 256); - bytes[i++] = (byte)((TeleportFlags >> 16) % 256); - bytes[i++] = (byte)((TeleportFlags >> 24) % 256); + { + bytes[i++] = (byte)(TeleportFlags % 256); + bytes[i++] = (byte)((TeleportFlags >> 8) % 256); + bytes[i++] = (byte)((TeleportFlags >> 16) % 256); + bytes[i++] = (byte)((TeleportFlags >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Info --\n"; - output += "TeleportFlags: " + TeleportFlags.ToString() + "\n"; + { + string output = "-- Info --\n"; + output += "TeleportFlags: " + TeleportFlags.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.TeleportStart - public override PacketType Type { get { return PacketType.TeleportStart; } } - /// Info block - public InfoBlock Info; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.TeleportStart + public override PacketType Type { get { return PacketType.TeleportStart; } } + /// Info block + public InfoBlock Info; + + /// Default constructor public TeleportStartPacket() - { - Header = new LowHeader(); - Header.ID = 100; - Header.Reliable = true; - Info = new InfoBlock(); + { + Header = new LowHeader(); + Header.ID = 100; + Header.Reliable = true; + Info = new InfoBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public TeleportStartPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Info = new InfoBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Info = new InfoBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public TeleportStartPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Info = new InfoBlock(bytes, ref i); + { + Header = head; + Info = new InfoBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Info.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Info.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Info.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Info.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- TeleportStart ---\n"; - output += Info.ToString() + "\n"; + { + string output = "--- TeleportStart ---\n"; + output += Info.ToString() + "\n"; return output; } - + } - - /// TeleportFailed packet + + /// TeleportFailed packet public class TeleportFailedPacket : Packet - { - /// Info block + { + /// Info block public class InfoBlock - { - /// AgentID field - public LLUUID AgentID; - private byte[] _reason; - /// Reason field + { + /// AgentID field + public LLUUID AgentID; + private byte[] _reason; + /// Reason field public byte[] Reason - { - get { return _reason; } + { + get { return _reason; } set - { - if (value == null) { _reason = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _reason = new byte[value.Length]; Array.Copy(value, _reason, value.Length); } + { + if (value == null) { _reason = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _reason = new byte[value.Length]; Array.Copy(value, _reason, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 16; - if (Reason != null) { length += 1 + Reason.Length; } - return length; + { + int length = 16; + if (Reason != null) { length += 1 + Reason.Length; } + return length; } } - - /// Default constructor - public InfoBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public InfoBlock() { } + /// Constructor for building the block from a byte array public InfoBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - AgentID = new LLUUID(bytes, i); i += 16; - length = (ushort)bytes[i++]; - _reason = new byte[length]; - Array.Copy(bytes, i, _reason, 0, length); i += length; + { + AgentID = new LLUUID(bytes, i); i += 16; + length = (ushort)bytes[i++]; + _reason = new byte[length]; + Array.Copy(bytes, i, _reason, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(Reason == null) { Console.WriteLine("Warning: Reason is null, in " + this.GetType()); } - bytes[i++] = (byte)Reason.Length; - Array.Copy(Reason, 0, bytes, i, Reason.Length); i += Reason.Length; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(Reason == null) { Console.WriteLine("Warning: Reason is null, in " + this.GetType()); } + bytes[i++] = (byte)Reason.Length; + Array.Copy(Reason, 0, bytes, i, Reason.Length); i += Reason.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Info --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += Helpers.FieldToString(Reason, "Reason") + "\n"; + { + string output = "-- Info --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += Helpers.FieldToString(Reason, "Reason") + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.TeleportFailed - public override PacketType Type { get { return PacketType.TeleportFailed; } } - /// Info block - public InfoBlock Info; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.TeleportFailed + public override PacketType Type { get { return PacketType.TeleportFailed; } } + /// Info block + public InfoBlock Info; + + /// Default constructor public TeleportFailedPacket() - { - Header = new LowHeader(); - Header.ID = 101; - Header.Reliable = true; - Info = new InfoBlock(); + { + Header = new LowHeader(); + Header.ID = 101; + Header.Reliable = true; + Info = new InfoBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public TeleportFailedPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Info = new InfoBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Info = new InfoBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public TeleportFailedPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Info = new InfoBlock(bytes, ref i); + { + Header = head; + Info = new InfoBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Info.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Info.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Info.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Info.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- TeleportFailed ---\n"; - output += Info.ToString() + "\n"; + { + string output = "--- TeleportFailed ---\n"; + output += Info.ToString() + "\n"; return output; } - + } - - /// LeaderBoardRequest packet + + /// LeaderBoardRequest packet public class LeaderBoardRequestPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - /// Type field - public int Type; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + /// Type field + public int Type; + + /// Length of this block serialized in bytes public int Length { get - { - return 36; + { + return 36; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; - Type = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; + Type = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(Type % 256); - bytes[i++] = (byte)((Type >> 8) % 256); - bytes[i++] = (byte)((Type >> 16) % 256); - bytes[i++] = (byte)((Type >> 24) % 256); + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(Type % 256); + bytes[i++] = (byte)((Type >> 8) % 256); + bytes[i++] = (byte)((Type >> 16) % 256); + bytes[i++] = (byte)((Type >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "Type: " + Type.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "Type: " + Type.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.LeaderBoardRequest - public override PacketType Type { get { return PacketType.LeaderBoardRequest; } } - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.LeaderBoardRequest + public override PacketType Type { get { return PacketType.LeaderBoardRequest; } } + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public LeaderBoardRequestPacket() - { - Header = new LowHeader(); - Header.ID = 102; - Header.Reliable = true; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 102; + Header.Reliable = true; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public LeaderBoardRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public LeaderBoardRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- LeaderBoardRequest ---\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- LeaderBoardRequest ---\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// LeaderBoardData packet + + /// LeaderBoardData packet public class LeaderBoardDataPacket : Packet - { - /// BoardData block + { + /// BoardData block public class BoardDataBlock - { - private byte[] _timestring; - /// TimeString field + { + private byte[] _timestring; + /// TimeString field public byte[] TimeString - { - get { return _timestring; } + { + get { return _timestring; } set - { - if (value == null) { _timestring = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _timestring = new byte[value.Length]; Array.Copy(value, _timestring, value.Length); } + { + if (value == null) { _timestring = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _timestring = new byte[value.Length]; Array.Copy(value, _timestring, value.Length); } } - } - /// MaxPlace field - public int MaxPlace; - /// MinPlace field - public int MinPlace; - /// Type field - public int Type; - - /// Length of this block serialized in bytes + } + /// MaxPlace field + public int MaxPlace; + /// MinPlace field + public int MinPlace; + /// Type field + public int Type; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 12; - if (TimeString != null) { length += 1 + TimeString.Length; } - return length; + { + int length = 12; + if (TimeString != null) { length += 1 + TimeString.Length; } + return length; } } - - /// Default constructor - public BoardDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public BoardDataBlock() { } + /// Constructor for building the block from a byte array public BoardDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _timestring = new byte[length]; - Array.Copy(bytes, i, _timestring, 0, length); i += length; - MaxPlace = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - MinPlace = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Type = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + length = (ushort)bytes[i++]; + _timestring = new byte[length]; + Array.Copy(bytes, i, _timestring, 0, length); i += length; + MaxPlace = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + MinPlace = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Type = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(TimeString == null) { Console.WriteLine("Warning: TimeString is null, in " + this.GetType()); } - bytes[i++] = (byte)TimeString.Length; - Array.Copy(TimeString, 0, bytes, i, TimeString.Length); i += TimeString.Length; - bytes[i++] = (byte)(MaxPlace % 256); - bytes[i++] = (byte)((MaxPlace >> 8) % 256); - bytes[i++] = (byte)((MaxPlace >> 16) % 256); - bytes[i++] = (byte)((MaxPlace >> 24) % 256); - bytes[i++] = (byte)(MinPlace % 256); - bytes[i++] = (byte)((MinPlace >> 8) % 256); - bytes[i++] = (byte)((MinPlace >> 16) % 256); - bytes[i++] = (byte)((MinPlace >> 24) % 256); - bytes[i++] = (byte)(Type % 256); - bytes[i++] = (byte)((Type >> 8) % 256); - bytes[i++] = (byte)((Type >> 16) % 256); - bytes[i++] = (byte)((Type >> 24) % 256); + { + if(TimeString == null) { Console.WriteLine("Warning: TimeString is null, in " + this.GetType()); } + bytes[i++] = (byte)TimeString.Length; + Array.Copy(TimeString, 0, bytes, i, TimeString.Length); i += TimeString.Length; + bytes[i++] = (byte)(MaxPlace % 256); + bytes[i++] = (byte)((MaxPlace >> 8) % 256); + bytes[i++] = (byte)((MaxPlace >> 16) % 256); + bytes[i++] = (byte)((MaxPlace >> 24) % 256); + bytes[i++] = (byte)(MinPlace % 256); + bytes[i++] = (byte)((MinPlace >> 8) % 256); + bytes[i++] = (byte)((MinPlace >> 16) % 256); + bytes[i++] = (byte)((MinPlace >> 24) % 256); + bytes[i++] = (byte)(Type % 256); + bytes[i++] = (byte)((Type >> 8) % 256); + bytes[i++] = (byte)((Type >> 16) % 256); + bytes[i++] = (byte)((Type >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- BoardData --\n"; - output += Helpers.FieldToString(TimeString, "TimeString") + "\n"; - output += "MaxPlace: " + MaxPlace.ToString() + "\n"; - output += "MinPlace: " + MinPlace.ToString() + "\n"; - output += "Type: " + Type.ToString() + "\n"; + { + string output = "-- BoardData --\n"; + output += Helpers.FieldToString(TimeString, "TimeString") + "\n"; + output += "MaxPlace: " + MaxPlace.ToString() + "\n"; + output += "MinPlace: " + MinPlace.ToString() + "\n"; + output += "Type: " + Type.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// Entry block + + /// Entry block public class EntryBlock - { - /// ID field - public LLUUID ID; - /// Name field - public byte[] Name; - /// Sequence field - public int Sequence; - /// Place field - public int Place; - /// Score field - public int Score; - - /// Length of this block serialized in bytes + { + /// ID field + public LLUUID ID; + /// Name field + public byte[] Name; + /// Sequence field + public int Sequence; + /// Place field + public int Place; + /// Score field + public int Score; + + /// Length of this block serialized in bytes public int Length { get - { - return 60; + { + return 60; } } - - /// Default constructor - public EntryBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public EntryBlock() { } + /// Constructor for building the block from a byte array public EntryBlock(byte[] bytes, ref int i) - { + { try - { - ID = new LLUUID(bytes, i); i += 16; - Name = new byte[32]; - Array.Copy(bytes, i, Name, 0, 32); i += 32; - Sequence = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Place = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Score = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + ID = new LLUUID(bytes, i); i += 16; + Name = new byte[32]; + Array.Copy(bytes, i, Name, 0, 32); i += 32; + Sequence = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Place = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Score = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } - Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; - Array.Copy(Name, 0, bytes, i, 32);i += 32; - bytes[i++] = (byte)(Sequence % 256); - bytes[i++] = (byte)((Sequence >> 8) % 256); - bytes[i++] = (byte)((Sequence >> 16) % 256); - bytes[i++] = (byte)((Sequence >> 24) % 256); - bytes[i++] = (byte)(Place % 256); - bytes[i++] = (byte)((Place >> 8) % 256); - bytes[i++] = (byte)((Place >> 16) % 256); - bytes[i++] = (byte)((Place >> 24) % 256); - bytes[i++] = (byte)(Score % 256); - bytes[i++] = (byte)((Score >> 8) % 256); - bytes[i++] = (byte)((Score >> 16) % 256); - bytes[i++] = (byte)((Score >> 24) % 256); + { + if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } + Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; + Array.Copy(Name, 0, bytes, i, 32);i += 32; + bytes[i++] = (byte)(Sequence % 256); + bytes[i++] = (byte)((Sequence >> 8) % 256); + bytes[i++] = (byte)((Sequence >> 16) % 256); + bytes[i++] = (byte)((Sequence >> 24) % 256); + bytes[i++] = (byte)(Place % 256); + bytes[i++] = (byte)((Place >> 8) % 256); + bytes[i++] = (byte)((Place >> 16) % 256); + bytes[i++] = (byte)((Place >> 24) % 256); + bytes[i++] = (byte)(Score % 256); + bytes[i++] = (byte)((Score >> 8) % 256); + bytes[i++] = (byte)((Score >> 16) % 256); + bytes[i++] = (byte)((Score >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Entry --\n"; - output += "ID: " + ID.ToString() + "\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; - output += "Sequence: " + Sequence.ToString() + "\n"; - output += "Place: " + Place.ToString() + "\n"; - output += "Score: " + Score.ToString() + "\n"; + { + string output = "-- Entry --\n"; + output += "ID: " + ID.ToString() + "\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; + output += "Sequence: " + Sequence.ToString() + "\n"; + output += "Place: " + Place.ToString() + "\n"; + output += "Score: " + Score.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.LeaderBoardData - public override PacketType Type { get { return PacketType.LeaderBoardData; } } - /// BoardData block - public BoardDataBlock BoardData; - /// Entry block - public EntryBlock[] Entry; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.LeaderBoardData + public override PacketType Type { get { return PacketType.LeaderBoardData; } } + /// BoardData block + public BoardDataBlock BoardData; + /// Entry block + public EntryBlock[] Entry; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public LeaderBoardDataPacket() - { - Header = new LowHeader(); - Header.ID = 103; - Header.Reliable = true; - Header.Zerocoded = true; - BoardData = new BoardDataBlock(); - Entry = new EntryBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 103; + Header.Reliable = true; + Header.Zerocoded = true; + BoardData = new BoardDataBlock(); + Entry = new EntryBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public LeaderBoardDataPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - BoardData = new BoardDataBlock(bytes, ref i); - int count = (int)bytes[i++]; - Entry = new EntryBlock[count]; - for (int j = 0; j < count; j++) - { Entry[j] = new EntryBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + BoardData = new BoardDataBlock(bytes, ref i); + int count = (int)bytes[i++]; + Entry = new EntryBlock[count]; + for (int j = 0; j < count; j++) + { Entry[j] = new EntryBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public LeaderBoardDataPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - BoardData = new BoardDataBlock(bytes, ref i); - int count = (int)bytes[i++]; - Entry = new EntryBlock[count]; - for (int j = 0; j < count; j++) - { Entry[j] = new EntryBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + BoardData = new BoardDataBlock(bytes, ref i); + int count = (int)bytes[i++]; + Entry = new EntryBlock[count]; + for (int j = 0; j < count; j++) + { Entry[j] = new EntryBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += BoardData.Length; length += AgentData.Length;; - length++; - for (int j = 0; j < Entry.Length; j++) { length += Entry[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - BoardData.ToBytes(bytes, ref i); - bytes[i++] = (byte)Entry.Length; - for (int j = 0; j < Entry.Length; j++) { Entry[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += BoardData.Length; length += AgentData.Length;; + length++; + for (int j = 0; j < Entry.Length; j++) { length += Entry[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + BoardData.ToBytes(bytes, ref i); + bytes[i++] = (byte)Entry.Length; + for (int j = 0; j < Entry.Length; j++) { Entry[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- LeaderBoardData ---\n"; - output += BoardData.ToString() + "\n"; + { + string output = "--- LeaderBoardData ---\n"; + output += BoardData.ToString() + "\n"; for (int j = 0; j < Entry.Length; j++) - { + { output += Entry[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// RegisterNewAgent packet + + /// RegisterNewAgent packet public class RegisterNewAgentPacket : Packet - { - /// HelloBlock block + { + /// HelloBlock block public class HelloBlockBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - /// Godlike field - public bool Godlike; - /// LocationID field - public uint LocationID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + /// Godlike field + public bool Godlike; + /// LocationID field + public uint LocationID; + + /// Length of this block serialized in bytes public int Length { get - { - return 37; + { + return 37; } } - - /// Default constructor - public HelloBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public HelloBlockBlock() { } + /// Constructor for building the block from a byte array public HelloBlockBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; - Godlike = (bytes[i++] != 0) ? (bool)true : (bool)false; - LocationID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; + Godlike = (bytes[i++] != 0) ? (bool)true : (bool)false; + LocationID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((Godlike) ? 1 : 0); - bytes[i++] = (byte)(LocationID % 256); - bytes[i++] = (byte)((LocationID >> 8) % 256); - bytes[i++] = (byte)((LocationID >> 16) % 256); - bytes[i++] = (byte)((LocationID >> 24) % 256); + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((Godlike) ? 1 : 0); + bytes[i++] = (byte)(LocationID % 256); + bytes[i++] = (byte)((LocationID >> 8) % 256); + bytes[i++] = (byte)((LocationID >> 16) % 256); + bytes[i++] = (byte)((LocationID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- HelloBlock --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "Godlike: " + Godlike.ToString() + "\n"; - output += "LocationID: " + LocationID.ToString() + "\n"; + { + string output = "-- HelloBlock --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "Godlike: " + Godlike.ToString() + "\n"; + output += "LocationID: " + LocationID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.RegisterNewAgent - public override PacketType Type { get { return PacketType.RegisterNewAgent; } } - /// HelloBlock block - public HelloBlockBlock HelloBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.RegisterNewAgent + public override PacketType Type { get { return PacketType.RegisterNewAgent; } } + /// HelloBlock block + public HelloBlockBlock HelloBlock; + + /// Default constructor public RegisterNewAgentPacket() - { - Header = new LowHeader(); - Header.ID = 104; - Header.Reliable = true; - HelloBlock = new HelloBlockBlock(); + { + Header = new LowHeader(); + Header.ID = 104; + Header.Reliable = true; + HelloBlock = new HelloBlockBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public RegisterNewAgentPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - HelloBlock = new HelloBlockBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + HelloBlock = new HelloBlockBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public RegisterNewAgentPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - HelloBlock = new HelloBlockBlock(bytes, ref i); + { + Header = head; + HelloBlock = new HelloBlockBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += HelloBlock.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - HelloBlock.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += HelloBlock.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + HelloBlock.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- RegisterNewAgent ---\n"; - output += HelloBlock.ToString() + "\n"; + { + string output = "--- RegisterNewAgent ---\n"; + output += HelloBlock.ToString() + "\n"; return output; } - + } - - /// Undo packet + + /// Undo packet public class UndoPacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - /// ObjectID field - public LLUUID ObjectID; - - /// Length of this block serialized in bytes + { + /// ObjectID field + public LLUUID ObjectID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { + { try - { - ObjectID = new LLUUID(bytes, i); i += 16; + { + ObjectID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } - Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } + Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += "ObjectID: " + ObjectID.ToString() + "\n"; + { + string output = "-- ObjectData --\n"; + output += "ObjectID: " + ObjectID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - /// GroupID field - public LLUUID GroupID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + /// GroupID field + public LLUUID GroupID; + + /// Length of this block serialized in bytes public int Length { get - { - return 48; + { + return 48; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; - GroupID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; + GroupID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.Undo - public override PacketType Type { get { return PacketType.Undo; } } - /// ObjectData block - public ObjectDataBlock[] ObjectData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.Undo + public override PacketType Type { get { return PacketType.Undo; } } + /// ObjectData block + public ObjectDataBlock[] ObjectData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public UndoPacket() - { - Header = new LowHeader(); - Header.ID = 105; - Header.Reliable = true; - ObjectData = new ObjectDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 105; + Header.Reliable = true; + ObjectData = new ObjectDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public UndoPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public UndoPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ObjectData.Length; - for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ObjectData.Length; + for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- Undo ---\n"; + { + string output = "--- Undo ---\n"; for (int j = 0; j < ObjectData.Length; j++) - { + { output += ObjectData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// Redo packet + + /// Redo packet public class RedoPacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - /// ObjectID field - public LLUUID ObjectID; - - /// Length of this block serialized in bytes + { + /// ObjectID field + public LLUUID ObjectID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { + { try - { - ObjectID = new LLUUID(bytes, i); i += 16; + { + ObjectID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } - Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } + Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += "ObjectID: " + ObjectID.ToString() + "\n"; + { + string output = "-- ObjectData --\n"; + output += "ObjectID: " + ObjectID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - /// GroupID field - public LLUUID GroupID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + /// GroupID field + public LLUUID GroupID; + + /// Length of this block serialized in bytes public int Length { get - { - return 48; + { + return 48; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; - GroupID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; + GroupID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.Redo - public override PacketType Type { get { return PacketType.Redo; } } - /// ObjectData block - public ObjectDataBlock[] ObjectData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.Redo + public override PacketType Type { get { return PacketType.Redo; } } + /// ObjectData block + public ObjectDataBlock[] ObjectData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public RedoPacket() - { - Header = new LowHeader(); - Header.ID = 106; - Header.Reliable = true; - ObjectData = new ObjectDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 106; + Header.Reliable = true; + ObjectData = new ObjectDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public RedoPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public RedoPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ObjectData.Length; - for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ObjectData.Length; + for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- Redo ---\n"; + { + string output = "--- Redo ---\n"; for (int j = 0; j < ObjectData.Length; j++) - { + { output += ObjectData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// UndoLand packet + + /// UndoLand packet public class UndoLandPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.UndoLand - public override PacketType Type { get { return PacketType.UndoLand; } } - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.UndoLand + public override PacketType Type { get { return PacketType.UndoLand; } } + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public UndoLandPacket() - { - Header = new LowHeader(); - Header.ID = 107; - Header.Reliable = true; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 107; + Header.Reliable = true; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public UndoLandPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public UndoLandPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- UndoLand ---\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- UndoLand ---\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// RedoLand packet + + /// RedoLand packet public class RedoLandPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.RedoLand - public override PacketType Type { get { return PacketType.RedoLand; } } - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.RedoLand + public override PacketType Type { get { return PacketType.RedoLand; } } + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public RedoLandPacket() - { - Header = new LowHeader(); - Header.ID = 108; - Header.Reliable = true; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 108; + Header.Reliable = true; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public RedoLandPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public RedoLandPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- RedoLand ---\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- RedoLand ---\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// AgentPause packet + + /// AgentPause packet public class AgentPausePacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// SerialNum field - public uint SerialNum; - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// SerialNum field + public uint SerialNum; + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 36; + { + return 36; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - SerialNum = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + SerialNum = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(SerialNum % 256); - bytes[i++] = (byte)((SerialNum >> 8) % 256); - bytes[i++] = (byte)((SerialNum >> 16) % 256); - bytes[i++] = (byte)((SerialNum >> 24) % 256); - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + bytes[i++] = (byte)(SerialNum % 256); + bytes[i++] = (byte)((SerialNum >> 8) % 256); + bytes[i++] = (byte)((SerialNum >> 16) % 256); + bytes[i++] = (byte)((SerialNum >> 24) % 256); + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "SerialNum: " + SerialNum.ToString() + "\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "SerialNum: " + SerialNum.ToString() + "\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AgentPause - public override PacketType Type { get { return PacketType.AgentPause; } } - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AgentPause + public override PacketType Type { get { return PacketType.AgentPause; } } + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public AgentPausePacket() - { - Header = new LowHeader(); - Header.ID = 109; - Header.Reliable = true; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 109; + Header.Reliable = true; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AgentPausePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AgentPausePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AgentPause ---\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- AgentPause ---\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// AgentResume packet + + /// AgentResume packet public class AgentResumePacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// SerialNum field - public uint SerialNum; - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// SerialNum field + public uint SerialNum; + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 36; + { + return 36; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - SerialNum = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + SerialNum = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(SerialNum % 256); - bytes[i++] = (byte)((SerialNum >> 8) % 256); - bytes[i++] = (byte)((SerialNum >> 16) % 256); - bytes[i++] = (byte)((SerialNum >> 24) % 256); - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + bytes[i++] = (byte)(SerialNum % 256); + bytes[i++] = (byte)((SerialNum >> 8) % 256); + bytes[i++] = (byte)((SerialNum >> 16) % 256); + bytes[i++] = (byte)((SerialNum >> 24) % 256); + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "SerialNum: " + SerialNum.ToString() + "\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "SerialNum: " + SerialNum.ToString() + "\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AgentResume - public override PacketType Type { get { return PacketType.AgentResume; } } - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AgentResume + public override PacketType Type { get { return PacketType.AgentResume; } } + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public AgentResumePacket() - { - Header = new LowHeader(); - Header.ID = 110; - Header.Reliable = true; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 110; + Header.Reliable = true; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AgentResumePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AgentResumePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AgentResume ---\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- AgentResume ---\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ChatFromViewer packet + + /// ChatFromViewer packet public class ChatFromViewerPacket : Packet - { - /// ChatData block + { + /// ChatData block public class ChatDataBlock - { - /// Channel field - public int Channel; - private byte[] _message; - /// Message field + { + /// Channel field + public int Channel; + private byte[] _message; + /// Message field public byte[] Message - { - get { return _message; } + { + get { return _message; } set - { - if (value == null) { _message = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _message = new byte[value.Length]; Array.Copy(value, _message, value.Length); } + { + if (value == null) { _message = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _message = new byte[value.Length]; Array.Copy(value, _message, value.Length); } } - } - /// Type field - public byte Type; - - /// Length of this block serialized in bytes + } + /// Type field + public byte Type; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 5; - if (Message != null) { length += 2 + Message.Length; } - return length; + { + int length = 5; + if (Message != null) { length += 2 + Message.Length; } + return length; } } - - /// Default constructor - public ChatDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ChatDataBlock() { } + /// Constructor for building the block from a byte array public ChatDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - Channel = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _message = new byte[length]; - Array.Copy(bytes, i, _message, 0, length); i += length; - Type = (byte)bytes[i++]; + { + Channel = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _message = new byte[length]; + Array.Copy(bytes, i, _message, 0, length); i += length; + Type = (byte)bytes[i++]; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(Channel % 256); - bytes[i++] = (byte)((Channel >> 8) % 256); - bytes[i++] = (byte)((Channel >> 16) % 256); - bytes[i++] = (byte)((Channel >> 24) % 256); - if(Message == null) { Console.WriteLine("Warning: Message is null, in " + this.GetType()); } - bytes[i++] = (byte)(Message.Length % 256); - bytes[i++] = (byte)((Message.Length >> 8) % 256); - Array.Copy(Message, 0, bytes, i, Message.Length); i += Message.Length; - bytes[i++] = Type; + { + bytes[i++] = (byte)(Channel % 256); + bytes[i++] = (byte)((Channel >> 8) % 256); + bytes[i++] = (byte)((Channel >> 16) % 256); + bytes[i++] = (byte)((Channel >> 24) % 256); + if(Message == null) { Console.WriteLine("Warning: Message is null, in " + this.GetType()); } + bytes[i++] = (byte)(Message.Length % 256); + bytes[i++] = (byte)((Message.Length >> 8) % 256); + Array.Copy(Message, 0, bytes, i, Message.Length); i += Message.Length; + bytes[i++] = Type; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ChatData --\n"; - output += "Channel: " + Channel.ToString() + "\n"; - output += Helpers.FieldToString(Message, "Message") + "\n"; - output += "Type: " + Type.ToString() + "\n"; + { + string output = "-- ChatData --\n"; + output += "Channel: " + Channel.ToString() + "\n"; + output += Helpers.FieldToString(Message, "Message") + "\n"; + output += "Type: " + Type.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ChatFromViewer - public override PacketType Type { get { return PacketType.ChatFromViewer; } } - /// ChatData block - public ChatDataBlock ChatData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ChatFromViewer + public override PacketType Type { get { return PacketType.ChatFromViewer; } } + /// ChatData block + public ChatDataBlock ChatData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ChatFromViewerPacket() - { - Header = new LowHeader(); - Header.ID = 111; - Header.Reliable = true; - Header.Zerocoded = true; - ChatData = new ChatDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 111; + Header.Reliable = true; + Header.Zerocoded = true; + ChatData = new ChatDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ChatFromViewerPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - ChatData = new ChatDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + ChatData = new ChatDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ChatFromViewerPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - ChatData = new ChatDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + ChatData = new ChatDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += ChatData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - ChatData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += ChatData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + ChatData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ChatFromViewer ---\n"; - output += ChatData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- ChatFromViewer ---\n"; + output += ChatData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// AgentThrottle packet + + /// AgentThrottle packet public class AgentThrottlePacket : Packet - { - /// Throttle block + { + /// Throttle block public class ThrottleBlock - { - /// GenCounter field - public uint GenCounter; - private byte[] _throttles; - /// Throttles field + { + /// GenCounter field + public uint GenCounter; + private byte[] _throttles; + /// Throttles field public byte[] Throttles - { - get { return _throttles; } + { + get { return _throttles; } set - { - if (value == null) { _throttles = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _throttles = new byte[value.Length]; Array.Copy(value, _throttles, value.Length); } + { + if (value == null) { _throttles = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _throttles = new byte[value.Length]; Array.Copy(value, _throttles, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 4; - if (Throttles != null) { length += 1 + Throttles.Length; } - return length; + { + int length = 4; + if (Throttles != null) { length += 1 + Throttles.Length; } + return length; } } - - /// Default constructor - public ThrottleBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ThrottleBlock() { } + /// Constructor for building the block from a byte array public ThrottleBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - GenCounter = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _throttles = new byte[length]; - Array.Copy(bytes, i, _throttles, 0, length); i += length; + { + GenCounter = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _throttles = new byte[length]; + Array.Copy(bytes, i, _throttles, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(GenCounter % 256); - bytes[i++] = (byte)((GenCounter >> 8) % 256); - bytes[i++] = (byte)((GenCounter >> 16) % 256); - bytes[i++] = (byte)((GenCounter >> 24) % 256); - if(Throttles == null) { Console.WriteLine("Warning: Throttles is null, in " + this.GetType()); } - bytes[i++] = (byte)Throttles.Length; - Array.Copy(Throttles, 0, bytes, i, Throttles.Length); i += Throttles.Length; + { + bytes[i++] = (byte)(GenCounter % 256); + bytes[i++] = (byte)((GenCounter >> 8) % 256); + bytes[i++] = (byte)((GenCounter >> 16) % 256); + bytes[i++] = (byte)((GenCounter >> 24) % 256); + if(Throttles == null) { Console.WriteLine("Warning: Throttles is null, in " + this.GetType()); } + bytes[i++] = (byte)Throttles.Length; + Array.Copy(Throttles, 0, bytes, i, Throttles.Length); i += Throttles.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Throttle --\n"; - output += "GenCounter: " + GenCounter.ToString() + "\n"; - output += Helpers.FieldToString(Throttles, "Throttles") + "\n"; + { + string output = "-- Throttle --\n"; + output += "GenCounter: " + GenCounter.ToString() + "\n"; + output += Helpers.FieldToString(Throttles, "Throttles") + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - /// CircuitCode field - public uint CircuitCode; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + /// CircuitCode field + public uint CircuitCode; + + /// Length of this block serialized in bytes public int Length { get - { - return 36; + { + return 36; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; - CircuitCode = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; + CircuitCode = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(CircuitCode % 256); - bytes[i++] = (byte)((CircuitCode >> 8) % 256); - bytes[i++] = (byte)((CircuitCode >> 16) % 256); - bytes[i++] = (byte)((CircuitCode >> 24) % 256); + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(CircuitCode % 256); + bytes[i++] = (byte)((CircuitCode >> 8) % 256); + bytes[i++] = (byte)((CircuitCode >> 16) % 256); + bytes[i++] = (byte)((CircuitCode >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "CircuitCode: " + CircuitCode.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "CircuitCode: " + CircuitCode.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AgentThrottle - public override PacketType Type { get { return PacketType.AgentThrottle; } } - /// Throttle block - public ThrottleBlock Throttle; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AgentThrottle + public override PacketType Type { get { return PacketType.AgentThrottle; } } + /// Throttle block + public ThrottleBlock Throttle; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public AgentThrottlePacket() - { - Header = new LowHeader(); - Header.ID = 112; - Header.Reliable = true; - Header.Zerocoded = true; - Throttle = new ThrottleBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 112; + Header.Reliable = true; + Header.Zerocoded = true; + Throttle = new ThrottleBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AgentThrottlePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Throttle = new ThrottleBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Throttle = new ThrottleBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AgentThrottlePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Throttle = new ThrottleBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + Throttle = new ThrottleBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Throttle.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Throttle.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Throttle.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Throttle.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AgentThrottle ---\n"; - output += Throttle.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- AgentThrottle ---\n"; + output += Throttle.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// AgentFOV packet + + /// AgentFOV packet public class AgentFOVPacket : Packet - { - /// FOVBlock block + { + /// FOVBlock block public class FOVBlockBlock - { - /// GenCounter field - public uint GenCounter; - /// VerticalAngle field - public float VerticalAngle; - - /// Length of this block serialized in bytes + { + /// GenCounter field + public uint GenCounter; + /// VerticalAngle field + public float VerticalAngle; + + /// Length of this block serialized in bytes public int Length { get - { - return 8; + { + return 8; } } - - /// Default constructor - public FOVBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public FOVBlockBlock() { } + /// Constructor for building the block from a byte array public FOVBlockBlock(byte[] bytes, ref int i) - { + { try - { - GenCounter = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - VerticalAngle = BitConverter.ToSingle(bytes, i); i += 4; + { + GenCounter = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + VerticalAngle = BitConverter.ToSingle(bytes, i); i += 4; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; - bytes[i++] = (byte)(GenCounter % 256); - bytes[i++] = (byte)((GenCounter >> 8) % 256); - bytes[i++] = (byte)((GenCounter >> 16) % 256); - bytes[i++] = (byte)((GenCounter >> 24) % 256); + { + byte[] ba; + bytes[i++] = (byte)(GenCounter % 256); + bytes[i++] = (byte)((GenCounter >> 8) % 256); + bytes[i++] = (byte)((GenCounter >> 16) % 256); + bytes[i++] = (byte)((GenCounter >> 24) % 256); ba = BitConverter.GetBytes(VerticalAngle); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- FOVBlock --\n"; - output += "GenCounter: " + GenCounter.ToString() + "\n"; - output += "VerticalAngle: " + VerticalAngle.ToString() + "\n"; + { + string output = "-- FOVBlock --\n"; + output += "GenCounter: " + GenCounter.ToString() + "\n"; + output += "VerticalAngle: " + VerticalAngle.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - /// CircuitCode field - public uint CircuitCode; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + /// CircuitCode field + public uint CircuitCode; + + /// Length of this block serialized in bytes public int Length { get - { - return 36; + { + return 36; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; - CircuitCode = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; + CircuitCode = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(CircuitCode % 256); - bytes[i++] = (byte)((CircuitCode >> 8) % 256); - bytes[i++] = (byte)((CircuitCode >> 16) % 256); - bytes[i++] = (byte)((CircuitCode >> 24) % 256); + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(CircuitCode % 256); + bytes[i++] = (byte)((CircuitCode >> 8) % 256); + bytes[i++] = (byte)((CircuitCode >> 16) % 256); + bytes[i++] = (byte)((CircuitCode >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "CircuitCode: " + CircuitCode.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "CircuitCode: " + CircuitCode.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AgentFOV - public override PacketType Type { get { return PacketType.AgentFOV; } } - /// FOVBlock block - public FOVBlockBlock FOVBlock; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AgentFOV + public override PacketType Type { get { return PacketType.AgentFOV; } } + /// FOVBlock block + public FOVBlockBlock FOVBlock; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public AgentFOVPacket() - { - Header = new LowHeader(); - Header.ID = 113; - Header.Reliable = true; - FOVBlock = new FOVBlockBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 113; + Header.Reliable = true; + FOVBlock = new FOVBlockBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AgentFOVPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - FOVBlock = new FOVBlockBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + FOVBlock = new FOVBlockBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AgentFOVPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - FOVBlock = new FOVBlockBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + FOVBlock = new FOVBlockBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += FOVBlock.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - FOVBlock.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += FOVBlock.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + FOVBlock.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AgentFOV ---\n"; - output += FOVBlock.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- AgentFOV ---\n"; + output += FOVBlock.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// AgentHeightWidth packet + + /// AgentHeightWidth packet public class AgentHeightWidthPacket : Packet - { - /// HeightWidthBlock block + { + /// HeightWidthBlock block public class HeightWidthBlockBlock - { - /// GenCounter field - public uint GenCounter; - /// Height field - public ushort Height; - /// Width field - public ushort Width; - - /// Length of this block serialized in bytes + { + /// GenCounter field + public uint GenCounter; + /// Height field + public ushort Height; + /// Width field + public ushort Width; + + /// Length of this block serialized in bytes public int Length { get - { - return 8; + { + return 8; } } - - /// Default constructor - public HeightWidthBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public HeightWidthBlockBlock() { } + /// Constructor for building the block from a byte array public HeightWidthBlockBlock(byte[] bytes, ref int i) - { + { try - { - GenCounter = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Height = (ushort)(bytes[i++] + (bytes[i++] << 8)); - Width = (ushort)(bytes[i++] + (bytes[i++] << 8)); + { + GenCounter = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Height = (ushort)(bytes[i++] + (bytes[i++] << 8)); + Width = (ushort)(bytes[i++] + (bytes[i++] << 8)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(GenCounter % 256); - bytes[i++] = (byte)((GenCounter >> 8) % 256); - bytes[i++] = (byte)((GenCounter >> 16) % 256); - bytes[i++] = (byte)((GenCounter >> 24) % 256); - bytes[i++] = (byte)(Height % 256); - bytes[i++] = (byte)((Height >> 8) % 256); - bytes[i++] = (byte)(Width % 256); - bytes[i++] = (byte)((Width >> 8) % 256); + { + bytes[i++] = (byte)(GenCounter % 256); + bytes[i++] = (byte)((GenCounter >> 8) % 256); + bytes[i++] = (byte)((GenCounter >> 16) % 256); + bytes[i++] = (byte)((GenCounter >> 24) % 256); + bytes[i++] = (byte)(Height % 256); + bytes[i++] = (byte)((Height >> 8) % 256); + bytes[i++] = (byte)(Width % 256); + bytes[i++] = (byte)((Width >> 8) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- HeightWidthBlock --\n"; - output += "GenCounter: " + GenCounter.ToString() + "\n"; - output += "Height: " + Height.ToString() + "\n"; - output += "Width: " + Width.ToString() + "\n"; + { + string output = "-- HeightWidthBlock --\n"; + output += "GenCounter: " + GenCounter.ToString() + "\n"; + output += "Height: " + Height.ToString() + "\n"; + output += "Width: " + Width.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - /// CircuitCode field - public uint CircuitCode; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + /// CircuitCode field + public uint CircuitCode; + + /// Length of this block serialized in bytes public int Length { get - { - return 36; + { + return 36; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; - CircuitCode = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; + CircuitCode = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(CircuitCode % 256); - bytes[i++] = (byte)((CircuitCode >> 8) % 256); - bytes[i++] = (byte)((CircuitCode >> 16) % 256); - bytes[i++] = (byte)((CircuitCode >> 24) % 256); + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(CircuitCode % 256); + bytes[i++] = (byte)((CircuitCode >> 8) % 256); + bytes[i++] = (byte)((CircuitCode >> 16) % 256); + bytes[i++] = (byte)((CircuitCode >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "CircuitCode: " + CircuitCode.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "CircuitCode: " + CircuitCode.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AgentHeightWidth - public override PacketType Type { get { return PacketType.AgentHeightWidth; } } - /// HeightWidthBlock block - public HeightWidthBlockBlock HeightWidthBlock; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AgentHeightWidth + public override PacketType Type { get { return PacketType.AgentHeightWidth; } } + /// HeightWidthBlock block + public HeightWidthBlockBlock HeightWidthBlock; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public AgentHeightWidthPacket() - { - Header = new LowHeader(); - Header.ID = 114; - Header.Reliable = true; - HeightWidthBlock = new HeightWidthBlockBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 114; + Header.Reliable = true; + HeightWidthBlock = new HeightWidthBlockBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AgentHeightWidthPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - HeightWidthBlock = new HeightWidthBlockBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + HeightWidthBlock = new HeightWidthBlockBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AgentHeightWidthPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - HeightWidthBlock = new HeightWidthBlockBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + HeightWidthBlock = new HeightWidthBlockBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += HeightWidthBlock.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - HeightWidthBlock.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += HeightWidthBlock.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + HeightWidthBlock.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AgentHeightWidth ---\n"; - output += HeightWidthBlock.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- AgentHeightWidth ---\n"; + output += HeightWidthBlock.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// AgentSetAppearance packet + + /// AgentSetAppearance packet public class AgentSetAppearancePacket : Packet - { - /// VisualParam block + { + /// VisualParam block public class VisualParamBlock - { - /// ParamValue field - public byte ParamValue; - - /// Length of this block serialized in bytes + { + /// ParamValue field + public byte ParamValue; + + /// Length of this block serialized in bytes public int Length { get - { - return 1; + { + return 1; } } - - /// Default constructor - public VisualParamBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public VisualParamBlock() { } + /// Constructor for building the block from a byte array public VisualParamBlock(byte[] bytes, ref int i) - { + { try - { - ParamValue = (byte)bytes[i++]; + { + ParamValue = (byte)bytes[i++]; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = ParamValue; + { + bytes[i++] = ParamValue; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- VisualParam --\n"; - output += "ParamValue: " + ParamValue.ToString() + "\n"; + { + string output = "-- VisualParam --\n"; + output += "ParamValue: " + ParamValue.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// ObjectData block + + /// ObjectData block public class ObjectDataBlock - { - private byte[] _textureentry; - /// TextureEntry field + { + private byte[] _textureentry; + /// TextureEntry field public byte[] TextureEntry - { - get { return _textureentry; } + { + get { return _textureentry; } set - { - if (value == null) { _textureentry = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _textureentry = new byte[value.Length]; Array.Copy(value, _textureentry, value.Length); } + { + if (value == null) { _textureentry = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _textureentry = new byte[value.Length]; Array.Copy(value, _textureentry, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 0; - if (TextureEntry != null) { length += 2 + TextureEntry.Length; } - return length; + { + int length = 0; + if (TextureEntry != null) { length += 2 + TextureEntry.Length; } + return length; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _textureentry = new byte[length]; - Array.Copy(bytes, i, _textureentry, 0, length); i += length; + { + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _textureentry = new byte[length]; + Array.Copy(bytes, i, _textureentry, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(TextureEntry == null) { Console.WriteLine("Warning: TextureEntry is null, in " + this.GetType()); } - bytes[i++] = (byte)(TextureEntry.Length % 256); - bytes[i++] = (byte)((TextureEntry.Length >> 8) % 256); - Array.Copy(TextureEntry, 0, bytes, i, TextureEntry.Length); i += TextureEntry.Length; + { + if(TextureEntry == null) { Console.WriteLine("Warning: TextureEntry is null, in " + this.GetType()); } + bytes[i++] = (byte)(TextureEntry.Length % 256); + bytes[i++] = (byte)((TextureEntry.Length >> 8) % 256); + Array.Copy(TextureEntry, 0, bytes, i, TextureEntry.Length); i += TextureEntry.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += Helpers.FieldToString(TextureEntry, "TextureEntry") + "\n"; + { + string output = "-- ObjectData --\n"; + output += Helpers.FieldToString(TextureEntry, "TextureEntry") + "\n"; output = output.Trim(); return output; - } + } } - - /// WearableData block + + /// WearableData block public class WearableDataBlock - { - /// TextureIndex field - public byte TextureIndex; - /// CacheID field - public LLUUID CacheID; - - /// Length of this block serialized in bytes + { + /// TextureIndex field + public byte TextureIndex; + /// CacheID field + public LLUUID CacheID; + + /// Length of this block serialized in bytes public int Length { get - { - return 17; + { + return 17; } } - - /// Default constructor - public WearableDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public WearableDataBlock() { } + /// Constructor for building the block from a byte array public WearableDataBlock(byte[] bytes, ref int i) - { + { try - { - TextureIndex = (byte)bytes[i++]; - CacheID = new LLUUID(bytes, i); i += 16; + { + TextureIndex = (byte)bytes[i++]; + CacheID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = TextureIndex; - if(CacheID == null) { Console.WriteLine("Warning: CacheID is null, in " + this.GetType()); } - Array.Copy(CacheID.GetBytes(), 0, bytes, i, 16); i += 16; + { + bytes[i++] = TextureIndex; + if(CacheID == null) { Console.WriteLine("Warning: CacheID is null, in " + this.GetType()); } + Array.Copy(CacheID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- WearableData --\n"; - output += "TextureIndex: " + TextureIndex.ToString() + "\n"; - output += "CacheID: " + CacheID.ToString() + "\n"; + { + string output = "-- WearableData --\n"; + output += "TextureIndex: " + TextureIndex.ToString() + "\n"; + output += "CacheID: " + CacheID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// SerialNum field - public uint SerialNum; - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - /// Size field - public LLVector3 Size; - - /// Length of this block serialized in bytes + { + /// SerialNum field + public uint SerialNum; + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + /// Size field + public LLVector3 Size; + + /// Length of this block serialized in bytes public int Length { get - { - return 48; + { + return 48; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - SerialNum = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; - Size = new LLVector3(bytes, i); i += 12; + { + SerialNum = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; + Size = new LLVector3(bytes, i); i += 12; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(SerialNum % 256); - bytes[i++] = (byte)((SerialNum >> 8) % 256); - bytes[i++] = (byte)((SerialNum >> 16) % 256); - bytes[i++] = (byte)((SerialNum >> 24) % 256); - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - if(Size == null) { Console.WriteLine("Warning: Size is null, in " + this.GetType()); } - Array.Copy(Size.GetBytes(), 0, bytes, i, 12); i += 12; + { + bytes[i++] = (byte)(SerialNum % 256); + bytes[i++] = (byte)((SerialNum >> 8) % 256); + bytes[i++] = (byte)((SerialNum >> 16) % 256); + bytes[i++] = (byte)((SerialNum >> 24) % 256); + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + if(Size == null) { Console.WriteLine("Warning: Size is null, in " + this.GetType()); } + Array.Copy(Size.GetBytes(), 0, bytes, i, 12); i += 12; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "SerialNum: " + SerialNum.ToString() + "\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "Size: " + Size.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "SerialNum: " + SerialNum.ToString() + "\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "Size: " + Size.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AgentSetAppearance - public override PacketType Type { get { return PacketType.AgentSetAppearance; } } - /// VisualParam block - public VisualParamBlock[] VisualParam; - /// ObjectData block - public ObjectDataBlock ObjectData; - /// WearableData block - public WearableDataBlock[] WearableData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AgentSetAppearance + public override PacketType Type { get { return PacketType.AgentSetAppearance; } } + /// VisualParam block + public VisualParamBlock[] VisualParam; + /// ObjectData block + public ObjectDataBlock ObjectData; + /// WearableData block + public WearableDataBlock[] WearableData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public AgentSetAppearancePacket() - { - Header = new LowHeader(); - Header.ID = 115; - Header.Reliable = true; - Header.Zerocoded = true; - VisualParam = new VisualParamBlock[0]; - ObjectData = new ObjectDataBlock(); - WearableData = new WearableDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 115; + Header.Reliable = true; + Header.Zerocoded = true; + VisualParam = new VisualParamBlock[0]; + ObjectData = new ObjectDataBlock(); + WearableData = new WearableDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AgentSetAppearancePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - VisualParam = new VisualParamBlock[count]; - for (int j = 0; j < count; j++) - { VisualParam[j] = new VisualParamBlock(bytes, ref i); } - ObjectData = new ObjectDataBlock(bytes, ref i); - count = (int)bytes[i++]; - WearableData = new WearableDataBlock[count]; - for (int j = 0; j < count; j++) - { WearableData[j] = new WearableDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + VisualParam = new VisualParamBlock[count]; + for (int j = 0; j < count; j++) + { VisualParam[j] = new VisualParamBlock(bytes, ref i); } + ObjectData = new ObjectDataBlock(bytes, ref i); + count = (int)bytes[i++]; + WearableData = new WearableDataBlock[count]; + for (int j = 0; j < count; j++) + { WearableData[j] = new WearableDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AgentSetAppearancePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - VisualParam = new VisualParamBlock[count]; - for (int j = 0; j < count; j++) - { VisualParam[j] = new VisualParamBlock(bytes, ref i); } - ObjectData = new ObjectDataBlock(bytes, ref i); - count = (int)bytes[i++]; - WearableData = new WearableDataBlock[count]; - for (int j = 0; j < count; j++) - { WearableData[j] = new WearableDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + VisualParam = new VisualParamBlock[count]; + for (int j = 0; j < count; j++) + { VisualParam[j] = new VisualParamBlock(bytes, ref i); } + ObjectData = new ObjectDataBlock(bytes, ref i); + count = (int)bytes[i++]; + WearableData = new WearableDataBlock[count]; + for (int j = 0; j < count; j++) + { WearableData[j] = new WearableDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += ObjectData.Length; length += AgentData.Length;; - length++; - for (int j = 0; j < VisualParam.Length; j++) { length += VisualParam[j].Length; } - length++; - for (int j = 0; j < WearableData.Length; j++) { length += WearableData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)VisualParam.Length; - for (int j = 0; j < VisualParam.Length; j++) { VisualParam[j].ToBytes(bytes, ref i); } - ObjectData.ToBytes(bytes, ref i); - bytes[i++] = (byte)WearableData.Length; - for (int j = 0; j < WearableData.Length; j++) { WearableData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += ObjectData.Length; length += AgentData.Length;; + length++; + for (int j = 0; j < VisualParam.Length; j++) { length += VisualParam[j].Length; } + length++; + for (int j = 0; j < WearableData.Length; j++) { length += WearableData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)VisualParam.Length; + for (int j = 0; j < VisualParam.Length; j++) { VisualParam[j].ToBytes(bytes, ref i); } + ObjectData.ToBytes(bytes, ref i); + bytes[i++] = (byte)WearableData.Length; + for (int j = 0; j < WearableData.Length; j++) { WearableData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AgentSetAppearance ---\n"; + { + string output = "--- AgentSetAppearance ---\n"; for (int j = 0; j < VisualParam.Length; j++) - { + { output += VisualParam[j].ToString() + "\n"; - } - output += ObjectData.ToString() + "\n"; + } + output += ObjectData.ToString() + "\n"; for (int j = 0; j < WearableData.Length; j++) - { + { output += WearableData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// AgentQuit packet + + /// AgentQuit packet public class AgentQuitPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AgentQuit - public override PacketType Type { get { return PacketType.AgentQuit; } } - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AgentQuit + public override PacketType Type { get { return PacketType.AgentQuit; } } + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public AgentQuitPacket() - { - Header = new LowHeader(); - Header.ID = 116; - Header.Reliable = true; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 116; + Header.Reliable = true; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AgentQuitPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AgentQuitPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AgentQuit ---\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- AgentQuit ---\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// AgentQuitCopy packet + + /// AgentQuitCopy packet public class AgentQuitCopyPacket : Packet - { - /// FuseBlock block + { + /// FuseBlock block public class FuseBlockBlock - { - /// ViewerCircuitCode field - public uint ViewerCircuitCode; - - /// Length of this block serialized in bytes + { + /// ViewerCircuitCode field + public uint ViewerCircuitCode; + + /// Length of this block serialized in bytes public int Length { get - { - return 4; + { + return 4; } } - - /// Default constructor - public FuseBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public FuseBlockBlock() { } + /// Constructor for building the block from a byte array public FuseBlockBlock(byte[] bytes, ref int i) - { + { try - { - ViewerCircuitCode = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + ViewerCircuitCode = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(ViewerCircuitCode % 256); - bytes[i++] = (byte)((ViewerCircuitCode >> 8) % 256); - bytes[i++] = (byte)((ViewerCircuitCode >> 16) % 256); - bytes[i++] = (byte)((ViewerCircuitCode >> 24) % 256); + { + bytes[i++] = (byte)(ViewerCircuitCode % 256); + bytes[i++] = (byte)((ViewerCircuitCode >> 8) % 256); + bytes[i++] = (byte)((ViewerCircuitCode >> 16) % 256); + bytes[i++] = (byte)((ViewerCircuitCode >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- FuseBlock --\n"; - output += "ViewerCircuitCode: " + ViewerCircuitCode.ToString() + "\n"; + { + string output = "-- FuseBlock --\n"; + output += "ViewerCircuitCode: " + ViewerCircuitCode.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AgentQuitCopy - public override PacketType Type { get { return PacketType.AgentQuitCopy; } } - /// FuseBlock block - public FuseBlockBlock FuseBlock; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AgentQuitCopy + public override PacketType Type { get { return PacketType.AgentQuitCopy; } } + /// FuseBlock block + public FuseBlockBlock FuseBlock; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public AgentQuitCopyPacket() - { - Header = new LowHeader(); - Header.ID = 117; - Header.Reliable = true; - FuseBlock = new FuseBlockBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 117; + Header.Reliable = true; + FuseBlock = new FuseBlockBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AgentQuitCopyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - FuseBlock = new FuseBlockBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + FuseBlock = new FuseBlockBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AgentQuitCopyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - FuseBlock = new FuseBlockBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + FuseBlock = new FuseBlockBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += FuseBlock.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - FuseBlock.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += FuseBlock.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + FuseBlock.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AgentQuitCopy ---\n"; - output += FuseBlock.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- AgentQuitCopy ---\n"; + output += FuseBlock.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ImageNotInDatabase packet + + /// ImageNotInDatabase packet public class ImageNotInDatabasePacket : Packet - { - /// ImageID block + { + /// ImageID block public class ImageIDBlock - { - /// ID field - public LLUUID ID; - - /// Length of this block serialized in bytes + { + /// ID field + public LLUUID ID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public ImageIDBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ImageIDBlock() { } + /// Constructor for building the block from a byte array public ImageIDBlock(byte[] bytes, ref int i) - { + { try - { - ID = new LLUUID(bytes, i); i += 16; + { + ID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } - Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } + Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ImageID --\n"; - output += "ID: " + ID.ToString() + "\n"; + { + string output = "-- ImageID --\n"; + output += "ID: " + ID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ImageNotInDatabase - public override PacketType Type { get { return PacketType.ImageNotInDatabase; } } - /// ImageID block - public ImageIDBlock ImageID; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ImageNotInDatabase + public override PacketType Type { get { return PacketType.ImageNotInDatabase; } } + /// ImageID block + public ImageIDBlock ImageID; + + /// Default constructor public ImageNotInDatabasePacket() - { - Header = new LowHeader(); - Header.ID = 118; - Header.Reliable = true; - ImageID = new ImageIDBlock(); + { + Header = new LowHeader(); + Header.ID = 118; + Header.Reliable = true; + ImageID = new ImageIDBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ImageNotInDatabasePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - ImageID = new ImageIDBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + ImageID = new ImageIDBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ImageNotInDatabasePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - ImageID = new ImageIDBlock(bytes, ref i); + { + Header = head; + ImageID = new ImageIDBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += ImageID.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - ImageID.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += ImageID.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + ImageID.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ImageNotInDatabase ---\n"; - output += ImageID.ToString() + "\n"; + { + string output = "--- ImageNotInDatabase ---\n"; + output += ImageID.ToString() + "\n"; return output; } - + } - - /// RebakeAvatarTextures packet + + /// RebakeAvatarTextures packet public class RebakeAvatarTexturesPacket : Packet - { - /// TextureData block + { + /// TextureData block public class TextureDataBlock - { - /// TextureID field - public LLUUID TextureID; - - /// Length of this block serialized in bytes + { + /// TextureID field + public LLUUID TextureID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public TextureDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public TextureDataBlock() { } + /// Constructor for building the block from a byte array public TextureDataBlock(byte[] bytes, ref int i) - { + { try - { - TextureID = new LLUUID(bytes, i); i += 16; + { + TextureID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(TextureID == null) { Console.WriteLine("Warning: TextureID is null, in " + this.GetType()); } - Array.Copy(TextureID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(TextureID == null) { Console.WriteLine("Warning: TextureID is null, in " + this.GetType()); } + Array.Copy(TextureID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- TextureData --\n"; - output += "TextureID: " + TextureID.ToString() + "\n"; + { + string output = "-- TextureData --\n"; + output += "TextureID: " + TextureID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.RebakeAvatarTextures - public override PacketType Type { get { return PacketType.RebakeAvatarTextures; } } - /// TextureData block - public TextureDataBlock TextureData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.RebakeAvatarTextures + public override PacketType Type { get { return PacketType.RebakeAvatarTextures; } } + /// TextureData block + public TextureDataBlock TextureData; + + /// Default constructor public RebakeAvatarTexturesPacket() - { - Header = new LowHeader(); - Header.ID = 119; - Header.Reliable = true; - TextureData = new TextureDataBlock(); + { + Header = new LowHeader(); + Header.ID = 119; + Header.Reliable = true; + TextureData = new TextureDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public RebakeAvatarTexturesPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - TextureData = new TextureDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + TextureData = new TextureDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public RebakeAvatarTexturesPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - TextureData = new TextureDataBlock(bytes, ref i); + { + Header = head; + TextureData = new TextureDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += TextureData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - TextureData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += TextureData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + TextureData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- RebakeAvatarTextures ---\n"; - output += TextureData.ToString() + "\n"; + { + string output = "--- RebakeAvatarTextures ---\n"; + output += TextureData.ToString() + "\n"; return output; } - + } - - /// SetAlwaysRun packet + + /// SetAlwaysRun packet public class SetAlwaysRunPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - /// AlwaysRun field - public bool AlwaysRun; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + /// AlwaysRun field + public bool AlwaysRun; + + /// Length of this block serialized in bytes public int Length { get - { - return 33; + { + return 33; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; - AlwaysRun = (bytes[i++] != 0) ? (bool)true : (bool)false; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; + AlwaysRun = (bytes[i++] != 0) ? (bool)true : (bool)false; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((AlwaysRun) ? 1 : 0); + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((AlwaysRun) ? 1 : 0); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "AlwaysRun: " + AlwaysRun.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "AlwaysRun: " + AlwaysRun.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.SetAlwaysRun - public override PacketType Type { get { return PacketType.SetAlwaysRun; } } - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.SetAlwaysRun + public override PacketType Type { get { return PacketType.SetAlwaysRun; } } + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public SetAlwaysRunPacket() - { - Header = new LowHeader(); - Header.ID = 120; - Header.Reliable = true; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 120; + Header.Reliable = true; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public SetAlwaysRunPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public SetAlwaysRunPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- SetAlwaysRun ---\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- SetAlwaysRun ---\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ObjectDelete packet + + /// ObjectDelete packet public class ObjectDeletePacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - /// ObjectLocalID field - public uint ObjectLocalID; - - /// Length of this block serialized in bytes + { + /// ObjectLocalID field + public uint ObjectLocalID; + + /// Length of this block serialized in bytes public int Length { get - { - return 4; + { + return 4; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { + { try - { - ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(ObjectLocalID % 256); - bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); + { + bytes[i++] = (byte)(ObjectLocalID % 256); + bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; + { + string output = "-- ObjectData --\n"; + output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - /// Force field - public bool Force; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + /// Force field + public bool Force; + + /// Length of this block serialized in bytes public int Length { get - { - return 33; + { + return 33; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; - Force = (bytes[i++] != 0) ? (bool)true : (bool)false; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; + Force = (bytes[i++] != 0) ? (bool)true : (bool)false; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((Force) ? 1 : 0); + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((Force) ? 1 : 0); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "Force: " + Force.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "Force: " + Force.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ObjectDelete - public override PacketType Type { get { return PacketType.ObjectDelete; } } - /// ObjectData block - public ObjectDataBlock[] ObjectData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ObjectDelete + public override PacketType Type { get { return PacketType.ObjectDelete; } } + /// ObjectData block + public ObjectDataBlock[] ObjectData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ObjectDeletePacket() - { - Header = new LowHeader(); - Header.ID = 121; - Header.Reliable = true; - Header.Zerocoded = true; - ObjectData = new ObjectDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 121; + Header.Reliable = true; + Header.Zerocoded = true; + ObjectData = new ObjectDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ObjectDeletePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ObjectDeletePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ObjectData.Length; - for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ObjectData.Length; + for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ObjectDelete ---\n"; + { + string output = "--- ObjectDelete ---\n"; for (int j = 0; j < ObjectData.Length; j++) - { + { output += ObjectData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ObjectDuplicate packet + + /// ObjectDuplicate packet public class ObjectDuplicatePacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - /// ObjectLocalID field - public uint ObjectLocalID; - - /// Length of this block serialized in bytes + { + /// ObjectLocalID field + public uint ObjectLocalID; + + /// Length of this block serialized in bytes public int Length { get - { - return 4; + { + return 4; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { + { try - { - ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(ObjectLocalID % 256); - bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); + { + bytes[i++] = (byte)(ObjectLocalID % 256); + bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; + { + string output = "-- ObjectData --\n"; + output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// SharedData block + + /// SharedData block public class SharedDataBlock - { - /// DuplicateFlags field - public uint DuplicateFlags; - /// Offset field - public LLVector3 Offset; - - /// Length of this block serialized in bytes + { + /// DuplicateFlags field + public uint DuplicateFlags; + /// Offset field + public LLVector3 Offset; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public SharedDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public SharedDataBlock() { } + /// Constructor for building the block from a byte array public SharedDataBlock(byte[] bytes, ref int i) - { + { try - { - DuplicateFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Offset = new LLVector3(bytes, i); i += 12; + { + DuplicateFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Offset = new LLVector3(bytes, i); i += 12; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(DuplicateFlags % 256); - bytes[i++] = (byte)((DuplicateFlags >> 8) % 256); - bytes[i++] = (byte)((DuplicateFlags >> 16) % 256); - bytes[i++] = (byte)((DuplicateFlags >> 24) % 256); - if(Offset == null) { Console.WriteLine("Warning: Offset is null, in " + this.GetType()); } - Array.Copy(Offset.GetBytes(), 0, bytes, i, 12); i += 12; + { + bytes[i++] = (byte)(DuplicateFlags % 256); + bytes[i++] = (byte)((DuplicateFlags >> 8) % 256); + bytes[i++] = (byte)((DuplicateFlags >> 16) % 256); + bytes[i++] = (byte)((DuplicateFlags >> 24) % 256); + if(Offset == null) { Console.WriteLine("Warning: Offset is null, in " + this.GetType()); } + Array.Copy(Offset.GetBytes(), 0, bytes, i, 12); i += 12; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- SharedData --\n"; - output += "DuplicateFlags: " + DuplicateFlags.ToString() + "\n"; - output += "Offset: " + Offset.ToString() + "\n"; + { + string output = "-- SharedData --\n"; + output += "DuplicateFlags: " + DuplicateFlags.ToString() + "\n"; + output += "Offset: " + Offset.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - /// GroupID field - public LLUUID GroupID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + /// GroupID field + public LLUUID GroupID; + + /// Length of this block serialized in bytes public int Length { get - { - return 48; + { + return 48; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; - GroupID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; + GroupID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ObjectDuplicate - public override PacketType Type { get { return PacketType.ObjectDuplicate; } } - /// ObjectData block - public ObjectDataBlock[] ObjectData; - /// SharedData block - public SharedDataBlock SharedData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ObjectDuplicate + public override PacketType Type { get { return PacketType.ObjectDuplicate; } } + /// ObjectData block + public ObjectDataBlock[] ObjectData; + /// SharedData block + public SharedDataBlock SharedData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ObjectDuplicatePacket() - { - Header = new LowHeader(); - Header.ID = 122; - Header.Reliable = true; - Header.Zerocoded = true; - ObjectData = new ObjectDataBlock[0]; - SharedData = new SharedDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 122; + Header.Reliable = true; + Header.Zerocoded = true; + ObjectData = new ObjectDataBlock[0]; + SharedData = new SharedDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ObjectDuplicatePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - SharedData = new SharedDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + SharedData = new SharedDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ObjectDuplicatePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - SharedData = new SharedDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + SharedData = new SharedDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += SharedData.Length; length += AgentData.Length;; - length++; - for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ObjectData.Length; - for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } - SharedData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += SharedData.Length; length += AgentData.Length;; + length++; + for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ObjectData.Length; + for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } + SharedData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ObjectDuplicate ---\n"; + { + string output = "--- ObjectDuplicate ---\n"; for (int j = 0; j < ObjectData.Length; j++) - { + { output += ObjectData[j].ToString() + "\n"; - } - output += SharedData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + } + output += SharedData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ObjectDuplicateOnRay packet + + /// ObjectDuplicateOnRay packet public class ObjectDuplicateOnRayPacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - /// ObjectLocalID field - public uint ObjectLocalID; - - /// Length of this block serialized in bytes + { + /// ObjectLocalID field + public uint ObjectLocalID; + + /// Length of this block serialized in bytes public int Length { get - { - return 4; + { + return 4; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { + { try - { - ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(ObjectLocalID % 256); - bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); + { + bytes[i++] = (byte)(ObjectLocalID % 256); + bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; + { + string output = "-- ObjectData --\n"; + output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// DuplicateFlags field - public uint DuplicateFlags; - /// CopyRotates field - public bool CopyRotates; - /// SessionID field - public LLUUID SessionID; - /// RayStart field - public LLVector3 RayStart; - /// GroupID field - public LLUUID GroupID; - /// RayEndIsIntersection field - public bool RayEndIsIntersection; - /// RayEnd field - public LLVector3 RayEnd; - /// BypassRaycast field - public bool BypassRaycast; - /// CopyCenters field - public bool CopyCenters; - /// RayTargetID field - public LLUUID RayTargetID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// DuplicateFlags field + public uint DuplicateFlags; + /// CopyRotates field + public bool CopyRotates; + /// SessionID field + public LLUUID SessionID; + /// RayStart field + public LLVector3 RayStart; + /// GroupID field + public LLUUID GroupID; + /// RayEndIsIntersection field + public bool RayEndIsIntersection; + /// RayEnd field + public LLVector3 RayEnd; + /// BypassRaycast field + public bool BypassRaycast; + /// CopyCenters field + public bool CopyCenters; + /// RayTargetID field + public LLUUID RayTargetID; + + /// Length of this block serialized in bytes public int Length { get - { - return 96; + { + return 96; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - DuplicateFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - CopyRotates = (bytes[i++] != 0) ? (bool)true : (bool)false; - SessionID = new LLUUID(bytes, i); i += 16; - RayStart = new LLVector3(bytes, i); i += 12; - GroupID = new LLUUID(bytes, i); i += 16; - RayEndIsIntersection = (bytes[i++] != 0) ? (bool)true : (bool)false; - RayEnd = new LLVector3(bytes, i); i += 12; - BypassRaycast = (bytes[i++] != 0) ? (bool)true : (bool)false; - CopyCenters = (bytes[i++] != 0) ? (bool)true : (bool)false; - RayTargetID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + DuplicateFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + CopyRotates = (bytes[i++] != 0) ? (bool)true : (bool)false; + SessionID = new LLUUID(bytes, i); i += 16; + RayStart = new LLVector3(bytes, i); i += 12; + GroupID = new LLUUID(bytes, i); i += 16; + RayEndIsIntersection = (bytes[i++] != 0) ? (bool)true : (bool)false; + RayEnd = new LLVector3(bytes, i); i += 12; + BypassRaycast = (bytes[i++] != 0) ? (bool)true : (bool)false; + CopyCenters = (bytes[i++] != 0) ? (bool)true : (bool)false; + RayTargetID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(DuplicateFlags % 256); - bytes[i++] = (byte)((DuplicateFlags >> 8) % 256); - bytes[i++] = (byte)((DuplicateFlags >> 16) % 256); - bytes[i++] = (byte)((DuplicateFlags >> 24) % 256); - bytes[i++] = (byte)((CopyRotates) ? 1 : 0); - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - if(RayStart == null) { Console.WriteLine("Warning: RayStart is null, in " + this.GetType()); } - Array.Copy(RayStart.GetBytes(), 0, bytes, i, 12); i += 12; - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((RayEndIsIntersection) ? 1 : 0); - if(RayEnd == null) { Console.WriteLine("Warning: RayEnd is null, in " + this.GetType()); } - Array.Copy(RayEnd.GetBytes(), 0, bytes, i, 12); i += 12; - bytes[i++] = (byte)((BypassRaycast) ? 1 : 0); - bytes[i++] = (byte)((CopyCenters) ? 1 : 0); - if(RayTargetID == null) { Console.WriteLine("Warning: RayTargetID is null, in " + this.GetType()); } - Array.Copy(RayTargetID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(DuplicateFlags % 256); + bytes[i++] = (byte)((DuplicateFlags >> 8) % 256); + bytes[i++] = (byte)((DuplicateFlags >> 16) % 256); + bytes[i++] = (byte)((DuplicateFlags >> 24) % 256); + bytes[i++] = (byte)((CopyRotates) ? 1 : 0); + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + if(RayStart == null) { Console.WriteLine("Warning: RayStart is null, in " + this.GetType()); } + Array.Copy(RayStart.GetBytes(), 0, bytes, i, 12); i += 12; + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((RayEndIsIntersection) ? 1 : 0); + if(RayEnd == null) { Console.WriteLine("Warning: RayEnd is null, in " + this.GetType()); } + Array.Copy(RayEnd.GetBytes(), 0, bytes, i, 12); i += 12; + bytes[i++] = (byte)((BypassRaycast) ? 1 : 0); + bytes[i++] = (byte)((CopyCenters) ? 1 : 0); + if(RayTargetID == null) { Console.WriteLine("Warning: RayTargetID is null, in " + this.GetType()); } + Array.Copy(RayTargetID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "DuplicateFlags: " + DuplicateFlags.ToString() + "\n"; - output += "CopyRotates: " + CopyRotates.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "RayStart: " + RayStart.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; - output += "RayEndIsIntersection: " + RayEndIsIntersection.ToString() + "\n"; - output += "RayEnd: " + RayEnd.ToString() + "\n"; - output += "BypassRaycast: " + BypassRaycast.ToString() + "\n"; - output += "CopyCenters: " + CopyCenters.ToString() + "\n"; - output += "RayTargetID: " + RayTargetID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "DuplicateFlags: " + DuplicateFlags.ToString() + "\n"; + output += "CopyRotates: " + CopyRotates.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "RayStart: " + RayStart.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; + output += "RayEndIsIntersection: " + RayEndIsIntersection.ToString() + "\n"; + output += "RayEnd: " + RayEnd.ToString() + "\n"; + output += "BypassRaycast: " + BypassRaycast.ToString() + "\n"; + output += "CopyCenters: " + CopyCenters.ToString() + "\n"; + output += "RayTargetID: " + RayTargetID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ObjectDuplicateOnRay - public override PacketType Type { get { return PacketType.ObjectDuplicateOnRay; } } - /// ObjectData block - public ObjectDataBlock[] ObjectData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ObjectDuplicateOnRay + public override PacketType Type { get { return PacketType.ObjectDuplicateOnRay; } } + /// ObjectData block + public ObjectDataBlock[] ObjectData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ObjectDuplicateOnRayPacket() - { - Header = new LowHeader(); - Header.ID = 123; - Header.Reliable = true; - Header.Zerocoded = true; - ObjectData = new ObjectDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 123; + Header.Reliable = true; + Header.Zerocoded = true; + ObjectData = new ObjectDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ObjectDuplicateOnRayPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ObjectDuplicateOnRayPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ObjectData.Length; - for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ObjectData.Length; + for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ObjectDuplicateOnRay ---\n"; + { + string output = "--- ObjectDuplicateOnRay ---\n"; for (int j = 0; j < ObjectData.Length; j++) - { + { output += ObjectData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ObjectScale packet + + /// ObjectScale packet public class ObjectScalePacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - /// ObjectLocalID field - public uint ObjectLocalID; - /// Scale field - public LLVector3 Scale; - - /// Length of this block serialized in bytes + { + /// ObjectLocalID field + public uint ObjectLocalID; + /// Scale field + public LLVector3 Scale; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { + { try - { - ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Scale = new LLVector3(bytes, i); i += 12; + { + ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Scale = new LLVector3(bytes, i); i += 12; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(ObjectLocalID % 256); - bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); - if(Scale == null) { Console.WriteLine("Warning: Scale is null, in " + this.GetType()); } - Array.Copy(Scale.GetBytes(), 0, bytes, i, 12); i += 12; + { + bytes[i++] = (byte)(ObjectLocalID % 256); + bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); + if(Scale == null) { Console.WriteLine("Warning: Scale is null, in " + this.GetType()); } + Array.Copy(Scale.GetBytes(), 0, bytes, i, 12); i += 12; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; - output += "Scale: " + Scale.ToString() + "\n"; + { + string output = "-- ObjectData --\n"; + output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; + output += "Scale: " + Scale.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ObjectScale - public override PacketType Type { get { return PacketType.ObjectScale; } } - /// ObjectData block - public ObjectDataBlock[] ObjectData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ObjectScale + public override PacketType Type { get { return PacketType.ObjectScale; } } + /// ObjectData block + public ObjectDataBlock[] ObjectData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ObjectScalePacket() - { - Header = new LowHeader(); - Header.ID = 124; - Header.Reliable = true; - Header.Zerocoded = true; - ObjectData = new ObjectDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 124; + Header.Reliable = true; + Header.Zerocoded = true; + ObjectData = new ObjectDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ObjectScalePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ObjectScalePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ObjectData.Length; - for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ObjectData.Length; + for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ObjectScale ---\n"; + { + string output = "--- ObjectScale ---\n"; for (int j = 0; j < ObjectData.Length; j++) - { + { output += ObjectData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ObjectRotation packet + + /// ObjectRotation packet public class ObjectRotationPacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - /// ObjectLocalID field - public uint ObjectLocalID; - /// Rotation field - public LLQuaternion Rotation; - - /// Length of this block serialized in bytes + { + /// ObjectLocalID field + public uint ObjectLocalID; + /// Rotation field + public LLQuaternion Rotation; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { + { try - { - ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Rotation = new LLQuaternion(bytes, i, true); i += 12; + { + ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Rotation = new LLQuaternion(bytes, i, true); i += 12; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(ObjectLocalID % 256); - bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); - if(Rotation == null) { Console.WriteLine("Warning: Rotation is null, in " + this.GetType()); } - Array.Copy(Rotation.GetBytes(), 0, bytes, i, 12); i += 12; + { + bytes[i++] = (byte)(ObjectLocalID % 256); + bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); + if(Rotation == null) { Console.WriteLine("Warning: Rotation is null, in " + this.GetType()); } + Array.Copy(Rotation.GetBytes(), 0, bytes, i, 12); i += 12; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; - output += "Rotation: " + Rotation.ToString() + "\n"; + { + string output = "-- ObjectData --\n"; + output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; + output += "Rotation: " + Rotation.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ObjectRotation - public override PacketType Type { get { return PacketType.ObjectRotation; } } - /// ObjectData block - public ObjectDataBlock[] ObjectData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ObjectRotation + public override PacketType Type { get { return PacketType.ObjectRotation; } } + /// ObjectData block + public ObjectDataBlock[] ObjectData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ObjectRotationPacket() - { - Header = new LowHeader(); - Header.ID = 125; - Header.Reliable = true; - Header.Zerocoded = true; - ObjectData = new ObjectDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 125; + Header.Reliable = true; + Header.Zerocoded = true; + ObjectData = new ObjectDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ObjectRotationPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ObjectRotationPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ObjectData.Length; - for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ObjectData.Length; + for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ObjectRotation ---\n"; + { + string output = "--- ObjectRotation ---\n"; for (int j = 0; j < ObjectData.Length; j++) - { + { output += ObjectData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ObjectFlagUpdate packet + + /// ObjectFlagUpdate packet public class ObjectFlagUpdatePacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - /// IsTemporary field - public bool IsTemporary; - /// ObjectLocalID field - public uint ObjectLocalID; - /// UsePhysics field - public bool UsePhysics; - /// CastsShadows field - public bool CastsShadows; - /// IsPhantom field - public bool IsPhantom; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + /// IsTemporary field + public bool IsTemporary; + /// ObjectLocalID field + public uint ObjectLocalID; + /// UsePhysics field + public bool UsePhysics; + /// CastsShadows field + public bool CastsShadows; + /// IsPhantom field + public bool IsPhantom; + + /// Length of this block serialized in bytes public int Length { get - { - return 40; + { + return 40; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; - IsTemporary = (bytes[i++] != 0) ? (bool)true : (bool)false; - ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - UsePhysics = (bytes[i++] != 0) ? (bool)true : (bool)false; - CastsShadows = (bytes[i++] != 0) ? (bool)true : (bool)false; - IsPhantom = (bytes[i++] != 0) ? (bool)true : (bool)false; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; + IsTemporary = (bytes[i++] != 0) ? (bool)true : (bool)false; + ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + UsePhysics = (bytes[i++] != 0) ? (bool)true : (bool)false; + CastsShadows = (bytes[i++] != 0) ? (bool)true : (bool)false; + IsPhantom = (bytes[i++] != 0) ? (bool)true : (bool)false; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((IsTemporary) ? 1 : 0); - bytes[i++] = (byte)(ObjectLocalID % 256); - bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); - bytes[i++] = (byte)((UsePhysics) ? 1 : 0); - bytes[i++] = (byte)((CastsShadows) ? 1 : 0); - bytes[i++] = (byte)((IsPhantom) ? 1 : 0); + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((IsTemporary) ? 1 : 0); + bytes[i++] = (byte)(ObjectLocalID % 256); + bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); + bytes[i++] = (byte)((UsePhysics) ? 1 : 0); + bytes[i++] = (byte)((CastsShadows) ? 1 : 0); + bytes[i++] = (byte)((IsPhantom) ? 1 : 0); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "IsTemporary: " + IsTemporary.ToString() + "\n"; - output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; - output += "UsePhysics: " + UsePhysics.ToString() + "\n"; - output += "CastsShadows: " + CastsShadows.ToString() + "\n"; - output += "IsPhantom: " + IsPhantom.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "IsTemporary: " + IsTemporary.ToString() + "\n"; + output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; + output += "UsePhysics: " + UsePhysics.ToString() + "\n"; + output += "CastsShadows: " + CastsShadows.ToString() + "\n"; + output += "IsPhantom: " + IsPhantom.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ObjectFlagUpdate - public override PacketType Type { get { return PacketType.ObjectFlagUpdate; } } - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ObjectFlagUpdate + public override PacketType Type { get { return PacketType.ObjectFlagUpdate; } } + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ObjectFlagUpdatePacket() - { - Header = new LowHeader(); - Header.ID = 126; - Header.Reliable = true; - Header.Zerocoded = true; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 126; + Header.Reliable = true; + Header.Zerocoded = true; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ObjectFlagUpdatePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ObjectFlagUpdatePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ObjectFlagUpdate ---\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- ObjectFlagUpdate ---\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ObjectClickAction packet + + /// ObjectClickAction packet public class ObjectClickActionPacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - /// ClickAction field - public byte ClickAction; - /// ObjectLocalID field - public uint ObjectLocalID; - - /// Length of this block serialized in bytes + { + /// ClickAction field + public byte ClickAction; + /// ObjectLocalID field + public uint ObjectLocalID; + + /// Length of this block serialized in bytes public int Length { get - { - return 5; + { + return 5; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { + { try - { - ClickAction = (byte)bytes[i++]; - ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + ClickAction = (byte)bytes[i++]; + ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = ClickAction; - bytes[i++] = (byte)(ObjectLocalID % 256); - bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); + { + bytes[i++] = ClickAction; + bytes[i++] = (byte)(ObjectLocalID % 256); + bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += "ClickAction: " + ClickAction.ToString() + "\n"; - output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; + { + string output = "-- ObjectData --\n"; + output += "ClickAction: " + ClickAction.ToString() + "\n"; + output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ObjectClickAction - public override PacketType Type { get { return PacketType.ObjectClickAction; } } - /// ObjectData block - public ObjectDataBlock[] ObjectData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ObjectClickAction + public override PacketType Type { get { return PacketType.ObjectClickAction; } } + /// ObjectData block + public ObjectDataBlock[] ObjectData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ObjectClickActionPacket() - { - Header = new LowHeader(); - Header.ID = 127; - Header.Reliable = true; - Header.Zerocoded = true; - ObjectData = new ObjectDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 127; + Header.Reliable = true; + Header.Zerocoded = true; + ObjectData = new ObjectDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ObjectClickActionPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ObjectClickActionPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ObjectData.Length; - for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ObjectData.Length; + for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ObjectClickAction ---\n"; + { + string output = "--- ObjectClickAction ---\n"; for (int j = 0; j < ObjectData.Length; j++) - { + { output += ObjectData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ObjectImage packet + + /// ObjectImage packet public class ObjectImagePacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - private byte[] _mediaurl; - /// MediaURL field + { + private byte[] _mediaurl; + /// MediaURL field public byte[] MediaURL - { - get { return _mediaurl; } + { + get { return _mediaurl; } set - { - if (value == null) { _mediaurl = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _mediaurl = new byte[value.Length]; Array.Copy(value, _mediaurl, value.Length); } + { + if (value == null) { _mediaurl = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _mediaurl = new byte[value.Length]; Array.Copy(value, _mediaurl, value.Length); } } - } - /// ObjectLocalID field - public uint ObjectLocalID; - private byte[] _textureentry; - /// TextureEntry field + } + /// ObjectLocalID field + public uint ObjectLocalID; + private byte[] _textureentry; + /// TextureEntry field public byte[] TextureEntry - { - get { return _textureentry; } + { + get { return _textureentry; } set - { - if (value == null) { _textureentry = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _textureentry = new byte[value.Length]; Array.Copy(value, _textureentry, value.Length); } + { + if (value == null) { _textureentry = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _textureentry = new byte[value.Length]; Array.Copy(value, _textureentry, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 4; - if (MediaURL != null) { length += 1 + MediaURL.Length; } - if (TextureEntry != null) { length += 2 + TextureEntry.Length; } - return length; + { + int length = 4; + if (MediaURL != null) { length += 1 + MediaURL.Length; } + if (TextureEntry != null) { length += 2 + TextureEntry.Length; } + return length; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _mediaurl = new byte[length]; - Array.Copy(bytes, i, _mediaurl, 0, length); i += length; - ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _textureentry = new byte[length]; - Array.Copy(bytes, i, _textureentry, 0, length); i += length; + { + length = (ushort)bytes[i++]; + _mediaurl = new byte[length]; + Array.Copy(bytes, i, _mediaurl, 0, length); i += length; + ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _textureentry = new byte[length]; + Array.Copy(bytes, i, _textureentry, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(MediaURL == null) { Console.WriteLine("Warning: MediaURL is null, in " + this.GetType()); } - bytes[i++] = (byte)MediaURL.Length; - Array.Copy(MediaURL, 0, bytes, i, MediaURL.Length); i += MediaURL.Length; - bytes[i++] = (byte)(ObjectLocalID % 256); - bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); - if(TextureEntry == null) { Console.WriteLine("Warning: TextureEntry is null, in " + this.GetType()); } - bytes[i++] = (byte)(TextureEntry.Length % 256); - bytes[i++] = (byte)((TextureEntry.Length >> 8) % 256); - Array.Copy(TextureEntry, 0, bytes, i, TextureEntry.Length); i += TextureEntry.Length; + { + if(MediaURL == null) { Console.WriteLine("Warning: MediaURL is null, in " + this.GetType()); } + bytes[i++] = (byte)MediaURL.Length; + Array.Copy(MediaURL, 0, bytes, i, MediaURL.Length); i += MediaURL.Length; + bytes[i++] = (byte)(ObjectLocalID % 256); + bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); + if(TextureEntry == null) { Console.WriteLine("Warning: TextureEntry is null, in " + this.GetType()); } + bytes[i++] = (byte)(TextureEntry.Length % 256); + bytes[i++] = (byte)((TextureEntry.Length >> 8) % 256); + Array.Copy(TextureEntry, 0, bytes, i, TextureEntry.Length); i += TextureEntry.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += Helpers.FieldToString(MediaURL, "MediaURL") + "\n"; - output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; - output += Helpers.FieldToString(TextureEntry, "TextureEntry") + "\n"; + { + string output = "-- ObjectData --\n"; + output += Helpers.FieldToString(MediaURL, "MediaURL") + "\n"; + output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; + output += Helpers.FieldToString(TextureEntry, "TextureEntry") + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ObjectImage - public override PacketType Type { get { return PacketType.ObjectImage; } } - /// ObjectData block - public ObjectDataBlock[] ObjectData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ObjectImage + public override PacketType Type { get { return PacketType.ObjectImage; } } + /// ObjectData block + public ObjectDataBlock[] ObjectData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ObjectImagePacket() - { - Header = new LowHeader(); - Header.ID = 128; - Header.Reliable = true; - Header.Zerocoded = true; - ObjectData = new ObjectDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 128; + Header.Reliable = true; + Header.Zerocoded = true; + ObjectData = new ObjectDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ObjectImagePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ObjectImagePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ObjectData.Length; - for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ObjectData.Length; + for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ObjectImage ---\n"; + { + string output = "--- ObjectImage ---\n"; for (int j = 0; j < ObjectData.Length; j++) - { + { output += ObjectData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ObjectMaterial packet + + /// ObjectMaterial packet public class ObjectMaterialPacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - /// Material field - public byte Material; - /// ObjectLocalID field - public uint ObjectLocalID; - - /// Length of this block serialized in bytes + { + /// Material field + public byte Material; + /// ObjectLocalID field + public uint ObjectLocalID; + + /// Length of this block serialized in bytes public int Length { get - { - return 5; + { + return 5; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { + { try - { - Material = (byte)bytes[i++]; - ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + Material = (byte)bytes[i++]; + ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = Material; - bytes[i++] = (byte)(ObjectLocalID % 256); - bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); + { + bytes[i++] = Material; + bytes[i++] = (byte)(ObjectLocalID % 256); + bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += "Material: " + Material.ToString() + "\n"; - output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; + { + string output = "-- ObjectData --\n"; + output += "Material: " + Material.ToString() + "\n"; + output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ObjectMaterial - public override PacketType Type { get { return PacketType.ObjectMaterial; } } - /// ObjectData block - public ObjectDataBlock[] ObjectData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ObjectMaterial + public override PacketType Type { get { return PacketType.ObjectMaterial; } } + /// ObjectData block + public ObjectDataBlock[] ObjectData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ObjectMaterialPacket() - { - Header = new LowHeader(); - Header.ID = 129; - Header.Reliable = true; - Header.Zerocoded = true; - ObjectData = new ObjectDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 129; + Header.Reliable = true; + Header.Zerocoded = true; + ObjectData = new ObjectDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ObjectMaterialPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ObjectMaterialPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ObjectData.Length; - for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ObjectData.Length; + for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ObjectMaterial ---\n"; + { + string output = "--- ObjectMaterial ---\n"; for (int j = 0; j < ObjectData.Length; j++) - { + { output += ObjectData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ObjectShape packet + + /// ObjectShape packet public class ObjectShapePacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - /// PathTwistBegin field - public sbyte PathTwistBegin; - /// PathEnd field - public byte PathEnd; - /// ProfileBegin field - public byte ProfileBegin; - /// PathRadiusOffset field - public sbyte PathRadiusOffset; - /// PathSkew field - public sbyte PathSkew; - /// ProfileCurve field - public byte ProfileCurve; - /// PathScaleX field - public byte PathScaleX; - /// PathScaleY field - public byte PathScaleY; - /// ObjectLocalID field - public uint ObjectLocalID; - /// PathShearX field - public byte PathShearX; - /// PathShearY field - public byte PathShearY; - /// PathTaperX field - public sbyte PathTaperX; - /// PathTaperY field - public sbyte PathTaperY; - /// ProfileEnd field - public byte ProfileEnd; - /// PathBegin field - public byte PathBegin; - /// PathCurve field - public byte PathCurve; - /// PathTwist field - public sbyte PathTwist; - /// ProfileHollow field - public byte ProfileHollow; - /// PathRevolutions field - public byte PathRevolutions; - - /// Length of this block serialized in bytes + { + /// PathTwistBegin field + public sbyte PathTwistBegin; + /// PathEnd field + public byte PathEnd; + /// ProfileBegin field + public byte ProfileBegin; + /// PathRadiusOffset field + public sbyte PathRadiusOffset; + /// PathSkew field + public sbyte PathSkew; + /// ProfileCurve field + public byte ProfileCurve; + /// PathScaleX field + public byte PathScaleX; + /// PathScaleY field + public byte PathScaleY; + /// ObjectLocalID field + public uint ObjectLocalID; + /// PathShearX field + public byte PathShearX; + /// PathShearY field + public byte PathShearY; + /// PathTaperX field + public sbyte PathTaperX; + /// PathTaperY field + public sbyte PathTaperY; + /// ProfileEnd field + public byte ProfileEnd; + /// PathBegin field + public byte PathBegin; + /// PathCurve field + public byte PathCurve; + /// PathTwist field + public sbyte PathTwist; + /// ProfileHollow field + public byte ProfileHollow; + /// PathRevolutions field + public byte PathRevolutions; + + /// Length of this block serialized in bytes public int Length { get - { - return 22; + { + return 22; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { + { try - { - PathTwistBegin = (sbyte)bytes[i++]; - PathEnd = (byte)bytes[i++]; - ProfileBegin = (byte)bytes[i++]; - PathRadiusOffset = (sbyte)bytes[i++]; - PathSkew = (sbyte)bytes[i++]; - ProfileCurve = (byte)bytes[i++]; - PathScaleX = (byte)bytes[i++]; - PathScaleY = (byte)bytes[i++]; - ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - PathShearX = (byte)bytes[i++]; - PathShearY = (byte)bytes[i++]; - PathTaperX = (sbyte)bytes[i++]; - PathTaperY = (sbyte)bytes[i++]; - ProfileEnd = (byte)bytes[i++]; - PathBegin = (byte)bytes[i++]; - PathCurve = (byte)bytes[i++]; - PathTwist = (sbyte)bytes[i++]; - ProfileHollow = (byte)bytes[i++]; - PathRevolutions = (byte)bytes[i++]; + { + PathTwistBegin = (sbyte)bytes[i++]; + PathEnd = (byte)bytes[i++]; + ProfileBegin = (byte)bytes[i++]; + PathRadiusOffset = (sbyte)bytes[i++]; + PathSkew = (sbyte)bytes[i++]; + ProfileCurve = (byte)bytes[i++]; + PathScaleX = (byte)bytes[i++]; + PathScaleY = (byte)bytes[i++]; + ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + PathShearX = (byte)bytes[i++]; + PathShearY = (byte)bytes[i++]; + PathTaperX = (sbyte)bytes[i++]; + PathTaperY = (sbyte)bytes[i++]; + ProfileEnd = (byte)bytes[i++]; + PathBegin = (byte)bytes[i++]; + PathCurve = (byte)bytes[i++]; + PathTwist = (sbyte)bytes[i++]; + ProfileHollow = (byte)bytes[i++]; + PathRevolutions = (byte)bytes[i++]; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)PathTwistBegin; - bytes[i++] = PathEnd; - bytes[i++] = ProfileBegin; - bytes[i++] = (byte)PathRadiusOffset; - bytes[i++] = (byte)PathSkew; - bytes[i++] = ProfileCurve; - bytes[i++] = PathScaleX; - bytes[i++] = PathScaleY; - bytes[i++] = (byte)(ObjectLocalID % 256); - bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); - bytes[i++] = PathShearX; - bytes[i++] = PathShearY; - bytes[i++] = (byte)PathTaperX; - bytes[i++] = (byte)PathTaperY; - bytes[i++] = ProfileEnd; - bytes[i++] = PathBegin; - bytes[i++] = PathCurve; - bytes[i++] = (byte)PathTwist; - bytes[i++] = ProfileHollow; - bytes[i++] = PathRevolutions; + { + bytes[i++] = (byte)PathTwistBegin; + bytes[i++] = PathEnd; + bytes[i++] = ProfileBegin; + bytes[i++] = (byte)PathRadiusOffset; + bytes[i++] = (byte)PathSkew; + bytes[i++] = ProfileCurve; + bytes[i++] = PathScaleX; + bytes[i++] = PathScaleY; + bytes[i++] = (byte)(ObjectLocalID % 256); + bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); + bytes[i++] = PathShearX; + bytes[i++] = PathShearY; + bytes[i++] = (byte)PathTaperX; + bytes[i++] = (byte)PathTaperY; + bytes[i++] = ProfileEnd; + bytes[i++] = PathBegin; + bytes[i++] = PathCurve; + bytes[i++] = (byte)PathTwist; + bytes[i++] = ProfileHollow; + bytes[i++] = PathRevolutions; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += "PathTwistBegin: " + PathTwistBegin.ToString() + "\n"; - output += "PathEnd: " + PathEnd.ToString() + "\n"; - output += "ProfileBegin: " + ProfileBegin.ToString() + "\n"; - output += "PathRadiusOffset: " + PathRadiusOffset.ToString() + "\n"; - output += "PathSkew: " + PathSkew.ToString() + "\n"; - output += "ProfileCurve: " + ProfileCurve.ToString() + "\n"; - output += "PathScaleX: " + PathScaleX.ToString() + "\n"; - output += "PathScaleY: " + PathScaleY.ToString() + "\n"; - output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; - output += "PathShearX: " + PathShearX.ToString() + "\n"; - output += "PathShearY: " + PathShearY.ToString() + "\n"; - output += "PathTaperX: " + PathTaperX.ToString() + "\n"; - output += "PathTaperY: " + PathTaperY.ToString() + "\n"; - output += "ProfileEnd: " + ProfileEnd.ToString() + "\n"; - output += "PathBegin: " + PathBegin.ToString() + "\n"; - output += "PathCurve: " + PathCurve.ToString() + "\n"; - output += "PathTwist: " + PathTwist.ToString() + "\n"; - output += "ProfileHollow: " + ProfileHollow.ToString() + "\n"; - output += "PathRevolutions: " + PathRevolutions.ToString() + "\n"; + { + string output = "-- ObjectData --\n"; + output += "PathTwistBegin: " + PathTwistBegin.ToString() + "\n"; + output += "PathEnd: " + PathEnd.ToString() + "\n"; + output += "ProfileBegin: " + ProfileBegin.ToString() + "\n"; + output += "PathRadiusOffset: " + PathRadiusOffset.ToString() + "\n"; + output += "PathSkew: " + PathSkew.ToString() + "\n"; + output += "ProfileCurve: " + ProfileCurve.ToString() + "\n"; + output += "PathScaleX: " + PathScaleX.ToString() + "\n"; + output += "PathScaleY: " + PathScaleY.ToString() + "\n"; + output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; + output += "PathShearX: " + PathShearX.ToString() + "\n"; + output += "PathShearY: " + PathShearY.ToString() + "\n"; + output += "PathTaperX: " + PathTaperX.ToString() + "\n"; + output += "PathTaperY: " + PathTaperY.ToString() + "\n"; + output += "ProfileEnd: " + ProfileEnd.ToString() + "\n"; + output += "PathBegin: " + PathBegin.ToString() + "\n"; + output += "PathCurve: " + PathCurve.ToString() + "\n"; + output += "PathTwist: " + PathTwist.ToString() + "\n"; + output += "ProfileHollow: " + ProfileHollow.ToString() + "\n"; + output += "PathRevolutions: " + PathRevolutions.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ObjectShape - public override PacketType Type { get { return PacketType.ObjectShape; } } - /// ObjectData block - public ObjectDataBlock[] ObjectData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ObjectShape + public override PacketType Type { get { return PacketType.ObjectShape; } } + /// ObjectData block + public ObjectDataBlock[] ObjectData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ObjectShapePacket() - { - Header = new LowHeader(); - Header.ID = 130; - Header.Reliable = true; - Header.Zerocoded = true; - ObjectData = new ObjectDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 130; + Header.Reliable = true; + Header.Zerocoded = true; + ObjectData = new ObjectDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ObjectShapePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ObjectShapePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ObjectData.Length; - for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ObjectData.Length; + for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ObjectShape ---\n"; + { + string output = "--- ObjectShape ---\n"; for (int j = 0; j < ObjectData.Length; j++) - { + { output += ObjectData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ObjectExtraParams packet + + /// ObjectExtraParams packet public class ObjectExtraParamsPacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - /// ParamInUse field - public bool ParamInUse; - /// ObjectLocalID field - public uint ObjectLocalID; - private byte[] _paramdata; - /// ParamData field + { + /// ParamInUse field + public bool ParamInUse; + /// ObjectLocalID field + public uint ObjectLocalID; + private byte[] _paramdata; + /// ParamData field public byte[] ParamData - { - get { return _paramdata; } + { + get { return _paramdata; } set - { - if (value == null) { _paramdata = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _paramdata = new byte[value.Length]; Array.Copy(value, _paramdata, value.Length); } + { + if (value == null) { _paramdata = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _paramdata = new byte[value.Length]; Array.Copy(value, _paramdata, value.Length); } } - } - /// ParamSize field - public uint ParamSize; - /// ParamType field - public ushort ParamType; - - /// Length of this block serialized in bytes + } + /// ParamSize field + public uint ParamSize; + /// ParamType field + public ushort ParamType; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 11; - if (ParamData != null) { length += 1 + ParamData.Length; } - return length; + { + int length = 11; + if (ParamData != null) { length += 1 + ParamData.Length; } + return length; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - ParamInUse = (bytes[i++] != 0) ? (bool)true : (bool)false; - ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _paramdata = new byte[length]; - Array.Copy(bytes, i, _paramdata, 0, length); i += length; - ParamSize = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - ParamType = (ushort)(bytes[i++] + (bytes[i++] << 8)); + { + ParamInUse = (bytes[i++] != 0) ? (bool)true : (bool)false; + ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _paramdata = new byte[length]; + Array.Copy(bytes, i, _paramdata, 0, length); i += length; + ParamSize = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + ParamType = (ushort)(bytes[i++] + (bytes[i++] << 8)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)((ParamInUse) ? 1 : 0); - bytes[i++] = (byte)(ObjectLocalID % 256); - bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); - if(ParamData == null) { Console.WriteLine("Warning: ParamData is null, in " + this.GetType()); } - bytes[i++] = (byte)ParamData.Length; - Array.Copy(ParamData, 0, bytes, i, ParamData.Length); i += ParamData.Length; - bytes[i++] = (byte)(ParamSize % 256); - bytes[i++] = (byte)((ParamSize >> 8) % 256); - bytes[i++] = (byte)((ParamSize >> 16) % 256); - bytes[i++] = (byte)((ParamSize >> 24) % 256); - bytes[i++] = (byte)(ParamType % 256); - bytes[i++] = (byte)((ParamType >> 8) % 256); + { + bytes[i++] = (byte)((ParamInUse) ? 1 : 0); + bytes[i++] = (byte)(ObjectLocalID % 256); + bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); + if(ParamData == null) { Console.WriteLine("Warning: ParamData is null, in " + this.GetType()); } + bytes[i++] = (byte)ParamData.Length; + Array.Copy(ParamData, 0, bytes, i, ParamData.Length); i += ParamData.Length; + bytes[i++] = (byte)(ParamSize % 256); + bytes[i++] = (byte)((ParamSize >> 8) % 256); + bytes[i++] = (byte)((ParamSize >> 16) % 256); + bytes[i++] = (byte)((ParamSize >> 24) % 256); + bytes[i++] = (byte)(ParamType % 256); + bytes[i++] = (byte)((ParamType >> 8) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += "ParamInUse: " + ParamInUse.ToString() + "\n"; - output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; - output += Helpers.FieldToString(ParamData, "ParamData") + "\n"; - output += "ParamSize: " + ParamSize.ToString() + "\n"; - output += "ParamType: " + ParamType.ToString() + "\n"; + { + string output = "-- ObjectData --\n"; + output += "ParamInUse: " + ParamInUse.ToString() + "\n"; + output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; + output += Helpers.FieldToString(ParamData, "ParamData") + "\n"; + output += "ParamSize: " + ParamSize.ToString() + "\n"; + output += "ParamType: " + ParamType.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ObjectExtraParams - public override PacketType Type { get { return PacketType.ObjectExtraParams; } } - /// ObjectData block - public ObjectDataBlock[] ObjectData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ObjectExtraParams + public override PacketType Type { get { return PacketType.ObjectExtraParams; } } + /// ObjectData block + public ObjectDataBlock[] ObjectData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ObjectExtraParamsPacket() - { - Header = new LowHeader(); - Header.ID = 131; - Header.Reliable = true; - Header.Zerocoded = true; - ObjectData = new ObjectDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 131; + Header.Reliable = true; + Header.Zerocoded = true; + ObjectData = new ObjectDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ObjectExtraParamsPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ObjectExtraParamsPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ObjectData.Length; - for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ObjectData.Length; + for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ObjectExtraParams ---\n"; + { + string output = "--- ObjectExtraParams ---\n"; for (int j = 0; j < ObjectData.Length; j++) - { + { output += ObjectData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ObjectOwner packet + + /// ObjectOwner packet public class ObjectOwnerPacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - /// ObjectLocalID field - public uint ObjectLocalID; - - /// Length of this block serialized in bytes + { + /// ObjectLocalID field + public uint ObjectLocalID; + + /// Length of this block serialized in bytes public int Length { get - { - return 4; + { + return 4; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { + { try - { - ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(ObjectLocalID % 256); - bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); + { + bytes[i++] = (byte)(ObjectLocalID % 256); + bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; + { + string output = "-- ObjectData --\n"; + output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// HeaderData block + + /// HeaderData block public class HeaderDataBlock - { - /// GroupID field - public LLUUID GroupID; - /// OwnerID field - public LLUUID OwnerID; - /// Override field - public bool Override; - - /// Length of this block serialized in bytes + { + /// GroupID field + public LLUUID GroupID; + /// OwnerID field + public LLUUID OwnerID; + /// Override field + public bool Override; + + /// Length of this block serialized in bytes public int Length { get - { - return 33; + { + return 33; } } - - /// Default constructor - public HeaderDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public HeaderDataBlock() { } + /// Constructor for building the block from a byte array public HeaderDataBlock(byte[] bytes, ref int i) - { + { try - { - GroupID = new LLUUID(bytes, i); i += 16; - OwnerID = new LLUUID(bytes, i); i += 16; - Override = (bytes[i++] != 0) ? (bool)true : (bool)false; + { + GroupID = new LLUUID(bytes, i); i += 16; + OwnerID = new LLUUID(bytes, i); i += 16; + Override = (bytes[i++] != 0) ? (bool)true : (bool)false; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; - if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } - Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((Override) ? 1 : 0); + { + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } + Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((Override) ? 1 : 0); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- HeaderData --\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; - output += "OwnerID: " + OwnerID.ToString() + "\n"; - output += "Override: " + Override.ToString() + "\n"; + { + string output = "-- HeaderData --\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; + output += "OwnerID: " + OwnerID.ToString() + "\n"; + output += "Override: " + Override.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ObjectOwner - public override PacketType Type { get { return PacketType.ObjectOwner; } } - /// ObjectData block - public ObjectDataBlock[] ObjectData; - /// AgentData block - public AgentDataBlock AgentData; - /// HeaderData block - public HeaderDataBlock HeaderData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ObjectOwner + public override PacketType Type { get { return PacketType.ObjectOwner; } } + /// ObjectData block + public ObjectDataBlock[] ObjectData; + /// AgentData block + public AgentDataBlock AgentData; + /// HeaderData block + public HeaderDataBlock HeaderData; + + /// Default constructor public ObjectOwnerPacket() - { - Header = new LowHeader(); - Header.ID = 132; - Header.Reliable = true; - Header.Zerocoded = true; - ObjectData = new ObjectDataBlock[0]; - AgentData = new AgentDataBlock(); - HeaderData = new HeaderDataBlock(); + { + Header = new LowHeader(); + Header.ID = 132; + Header.Reliable = true; + Header.Zerocoded = true; + ObjectData = new ObjectDataBlock[0]; + AgentData = new AgentDataBlock(); + HeaderData = new HeaderDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ObjectOwnerPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); - HeaderData = new HeaderDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); + HeaderData = new HeaderDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ObjectOwnerPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); - HeaderData = new HeaderDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); + HeaderData = new HeaderDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length; length += HeaderData.Length;; - length++; - for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ObjectData.Length; - for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - HeaderData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length; length += HeaderData.Length;; + length++; + for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ObjectData.Length; + for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + HeaderData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ObjectOwner ---\n"; + { + string output = "--- ObjectOwner ---\n"; for (int j = 0; j < ObjectData.Length; j++) - { + { output += ObjectData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; - output += HeaderData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; + output += HeaderData.ToString() + "\n"; return output; } - + } - - /// ObjectGroup packet + + /// ObjectGroup packet public class ObjectGroupPacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - /// ObjectLocalID field - public uint ObjectLocalID; - - /// Length of this block serialized in bytes + { + /// ObjectLocalID field + public uint ObjectLocalID; + + /// Length of this block serialized in bytes public int Length { get - { - return 4; + { + return 4; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { + { try - { - ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(ObjectLocalID % 256); - bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); + { + bytes[i++] = (byte)(ObjectLocalID % 256); + bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; + { + string output = "-- ObjectData --\n"; + output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - /// GroupID field - public LLUUID GroupID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + /// GroupID field + public LLUUID GroupID; + + /// Length of this block serialized in bytes public int Length { get - { - return 48; + { + return 48; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; - GroupID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; + GroupID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ObjectGroup - public override PacketType Type { get { return PacketType.ObjectGroup; } } - /// ObjectData block - public ObjectDataBlock[] ObjectData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ObjectGroup + public override PacketType Type { get { return PacketType.ObjectGroup; } } + /// ObjectData block + public ObjectDataBlock[] ObjectData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ObjectGroupPacket() - { - Header = new LowHeader(); - Header.ID = 133; - Header.Reliable = true; - Header.Zerocoded = true; - ObjectData = new ObjectDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 133; + Header.Reliable = true; + Header.Zerocoded = true; + ObjectData = new ObjectDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ObjectGroupPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ObjectGroupPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ObjectData.Length; - for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ObjectData.Length; + for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ObjectGroup ---\n"; + { + string output = "--- ObjectGroup ---\n"; for (int j = 0; j < ObjectData.Length; j++) - { + { output += ObjectData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ObjectBuy packet + + /// ObjectBuy packet public class ObjectBuyPacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - /// SaleType field - public byte SaleType; - /// SalePrice field - public int SalePrice; - /// ObjectLocalID field - public uint ObjectLocalID; - - /// Length of this block serialized in bytes + { + /// SaleType field + public byte SaleType; + /// SalePrice field + public int SalePrice; + /// ObjectLocalID field + public uint ObjectLocalID; + + /// Length of this block serialized in bytes public int Length { get - { - return 9; + { + return 9; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { + { try - { - SaleType = (byte)bytes[i++]; - SalePrice = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + SaleType = (byte)bytes[i++]; + SalePrice = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = SaleType; - bytes[i++] = (byte)(SalePrice % 256); - bytes[i++] = (byte)((SalePrice >> 8) % 256); - bytes[i++] = (byte)((SalePrice >> 16) % 256); - bytes[i++] = (byte)((SalePrice >> 24) % 256); - bytes[i++] = (byte)(ObjectLocalID % 256); - bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); + { + bytes[i++] = SaleType; + bytes[i++] = (byte)(SalePrice % 256); + bytes[i++] = (byte)((SalePrice >> 8) % 256); + bytes[i++] = (byte)((SalePrice >> 16) % 256); + bytes[i++] = (byte)((SalePrice >> 24) % 256); + bytes[i++] = (byte)(ObjectLocalID % 256); + bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += "SaleType: " + SaleType.ToString() + "\n"; - output += "SalePrice: " + SalePrice.ToString() + "\n"; - output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; + { + string output = "-- ObjectData --\n"; + output += "SaleType: " + SaleType.ToString() + "\n"; + output += "SalePrice: " + SalePrice.ToString() + "\n"; + output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - /// GroupID field - public LLUUID GroupID; - /// CategoryID field - public LLUUID CategoryID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + /// GroupID field + public LLUUID GroupID; + /// CategoryID field + public LLUUID CategoryID; + + /// Length of this block serialized in bytes public int Length { get - { - return 64; + { + return 64; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; - GroupID = new LLUUID(bytes, i); i += 16; - CategoryID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; + GroupID = new LLUUID(bytes, i); i += 16; + CategoryID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; - if(CategoryID == null) { Console.WriteLine("Warning: CategoryID is null, in " + this.GetType()); } - Array.Copy(CategoryID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + if(CategoryID == null) { Console.WriteLine("Warning: CategoryID is null, in " + this.GetType()); } + Array.Copy(CategoryID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; - output += "CategoryID: " + CategoryID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; + output += "CategoryID: " + CategoryID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ObjectBuy - public override PacketType Type { get { return PacketType.ObjectBuy; } } - /// ObjectData block - public ObjectDataBlock[] ObjectData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ObjectBuy + public override PacketType Type { get { return PacketType.ObjectBuy; } } + /// ObjectData block + public ObjectDataBlock[] ObjectData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ObjectBuyPacket() - { - Header = new LowHeader(); - Header.ID = 134; - Header.Reliable = true; - Header.Zerocoded = true; - ObjectData = new ObjectDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 134; + Header.Reliable = true; + Header.Zerocoded = true; + ObjectData = new ObjectDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ObjectBuyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ObjectBuyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ObjectData.Length; - for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ObjectData.Length; + for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ObjectBuy ---\n"; + { + string output = "--- ObjectBuy ---\n"; for (int j = 0; j < ObjectData.Length; j++) - { + { output += ObjectData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// BuyObjectInventory packet + + /// BuyObjectInventory packet public class BuyObjectInventoryPacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - /// ObjectID field - public LLUUID ObjectID; - /// ItemID field - public LLUUID ItemID; - /// FolderID field - public LLUUID FolderID; - - /// Length of this block serialized in bytes + { + /// ObjectID field + public LLUUID ObjectID; + /// ItemID field + public LLUUID ItemID; + /// FolderID field + public LLUUID FolderID; + + /// Length of this block serialized in bytes public int Length { get - { - return 48; + { + return 48; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { + { try - { - ObjectID = new LLUUID(bytes, i); i += 16; - ItemID = new LLUUID(bytes, i); i += 16; - FolderID = new LLUUID(bytes, i); i += 16; + { + ObjectID = new LLUUID(bytes, i); i += 16; + ItemID = new LLUUID(bytes, i); i += 16; + FolderID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } - Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; - if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } - Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; - if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } - Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } + Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; + if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } + Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; + if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } + Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "ObjectID: " + ObjectID.ToString() + "\n"; - output += "ItemID: " + ItemID.ToString() + "\n"; - output += "FolderID: " + FolderID.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += "ObjectID: " + ObjectID.ToString() + "\n"; + output += "ItemID: " + ItemID.ToString() + "\n"; + output += "FolderID: " + FolderID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.BuyObjectInventory - public override PacketType Type { get { return PacketType.BuyObjectInventory; } } - /// Data block - public DataBlock Data; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.BuyObjectInventory + public override PacketType Type { get { return PacketType.BuyObjectInventory; } } + /// Data block + public DataBlock Data; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public BuyObjectInventoryPacket() - { - Header = new LowHeader(); - Header.ID = 135; - Header.Reliable = true; - Header.Zerocoded = true; - Data = new DataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 135; + Header.Reliable = true; + Header.Zerocoded = true; + Data = new DataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public BuyObjectInventoryPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public BuyObjectInventoryPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Data.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Data.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Data.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Data.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- BuyObjectInventory ---\n"; - output += Data.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- BuyObjectInventory ---\n"; + output += Data.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// DerezContainer packet + + /// DerezContainer packet public class DerezContainerPacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - /// ObjectID field - public LLUUID ObjectID; - /// Delete field - public bool Delete; - - /// Length of this block serialized in bytes + { + /// ObjectID field + public LLUUID ObjectID; + /// Delete field + public bool Delete; + + /// Length of this block serialized in bytes public int Length { get - { - return 17; + { + return 17; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { + { try - { - ObjectID = new LLUUID(bytes, i); i += 16; - Delete = (bytes[i++] != 0) ? (bool)true : (bool)false; + { + ObjectID = new LLUUID(bytes, i); i += 16; + Delete = (bytes[i++] != 0) ? (bool)true : (bool)false; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } - Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((Delete) ? 1 : 0); + { + if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } + Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((Delete) ? 1 : 0); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "ObjectID: " + ObjectID.ToString() + "\n"; - output += "Delete: " + Delete.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += "ObjectID: " + ObjectID.ToString() + "\n"; + output += "Delete: " + Delete.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.DerezContainer - public override PacketType Type { get { return PacketType.DerezContainer; } } - /// Data block - public DataBlock Data; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.DerezContainer + public override PacketType Type { get { return PacketType.DerezContainer; } } + /// Data block + public DataBlock Data; + + /// Default constructor public DerezContainerPacket() - { - Header = new LowHeader(); - Header.ID = 136; - Header.Reliable = true; - Header.Zerocoded = true; - Data = new DataBlock(); + { + Header = new LowHeader(); + Header.ID = 136; + Header.Reliable = true; + Header.Zerocoded = true; + Data = new DataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public DerezContainerPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Data = new DataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Data = new DataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public DerezContainerPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Data = new DataBlock(bytes, ref i); + { + Header = head; + Data = new DataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Data.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Data.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Data.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Data.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- DerezContainer ---\n"; - output += Data.ToString() + "\n"; + { + string output = "--- DerezContainer ---\n"; + output += Data.ToString() + "\n"; return output; } - + } - - /// ObjectPermissions packet + + /// ObjectPermissions packet public class ObjectPermissionsPacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - /// Set field - public byte Set; - /// Mask field - public uint Mask; - /// ObjectLocalID field - public uint ObjectLocalID; - /// Field field - public byte Field; - - /// Length of this block serialized in bytes + { + /// Set field + public byte Set; + /// Mask field + public uint Mask; + /// ObjectLocalID field + public uint ObjectLocalID; + /// Field field + public byte Field; + + /// Length of this block serialized in bytes public int Length { get - { - return 10; + { + return 10; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { + { try - { - Set = (byte)bytes[i++]; - Mask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Field = (byte)bytes[i++]; + { + Set = (byte)bytes[i++]; + Mask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Field = (byte)bytes[i++]; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = Set; - bytes[i++] = (byte)(Mask % 256); - bytes[i++] = (byte)((Mask >> 8) % 256); - bytes[i++] = (byte)((Mask >> 16) % 256); - bytes[i++] = (byte)((Mask >> 24) % 256); - bytes[i++] = (byte)(ObjectLocalID % 256); - bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); - bytes[i++] = Field; + { + bytes[i++] = Set; + bytes[i++] = (byte)(Mask % 256); + bytes[i++] = (byte)((Mask >> 8) % 256); + bytes[i++] = (byte)((Mask >> 16) % 256); + bytes[i++] = (byte)((Mask >> 24) % 256); + bytes[i++] = (byte)(ObjectLocalID % 256); + bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); + bytes[i++] = Field; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += "Set: " + Set.ToString() + "\n"; - output += "Mask: " + Mask.ToString() + "\n"; - output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; - output += "Field: " + Field.ToString() + "\n"; + { + string output = "-- ObjectData --\n"; + output += "Set: " + Set.ToString() + "\n"; + output += "Mask: " + Mask.ToString() + "\n"; + output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; + output += "Field: " + Field.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// HeaderData block + + /// HeaderData block public class HeaderDataBlock - { - /// Override field - public bool Override; - - /// Length of this block serialized in bytes + { + /// Override field + public bool Override; + + /// Length of this block serialized in bytes public int Length { get - { - return 1; + { + return 1; } } - - /// Default constructor - public HeaderDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public HeaderDataBlock() { } + /// Constructor for building the block from a byte array public HeaderDataBlock(byte[] bytes, ref int i) - { + { try - { - Override = (bytes[i++] != 0) ? (bool)true : (bool)false; + { + Override = (bytes[i++] != 0) ? (bool)true : (bool)false; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)((Override) ? 1 : 0); + { + bytes[i++] = (byte)((Override) ? 1 : 0); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- HeaderData --\n"; - output += "Override: " + Override.ToString() + "\n"; + { + string output = "-- HeaderData --\n"; + output += "Override: " + Override.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ObjectPermissions - public override PacketType Type { get { return PacketType.ObjectPermissions; } } - /// ObjectData block - public ObjectDataBlock[] ObjectData; - /// AgentData block - public AgentDataBlock AgentData; - /// HeaderData block - public HeaderDataBlock HeaderData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ObjectPermissions + public override PacketType Type { get { return PacketType.ObjectPermissions; } } + /// ObjectData block + public ObjectDataBlock[] ObjectData; + /// AgentData block + public AgentDataBlock AgentData; + /// HeaderData block + public HeaderDataBlock HeaderData; + + /// Default constructor public ObjectPermissionsPacket() - { - Header = new LowHeader(); - Header.ID = 137; - Header.Reliable = true; - Header.Zerocoded = true; - ObjectData = new ObjectDataBlock[0]; - AgentData = new AgentDataBlock(); - HeaderData = new HeaderDataBlock(); + { + Header = new LowHeader(); + Header.ID = 137; + Header.Reliable = true; + Header.Zerocoded = true; + ObjectData = new ObjectDataBlock[0]; + AgentData = new AgentDataBlock(); + HeaderData = new HeaderDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ObjectPermissionsPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); - HeaderData = new HeaderDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); + HeaderData = new HeaderDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ObjectPermissionsPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); - HeaderData = new HeaderDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); + HeaderData = new HeaderDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length; length += HeaderData.Length;; - length++; - for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ObjectData.Length; - for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - HeaderData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length; length += HeaderData.Length;; + length++; + for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ObjectData.Length; + for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + HeaderData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ObjectPermissions ---\n"; + { + string output = "--- ObjectPermissions ---\n"; for (int j = 0; j < ObjectData.Length; j++) - { + { output += ObjectData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; - output += HeaderData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; + output += HeaderData.ToString() + "\n"; return output; } - + } - - /// ObjectSaleInfo packet + + /// ObjectSaleInfo packet public class ObjectSaleInfoPacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - /// LocalID field - public uint LocalID; - /// SaleType field - public byte SaleType; - /// SalePrice field - public int SalePrice; - - /// Length of this block serialized in bytes + { + /// LocalID field + public uint LocalID; + /// SaleType field + public byte SaleType; + /// SalePrice field + public int SalePrice; + + /// Length of this block serialized in bytes public int Length { get - { - return 9; + { + return 9; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { + { try - { - LocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - SaleType = (byte)bytes[i++]; - SalePrice = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + LocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + SaleType = (byte)bytes[i++]; + SalePrice = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(LocalID % 256); - bytes[i++] = (byte)((LocalID >> 8) % 256); - bytes[i++] = (byte)((LocalID >> 16) % 256); - bytes[i++] = (byte)((LocalID >> 24) % 256); - bytes[i++] = SaleType; - bytes[i++] = (byte)(SalePrice % 256); - bytes[i++] = (byte)((SalePrice >> 8) % 256); - bytes[i++] = (byte)((SalePrice >> 16) % 256); - bytes[i++] = (byte)((SalePrice >> 24) % 256); + { + bytes[i++] = (byte)(LocalID % 256); + bytes[i++] = (byte)((LocalID >> 8) % 256); + bytes[i++] = (byte)((LocalID >> 16) % 256); + bytes[i++] = (byte)((LocalID >> 24) % 256); + bytes[i++] = SaleType; + bytes[i++] = (byte)(SalePrice % 256); + bytes[i++] = (byte)((SalePrice >> 8) % 256); + bytes[i++] = (byte)((SalePrice >> 16) % 256); + bytes[i++] = (byte)((SalePrice >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += "LocalID: " + LocalID.ToString() + "\n"; - output += "SaleType: " + SaleType.ToString() + "\n"; - output += "SalePrice: " + SalePrice.ToString() + "\n"; + { + string output = "-- ObjectData --\n"; + output += "LocalID: " + LocalID.ToString() + "\n"; + output += "SaleType: " + SaleType.ToString() + "\n"; + output += "SalePrice: " + SalePrice.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ObjectSaleInfo - public override PacketType Type { get { return PacketType.ObjectSaleInfo; } } - /// ObjectData block - public ObjectDataBlock[] ObjectData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ObjectSaleInfo + public override PacketType Type { get { return PacketType.ObjectSaleInfo; } } + /// ObjectData block + public ObjectDataBlock[] ObjectData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ObjectSaleInfoPacket() - { - Header = new LowHeader(); - Header.ID = 138; - Header.Reliable = true; - Header.Zerocoded = true; - ObjectData = new ObjectDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 138; + Header.Reliable = true; + Header.Zerocoded = true; + ObjectData = new ObjectDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ObjectSaleInfoPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ObjectSaleInfoPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ObjectData.Length; - for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ObjectData.Length; + for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ObjectSaleInfo ---\n"; + { + string output = "--- ObjectSaleInfo ---\n"; for (int j = 0; j < ObjectData.Length; j++) - { + { output += ObjectData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ObjectName packet + + /// ObjectName packet public class ObjectNamePacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - /// LocalID field - public uint LocalID; - private byte[] _name; - /// Name field + { + /// LocalID field + public uint LocalID; + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 4; - if (Name != null) { length += 1 + Name.Length; } - return length; + { + int length = 4; + if (Name != null) { length += 1 + Name.Length; } + return length; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - LocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; + { + LocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(LocalID % 256); - bytes[i++] = (byte)((LocalID >> 8) % 256); - bytes[i++] = (byte)((LocalID >> 16) % 256); - bytes[i++] = (byte)((LocalID >> 24) % 256); - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + { + bytes[i++] = (byte)(LocalID % 256); + bytes[i++] = (byte)((LocalID >> 8) % 256); + bytes[i++] = (byte)((LocalID >> 16) % 256); + bytes[i++] = (byte)((LocalID >> 24) % 256); + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += "LocalID: " + LocalID.ToString() + "\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; + { + string output = "-- ObjectData --\n"; + output += "LocalID: " + LocalID.ToString() + "\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ObjectName - public override PacketType Type { get { return PacketType.ObjectName; } } - /// ObjectData block - public ObjectDataBlock[] ObjectData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ObjectName + public override PacketType Type { get { return PacketType.ObjectName; } } + /// ObjectData block + public ObjectDataBlock[] ObjectData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ObjectNamePacket() - { - Header = new LowHeader(); - Header.ID = 139; - Header.Reliable = true; - Header.Zerocoded = true; - ObjectData = new ObjectDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 139; + Header.Reliable = true; + Header.Zerocoded = true; + ObjectData = new ObjectDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ObjectNamePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ObjectNamePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ObjectData.Length; - for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ObjectData.Length; + for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ObjectName ---\n"; + { + string output = "--- ObjectName ---\n"; for (int j = 0; j < ObjectData.Length; j++) - { + { output += ObjectData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ObjectDescription packet + + /// ObjectDescription packet public class ObjectDescriptionPacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - /// LocalID field - public uint LocalID; - private byte[] _description; - /// Description field + { + /// LocalID field + public uint LocalID; + private byte[] _description; + /// Description field public byte[] Description - { - get { return _description; } + { + get { return _description; } set - { - if (value == null) { _description = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } + { + if (value == null) { _description = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 4; - if (Description != null) { length += 1 + Description.Length; } - return length; + { + int length = 4; + if (Description != null) { length += 1 + Description.Length; } + return length; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - LocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _description = new byte[length]; - Array.Copy(bytes, i, _description, 0, length); i += length; + { + LocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _description = new byte[length]; + Array.Copy(bytes, i, _description, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(LocalID % 256); - bytes[i++] = (byte)((LocalID >> 8) % 256); - bytes[i++] = (byte)((LocalID >> 16) % 256); - bytes[i++] = (byte)((LocalID >> 24) % 256); - if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } - bytes[i++] = (byte)Description.Length; - Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; + { + bytes[i++] = (byte)(LocalID % 256); + bytes[i++] = (byte)((LocalID >> 8) % 256); + bytes[i++] = (byte)((LocalID >> 16) % 256); + bytes[i++] = (byte)((LocalID >> 24) % 256); + if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } + bytes[i++] = (byte)Description.Length; + Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += "LocalID: " + LocalID.ToString() + "\n"; - output += Helpers.FieldToString(Description, "Description") + "\n"; + { + string output = "-- ObjectData --\n"; + output += "LocalID: " + LocalID.ToString() + "\n"; + output += Helpers.FieldToString(Description, "Description") + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ObjectDescription - public override PacketType Type { get { return PacketType.ObjectDescription; } } - /// ObjectData block - public ObjectDataBlock[] ObjectData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ObjectDescription + public override PacketType Type { get { return PacketType.ObjectDescription; } } + /// ObjectData block + public ObjectDataBlock[] ObjectData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ObjectDescriptionPacket() - { - Header = new LowHeader(); - Header.ID = 140; - Header.Reliable = true; - Header.Zerocoded = true; - ObjectData = new ObjectDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 140; + Header.Reliable = true; + Header.Zerocoded = true; + ObjectData = new ObjectDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ObjectDescriptionPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ObjectDescriptionPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ObjectData.Length; - for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ObjectData.Length; + for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ObjectDescription ---\n"; + { + string output = "--- ObjectDescription ---\n"; for (int j = 0; j < ObjectData.Length; j++) - { + { output += ObjectData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ObjectCategory packet + + /// ObjectCategory packet public class ObjectCategoryPacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - /// LocalID field - public uint LocalID; - /// Category field - public uint Category; - - /// Length of this block serialized in bytes + { + /// LocalID field + public uint LocalID; + /// Category field + public uint Category; + + /// Length of this block serialized in bytes public int Length { get - { - return 8; + { + return 8; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { + { try - { - LocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Category = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + LocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Category = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(LocalID % 256); - bytes[i++] = (byte)((LocalID >> 8) % 256); - bytes[i++] = (byte)((LocalID >> 16) % 256); - bytes[i++] = (byte)((LocalID >> 24) % 256); - bytes[i++] = (byte)(Category % 256); - bytes[i++] = (byte)((Category >> 8) % 256); - bytes[i++] = (byte)((Category >> 16) % 256); - bytes[i++] = (byte)((Category >> 24) % 256); + { + bytes[i++] = (byte)(LocalID % 256); + bytes[i++] = (byte)((LocalID >> 8) % 256); + bytes[i++] = (byte)((LocalID >> 16) % 256); + bytes[i++] = (byte)((LocalID >> 24) % 256); + bytes[i++] = (byte)(Category % 256); + bytes[i++] = (byte)((Category >> 8) % 256); + bytes[i++] = (byte)((Category >> 16) % 256); + bytes[i++] = (byte)((Category >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += "LocalID: " + LocalID.ToString() + "\n"; - output += "Category: " + Category.ToString() + "\n"; + { + string output = "-- ObjectData --\n"; + output += "LocalID: " + LocalID.ToString() + "\n"; + output += "Category: " + Category.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ObjectCategory - public override PacketType Type { get { return PacketType.ObjectCategory; } } - /// ObjectData block - public ObjectDataBlock[] ObjectData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ObjectCategory + public override PacketType Type { get { return PacketType.ObjectCategory; } } + /// ObjectData block + public ObjectDataBlock[] ObjectData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ObjectCategoryPacket() - { - Header = new LowHeader(); - Header.ID = 141; - Header.Reliable = true; - Header.Zerocoded = true; - ObjectData = new ObjectDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 141; + Header.Reliable = true; + Header.Zerocoded = true; + ObjectData = new ObjectDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ObjectCategoryPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ObjectCategoryPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ObjectData.Length; - for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ObjectData.Length; + for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ObjectCategory ---\n"; + { + string output = "--- ObjectCategory ---\n"; for (int j = 0; j < ObjectData.Length; j++) - { + { output += ObjectData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ObjectSelect packet + + /// ObjectSelect packet public class ObjectSelectPacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - /// ObjectLocalID field - public uint ObjectLocalID; - - /// Length of this block serialized in bytes + { + /// ObjectLocalID field + public uint ObjectLocalID; + + /// Length of this block serialized in bytes public int Length { get - { - return 4; + { + return 4; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { + { try - { - ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(ObjectLocalID % 256); - bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); + { + bytes[i++] = (byte)(ObjectLocalID % 256); + bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; + { + string output = "-- ObjectData --\n"; + output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ObjectSelect - public override PacketType Type { get { return PacketType.ObjectSelect; } } - /// ObjectData block - public ObjectDataBlock[] ObjectData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ObjectSelect + public override PacketType Type { get { return PacketType.ObjectSelect; } } + /// ObjectData block + public ObjectDataBlock[] ObjectData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ObjectSelectPacket() - { - Header = new LowHeader(); - Header.ID = 142; - Header.Reliable = true; - Header.Zerocoded = true; - ObjectData = new ObjectDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 142; + Header.Reliable = true; + Header.Zerocoded = true; + ObjectData = new ObjectDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ObjectSelectPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ObjectSelectPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ObjectData.Length; - for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ObjectData.Length; + for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ObjectSelect ---\n"; + { + string output = "--- ObjectSelect ---\n"; for (int j = 0; j < ObjectData.Length; j++) - { + { output += ObjectData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ObjectDeselect packet + + /// ObjectDeselect packet public class ObjectDeselectPacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - /// ObjectLocalID field - public uint ObjectLocalID; - - /// Length of this block serialized in bytes + { + /// ObjectLocalID field + public uint ObjectLocalID; + + /// Length of this block serialized in bytes public int Length { get - { - return 4; + { + return 4; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { + { try - { - ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(ObjectLocalID % 256); - bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); + { + bytes[i++] = (byte)(ObjectLocalID % 256); + bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; + { + string output = "-- ObjectData --\n"; + output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ObjectDeselect - public override PacketType Type { get { return PacketType.ObjectDeselect; } } - /// ObjectData block - public ObjectDataBlock[] ObjectData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ObjectDeselect + public override PacketType Type { get { return PacketType.ObjectDeselect; } } + /// ObjectData block + public ObjectDataBlock[] ObjectData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ObjectDeselectPacket() - { - Header = new LowHeader(); - Header.ID = 143; - Header.Reliable = true; - Header.Zerocoded = true; - ObjectData = new ObjectDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 143; + Header.Reliable = true; + Header.Zerocoded = true; + ObjectData = new ObjectDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ObjectDeselectPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ObjectDeselectPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ObjectData.Length; - for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ObjectData.Length; + for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ObjectDeselect ---\n"; + { + string output = "--- ObjectDeselect ---\n"; for (int j = 0; j < ObjectData.Length; j++) - { + { output += ObjectData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ObjectAttach packet + + /// ObjectAttach packet public class ObjectAttachPacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - /// ObjectLocalID field - public uint ObjectLocalID; - /// Rotation field - public LLQuaternion Rotation; - - /// Length of this block serialized in bytes + { + /// ObjectLocalID field + public uint ObjectLocalID; + /// Rotation field + public LLQuaternion Rotation; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { + { try - { - ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Rotation = new LLQuaternion(bytes, i, true); i += 12; + { + ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Rotation = new LLQuaternion(bytes, i, true); i += 12; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(ObjectLocalID % 256); - bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); - if(Rotation == null) { Console.WriteLine("Warning: Rotation is null, in " + this.GetType()); } - Array.Copy(Rotation.GetBytes(), 0, bytes, i, 12); i += 12; + { + bytes[i++] = (byte)(ObjectLocalID % 256); + bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); + if(Rotation == null) { Console.WriteLine("Warning: Rotation is null, in " + this.GetType()); } + Array.Copy(Rotation.GetBytes(), 0, bytes, i, 12); i += 12; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; - output += "Rotation: " + Rotation.ToString() + "\n"; + { + string output = "-- ObjectData --\n"; + output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; + output += "Rotation: " + Rotation.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AttachmentPoint field - public byte AttachmentPoint; - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AttachmentPoint field + public byte AttachmentPoint; + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 33; + { + return 33; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AttachmentPoint = (byte)bytes[i++]; - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AttachmentPoint = (byte)bytes[i++]; + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = AttachmentPoint; - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + bytes[i++] = AttachmentPoint; + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AttachmentPoint: " + AttachmentPoint.ToString() + "\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AttachmentPoint: " + AttachmentPoint.ToString() + "\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ObjectAttach - public override PacketType Type { get { return PacketType.ObjectAttach; } } - /// ObjectData block - public ObjectDataBlock[] ObjectData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ObjectAttach + public override PacketType Type { get { return PacketType.ObjectAttach; } } + /// ObjectData block + public ObjectDataBlock[] ObjectData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ObjectAttachPacket() - { - Header = new LowHeader(); - Header.ID = 144; - Header.Reliable = true; - Header.Zerocoded = true; - ObjectData = new ObjectDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 144; + Header.Reliable = true; + Header.Zerocoded = true; + ObjectData = new ObjectDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ObjectAttachPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ObjectAttachPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ObjectData.Length; - for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ObjectData.Length; + for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ObjectAttach ---\n"; + { + string output = "--- ObjectAttach ---\n"; for (int j = 0; j < ObjectData.Length; j++) - { + { output += ObjectData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ObjectDetach packet + + /// ObjectDetach packet public class ObjectDetachPacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - /// ObjectLocalID field - public uint ObjectLocalID; - - /// Length of this block serialized in bytes + { + /// ObjectLocalID field + public uint ObjectLocalID; + + /// Length of this block serialized in bytes public int Length { get - { - return 4; + { + return 4; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { + { try - { - ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(ObjectLocalID % 256); - bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); + { + bytes[i++] = (byte)(ObjectLocalID % 256); + bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; + { + string output = "-- ObjectData --\n"; + output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ObjectDetach - public override PacketType Type { get { return PacketType.ObjectDetach; } } - /// ObjectData block - public ObjectDataBlock[] ObjectData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ObjectDetach + public override PacketType Type { get { return PacketType.ObjectDetach; } } + /// ObjectData block + public ObjectDataBlock[] ObjectData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ObjectDetachPacket() - { - Header = new LowHeader(); - Header.ID = 145; - Header.Reliable = true; - ObjectData = new ObjectDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 145; + Header.Reliable = true; + ObjectData = new ObjectDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ObjectDetachPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ObjectDetachPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ObjectData.Length; - for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ObjectData.Length; + for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ObjectDetach ---\n"; + { + string output = "--- ObjectDetach ---\n"; for (int j = 0; j < ObjectData.Length; j++) - { + { output += ObjectData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ObjectDrop packet + + /// ObjectDrop packet public class ObjectDropPacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - /// ObjectLocalID field - public uint ObjectLocalID; - - /// Length of this block serialized in bytes + { + /// ObjectLocalID field + public uint ObjectLocalID; + + /// Length of this block serialized in bytes public int Length { get - { - return 4; + { + return 4; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { + { try - { - ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(ObjectLocalID % 256); - bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); + { + bytes[i++] = (byte)(ObjectLocalID % 256); + bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; + { + string output = "-- ObjectData --\n"; + output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ObjectDrop - public override PacketType Type { get { return PacketType.ObjectDrop; } } - /// ObjectData block - public ObjectDataBlock[] ObjectData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ObjectDrop + public override PacketType Type { get { return PacketType.ObjectDrop; } } + /// ObjectData block + public ObjectDataBlock[] ObjectData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ObjectDropPacket() - { - Header = new LowHeader(); - Header.ID = 146; - Header.Reliable = true; - ObjectData = new ObjectDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 146; + Header.Reliable = true; + ObjectData = new ObjectDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ObjectDropPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ObjectDropPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ObjectData.Length; - for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ObjectData.Length; + for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ObjectDrop ---\n"; + { + string output = "--- ObjectDrop ---\n"; for (int j = 0; j < ObjectData.Length; j++) - { + { output += ObjectData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ObjectLink packet + + /// ObjectLink packet public class ObjectLinkPacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - /// ObjectLocalID field - public uint ObjectLocalID; - - /// Length of this block serialized in bytes + { + /// ObjectLocalID field + public uint ObjectLocalID; + + /// Length of this block serialized in bytes public int Length { get - { - return 4; + { + return 4; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { + { try - { - ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(ObjectLocalID % 256); - bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); + { + bytes[i++] = (byte)(ObjectLocalID % 256); + bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; + { + string output = "-- ObjectData --\n"; + output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ObjectLink - public override PacketType Type { get { return PacketType.ObjectLink; } } - /// ObjectData block - public ObjectDataBlock[] ObjectData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ObjectLink + public override PacketType Type { get { return PacketType.ObjectLink; } } + /// ObjectData block + public ObjectDataBlock[] ObjectData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ObjectLinkPacket() - { - Header = new LowHeader(); - Header.ID = 147; - Header.Reliable = true; - ObjectData = new ObjectDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 147; + Header.Reliable = true; + ObjectData = new ObjectDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ObjectLinkPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ObjectLinkPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ObjectData.Length; - for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ObjectData.Length; + for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ObjectLink ---\n"; + { + string output = "--- ObjectLink ---\n"; for (int j = 0; j < ObjectData.Length; j++) - { + { output += ObjectData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ObjectDelink packet + + /// ObjectDelink packet public class ObjectDelinkPacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - /// ObjectLocalID field - public uint ObjectLocalID; - - /// Length of this block serialized in bytes + { + /// ObjectLocalID field + public uint ObjectLocalID; + + /// Length of this block serialized in bytes public int Length { get - { - return 4; + { + return 4; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { + { try - { - ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(ObjectLocalID % 256); - bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); + { + bytes[i++] = (byte)(ObjectLocalID % 256); + bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; + { + string output = "-- ObjectData --\n"; + output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ObjectDelink - public override PacketType Type { get { return PacketType.ObjectDelink; } } - /// ObjectData block - public ObjectDataBlock[] ObjectData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ObjectDelink + public override PacketType Type { get { return PacketType.ObjectDelink; } } + /// ObjectData block + public ObjectDataBlock[] ObjectData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ObjectDelinkPacket() - { - Header = new LowHeader(); - Header.ID = 148; - Header.Reliable = true; - ObjectData = new ObjectDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 148; + Header.Reliable = true; + ObjectData = new ObjectDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ObjectDelinkPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ObjectDelinkPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ObjectData.Length; - for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ObjectData.Length; + for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ObjectDelink ---\n"; + { + string output = "--- ObjectDelink ---\n"; for (int j = 0; j < ObjectData.Length; j++) - { + { output += ObjectData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ObjectHinge packet + + /// ObjectHinge packet public class ObjectHingePacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - /// ObjectLocalID field - public uint ObjectLocalID; - - /// Length of this block serialized in bytes + { + /// ObjectLocalID field + public uint ObjectLocalID; + + /// Length of this block serialized in bytes public int Length { get - { - return 4; + { + return 4; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { + { try - { - ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(ObjectLocalID % 256); - bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); + { + bytes[i++] = (byte)(ObjectLocalID % 256); + bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; + { + string output = "-- ObjectData --\n"; + output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// JointType block + + /// JointType block public class JointTypeBlock - { - /// Type field - public byte Type; - - /// Length of this block serialized in bytes + { + /// Type field + public byte Type; + + /// Length of this block serialized in bytes public int Length { get - { - return 1; + { + return 1; } } - - /// Default constructor - public JointTypeBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public JointTypeBlock() { } + /// Constructor for building the block from a byte array public JointTypeBlock(byte[] bytes, ref int i) - { + { try - { - Type = (byte)bytes[i++]; + { + Type = (byte)bytes[i++]; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = Type; + { + bytes[i++] = Type; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- JointType --\n"; - output += "Type: " + Type.ToString() + "\n"; + { + string output = "-- JointType --\n"; + output += "Type: " + Type.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ObjectHinge - public override PacketType Type { get { return PacketType.ObjectHinge; } } - /// ObjectData block - public ObjectDataBlock[] ObjectData; - /// JointType block - public JointTypeBlock JointType; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ObjectHinge + public override PacketType Type { get { return PacketType.ObjectHinge; } } + /// ObjectData block + public ObjectDataBlock[] ObjectData; + /// JointType block + public JointTypeBlock JointType; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ObjectHingePacket() - { - Header = new LowHeader(); - Header.ID = 149; - Header.Reliable = true; - ObjectData = new ObjectDataBlock[0]; - JointType = new JointTypeBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 149; + Header.Reliable = true; + ObjectData = new ObjectDataBlock[0]; + JointType = new JointTypeBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ObjectHingePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - JointType = new JointTypeBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + JointType = new JointTypeBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ObjectHingePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - JointType = new JointTypeBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + JointType = new JointTypeBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += JointType.Length; length += AgentData.Length;; - length++; - for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ObjectData.Length; - for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } - JointType.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += JointType.Length; length += AgentData.Length;; + length++; + for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ObjectData.Length; + for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } + JointType.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ObjectHinge ---\n"; + { + string output = "--- ObjectHinge ---\n"; for (int j = 0; j < ObjectData.Length; j++) - { + { output += ObjectData[j].ToString() + "\n"; - } - output += JointType.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + } + output += JointType.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ObjectDehinge packet + + /// ObjectDehinge packet public class ObjectDehingePacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - /// ObjectLocalID field - public uint ObjectLocalID; - - /// Length of this block serialized in bytes + { + /// ObjectLocalID field + public uint ObjectLocalID; + + /// Length of this block serialized in bytes public int Length { get - { - return 4; + { + return 4; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { + { try - { - ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(ObjectLocalID % 256); - bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); + { + bytes[i++] = (byte)(ObjectLocalID % 256); + bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; + { + string output = "-- ObjectData --\n"; + output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ObjectDehinge - public override PacketType Type { get { return PacketType.ObjectDehinge; } } - /// ObjectData block - public ObjectDataBlock[] ObjectData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ObjectDehinge + public override PacketType Type { get { return PacketType.ObjectDehinge; } } + /// ObjectData block + public ObjectDataBlock[] ObjectData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ObjectDehingePacket() - { - Header = new LowHeader(); - Header.ID = 150; - Header.Reliable = true; - ObjectData = new ObjectDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 150; + Header.Reliable = true; + ObjectData = new ObjectDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ObjectDehingePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ObjectDehingePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ObjectData.Length; - for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ObjectData.Length; + for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ObjectDehinge ---\n"; + { + string output = "--- ObjectDehinge ---\n"; for (int j = 0; j < ObjectData.Length; j++) - { + { output += ObjectData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ObjectGrab packet + + /// ObjectGrab packet public class ObjectGrabPacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - /// GrabOffset field - public LLVector3 GrabOffset; - /// LocalID field - public uint LocalID; - - /// Length of this block serialized in bytes + { + /// GrabOffset field + public LLVector3 GrabOffset; + /// LocalID field + public uint LocalID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { + { try - { - GrabOffset = new LLVector3(bytes, i); i += 12; - LocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + GrabOffset = new LLVector3(bytes, i); i += 12; + LocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(GrabOffset == null) { Console.WriteLine("Warning: GrabOffset is null, in " + this.GetType()); } - Array.Copy(GrabOffset.GetBytes(), 0, bytes, i, 12); i += 12; - bytes[i++] = (byte)(LocalID % 256); - bytes[i++] = (byte)((LocalID >> 8) % 256); - bytes[i++] = (byte)((LocalID >> 16) % 256); - bytes[i++] = (byte)((LocalID >> 24) % 256); + { + if(GrabOffset == null) { Console.WriteLine("Warning: GrabOffset is null, in " + this.GetType()); } + Array.Copy(GrabOffset.GetBytes(), 0, bytes, i, 12); i += 12; + bytes[i++] = (byte)(LocalID % 256); + bytes[i++] = (byte)((LocalID >> 8) % 256); + bytes[i++] = (byte)((LocalID >> 16) % 256); + bytes[i++] = (byte)((LocalID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += "GrabOffset: " + GrabOffset.ToString() + "\n"; - output += "LocalID: " + LocalID.ToString() + "\n"; + { + string output = "-- ObjectData --\n"; + output += "GrabOffset: " + GrabOffset.ToString() + "\n"; + output += "LocalID: " + LocalID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ObjectGrab - public override PacketType Type { get { return PacketType.ObjectGrab; } } - /// ObjectData block - public ObjectDataBlock ObjectData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ObjectGrab + public override PacketType Type { get { return PacketType.ObjectGrab; } } + /// ObjectData block + public ObjectDataBlock ObjectData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ObjectGrabPacket() - { - Header = new LowHeader(); - Header.ID = 151; - Header.Reliable = true; - Header.Zerocoded = true; - ObjectData = new ObjectDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 151; + Header.Reliable = true; + Header.Zerocoded = true; + ObjectData = new ObjectDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ObjectGrabPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - ObjectData = new ObjectDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + ObjectData = new ObjectDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ObjectGrabPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - ObjectData = new ObjectDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + ObjectData = new ObjectDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += ObjectData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - ObjectData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += ObjectData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + ObjectData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ObjectGrab ---\n"; - output += ObjectData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- ObjectGrab ---\n"; + output += ObjectData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ObjectGrabUpdate packet + + /// ObjectGrabUpdate packet public class ObjectGrabUpdatePacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - /// TimeSinceLast field - public uint TimeSinceLast; - /// ObjectID field - public LLUUID ObjectID; - /// GrabOffsetInitial field - public LLVector3 GrabOffsetInitial; - /// GrabPosition field - public LLVector3 GrabPosition; - - /// Length of this block serialized in bytes + { + /// TimeSinceLast field + public uint TimeSinceLast; + /// ObjectID field + public LLUUID ObjectID; + /// GrabOffsetInitial field + public LLVector3 GrabOffsetInitial; + /// GrabPosition field + public LLVector3 GrabPosition; + + /// Length of this block serialized in bytes public int Length { get - { - return 44; + { + return 44; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { + { try - { - TimeSinceLast = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - ObjectID = new LLUUID(bytes, i); i += 16; - GrabOffsetInitial = new LLVector3(bytes, i); i += 12; - GrabPosition = new LLVector3(bytes, i); i += 12; + { + TimeSinceLast = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + ObjectID = new LLUUID(bytes, i); i += 16; + GrabOffsetInitial = new LLVector3(bytes, i); i += 12; + GrabPosition = new LLVector3(bytes, i); i += 12; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(TimeSinceLast % 256); - bytes[i++] = (byte)((TimeSinceLast >> 8) % 256); - bytes[i++] = (byte)((TimeSinceLast >> 16) % 256); - bytes[i++] = (byte)((TimeSinceLast >> 24) % 256); - if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } - Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; - if(GrabOffsetInitial == null) { Console.WriteLine("Warning: GrabOffsetInitial is null, in " + this.GetType()); } - Array.Copy(GrabOffsetInitial.GetBytes(), 0, bytes, i, 12); i += 12; - if(GrabPosition == null) { Console.WriteLine("Warning: GrabPosition is null, in " + this.GetType()); } - Array.Copy(GrabPosition.GetBytes(), 0, bytes, i, 12); i += 12; + { + bytes[i++] = (byte)(TimeSinceLast % 256); + bytes[i++] = (byte)((TimeSinceLast >> 8) % 256); + bytes[i++] = (byte)((TimeSinceLast >> 16) % 256); + bytes[i++] = (byte)((TimeSinceLast >> 24) % 256); + if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } + Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; + if(GrabOffsetInitial == null) { Console.WriteLine("Warning: GrabOffsetInitial is null, in " + this.GetType()); } + Array.Copy(GrabOffsetInitial.GetBytes(), 0, bytes, i, 12); i += 12; + if(GrabPosition == null) { Console.WriteLine("Warning: GrabPosition is null, in " + this.GetType()); } + Array.Copy(GrabPosition.GetBytes(), 0, bytes, i, 12); i += 12; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += "TimeSinceLast: " + TimeSinceLast.ToString() + "\n"; - output += "ObjectID: " + ObjectID.ToString() + "\n"; - output += "GrabOffsetInitial: " + GrabOffsetInitial.ToString() + "\n"; - output += "GrabPosition: " + GrabPosition.ToString() + "\n"; + { + string output = "-- ObjectData --\n"; + output += "TimeSinceLast: " + TimeSinceLast.ToString() + "\n"; + output += "ObjectID: " + ObjectID.ToString() + "\n"; + output += "GrabOffsetInitial: " + GrabOffsetInitial.ToString() + "\n"; + output += "GrabPosition: " + GrabPosition.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ObjectGrabUpdate - public override PacketType Type { get { return PacketType.ObjectGrabUpdate; } } - /// ObjectData block - public ObjectDataBlock ObjectData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ObjectGrabUpdate + public override PacketType Type { get { return PacketType.ObjectGrabUpdate; } } + /// ObjectData block + public ObjectDataBlock ObjectData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ObjectGrabUpdatePacket() - { - Header = new LowHeader(); - Header.ID = 152; - Header.Reliable = true; - Header.Zerocoded = true; - ObjectData = new ObjectDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 152; + Header.Reliable = true; + Header.Zerocoded = true; + ObjectData = new ObjectDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ObjectGrabUpdatePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - ObjectData = new ObjectDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + ObjectData = new ObjectDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ObjectGrabUpdatePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - ObjectData = new ObjectDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + ObjectData = new ObjectDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += ObjectData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - ObjectData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += ObjectData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + ObjectData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ObjectGrabUpdate ---\n"; - output += ObjectData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- ObjectGrabUpdate ---\n"; + output += ObjectData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ObjectDeGrab packet + + /// ObjectDeGrab packet public class ObjectDeGrabPacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - /// LocalID field - public uint LocalID; - - /// Length of this block serialized in bytes + { + /// LocalID field + public uint LocalID; + + /// Length of this block serialized in bytes public int Length { get - { - return 4; + { + return 4; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { + { try - { - LocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + LocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(LocalID % 256); - bytes[i++] = (byte)((LocalID >> 8) % 256); - bytes[i++] = (byte)((LocalID >> 16) % 256); - bytes[i++] = (byte)((LocalID >> 24) % 256); + { + bytes[i++] = (byte)(LocalID % 256); + bytes[i++] = (byte)((LocalID >> 8) % 256); + bytes[i++] = (byte)((LocalID >> 16) % 256); + bytes[i++] = (byte)((LocalID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += "LocalID: " + LocalID.ToString() + "\n"; + { + string output = "-- ObjectData --\n"; + output += "LocalID: " + LocalID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ObjectDeGrab - public override PacketType Type { get { return PacketType.ObjectDeGrab; } } - /// ObjectData block - public ObjectDataBlock ObjectData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ObjectDeGrab + public override PacketType Type { get { return PacketType.ObjectDeGrab; } } + /// ObjectData block + public ObjectDataBlock ObjectData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ObjectDeGrabPacket() - { - Header = new LowHeader(); - Header.ID = 153; - Header.Reliable = true; - ObjectData = new ObjectDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 153; + Header.Reliable = true; + ObjectData = new ObjectDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ObjectDeGrabPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - ObjectData = new ObjectDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + ObjectData = new ObjectDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ObjectDeGrabPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - ObjectData = new ObjectDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + ObjectData = new ObjectDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += ObjectData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - ObjectData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += ObjectData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + ObjectData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ObjectDeGrab ---\n"; - output += ObjectData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- ObjectDeGrab ---\n"; + output += ObjectData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ObjectSpinStart packet + + /// ObjectSpinStart packet public class ObjectSpinStartPacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - /// ObjectID field - public LLUUID ObjectID; - - /// Length of this block serialized in bytes + { + /// ObjectID field + public LLUUID ObjectID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { + { try - { - ObjectID = new LLUUID(bytes, i); i += 16; + { + ObjectID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } - Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } + Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += "ObjectID: " + ObjectID.ToString() + "\n"; + { + string output = "-- ObjectData --\n"; + output += "ObjectID: " + ObjectID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ObjectSpinStart - public override PacketType Type { get { return PacketType.ObjectSpinStart; } } - /// ObjectData block - public ObjectDataBlock ObjectData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ObjectSpinStart + public override PacketType Type { get { return PacketType.ObjectSpinStart; } } + /// ObjectData block + public ObjectDataBlock ObjectData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ObjectSpinStartPacket() - { - Header = new LowHeader(); - Header.ID = 154; - Header.Reliable = true; - Header.Zerocoded = true; - ObjectData = new ObjectDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 154; + Header.Reliable = true; + Header.Zerocoded = true; + ObjectData = new ObjectDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ObjectSpinStartPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - ObjectData = new ObjectDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + ObjectData = new ObjectDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ObjectSpinStartPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - ObjectData = new ObjectDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + ObjectData = new ObjectDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += ObjectData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - ObjectData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += ObjectData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + ObjectData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ObjectSpinStart ---\n"; - output += ObjectData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- ObjectSpinStart ---\n"; + output += ObjectData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ObjectSpinUpdate packet + + /// ObjectSpinUpdate packet public class ObjectSpinUpdatePacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - /// ObjectID field - public LLUUID ObjectID; - /// Rotation field - public LLQuaternion Rotation; - - /// Length of this block serialized in bytes + { + /// ObjectID field + public LLUUID ObjectID; + /// Rotation field + public LLQuaternion Rotation; + + /// Length of this block serialized in bytes public int Length { get - { - return 28; + { + return 28; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { + { try - { - ObjectID = new LLUUID(bytes, i); i += 16; - Rotation = new LLQuaternion(bytes, i, true); i += 12; + { + ObjectID = new LLUUID(bytes, i); i += 16; + Rotation = new LLQuaternion(bytes, i, true); i += 12; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } - Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; - if(Rotation == null) { Console.WriteLine("Warning: Rotation is null, in " + this.GetType()); } - Array.Copy(Rotation.GetBytes(), 0, bytes, i, 12); i += 12; + { + if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } + Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; + if(Rotation == null) { Console.WriteLine("Warning: Rotation is null, in " + this.GetType()); } + Array.Copy(Rotation.GetBytes(), 0, bytes, i, 12); i += 12; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += "ObjectID: " + ObjectID.ToString() + "\n"; - output += "Rotation: " + Rotation.ToString() + "\n"; + { + string output = "-- ObjectData --\n"; + output += "ObjectID: " + ObjectID.ToString() + "\n"; + output += "Rotation: " + Rotation.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ObjectSpinUpdate - public override PacketType Type { get { return PacketType.ObjectSpinUpdate; } } - /// ObjectData block - public ObjectDataBlock ObjectData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ObjectSpinUpdate + public override PacketType Type { get { return PacketType.ObjectSpinUpdate; } } + /// ObjectData block + public ObjectDataBlock ObjectData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ObjectSpinUpdatePacket() - { - Header = new LowHeader(); - Header.ID = 155; - Header.Reliable = true; - Header.Zerocoded = true; - ObjectData = new ObjectDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 155; + Header.Reliable = true; + Header.Zerocoded = true; + ObjectData = new ObjectDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ObjectSpinUpdatePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - ObjectData = new ObjectDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + ObjectData = new ObjectDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ObjectSpinUpdatePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - ObjectData = new ObjectDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + ObjectData = new ObjectDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += ObjectData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - ObjectData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += ObjectData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + ObjectData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ObjectSpinUpdate ---\n"; - output += ObjectData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- ObjectSpinUpdate ---\n"; + output += ObjectData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ObjectSpinStop packet + + /// ObjectSpinStop packet public class ObjectSpinStopPacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - /// ObjectID field - public LLUUID ObjectID; - - /// Length of this block serialized in bytes + { + /// ObjectID field + public LLUUID ObjectID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { + { try - { - ObjectID = new LLUUID(bytes, i); i += 16; + { + ObjectID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } - Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } + Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += "ObjectID: " + ObjectID.ToString() + "\n"; + { + string output = "-- ObjectData --\n"; + output += "ObjectID: " + ObjectID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ObjectSpinStop - public override PacketType Type { get { return PacketType.ObjectSpinStop; } } - /// ObjectData block - public ObjectDataBlock ObjectData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ObjectSpinStop + public override PacketType Type { get { return PacketType.ObjectSpinStop; } } + /// ObjectData block + public ObjectDataBlock ObjectData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ObjectSpinStopPacket() - { - Header = new LowHeader(); - Header.ID = 156; - Header.Reliable = true; - Header.Zerocoded = true; - ObjectData = new ObjectDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 156; + Header.Reliable = true; + Header.Zerocoded = true; + ObjectData = new ObjectDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ObjectSpinStopPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - ObjectData = new ObjectDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + ObjectData = new ObjectDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ObjectSpinStopPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - ObjectData = new ObjectDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + ObjectData = new ObjectDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += ObjectData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - ObjectData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += ObjectData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + ObjectData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ObjectSpinStop ---\n"; - output += ObjectData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- ObjectSpinStop ---\n"; + output += ObjectData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ObjectExportSelected packet + + /// ObjectExportSelected packet public class ObjectExportSelectedPacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - /// ObjectID field - public LLUUID ObjectID; - - /// Length of this block serialized in bytes + { + /// ObjectID field + public LLUUID ObjectID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { + { try - { - ObjectID = new LLUUID(bytes, i); i += 16; + { + ObjectID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } - Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } + Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += "ObjectID: " + ObjectID.ToString() + "\n"; + { + string output = "-- ObjectData --\n"; + output += "ObjectID: " + ObjectID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// RequestID field - public LLUUID RequestID; - /// VolumeDetail field - public short VolumeDetail; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// RequestID field + public LLUUID RequestID; + /// VolumeDetail field + public short VolumeDetail; + + /// Length of this block serialized in bytes public int Length { get - { - return 34; + { + return 34; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - RequestID = new LLUUID(bytes, i); i += 16; - VolumeDetail = (short)(bytes[i++] + (bytes[i++] << 8)); + { + AgentID = new LLUUID(bytes, i); i += 16; + RequestID = new LLUUID(bytes, i); i += 16; + VolumeDetail = (short)(bytes[i++] + (bytes[i++] << 8)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(RequestID == null) { Console.WriteLine("Warning: RequestID is null, in " + this.GetType()); } - Array.Copy(RequestID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(VolumeDetail % 256); - bytes[i++] = (byte)((VolumeDetail >> 8) % 256); + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(RequestID == null) { Console.WriteLine("Warning: RequestID is null, in " + this.GetType()); } + Array.Copy(RequestID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(VolumeDetail % 256); + bytes[i++] = (byte)((VolumeDetail >> 8) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "RequestID: " + RequestID.ToString() + "\n"; - output += "VolumeDetail: " + VolumeDetail.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "RequestID: " + RequestID.ToString() + "\n"; + output += "VolumeDetail: " + VolumeDetail.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ObjectExportSelected - public override PacketType Type { get { return PacketType.ObjectExportSelected; } } - /// ObjectData block - public ObjectDataBlock[] ObjectData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ObjectExportSelected + public override PacketType Type { get { return PacketType.ObjectExportSelected; } } + /// ObjectData block + public ObjectDataBlock[] ObjectData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ObjectExportSelectedPacket() - { - Header = new LowHeader(); - Header.ID = 157; - Header.Reliable = true; - Header.Zerocoded = true; - ObjectData = new ObjectDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 157; + Header.Reliable = true; + Header.Zerocoded = true; + ObjectData = new ObjectDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ObjectExportSelectedPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ObjectExportSelectedPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ObjectData.Length; - for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ObjectData.Length; + for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ObjectExportSelected ---\n"; + { + string output = "--- ObjectExportSelected ---\n"; for (int j = 0; j < ObjectData.Length; j++) - { + { output += ObjectData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ObjectImport packet + + /// ObjectImport packet public class ObjectImportPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// FolderID field - public LLUUID FolderID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// FolderID field + public LLUUID FolderID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - FolderID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + FolderID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } - Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } + Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "FolderID: " + FolderID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "FolderID: " + FolderID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AssetData block + + /// AssetData block public class AssetDataBlock - { - private byte[] _objectname; - /// ObjectName field + { + private byte[] _objectname; + /// ObjectName field public byte[] ObjectName - { - get { return _objectname; } + { + get { return _objectname; } set - { - if (value == null) { _objectname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _objectname = new byte[value.Length]; Array.Copy(value, _objectname, value.Length); } + { + if (value == null) { _objectname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _objectname = new byte[value.Length]; Array.Copy(value, _objectname, value.Length); } } - } - /// FileID field - public LLUUID FileID; - private byte[] _description; - /// Description field + } + /// FileID field + public LLUUID FileID; + private byte[] _description; + /// Description field public byte[] Description - { - get { return _description; } + { + get { return _description; } set - { - if (value == null) { _description = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } + { + if (value == null) { _description = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 16; - if (ObjectName != null) { length += 1 + ObjectName.Length; } - if (Description != null) { length += 1 + Description.Length; } - return length; + { + int length = 16; + if (ObjectName != null) { length += 1 + ObjectName.Length; } + if (Description != null) { length += 1 + Description.Length; } + return length; } } - - /// Default constructor - public AssetDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AssetDataBlock() { } + /// Constructor for building the block from a byte array public AssetDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _objectname = new byte[length]; - Array.Copy(bytes, i, _objectname, 0, length); i += length; - FileID = new LLUUID(bytes, i); i += 16; - length = (ushort)bytes[i++]; - _description = new byte[length]; - Array.Copy(bytes, i, _description, 0, length); i += length; + { + length = (ushort)bytes[i++]; + _objectname = new byte[length]; + Array.Copy(bytes, i, _objectname, 0, length); i += length; + FileID = new LLUUID(bytes, i); i += 16; + length = (ushort)bytes[i++]; + _description = new byte[length]; + Array.Copy(bytes, i, _description, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ObjectName == null) { Console.WriteLine("Warning: ObjectName is null, in " + this.GetType()); } - bytes[i++] = (byte)ObjectName.Length; - Array.Copy(ObjectName, 0, bytes, i, ObjectName.Length); i += ObjectName.Length; - if(FileID == null) { Console.WriteLine("Warning: FileID is null, in " + this.GetType()); } - Array.Copy(FileID.GetBytes(), 0, bytes, i, 16); i += 16; - if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } - bytes[i++] = (byte)Description.Length; - Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; + { + if(ObjectName == null) { Console.WriteLine("Warning: ObjectName is null, in " + this.GetType()); } + bytes[i++] = (byte)ObjectName.Length; + Array.Copy(ObjectName, 0, bytes, i, ObjectName.Length); i += ObjectName.Length; + if(FileID == null) { Console.WriteLine("Warning: FileID is null, in " + this.GetType()); } + Array.Copy(FileID.GetBytes(), 0, bytes, i, 16); i += 16; + if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } + bytes[i++] = (byte)Description.Length; + Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AssetData --\n"; - output += Helpers.FieldToString(ObjectName, "ObjectName") + "\n"; - output += "FileID: " + FileID.ToString() + "\n"; - output += Helpers.FieldToString(Description, "Description") + "\n"; + { + string output = "-- AssetData --\n"; + output += Helpers.FieldToString(ObjectName, "ObjectName") + "\n"; + output += "FileID: " + FileID.ToString() + "\n"; + output += Helpers.FieldToString(Description, "Description") + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ObjectImport - public override PacketType Type { get { return PacketType.ObjectImport; } } - /// AgentData block - public AgentDataBlock AgentData; - /// AssetData block - public AssetDataBlock AssetData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ObjectImport + public override PacketType Type { get { return PacketType.ObjectImport; } } + /// AgentData block + public AgentDataBlock AgentData; + /// AssetData block + public AssetDataBlock AssetData; + + /// Default constructor public ObjectImportPacket() - { - Header = new LowHeader(); - Header.ID = 158; - Header.Reliable = true; - Header.Zerocoded = true; - AgentData = new AgentDataBlock(); - AssetData = new AssetDataBlock(); + { + Header = new LowHeader(); + Header.ID = 158; + Header.Reliable = true; + Header.Zerocoded = true; + AgentData = new AgentDataBlock(); + AssetData = new AssetDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ObjectImportPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); - AssetData = new AssetDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); + AssetData = new AssetDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ObjectImportPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); - AssetData = new AssetDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); + AssetData = new AssetDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length; length += AssetData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - AssetData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length; length += AssetData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + AssetData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ObjectImport ---\n"; - output += AgentData.ToString() + "\n"; - output += AssetData.ToString() + "\n"; + { + string output = "--- ObjectImport ---\n"; + output += AgentData.ToString() + "\n"; + output += AssetData.ToString() + "\n"; return output; } - + } - - /// ModifyLand packet + + /// ModifyLand packet public class ModifyLandPacket : Packet - { - /// ModifyBlock block + { + /// ModifyBlock block public class ModifyBlockBlock - { - /// BrushSize field - public byte BrushSize; - /// Seconds field - public float Seconds; - /// Height field - public float Height; - /// Action field - public byte Action; - - /// Length of this block serialized in bytes + { + /// BrushSize field + public byte BrushSize; + /// Seconds field + public float Seconds; + /// Height field + public float Height; + /// Action field + public byte Action; + + /// Length of this block serialized in bytes public int Length { get - { - return 10; + { + return 10; } } - - /// Default constructor - public ModifyBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ModifyBlockBlock() { } + /// Constructor for building the block from a byte array public ModifyBlockBlock(byte[] bytes, ref int i) - { + { try - { - BrushSize = (byte)bytes[i++]; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - Seconds = BitConverter.ToSingle(bytes, i); i += 4; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - Height = BitConverter.ToSingle(bytes, i); i += 4; - Action = (byte)bytes[i++]; + { + BrushSize = (byte)bytes[i++]; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + Seconds = BitConverter.ToSingle(bytes, i); i += 4; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + Height = BitConverter.ToSingle(bytes, i); i += 4; + Action = (byte)bytes[i++]; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; - bytes[i++] = BrushSize; + { + byte[] ba; + bytes[i++] = BrushSize; ba = BitConverter.GetBytes(Seconds); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; ba = BitConverter.GetBytes(Height); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - bytes[i++] = Action; + Array.Copy(ba, 0, bytes, i, 4); i += 4; + bytes[i++] = Action; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ModifyBlock --\n"; - output += "BrushSize: " + BrushSize.ToString() + "\n"; - output += "Seconds: " + Seconds.ToString() + "\n"; - output += "Height: " + Height.ToString() + "\n"; - output += "Action: " + Action.ToString() + "\n"; + { + string output = "-- ModifyBlock --\n"; + output += "BrushSize: " + BrushSize.ToString() + "\n"; + output += "Seconds: " + Seconds.ToString() + "\n"; + output += "Height: " + Height.ToString() + "\n"; + output += "Action: " + Action.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// ParcelData block + + /// ParcelData block public class ParcelDataBlock - { - /// LocalID field - public int LocalID; - /// East field - public float East; - /// West field - public float West; - /// North field - public float North; - /// South field - public float South; - - /// Length of this block serialized in bytes + { + /// LocalID field + public int LocalID; + /// East field + public float East; + /// West field + public float West; + /// North field + public float North; + /// South field + public float South; + + /// Length of this block serialized in bytes public int Length { get - { - return 20; + { + return 20; } } - - /// Default constructor - public ParcelDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ParcelDataBlock() { } + /// Constructor for building the block from a byte array public ParcelDataBlock(byte[] bytes, ref int i) - { + { try - { - LocalID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - East = BitConverter.ToSingle(bytes, i); i += 4; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - West = BitConverter.ToSingle(bytes, i); i += 4; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - North = BitConverter.ToSingle(bytes, i); i += 4; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - South = BitConverter.ToSingle(bytes, i); i += 4; + { + LocalID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + East = BitConverter.ToSingle(bytes, i); i += 4; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + West = BitConverter.ToSingle(bytes, i); i += 4; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + North = BitConverter.ToSingle(bytes, i); i += 4; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + South = BitConverter.ToSingle(bytes, i); i += 4; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; - bytes[i++] = (byte)(LocalID % 256); - bytes[i++] = (byte)((LocalID >> 8) % 256); - bytes[i++] = (byte)((LocalID >> 16) % 256); - bytes[i++] = (byte)((LocalID >> 24) % 256); + { + byte[] ba; + bytes[i++] = (byte)(LocalID % 256); + bytes[i++] = (byte)((LocalID >> 8) % 256); + bytes[i++] = (byte)((LocalID >> 16) % 256); + bytes[i++] = (byte)((LocalID >> 24) % 256); ba = BitConverter.GetBytes(East); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; ba = BitConverter.GetBytes(West); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; ba = BitConverter.GetBytes(North); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; ba = BitConverter.GetBytes(South); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ParcelData --\n"; - output += "LocalID: " + LocalID.ToString() + "\n"; - output += "East: " + East.ToString() + "\n"; - output += "West: " + West.ToString() + "\n"; - output += "North: " + North.ToString() + "\n"; - output += "South: " + South.ToString() + "\n"; + { + string output = "-- ParcelData --\n"; + output += "LocalID: " + LocalID.ToString() + "\n"; + output += "East: " + East.ToString() + "\n"; + output += "West: " + West.ToString() + "\n"; + output += "North: " + North.ToString() + "\n"; + output += "South: " + South.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ModifyLand - public override PacketType Type { get { return PacketType.ModifyLand; } } - /// ModifyBlock block - public ModifyBlockBlock ModifyBlock; - /// ParcelData block - public ParcelDataBlock[] ParcelData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ModifyLand + public override PacketType Type { get { return PacketType.ModifyLand; } } + /// ModifyBlock block + public ModifyBlockBlock ModifyBlock; + /// ParcelData block + public ParcelDataBlock[] ParcelData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ModifyLandPacket() - { - Header = new LowHeader(); - Header.ID = 159; - Header.Reliable = true; - Header.Zerocoded = true; - ModifyBlock = new ModifyBlockBlock(); - ParcelData = new ParcelDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 159; + Header.Reliable = true; + Header.Zerocoded = true; + ModifyBlock = new ModifyBlockBlock(); + ParcelData = new ParcelDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ModifyLandPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - ModifyBlock = new ModifyBlockBlock(bytes, ref i); - int count = (int)bytes[i++]; - ParcelData = new ParcelDataBlock[count]; - for (int j = 0; j < count; j++) - { ParcelData[j] = new ParcelDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + ModifyBlock = new ModifyBlockBlock(bytes, ref i); + int count = (int)bytes[i++]; + ParcelData = new ParcelDataBlock[count]; + for (int j = 0; j < count; j++) + { ParcelData[j] = new ParcelDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ModifyLandPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - ModifyBlock = new ModifyBlockBlock(bytes, ref i); - int count = (int)bytes[i++]; - ParcelData = new ParcelDataBlock[count]; - for (int j = 0; j < count; j++) - { ParcelData[j] = new ParcelDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + ModifyBlock = new ModifyBlockBlock(bytes, ref i); + int count = (int)bytes[i++]; + ParcelData = new ParcelDataBlock[count]; + for (int j = 0; j < count; j++) + { ParcelData[j] = new ParcelDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += ModifyBlock.Length; length += AgentData.Length;; - length++; - for (int j = 0; j < ParcelData.Length; j++) { length += ParcelData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - ModifyBlock.ToBytes(bytes, ref i); - bytes[i++] = (byte)ParcelData.Length; - for (int j = 0; j < ParcelData.Length; j++) { ParcelData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += ModifyBlock.Length; length += AgentData.Length;; + length++; + for (int j = 0; j < ParcelData.Length; j++) { length += ParcelData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + ModifyBlock.ToBytes(bytes, ref i); + bytes[i++] = (byte)ParcelData.Length; + for (int j = 0; j < ParcelData.Length; j++) { ParcelData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ModifyLand ---\n"; - output += ModifyBlock.ToString() + "\n"; + { + string output = "--- ModifyLand ---\n"; + output += ModifyBlock.ToString() + "\n"; for (int j = 0; j < ParcelData.Length; j++) - { + { output += ParcelData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// VelocityInterpolateOn packet + + /// VelocityInterpolateOn packet public class VelocityInterpolateOnPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.VelocityInterpolateOn - public override PacketType Type { get { return PacketType.VelocityInterpolateOn; } } - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.VelocityInterpolateOn + public override PacketType Type { get { return PacketType.VelocityInterpolateOn; } } + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public VelocityInterpolateOnPacket() - { - Header = new LowHeader(); - Header.ID = 160; - Header.Reliable = true; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 160; + Header.Reliable = true; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public VelocityInterpolateOnPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public VelocityInterpolateOnPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- VelocityInterpolateOn ---\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- VelocityInterpolateOn ---\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// VelocityInterpolateOff packet + + /// VelocityInterpolateOff packet public class VelocityInterpolateOffPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.VelocityInterpolateOff - public override PacketType Type { get { return PacketType.VelocityInterpolateOff; } } - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.VelocityInterpolateOff + public override PacketType Type { get { return PacketType.VelocityInterpolateOff; } } + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public VelocityInterpolateOffPacket() - { - Header = new LowHeader(); - Header.ID = 161; - Header.Reliable = true; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 161; + Header.Reliable = true; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public VelocityInterpolateOffPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public VelocityInterpolateOffPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- VelocityInterpolateOff ---\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- VelocityInterpolateOff ---\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// StateSave packet + + /// StateSave packet public class StateSavePacket : Packet - { - /// DataBlock block + { + /// DataBlock block public class DataBlockBlock - { - private byte[] _filename; - /// Filename field + { + private byte[] _filename; + /// Filename field public byte[] Filename - { - get { return _filename; } + { + get { return _filename; } set - { - if (value == null) { _filename = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _filename = new byte[value.Length]; Array.Copy(value, _filename, value.Length); } + { + if (value == null) { _filename = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _filename = new byte[value.Length]; Array.Copy(value, _filename, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 0; - if (Filename != null) { length += 1 + Filename.Length; } - return length; + { + int length = 0; + if (Filename != null) { length += 1 + Filename.Length; } + return length; } } - - /// Default constructor - public DataBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlockBlock() { } + /// Constructor for building the block from a byte array public DataBlockBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _filename = new byte[length]; - Array.Copy(bytes, i, _filename, 0, length); i += length; + { + length = (ushort)bytes[i++]; + _filename = new byte[length]; + Array.Copy(bytes, i, _filename, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(Filename == null) { Console.WriteLine("Warning: Filename is null, in " + this.GetType()); } - bytes[i++] = (byte)Filename.Length; - Array.Copy(Filename, 0, bytes, i, Filename.Length); i += Filename.Length; + { + if(Filename == null) { Console.WriteLine("Warning: Filename is null, in " + this.GetType()); } + bytes[i++] = (byte)Filename.Length; + Array.Copy(Filename, 0, bytes, i, Filename.Length); i += Filename.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- DataBlock --\n"; - output += Helpers.FieldToString(Filename, "Filename") + "\n"; + { + string output = "-- DataBlock --\n"; + output += Helpers.FieldToString(Filename, "Filename") + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.StateSave - public override PacketType Type { get { return PacketType.StateSave; } } - /// DataBlock block - public DataBlockBlock DataBlock; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.StateSave + public override PacketType Type { get { return PacketType.StateSave; } } + /// DataBlock block + public DataBlockBlock DataBlock; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public StateSavePacket() - { - Header = new LowHeader(); - Header.ID = 162; - Header.Reliable = true; - DataBlock = new DataBlockBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 162; + Header.Reliable = true; + DataBlock = new DataBlockBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public StateSavePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - DataBlock = new DataBlockBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + DataBlock = new DataBlockBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public StateSavePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - DataBlock = new DataBlockBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + DataBlock = new DataBlockBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += DataBlock.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - DataBlock.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += DataBlock.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + DataBlock.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- StateSave ---\n"; - output += DataBlock.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- StateSave ---\n"; + output += DataBlock.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ReportAutosaveCrash packet + + /// ReportAutosaveCrash packet public class ReportAutosaveCrashPacket : Packet - { - /// AutosaveData block + { + /// AutosaveData block public class AutosaveDataBlock - { - /// PID field - public int PID; - /// Status field - public int Status; - - /// Length of this block serialized in bytes + { + /// PID field + public int PID; + /// Status field + public int Status; + + /// Length of this block serialized in bytes public int Length { get - { - return 8; + { + return 8; } } - - /// Default constructor - public AutosaveDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AutosaveDataBlock() { } + /// Constructor for building the block from a byte array public AutosaveDataBlock(byte[] bytes, ref int i) - { + { try - { - PID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Status = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + PID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Status = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(PID % 256); - bytes[i++] = (byte)((PID >> 8) % 256); - bytes[i++] = (byte)((PID >> 16) % 256); - bytes[i++] = (byte)((PID >> 24) % 256); - bytes[i++] = (byte)(Status % 256); - bytes[i++] = (byte)((Status >> 8) % 256); - bytes[i++] = (byte)((Status >> 16) % 256); - bytes[i++] = (byte)((Status >> 24) % 256); + { + bytes[i++] = (byte)(PID % 256); + bytes[i++] = (byte)((PID >> 8) % 256); + bytes[i++] = (byte)((PID >> 16) % 256); + bytes[i++] = (byte)((PID >> 24) % 256); + bytes[i++] = (byte)(Status % 256); + bytes[i++] = (byte)((Status >> 8) % 256); + bytes[i++] = (byte)((Status >> 16) % 256); + bytes[i++] = (byte)((Status >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AutosaveData --\n"; - output += "PID: " + PID.ToString() + "\n"; - output += "Status: " + Status.ToString() + "\n"; + { + string output = "-- AutosaveData --\n"; + output += "PID: " + PID.ToString() + "\n"; + output += "Status: " + Status.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ReportAutosaveCrash - public override PacketType Type { get { return PacketType.ReportAutosaveCrash; } } - /// AutosaveData block - public AutosaveDataBlock AutosaveData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ReportAutosaveCrash + public override PacketType Type { get { return PacketType.ReportAutosaveCrash; } } + /// AutosaveData block + public AutosaveDataBlock AutosaveData; + + /// Default constructor public ReportAutosaveCrashPacket() - { - Header = new LowHeader(); - Header.ID = 163; - Header.Reliable = true; - AutosaveData = new AutosaveDataBlock(); + { + Header = new LowHeader(); + Header.ID = 163; + Header.Reliable = true; + AutosaveData = new AutosaveDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ReportAutosaveCrashPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AutosaveData = new AutosaveDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AutosaveData = new AutosaveDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ReportAutosaveCrashPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AutosaveData = new AutosaveDataBlock(bytes, ref i); + { + Header = head; + AutosaveData = new AutosaveDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AutosaveData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AutosaveData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AutosaveData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AutosaveData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ReportAutosaveCrash ---\n"; - output += AutosaveData.ToString() + "\n"; + { + string output = "--- ReportAutosaveCrash ---\n"; + output += AutosaveData.ToString() + "\n"; return output; } - + } - - /// SimWideDeletes packet + + /// SimWideDeletes packet public class SimWideDeletesPacket : Packet - { - /// DataBlock block + { + /// DataBlock block public class DataBlockBlock - { - /// TargetID field - public LLUUID TargetID; - /// Flags field - public uint Flags; - - /// Length of this block serialized in bytes + { + /// TargetID field + public LLUUID TargetID; + /// Flags field + public uint Flags; + + /// Length of this block serialized in bytes public int Length { get - { - return 20; + { + return 20; } } - - /// Default constructor - public DataBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlockBlock() { } + /// Constructor for building the block from a byte array public DataBlockBlock(byte[] bytes, ref int i) - { + { try - { - TargetID = new LLUUID(bytes, i); i += 16; - Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + TargetID = new LLUUID(bytes, i); i += 16; + Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(TargetID == null) { Console.WriteLine("Warning: TargetID is null, in " + this.GetType()); } - Array.Copy(TargetID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(Flags % 256); - bytes[i++] = (byte)((Flags >> 8) % 256); - bytes[i++] = (byte)((Flags >> 16) % 256); - bytes[i++] = (byte)((Flags >> 24) % 256); + { + if(TargetID == null) { Console.WriteLine("Warning: TargetID is null, in " + this.GetType()); } + Array.Copy(TargetID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(Flags % 256); + bytes[i++] = (byte)((Flags >> 8) % 256); + bytes[i++] = (byte)((Flags >> 16) % 256); + bytes[i++] = (byte)((Flags >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- DataBlock --\n"; - output += "TargetID: " + TargetID.ToString() + "\n"; - output += "Flags: " + Flags.ToString() + "\n"; + { + string output = "-- DataBlock --\n"; + output += "TargetID: " + TargetID.ToString() + "\n"; + output += "Flags: " + Flags.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.SimWideDeletes - public override PacketType Type { get { return PacketType.SimWideDeletes; } } - /// DataBlock block - public DataBlockBlock DataBlock; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.SimWideDeletes + public override PacketType Type { get { return PacketType.SimWideDeletes; } } + /// DataBlock block + public DataBlockBlock DataBlock; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public SimWideDeletesPacket() - { - Header = new LowHeader(); - Header.ID = 164; - Header.Reliable = true; - DataBlock = new DataBlockBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 164; + Header.Reliable = true; + DataBlock = new DataBlockBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public SimWideDeletesPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - DataBlock = new DataBlockBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + DataBlock = new DataBlockBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public SimWideDeletesPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - DataBlock = new DataBlockBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + DataBlock = new DataBlockBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += DataBlock.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - DataBlock.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += DataBlock.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + DataBlock.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- SimWideDeletes ---\n"; - output += DataBlock.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- SimWideDeletes ---\n"; + output += DataBlock.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// TrackAgent packet + + /// TrackAgent packet public class TrackAgentPacket : Packet - { - /// TargetData block + { + /// TargetData block public class TargetDataBlock - { - /// PreyID field - public LLUUID PreyID; - - /// Length of this block serialized in bytes + { + /// PreyID field + public LLUUID PreyID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public TargetDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public TargetDataBlock() { } + /// Constructor for building the block from a byte array public TargetDataBlock(byte[] bytes, ref int i) - { + { try - { - PreyID = new LLUUID(bytes, i); i += 16; + { + PreyID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(PreyID == null) { Console.WriteLine("Warning: PreyID is null, in " + this.GetType()); } - Array.Copy(PreyID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(PreyID == null) { Console.WriteLine("Warning: PreyID is null, in " + this.GetType()); } + Array.Copy(PreyID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- TargetData --\n"; - output += "PreyID: " + PreyID.ToString() + "\n"; + { + string output = "-- TargetData --\n"; + output += "PreyID: " + PreyID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.TrackAgent - public override PacketType Type { get { return PacketType.TrackAgent; } } - /// TargetData block - public TargetDataBlock TargetData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.TrackAgent + public override PacketType Type { get { return PacketType.TrackAgent; } } + /// TargetData block + public TargetDataBlock TargetData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public TrackAgentPacket() - { - Header = new LowHeader(); - Header.ID = 165; - Header.Reliable = true; - TargetData = new TargetDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 165; + Header.Reliable = true; + TargetData = new TargetDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public TrackAgentPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - TargetData = new TargetDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + TargetData = new TargetDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public TrackAgentPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - TargetData = new TargetDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + TargetData = new TargetDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += TargetData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - TargetData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += TargetData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + TargetData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- TrackAgent ---\n"; - output += TargetData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- TrackAgent ---\n"; + output += TargetData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// GrantModification packet + + /// GrantModification packet public class GrantModificationPacket : Packet - { - /// EmpoweredBlock block + { + /// EmpoweredBlock block public class EmpoweredBlockBlock - { - /// EmpoweredID field - public LLUUID EmpoweredID; - - /// Length of this block serialized in bytes + { + /// EmpoweredID field + public LLUUID EmpoweredID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public EmpoweredBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public EmpoweredBlockBlock() { } + /// Constructor for building the block from a byte array public EmpoweredBlockBlock(byte[] bytes, ref int i) - { + { try - { - EmpoweredID = new LLUUID(bytes, i); i += 16; + { + EmpoweredID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(EmpoweredID == null) { Console.WriteLine("Warning: EmpoweredID is null, in " + this.GetType()); } - Array.Copy(EmpoweredID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(EmpoweredID == null) { Console.WriteLine("Warning: EmpoweredID is null, in " + this.GetType()); } + Array.Copy(EmpoweredID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- EmpoweredBlock --\n"; - output += "EmpoweredID: " + EmpoweredID.ToString() + "\n"; + { + string output = "-- EmpoweredBlock --\n"; + output += "EmpoweredID: " + EmpoweredID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - private byte[] _grantername; - /// GranterName field + { + /// AgentID field + public LLUUID AgentID; + private byte[] _grantername; + /// GranterName field public byte[] GranterName - { - get { return _grantername; } + { + get { return _grantername; } set - { - if (value == null) { _grantername = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _grantername = new byte[value.Length]; Array.Copy(value, _grantername, value.Length); } + { + if (value == null) { _grantername = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _grantername = new byte[value.Length]; Array.Copy(value, _grantername, value.Length); } } - } - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + } + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 32; - if (GranterName != null) { length += 1 + GranterName.Length; } - return length; + { + int length = 32; + if (GranterName != null) { length += 1 + GranterName.Length; } + return length; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - AgentID = new LLUUID(bytes, i); i += 16; - length = (ushort)bytes[i++]; - _grantername = new byte[length]; - Array.Copy(bytes, i, _grantername, 0, length); i += length; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + length = (ushort)bytes[i++]; + _grantername = new byte[length]; + Array.Copy(bytes, i, _grantername, 0, length); i += length; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(GranterName == null) { Console.WriteLine("Warning: GranterName is null, in " + this.GetType()); } - bytes[i++] = (byte)GranterName.Length; - Array.Copy(GranterName, 0, bytes, i, GranterName.Length); i += GranterName.Length; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(GranterName == null) { Console.WriteLine("Warning: GranterName is null, in " + this.GetType()); } + bytes[i++] = (byte)GranterName.Length; + Array.Copy(GranterName, 0, bytes, i, GranterName.Length); i += GranterName.Length; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += Helpers.FieldToString(GranterName, "GranterName") + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += Helpers.FieldToString(GranterName, "GranterName") + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.GrantModification - public override PacketType Type { get { return PacketType.GrantModification; } } - /// EmpoweredBlock block - public EmpoweredBlockBlock[] EmpoweredBlock; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.GrantModification + public override PacketType Type { get { return PacketType.GrantModification; } } + /// EmpoweredBlock block + public EmpoweredBlockBlock[] EmpoweredBlock; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public GrantModificationPacket() - { - Header = new LowHeader(); - Header.ID = 166; - Header.Reliable = true; - EmpoweredBlock = new EmpoweredBlockBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 166; + Header.Reliable = true; + EmpoweredBlock = new EmpoweredBlockBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public GrantModificationPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - EmpoweredBlock = new EmpoweredBlockBlock[count]; - for (int j = 0; j < count; j++) - { EmpoweredBlock[j] = new EmpoweredBlockBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + EmpoweredBlock = new EmpoweredBlockBlock[count]; + for (int j = 0; j < count; j++) + { EmpoweredBlock[j] = new EmpoweredBlockBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public GrantModificationPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - EmpoweredBlock = new EmpoweredBlockBlock[count]; - for (int j = 0; j < count; j++) - { EmpoweredBlock[j] = new EmpoweredBlockBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + EmpoweredBlock = new EmpoweredBlockBlock[count]; + for (int j = 0; j < count; j++) + { EmpoweredBlock[j] = new EmpoweredBlockBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < EmpoweredBlock.Length; j++) { length += EmpoweredBlock[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)EmpoweredBlock.Length; - for (int j = 0; j < EmpoweredBlock.Length; j++) { EmpoweredBlock[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < EmpoweredBlock.Length; j++) { length += EmpoweredBlock[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)EmpoweredBlock.Length; + for (int j = 0; j < EmpoweredBlock.Length; j++) { EmpoweredBlock[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- GrantModification ---\n"; + { + string output = "--- GrantModification ---\n"; for (int j = 0; j < EmpoweredBlock.Length; j++) - { + { output += EmpoweredBlock[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// RevokeModification packet + + /// RevokeModification packet public class RevokeModificationPacket : Packet - { - /// RevokedBlock block + { + /// RevokedBlock block public class RevokedBlockBlock - { - /// RevokedID field - public LLUUID RevokedID; - - /// Length of this block serialized in bytes + { + /// RevokedID field + public LLUUID RevokedID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public RevokedBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public RevokedBlockBlock() { } + /// Constructor for building the block from a byte array public RevokedBlockBlock(byte[] bytes, ref int i) - { + { try - { - RevokedID = new LLUUID(bytes, i); i += 16; + { + RevokedID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(RevokedID == null) { Console.WriteLine("Warning: RevokedID is null, in " + this.GetType()); } - Array.Copy(RevokedID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(RevokedID == null) { Console.WriteLine("Warning: RevokedID is null, in " + this.GetType()); } + Array.Copy(RevokedID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- RevokedBlock --\n"; - output += "RevokedID: " + RevokedID.ToString() + "\n"; + { + string output = "-- RevokedBlock --\n"; + output += "RevokedID: " + RevokedID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - private byte[] _grantername; - /// GranterName field + { + /// AgentID field + public LLUUID AgentID; + private byte[] _grantername; + /// GranterName field public byte[] GranterName - { - get { return _grantername; } + { + get { return _grantername; } set - { - if (value == null) { _grantername = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _grantername = new byte[value.Length]; Array.Copy(value, _grantername, value.Length); } + { + if (value == null) { _grantername = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _grantername = new byte[value.Length]; Array.Copy(value, _grantername, value.Length); } } - } - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + } + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 32; - if (GranterName != null) { length += 1 + GranterName.Length; } - return length; + { + int length = 32; + if (GranterName != null) { length += 1 + GranterName.Length; } + return length; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - AgentID = new LLUUID(bytes, i); i += 16; - length = (ushort)bytes[i++]; - _grantername = new byte[length]; - Array.Copy(bytes, i, _grantername, 0, length); i += length; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + length = (ushort)bytes[i++]; + _grantername = new byte[length]; + Array.Copy(bytes, i, _grantername, 0, length); i += length; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(GranterName == null) { Console.WriteLine("Warning: GranterName is null, in " + this.GetType()); } - bytes[i++] = (byte)GranterName.Length; - Array.Copy(GranterName, 0, bytes, i, GranterName.Length); i += GranterName.Length; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(GranterName == null) { Console.WriteLine("Warning: GranterName is null, in " + this.GetType()); } + bytes[i++] = (byte)GranterName.Length; + Array.Copy(GranterName, 0, bytes, i, GranterName.Length); i += GranterName.Length; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += Helpers.FieldToString(GranterName, "GranterName") + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += Helpers.FieldToString(GranterName, "GranterName") + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.RevokeModification - public override PacketType Type { get { return PacketType.RevokeModification; } } - /// RevokedBlock block - public RevokedBlockBlock[] RevokedBlock; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.RevokeModification + public override PacketType Type { get { return PacketType.RevokeModification; } } + /// RevokedBlock block + public RevokedBlockBlock[] RevokedBlock; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public RevokeModificationPacket() - { - Header = new LowHeader(); - Header.ID = 167; - Header.Reliable = true; - RevokedBlock = new RevokedBlockBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 167; + Header.Reliable = true; + RevokedBlock = new RevokedBlockBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public RevokeModificationPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - RevokedBlock = new RevokedBlockBlock[count]; - for (int j = 0; j < count; j++) - { RevokedBlock[j] = new RevokedBlockBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + RevokedBlock = new RevokedBlockBlock[count]; + for (int j = 0; j < count; j++) + { RevokedBlock[j] = new RevokedBlockBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public RevokeModificationPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - RevokedBlock = new RevokedBlockBlock[count]; - for (int j = 0; j < count; j++) - { RevokedBlock[j] = new RevokedBlockBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + RevokedBlock = new RevokedBlockBlock[count]; + for (int j = 0; j < count; j++) + { RevokedBlock[j] = new RevokedBlockBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < RevokedBlock.Length; j++) { length += RevokedBlock[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)RevokedBlock.Length; - for (int j = 0; j < RevokedBlock.Length; j++) { RevokedBlock[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < RevokedBlock.Length; j++) { length += RevokedBlock[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)RevokedBlock.Length; + for (int j = 0; j < RevokedBlock.Length; j++) { RevokedBlock[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- RevokeModification ---\n"; + { + string output = "--- RevokeModification ---\n"; for (int j = 0; j < RevokedBlock.Length; j++) - { + { output += RevokedBlock[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// RequestGrantedProxies packet + + /// RequestGrantedProxies packet public class RequestGrantedProxiesPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.RequestGrantedProxies - public override PacketType Type { get { return PacketType.RequestGrantedProxies; } } - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.RequestGrantedProxies + public override PacketType Type { get { return PacketType.RequestGrantedProxies; } } + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public RequestGrantedProxiesPacket() - { - Header = new LowHeader(); - Header.ID = 168; - Header.Reliable = true; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 168; + Header.Reliable = true; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public RequestGrantedProxiesPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public RequestGrantedProxiesPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- RequestGrantedProxies ---\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- RequestGrantedProxies ---\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// GrantedProxies packet + + /// GrantedProxies packet public class GrantedProxiesPacket : Packet - { - /// EmpoweredBlock block + { + /// EmpoweredBlock block public class EmpoweredBlockBlock - { - /// EmpoweredID field - public LLUUID EmpoweredID; - - /// Length of this block serialized in bytes + { + /// EmpoweredID field + public LLUUID EmpoweredID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public EmpoweredBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public EmpoweredBlockBlock() { } + /// Constructor for building the block from a byte array public EmpoweredBlockBlock(byte[] bytes, ref int i) - { + { try - { - EmpoweredID = new LLUUID(bytes, i); i += 16; + { + EmpoweredID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(EmpoweredID == null) { Console.WriteLine("Warning: EmpoweredID is null, in " + this.GetType()); } - Array.Copy(EmpoweredID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(EmpoweredID == null) { Console.WriteLine("Warning: EmpoweredID is null, in " + this.GetType()); } + Array.Copy(EmpoweredID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- EmpoweredBlock --\n"; - output += "EmpoweredID: " + EmpoweredID.ToString() + "\n"; + { + string output = "-- EmpoweredBlock --\n"; + output += "EmpoweredID: " + EmpoweredID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// GranterBlock block + + /// GranterBlock block public class GranterBlockBlock - { - /// GranterID field - public LLUUID GranterID; - - /// Length of this block serialized in bytes + { + /// GranterID field + public LLUUID GranterID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public GranterBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public GranterBlockBlock() { } + /// Constructor for building the block from a byte array public GranterBlockBlock(byte[] bytes, ref int i) - { + { try - { - GranterID = new LLUUID(bytes, i); i += 16; + { + GranterID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(GranterID == null) { Console.WriteLine("Warning: GranterID is null, in " + this.GetType()); } - Array.Copy(GranterID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(GranterID == null) { Console.WriteLine("Warning: GranterID is null, in " + this.GetType()); } + Array.Copy(GranterID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- GranterBlock --\n"; - output += "GranterID: " + GranterID.ToString() + "\n"; + { + string output = "-- GranterBlock --\n"; + output += "GranterID: " + GranterID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.GrantedProxies - public override PacketType Type { get { return PacketType.GrantedProxies; } } - /// EmpoweredBlock block - public EmpoweredBlockBlock[] EmpoweredBlock; - /// GranterBlock block - public GranterBlockBlock[] GranterBlock; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.GrantedProxies + public override PacketType Type { get { return PacketType.GrantedProxies; } } + /// EmpoweredBlock block + public EmpoweredBlockBlock[] EmpoweredBlock; + /// GranterBlock block + public GranterBlockBlock[] GranterBlock; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public GrantedProxiesPacket() - { - Header = new LowHeader(); - Header.ID = 169; - Header.Reliable = true; - EmpoweredBlock = new EmpoweredBlockBlock[0]; - GranterBlock = new GranterBlockBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 169; + Header.Reliable = true; + EmpoweredBlock = new EmpoweredBlockBlock[0]; + GranterBlock = new GranterBlockBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public GrantedProxiesPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - EmpoweredBlock = new EmpoweredBlockBlock[count]; - for (int j = 0; j < count; j++) - { EmpoweredBlock[j] = new EmpoweredBlockBlock(bytes, ref i); } - count = (int)bytes[i++]; - GranterBlock = new GranterBlockBlock[count]; - for (int j = 0; j < count; j++) - { GranterBlock[j] = new GranterBlockBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + EmpoweredBlock = new EmpoweredBlockBlock[count]; + for (int j = 0; j < count; j++) + { EmpoweredBlock[j] = new EmpoweredBlockBlock(bytes, ref i); } + count = (int)bytes[i++]; + GranterBlock = new GranterBlockBlock[count]; + for (int j = 0; j < count; j++) + { GranterBlock[j] = new GranterBlockBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public GrantedProxiesPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - EmpoweredBlock = new EmpoweredBlockBlock[count]; - for (int j = 0; j < count; j++) - { EmpoweredBlock[j] = new EmpoweredBlockBlock(bytes, ref i); } - count = (int)bytes[i++]; - GranterBlock = new GranterBlockBlock[count]; - for (int j = 0; j < count; j++) - { GranterBlock[j] = new GranterBlockBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + EmpoweredBlock = new EmpoweredBlockBlock[count]; + for (int j = 0; j < count; j++) + { EmpoweredBlock[j] = new EmpoweredBlockBlock(bytes, ref i); } + count = (int)bytes[i++]; + GranterBlock = new GranterBlockBlock[count]; + for (int j = 0; j < count; j++) + { GranterBlock[j] = new GranterBlockBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < EmpoweredBlock.Length; j++) { length += EmpoweredBlock[j].Length; } - length++; - for (int j = 0; j < GranterBlock.Length; j++) { length += GranterBlock[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)EmpoweredBlock.Length; - for (int j = 0; j < EmpoweredBlock.Length; j++) { EmpoweredBlock[j].ToBytes(bytes, ref i); } - bytes[i++] = (byte)GranterBlock.Length; - for (int j = 0; j < GranterBlock.Length; j++) { GranterBlock[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < EmpoweredBlock.Length; j++) { length += EmpoweredBlock[j].Length; } + length++; + for (int j = 0; j < GranterBlock.Length; j++) { length += GranterBlock[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)EmpoweredBlock.Length; + for (int j = 0; j < EmpoweredBlock.Length; j++) { EmpoweredBlock[j].ToBytes(bytes, ref i); } + bytes[i++] = (byte)GranterBlock.Length; + for (int j = 0; j < GranterBlock.Length; j++) { GranterBlock[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- GrantedProxies ---\n"; + { + string output = "--- GrantedProxies ---\n"; for (int j = 0; j < EmpoweredBlock.Length; j++) - { + { output += EmpoweredBlock[j].ToString() + "\n"; - } + } for (int j = 0; j < GranterBlock.Length; j++) - { + { output += GranterBlock[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// AddModifyAbility packet + + /// AddModifyAbility packet public class AddModifyAbilityPacket : Packet - { - /// TargetBlock block + { + /// TargetBlock block public class TargetBlockBlock - { - /// TargetIP field - public uint TargetIP; - /// TargetPort field - public ushort TargetPort; - - /// Length of this block serialized in bytes + { + /// TargetIP field + public uint TargetIP; + /// TargetPort field + public ushort TargetPort; + + /// Length of this block serialized in bytes public int Length { get - { - return 6; + { + return 6; } } - - /// Default constructor - public TargetBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public TargetBlockBlock() { } + /// Constructor for building the block from a byte array public TargetBlockBlock(byte[] bytes, ref int i) - { + { try - { - TargetIP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - TargetPort = (ushort)((bytes[i++] << 8) + bytes[i++]); + { + TargetIP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + TargetPort = (ushort)((bytes[i++] << 8) + bytes[i++]); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(TargetIP % 256); - bytes[i++] = (byte)((TargetIP >> 8) % 256); - bytes[i++] = (byte)((TargetIP >> 16) % 256); - bytes[i++] = (byte)((TargetIP >> 24) % 256); - bytes[i++] = (byte)((TargetPort >> 8) % 256); - bytes[i++] = (byte)(TargetPort % 256); + { + bytes[i++] = (byte)(TargetIP % 256); + bytes[i++] = (byte)((TargetIP >> 8) % 256); + bytes[i++] = (byte)((TargetIP >> 16) % 256); + bytes[i++] = (byte)((TargetIP >> 24) % 256); + bytes[i++] = (byte)((TargetPort >> 8) % 256); + bytes[i++] = (byte)(TargetPort % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- TargetBlock --\n"; - output += "TargetIP: " + TargetIP.ToString() + "\n"; - output += "TargetPort: " + TargetPort.ToString() + "\n"; + { + string output = "-- TargetBlock --\n"; + output += "TargetIP: " + TargetIP.ToString() + "\n"; + output += "TargetPort: " + TargetPort.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// GranterBlock block + + /// GranterBlock block public class GranterBlockBlock - { - /// GranterID field - public LLUUID GranterID; - - /// Length of this block serialized in bytes + { + /// GranterID field + public LLUUID GranterID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public GranterBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public GranterBlockBlock() { } + /// Constructor for building the block from a byte array public GranterBlockBlock(byte[] bytes, ref int i) - { + { try - { - GranterID = new LLUUID(bytes, i); i += 16; + { + GranterID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(GranterID == null) { Console.WriteLine("Warning: GranterID is null, in " + this.GetType()); } - Array.Copy(GranterID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(GranterID == null) { Console.WriteLine("Warning: GranterID is null, in " + this.GetType()); } + Array.Copy(GranterID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- GranterBlock --\n"; - output += "GranterID: " + GranterID.ToString() + "\n"; + { + string output = "-- GranterBlock --\n"; + output += "GranterID: " + GranterID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentBlock block + + /// AgentBlock block public class AgentBlockBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentBlockBlock() { } + /// Constructor for building the block from a byte array public AgentBlockBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentBlock --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentBlock --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AddModifyAbility - public override PacketType Type { get { return PacketType.AddModifyAbility; } } - /// TargetBlock block - public TargetBlockBlock TargetBlock; - /// GranterBlock block - public GranterBlockBlock[] GranterBlock; - /// AgentBlock block - public AgentBlockBlock AgentBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AddModifyAbility + public override PacketType Type { get { return PacketType.AddModifyAbility; } } + /// TargetBlock block + public TargetBlockBlock TargetBlock; + /// GranterBlock block + public GranterBlockBlock[] GranterBlock; + /// AgentBlock block + public AgentBlockBlock AgentBlock; + + /// Default constructor public AddModifyAbilityPacket() - { - Header = new LowHeader(); - Header.ID = 170; - Header.Reliable = true; - Header.Zerocoded = true; - TargetBlock = new TargetBlockBlock(); - GranterBlock = new GranterBlockBlock[0]; - AgentBlock = new AgentBlockBlock(); + { + Header = new LowHeader(); + Header.ID = 170; + Header.Reliable = true; + Header.Zerocoded = true; + TargetBlock = new TargetBlockBlock(); + GranterBlock = new GranterBlockBlock[0]; + AgentBlock = new AgentBlockBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AddModifyAbilityPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - TargetBlock = new TargetBlockBlock(bytes, ref i); - int count = (int)bytes[i++]; - GranterBlock = new GranterBlockBlock[count]; - for (int j = 0; j < count; j++) - { GranterBlock[j] = new GranterBlockBlock(bytes, ref i); } - AgentBlock = new AgentBlockBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + TargetBlock = new TargetBlockBlock(bytes, ref i); + int count = (int)bytes[i++]; + GranterBlock = new GranterBlockBlock[count]; + for (int j = 0; j < count; j++) + { GranterBlock[j] = new GranterBlockBlock(bytes, ref i); } + AgentBlock = new AgentBlockBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AddModifyAbilityPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - TargetBlock = new TargetBlockBlock(bytes, ref i); - int count = (int)bytes[i++]; - GranterBlock = new GranterBlockBlock[count]; - for (int j = 0; j < count; j++) - { GranterBlock[j] = new GranterBlockBlock(bytes, ref i); } - AgentBlock = new AgentBlockBlock(bytes, ref i); + { + Header = head; + TargetBlock = new TargetBlockBlock(bytes, ref i); + int count = (int)bytes[i++]; + GranterBlock = new GranterBlockBlock[count]; + for (int j = 0; j < count; j++) + { GranterBlock[j] = new GranterBlockBlock(bytes, ref i); } + AgentBlock = new AgentBlockBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += TargetBlock.Length; length += AgentBlock.Length;; - length++; - for (int j = 0; j < GranterBlock.Length; j++) { length += GranterBlock[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - TargetBlock.ToBytes(bytes, ref i); - bytes[i++] = (byte)GranterBlock.Length; - for (int j = 0; j < GranterBlock.Length; j++) { GranterBlock[j].ToBytes(bytes, ref i); } - AgentBlock.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += TargetBlock.Length; length += AgentBlock.Length;; + length++; + for (int j = 0; j < GranterBlock.Length; j++) { length += GranterBlock[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + TargetBlock.ToBytes(bytes, ref i); + bytes[i++] = (byte)GranterBlock.Length; + for (int j = 0; j < GranterBlock.Length; j++) { GranterBlock[j].ToBytes(bytes, ref i); } + AgentBlock.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AddModifyAbility ---\n"; - output += TargetBlock.ToString() + "\n"; + { + string output = "--- AddModifyAbility ---\n"; + output += TargetBlock.ToString() + "\n"; for (int j = 0; j < GranterBlock.Length; j++) - { + { output += GranterBlock[j].ToString() + "\n"; - } - output += AgentBlock.ToString() + "\n"; + } + output += AgentBlock.ToString() + "\n"; return output; } - + } - - /// RemoveModifyAbility packet + + /// RemoveModifyAbility packet public class RemoveModifyAbilityPacket : Packet - { - /// TargetBlock block + { + /// TargetBlock block public class TargetBlockBlock - { - /// TargetIP field - public uint TargetIP; - /// TargetPort field - public ushort TargetPort; - - /// Length of this block serialized in bytes + { + /// TargetIP field + public uint TargetIP; + /// TargetPort field + public ushort TargetPort; + + /// Length of this block serialized in bytes public int Length { get - { - return 6; + { + return 6; } } - - /// Default constructor - public TargetBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public TargetBlockBlock() { } + /// Constructor for building the block from a byte array public TargetBlockBlock(byte[] bytes, ref int i) - { + { try - { - TargetIP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - TargetPort = (ushort)((bytes[i++] << 8) + bytes[i++]); + { + TargetIP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + TargetPort = (ushort)((bytes[i++] << 8) + bytes[i++]); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(TargetIP % 256); - bytes[i++] = (byte)((TargetIP >> 8) % 256); - bytes[i++] = (byte)((TargetIP >> 16) % 256); - bytes[i++] = (byte)((TargetIP >> 24) % 256); - bytes[i++] = (byte)((TargetPort >> 8) % 256); - bytes[i++] = (byte)(TargetPort % 256); + { + bytes[i++] = (byte)(TargetIP % 256); + bytes[i++] = (byte)((TargetIP >> 8) % 256); + bytes[i++] = (byte)((TargetIP >> 16) % 256); + bytes[i++] = (byte)((TargetIP >> 24) % 256); + bytes[i++] = (byte)((TargetPort >> 8) % 256); + bytes[i++] = (byte)(TargetPort % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- TargetBlock --\n"; - output += "TargetIP: " + TargetIP.ToString() + "\n"; - output += "TargetPort: " + TargetPort.ToString() + "\n"; + { + string output = "-- TargetBlock --\n"; + output += "TargetIP: " + TargetIP.ToString() + "\n"; + output += "TargetPort: " + TargetPort.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentBlock block + + /// AgentBlock block public class AgentBlockBlock - { - /// AgentID field - public LLUUID AgentID; - /// RevokerID field - public LLUUID RevokerID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// RevokerID field + public LLUUID RevokerID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentBlockBlock() { } + /// Constructor for building the block from a byte array public AgentBlockBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - RevokerID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + RevokerID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(RevokerID == null) { Console.WriteLine("Warning: RevokerID is null, in " + this.GetType()); } - Array.Copy(RevokerID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(RevokerID == null) { Console.WriteLine("Warning: RevokerID is null, in " + this.GetType()); } + Array.Copy(RevokerID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentBlock --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "RevokerID: " + RevokerID.ToString() + "\n"; + { + string output = "-- AgentBlock --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "RevokerID: " + RevokerID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.RemoveModifyAbility - public override PacketType Type { get { return PacketType.RemoveModifyAbility; } } - /// TargetBlock block - public TargetBlockBlock TargetBlock; - /// AgentBlock block - public AgentBlockBlock AgentBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.RemoveModifyAbility + public override PacketType Type { get { return PacketType.RemoveModifyAbility; } } + /// TargetBlock block + public TargetBlockBlock TargetBlock; + /// AgentBlock block + public AgentBlockBlock AgentBlock; + + /// Default constructor public RemoveModifyAbilityPacket() - { - Header = new LowHeader(); - Header.ID = 171; - Header.Reliable = true; - TargetBlock = new TargetBlockBlock(); - AgentBlock = new AgentBlockBlock(); + { + Header = new LowHeader(); + Header.ID = 171; + Header.Reliable = true; + TargetBlock = new TargetBlockBlock(); + AgentBlock = new AgentBlockBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public RemoveModifyAbilityPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - TargetBlock = new TargetBlockBlock(bytes, ref i); - AgentBlock = new AgentBlockBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + TargetBlock = new TargetBlockBlock(bytes, ref i); + AgentBlock = new AgentBlockBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public RemoveModifyAbilityPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - TargetBlock = new TargetBlockBlock(bytes, ref i); - AgentBlock = new AgentBlockBlock(bytes, ref i); + { + Header = head; + TargetBlock = new TargetBlockBlock(bytes, ref i); + AgentBlock = new AgentBlockBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += TargetBlock.Length; length += AgentBlock.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - TargetBlock.ToBytes(bytes, ref i); - AgentBlock.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += TargetBlock.Length; length += AgentBlock.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + TargetBlock.ToBytes(bytes, ref i); + AgentBlock.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- RemoveModifyAbility ---\n"; - output += TargetBlock.ToString() + "\n"; - output += AgentBlock.ToString() + "\n"; + { + string output = "--- RemoveModifyAbility ---\n"; + output += TargetBlock.ToString() + "\n"; + output += AgentBlock.ToString() + "\n"; return output; } - + } - - /// ViewerStats packet + + /// ViewerStats packet public class ViewerStatsPacket : Packet - { - /// DownloadTotals block + { + /// DownloadTotals block public class DownloadTotalsBlock - { - /// Objects field - public uint Objects; - /// Textures field - public uint Textures; - /// World field - public uint World; - - /// Length of this block serialized in bytes + { + /// Objects field + public uint Objects; + /// Textures field + public uint Textures; + /// World field + public uint World; + + /// Length of this block serialized in bytes public int Length { get - { - return 12; + { + return 12; } } - - /// Default constructor - public DownloadTotalsBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DownloadTotalsBlock() { } + /// Constructor for building the block from a byte array public DownloadTotalsBlock(byte[] bytes, ref int i) - { + { try - { - Objects = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Textures = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - World = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + Objects = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Textures = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + World = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(Objects % 256); - bytes[i++] = (byte)((Objects >> 8) % 256); - bytes[i++] = (byte)((Objects >> 16) % 256); - bytes[i++] = (byte)((Objects >> 24) % 256); - bytes[i++] = (byte)(Textures % 256); - bytes[i++] = (byte)((Textures >> 8) % 256); - bytes[i++] = (byte)((Textures >> 16) % 256); - bytes[i++] = (byte)((Textures >> 24) % 256); - bytes[i++] = (byte)(World % 256); - bytes[i++] = (byte)((World >> 8) % 256); - bytes[i++] = (byte)((World >> 16) % 256); - bytes[i++] = (byte)((World >> 24) % 256); + { + bytes[i++] = (byte)(Objects % 256); + bytes[i++] = (byte)((Objects >> 8) % 256); + bytes[i++] = (byte)((Objects >> 16) % 256); + bytes[i++] = (byte)((Objects >> 24) % 256); + bytes[i++] = (byte)(Textures % 256); + bytes[i++] = (byte)((Textures >> 8) % 256); + bytes[i++] = (byte)((Textures >> 16) % 256); + bytes[i++] = (byte)((Textures >> 24) % 256); + bytes[i++] = (byte)(World % 256); + bytes[i++] = (byte)((World >> 8) % 256); + bytes[i++] = (byte)((World >> 16) % 256); + bytes[i++] = (byte)((World >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- DownloadTotals --\n"; - output += "Objects: " + Objects.ToString() + "\n"; - output += "Textures: " + Textures.ToString() + "\n"; - output += "World: " + World.ToString() + "\n"; + { + string output = "-- DownloadTotals --\n"; + output += "Objects: " + Objects.ToString() + "\n"; + output += "Textures: " + Textures.ToString() + "\n"; + output += "World: " + World.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// MiscStats block + + /// MiscStats block public class MiscStatsBlock - { - /// Type field - public uint Type; - /// Value field - public double Value; - - /// Length of this block serialized in bytes + { + /// Type field + public uint Type; + /// Value field + public double Value; + + /// Length of this block serialized in bytes public int Length { get - { - return 12; + { + return 12; } } - - /// Default constructor - public MiscStatsBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public MiscStatsBlock() { } + /// Constructor for building the block from a byte array public MiscStatsBlock(byte[] bytes, ref int i) - { + { try - { - Type = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 8); - Value = BitConverter.ToDouble(bytes, i); i += 8; + { + Type = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 8); + Value = BitConverter.ToDouble(bytes, i); i += 8; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; - bytes[i++] = (byte)(Type % 256); - bytes[i++] = (byte)((Type >> 8) % 256); - bytes[i++] = (byte)((Type >> 16) % 256); - bytes[i++] = (byte)((Type >> 24) % 256); + { + byte[] ba; + bytes[i++] = (byte)(Type % 256); + bytes[i++] = (byte)((Type >> 8) % 256); + bytes[i++] = (byte)((Type >> 16) % 256); + bytes[i++] = (byte)((Type >> 24) % 256); ba = BitConverter.GetBytes(Value); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 8); } - Array.Copy(ba, 0, bytes, i, 8); i += 8; + Array.Copy(ba, 0, bytes, i, 8); i += 8; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- MiscStats --\n"; - output += "Type: " + Type.ToString() + "\n"; - output += "Value: " + Value.ToString() + "\n"; + { + string output = "-- MiscStats --\n"; + output += "Type: " + Type.ToString() + "\n"; + output += "Value: " + Value.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// NetStats block + + /// NetStats block public class NetStatsBlock - { - /// Packets field - public uint Packets; - /// Savings field - public uint Savings; - /// Compressed field - public uint Compressed; - /// Bytes field - public uint Bytes; - - /// Length of this block serialized in bytes + { + /// Packets field + public uint Packets; + /// Savings field + public uint Savings; + /// Compressed field + public uint Compressed; + /// Bytes field + public uint Bytes; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public NetStatsBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public NetStatsBlock() { } + /// Constructor for building the block from a byte array public NetStatsBlock(byte[] bytes, ref int i) - { + { try - { - Packets = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Savings = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Compressed = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Bytes = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + Packets = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Savings = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Compressed = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Bytes = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(Packets % 256); - bytes[i++] = (byte)((Packets >> 8) % 256); - bytes[i++] = (byte)((Packets >> 16) % 256); - bytes[i++] = (byte)((Packets >> 24) % 256); - bytes[i++] = (byte)(Savings % 256); - bytes[i++] = (byte)((Savings >> 8) % 256); - bytes[i++] = (byte)((Savings >> 16) % 256); - bytes[i++] = (byte)((Savings >> 24) % 256); - bytes[i++] = (byte)(Compressed % 256); - bytes[i++] = (byte)((Compressed >> 8) % 256); - bytes[i++] = (byte)((Compressed >> 16) % 256); - bytes[i++] = (byte)((Compressed >> 24) % 256); - bytes[i++] = (byte)(Bytes % 256); - bytes[i++] = (byte)((Bytes >> 8) % 256); - bytes[i++] = (byte)((Bytes >> 16) % 256); - bytes[i++] = (byte)((Bytes >> 24) % 256); + { + bytes[i++] = (byte)(Packets % 256); + bytes[i++] = (byte)((Packets >> 8) % 256); + bytes[i++] = (byte)((Packets >> 16) % 256); + bytes[i++] = (byte)((Packets >> 24) % 256); + bytes[i++] = (byte)(Savings % 256); + bytes[i++] = (byte)((Savings >> 8) % 256); + bytes[i++] = (byte)((Savings >> 16) % 256); + bytes[i++] = (byte)((Savings >> 24) % 256); + bytes[i++] = (byte)(Compressed % 256); + bytes[i++] = (byte)((Compressed >> 8) % 256); + bytes[i++] = (byte)((Compressed >> 16) % 256); + bytes[i++] = (byte)((Compressed >> 24) % 256); + bytes[i++] = (byte)(Bytes % 256); + bytes[i++] = (byte)((Bytes >> 8) % 256); + bytes[i++] = (byte)((Bytes >> 16) % 256); + bytes[i++] = (byte)((Bytes >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- NetStats --\n"; - output += "Packets: " + Packets.ToString() + "\n"; - output += "Savings: " + Savings.ToString() + "\n"; - output += "Compressed: " + Compressed.ToString() + "\n"; - output += "Bytes: " + Bytes.ToString() + "\n"; + { + string output = "-- NetStats --\n"; + output += "Packets: " + Packets.ToString() + "\n"; + output += "Savings: " + Savings.ToString() + "\n"; + output += "Compressed: " + Compressed.ToString() + "\n"; + output += "Bytes: " + Bytes.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// FailStats block + + /// FailStats block public class FailStatsBlock - { - /// FailedResends field - public uint FailedResends; - /// Invalid field - public uint Invalid; - /// SendPacket field - public uint SendPacket; - /// Dropped field - public uint Dropped; - /// OffCircuit field - public uint OffCircuit; - /// Resent field - public uint Resent; - - /// Length of this block serialized in bytes + { + /// FailedResends field + public uint FailedResends; + /// Invalid field + public uint Invalid; + /// SendPacket field + public uint SendPacket; + /// Dropped field + public uint Dropped; + /// OffCircuit field + public uint OffCircuit; + /// Resent field + public uint Resent; + + /// Length of this block serialized in bytes public int Length { get - { - return 24; + { + return 24; } } - - /// Default constructor - public FailStatsBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public FailStatsBlock() { } + /// Constructor for building the block from a byte array public FailStatsBlock(byte[] bytes, ref int i) - { + { try - { - FailedResends = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Invalid = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - SendPacket = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Dropped = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - OffCircuit = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Resent = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + FailedResends = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Invalid = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + SendPacket = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Dropped = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + OffCircuit = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Resent = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(FailedResends % 256); - bytes[i++] = (byte)((FailedResends >> 8) % 256); - bytes[i++] = (byte)((FailedResends >> 16) % 256); - bytes[i++] = (byte)((FailedResends >> 24) % 256); - bytes[i++] = (byte)(Invalid % 256); - bytes[i++] = (byte)((Invalid >> 8) % 256); - bytes[i++] = (byte)((Invalid >> 16) % 256); - bytes[i++] = (byte)((Invalid >> 24) % 256); - bytes[i++] = (byte)(SendPacket % 256); - bytes[i++] = (byte)((SendPacket >> 8) % 256); - bytes[i++] = (byte)((SendPacket >> 16) % 256); - bytes[i++] = (byte)((SendPacket >> 24) % 256); - bytes[i++] = (byte)(Dropped % 256); - bytes[i++] = (byte)((Dropped >> 8) % 256); - bytes[i++] = (byte)((Dropped >> 16) % 256); - bytes[i++] = (byte)((Dropped >> 24) % 256); - bytes[i++] = (byte)(OffCircuit % 256); - bytes[i++] = (byte)((OffCircuit >> 8) % 256); - bytes[i++] = (byte)((OffCircuit >> 16) % 256); - bytes[i++] = (byte)((OffCircuit >> 24) % 256); - bytes[i++] = (byte)(Resent % 256); - bytes[i++] = (byte)((Resent >> 8) % 256); - bytes[i++] = (byte)((Resent >> 16) % 256); - bytes[i++] = (byte)((Resent >> 24) % 256); + { + bytes[i++] = (byte)(FailedResends % 256); + bytes[i++] = (byte)((FailedResends >> 8) % 256); + bytes[i++] = (byte)((FailedResends >> 16) % 256); + bytes[i++] = (byte)((FailedResends >> 24) % 256); + bytes[i++] = (byte)(Invalid % 256); + bytes[i++] = (byte)((Invalid >> 8) % 256); + bytes[i++] = (byte)((Invalid >> 16) % 256); + bytes[i++] = (byte)((Invalid >> 24) % 256); + bytes[i++] = (byte)(SendPacket % 256); + bytes[i++] = (byte)((SendPacket >> 8) % 256); + bytes[i++] = (byte)((SendPacket >> 16) % 256); + bytes[i++] = (byte)((SendPacket >> 24) % 256); + bytes[i++] = (byte)(Dropped % 256); + bytes[i++] = (byte)((Dropped >> 8) % 256); + bytes[i++] = (byte)((Dropped >> 16) % 256); + bytes[i++] = (byte)((Dropped >> 24) % 256); + bytes[i++] = (byte)(OffCircuit % 256); + bytes[i++] = (byte)((OffCircuit >> 8) % 256); + bytes[i++] = (byte)((OffCircuit >> 16) % 256); + bytes[i++] = (byte)((OffCircuit >> 24) % 256); + bytes[i++] = (byte)(Resent % 256); + bytes[i++] = (byte)((Resent >> 8) % 256); + bytes[i++] = (byte)((Resent >> 16) % 256); + bytes[i++] = (byte)((Resent >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- FailStats --\n"; - output += "FailedResends: " + FailedResends.ToString() + "\n"; - output += "Invalid: " + Invalid.ToString() + "\n"; - output += "SendPacket: " + SendPacket.ToString() + "\n"; - output += "Dropped: " + Dropped.ToString() + "\n"; - output += "OffCircuit: " + OffCircuit.ToString() + "\n"; - output += "Resent: " + Resent.ToString() + "\n"; + { + string output = "-- FailStats --\n"; + output += "FailedResends: " + FailedResends.ToString() + "\n"; + output += "Invalid: " + Invalid.ToString() + "\n"; + output += "SendPacket: " + SendPacket.ToString() + "\n"; + output += "Dropped: " + Dropped.ToString() + "\n"; + output += "OffCircuit: " + OffCircuit.ToString() + "\n"; + output += "Resent: " + Resent.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// IP field - public uint IP; - /// FPS field - public float FPS; - /// AgentID field - public LLUUID AgentID; - /// RegionsVisited field - public int RegionsVisited; - /// SessionID field - public LLUUID SessionID; - /// Ping field - public float Ping; - /// RunTime field - public float RunTime; - /// MetersTraveled field - public double MetersTraveled; - private byte[] _syscpu; - /// SysCPU field + { + /// IP field + public uint IP; + /// FPS field + public float FPS; + /// AgentID field + public LLUUID AgentID; + /// RegionsVisited field + public int RegionsVisited; + /// SessionID field + public LLUUID SessionID; + /// Ping field + public float Ping; + /// RunTime field + public float RunTime; + /// MetersTraveled field + public double MetersTraveled; + private byte[] _syscpu; + /// SysCPU field public byte[] SysCPU - { - get { return _syscpu; } + { + get { return _syscpu; } set - { - if (value == null) { _syscpu = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _syscpu = new byte[value.Length]; Array.Copy(value, _syscpu, value.Length); } + { + if (value == null) { _syscpu = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _syscpu = new byte[value.Length]; Array.Copy(value, _syscpu, value.Length); } } - } - private byte[] _sysgpu; - /// SysGPU field + } + private byte[] _sysgpu; + /// SysGPU field public byte[] SysGPU - { - get { return _sysgpu; } + { + get { return _sysgpu; } set - { - if (value == null) { _sysgpu = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _sysgpu = new byte[value.Length]; Array.Copy(value, _sysgpu, value.Length); } + { + if (value == null) { _sysgpu = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _sysgpu = new byte[value.Length]; Array.Copy(value, _sysgpu, value.Length); } } - } - /// SysRAM field - public uint SysRAM; - /// StartTime field - public uint StartTime; - private byte[] _sysos; - /// SysOS field + } + /// SysRAM field + public uint SysRAM; + /// StartTime field + public uint StartTime; + private byte[] _sysos; + /// SysOS field public byte[] SysOS - { - get { return _sysos; } + { + get { return _sysos; } set - { - if (value == null) { _sysos = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _sysos = new byte[value.Length]; Array.Copy(value, _sysos, value.Length); } + { + if (value == null) { _sysos = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _sysos = new byte[value.Length]; Array.Copy(value, _sysos, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 68; - if (SysCPU != null) { length += 1 + SysCPU.Length; } - if (SysGPU != null) { length += 1 + SysGPU.Length; } - if (SysOS != null) { length += 1 + SysOS.Length; } - return length; + { + int length = 68; + if (SysCPU != null) { length += 1 + SysCPU.Length; } + if (SysGPU != null) { length += 1 + SysGPU.Length; } + if (SysOS != null) { length += 1 + SysOS.Length; } + return length; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - IP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - FPS = BitConverter.ToSingle(bytes, i); i += 4; - AgentID = new LLUUID(bytes, i); i += 16; - RegionsVisited = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - SessionID = new LLUUID(bytes, i); i += 16; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - Ping = BitConverter.ToSingle(bytes, i); i += 4; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - RunTime = BitConverter.ToSingle(bytes, i); i += 4; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 8); - MetersTraveled = BitConverter.ToDouble(bytes, i); i += 8; - length = (ushort)bytes[i++]; - _syscpu = new byte[length]; - Array.Copy(bytes, i, _syscpu, 0, length); i += length; - length = (ushort)bytes[i++]; - _sysgpu = new byte[length]; - Array.Copy(bytes, i, _sysgpu, 0, length); i += length; - SysRAM = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - StartTime = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _sysos = new byte[length]; - Array.Copy(bytes, i, _sysos, 0, length); i += length; + { + IP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + FPS = BitConverter.ToSingle(bytes, i); i += 4; + AgentID = new LLUUID(bytes, i); i += 16; + RegionsVisited = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + SessionID = new LLUUID(bytes, i); i += 16; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + Ping = BitConverter.ToSingle(bytes, i); i += 4; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + RunTime = BitConverter.ToSingle(bytes, i); i += 4; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 8); + MetersTraveled = BitConverter.ToDouble(bytes, i); i += 8; + length = (ushort)bytes[i++]; + _syscpu = new byte[length]; + Array.Copy(bytes, i, _syscpu, 0, length); i += length; + length = (ushort)bytes[i++]; + _sysgpu = new byte[length]; + Array.Copy(bytes, i, _sysgpu, 0, length); i += length; + SysRAM = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + StartTime = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _sysos = new byte[length]; + Array.Copy(bytes, i, _sysos, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; - bytes[i++] = (byte)(IP % 256); - bytes[i++] = (byte)((IP >> 8) % 256); - bytes[i++] = (byte)((IP >> 16) % 256); - bytes[i++] = (byte)((IP >> 24) % 256); + { + byte[] ba; + bytes[i++] = (byte)(IP % 256); + bytes[i++] = (byte)((IP >> 8) % 256); + bytes[i++] = (byte)((IP >> 16) % 256); + bytes[i++] = (byte)((IP >> 24) % 256); ba = BitConverter.GetBytes(FPS); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(RegionsVisited % 256); - bytes[i++] = (byte)((RegionsVisited >> 8) % 256); - bytes[i++] = (byte)((RegionsVisited >> 16) % 256); - bytes[i++] = (byte)((RegionsVisited >> 24) % 256); - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + Array.Copy(ba, 0, bytes, i, 4); i += 4; + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(RegionsVisited % 256); + bytes[i++] = (byte)((RegionsVisited >> 8) % 256); + bytes[i++] = (byte)((RegionsVisited >> 16) % 256); + bytes[i++] = (byte)((RegionsVisited >> 24) % 256); + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; ba = BitConverter.GetBytes(Ping); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; ba = BitConverter.GetBytes(RunTime); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; ba = BitConverter.GetBytes(MetersTraveled); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 8); } - Array.Copy(ba, 0, bytes, i, 8); i += 8; - if(SysCPU == null) { Console.WriteLine("Warning: SysCPU is null, in " + this.GetType()); } - bytes[i++] = (byte)SysCPU.Length; - Array.Copy(SysCPU, 0, bytes, i, SysCPU.Length); i += SysCPU.Length; - if(SysGPU == null) { Console.WriteLine("Warning: SysGPU is null, in " + this.GetType()); } - bytes[i++] = (byte)SysGPU.Length; - Array.Copy(SysGPU, 0, bytes, i, SysGPU.Length); i += SysGPU.Length; - bytes[i++] = (byte)(SysRAM % 256); - bytes[i++] = (byte)((SysRAM >> 8) % 256); - bytes[i++] = (byte)((SysRAM >> 16) % 256); - bytes[i++] = (byte)((SysRAM >> 24) % 256); - bytes[i++] = (byte)(StartTime % 256); - bytes[i++] = (byte)((StartTime >> 8) % 256); - bytes[i++] = (byte)((StartTime >> 16) % 256); - bytes[i++] = (byte)((StartTime >> 24) % 256); - if(SysOS == null) { Console.WriteLine("Warning: SysOS is null, in " + this.GetType()); } - bytes[i++] = (byte)SysOS.Length; - Array.Copy(SysOS, 0, bytes, i, SysOS.Length); i += SysOS.Length; + Array.Copy(ba, 0, bytes, i, 8); i += 8; + if(SysCPU == null) { Console.WriteLine("Warning: SysCPU is null, in " + this.GetType()); } + bytes[i++] = (byte)SysCPU.Length; + Array.Copy(SysCPU, 0, bytes, i, SysCPU.Length); i += SysCPU.Length; + if(SysGPU == null) { Console.WriteLine("Warning: SysGPU is null, in " + this.GetType()); } + bytes[i++] = (byte)SysGPU.Length; + Array.Copy(SysGPU, 0, bytes, i, SysGPU.Length); i += SysGPU.Length; + bytes[i++] = (byte)(SysRAM % 256); + bytes[i++] = (byte)((SysRAM >> 8) % 256); + bytes[i++] = (byte)((SysRAM >> 16) % 256); + bytes[i++] = (byte)((SysRAM >> 24) % 256); + bytes[i++] = (byte)(StartTime % 256); + bytes[i++] = (byte)((StartTime >> 8) % 256); + bytes[i++] = (byte)((StartTime >> 16) % 256); + bytes[i++] = (byte)((StartTime >> 24) % 256); + if(SysOS == null) { Console.WriteLine("Warning: SysOS is null, in " + this.GetType()); } + bytes[i++] = (byte)SysOS.Length; + Array.Copy(SysOS, 0, bytes, i, SysOS.Length); i += SysOS.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "IP: " + IP.ToString() + "\n"; - output += "FPS: " + FPS.ToString() + "\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "RegionsVisited: " + RegionsVisited.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "Ping: " + Ping.ToString() + "\n"; - output += "RunTime: " + RunTime.ToString() + "\n"; - output += "MetersTraveled: " + MetersTraveled.ToString() + "\n"; - output += Helpers.FieldToString(SysCPU, "SysCPU") + "\n"; - output += Helpers.FieldToString(SysGPU, "SysGPU") + "\n"; - output += "SysRAM: " + SysRAM.ToString() + "\n"; - output += "StartTime: " + StartTime.ToString() + "\n"; - output += Helpers.FieldToString(SysOS, "SysOS") + "\n"; + { + string output = "-- AgentData --\n"; + output += "IP: " + IP.ToString() + "\n"; + output += "FPS: " + FPS.ToString() + "\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "RegionsVisited: " + RegionsVisited.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "Ping: " + Ping.ToString() + "\n"; + output += "RunTime: " + RunTime.ToString() + "\n"; + output += "MetersTraveled: " + MetersTraveled.ToString() + "\n"; + output += Helpers.FieldToString(SysCPU, "SysCPU") + "\n"; + output += Helpers.FieldToString(SysGPU, "SysGPU") + "\n"; + output += "SysRAM: " + SysRAM.ToString() + "\n"; + output += "StartTime: " + StartTime.ToString() + "\n"; + output += Helpers.FieldToString(SysOS, "SysOS") + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ViewerStats - public override PacketType Type { get { return PacketType.ViewerStats; } } - /// DownloadTotals block - public DownloadTotalsBlock DownloadTotals; - /// MiscStats block - public MiscStatsBlock[] MiscStats; - /// NetStats block - public NetStatsBlock[] NetStats; - /// FailStats block - public FailStatsBlock FailStats; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ViewerStats + public override PacketType Type { get { return PacketType.ViewerStats; } } + /// DownloadTotals block + public DownloadTotalsBlock DownloadTotals; + /// MiscStats block + public MiscStatsBlock[] MiscStats; + /// NetStats block + public NetStatsBlock[] NetStats; + /// FailStats block + public FailStatsBlock FailStats; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ViewerStatsPacket() - { - Header = new LowHeader(); - Header.ID = 172; - Header.Reliable = true; - Header.Zerocoded = true; - DownloadTotals = new DownloadTotalsBlock(); - MiscStats = new MiscStatsBlock[0]; - NetStats = new NetStatsBlock[2]; - FailStats = new FailStatsBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 172; + Header.Reliable = true; + Header.Zerocoded = true; + DownloadTotals = new DownloadTotalsBlock(); + MiscStats = new MiscStatsBlock[0]; + NetStats = new NetStatsBlock[2]; + FailStats = new FailStatsBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ViewerStatsPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - DownloadTotals = new DownloadTotalsBlock(bytes, ref i); - int count = (int)bytes[i++]; - MiscStats = new MiscStatsBlock[count]; - for (int j = 0; j < count; j++) - { MiscStats[j] = new MiscStatsBlock(bytes, ref i); } - NetStats = new NetStatsBlock[2]; - for (int j = 0; j < 2; j++) - { NetStats[j] = new NetStatsBlock(bytes, ref i); } - FailStats = new FailStatsBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); - } - - /// Constructor that takes a byte array and a prebuilt header - public ViewerStatsPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - DownloadTotals = new DownloadTotalsBlock(bytes, ref i); - int count = (int)bytes[i++]; - MiscStats = new MiscStatsBlock[count]; - for (int j = 0; j < count; j++) - { MiscStats[j] = new MiscStatsBlock(bytes, ref i); } - NetStats = new NetStatsBlock[2]; - for (int j = 0; j < 2; j++) - { NetStats[j] = new NetStatsBlock(bytes, ref i); } - FailStats = new FailStatsBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); - } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet - public override byte[] ToBytes() - { - int length = 8; - length += DownloadTotals.Length; length += FailStats.Length; length += AgentData.Length;; - length++; - for (int j = 0; j < MiscStats.Length; j++) { length += MiscStats[j].Length; } - for (int j = 0; j < 2; j++) { length += NetStats[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - DownloadTotals.ToBytes(bytes, ref i); - bytes[i++] = (byte)MiscStats.Length; - for (int j = 0; j < MiscStats.Length; j++) { MiscStats[j].ToBytes(bytes, ref i); } - for (int j = 0; j < 2; j++) { NetStats[j].ToBytes(bytes, ref i); } - FailStats.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } - return bytes; - } - - /// Serialize this packet to a stringA string containing the serialized packet - public override string ToString() - { - string output = "--- ViewerStats ---\n"; - output += DownloadTotals.ToString() + "\n"; - for (int j = 0; j < MiscStats.Length; j++) - { - output += MiscStats[j].ToString() + "\n"; - } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + DownloadTotals = new DownloadTotalsBlock(bytes, ref i); + int count = (int)bytes[i++]; + MiscStats = new MiscStatsBlock[count]; + for (int j = 0; j < count; j++) + { MiscStats[j] = new MiscStatsBlock(bytes, ref i); } + NetStats = new NetStatsBlock[2]; for (int j = 0; j < 2; j++) - { + { NetStats[j] = new NetStatsBlock(bytes, ref i); } + FailStats = new FailStatsBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); + } + + /// Constructor that takes a byte array and a prebuilt header + public ViewerStatsPacket(Header head, byte[] bytes, ref int i) + { + Header = head; + DownloadTotals = new DownloadTotalsBlock(bytes, ref i); + int count = (int)bytes[i++]; + MiscStats = new MiscStatsBlock[count]; + for (int j = 0; j < count; j++) + { MiscStats[j] = new MiscStatsBlock(bytes, ref i); } + NetStats = new NetStatsBlock[2]; + for (int j = 0; j < 2; j++) + { NetStats[j] = new NetStatsBlock(bytes, ref i); } + FailStats = new FailStatsBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); + } + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet + public override byte[] ToBytes() + { + int length = 8; + length += DownloadTotals.Length; length += FailStats.Length; length += AgentData.Length;; + length++; + for (int j = 0; j < MiscStats.Length; j++) { length += MiscStats[j].Length; } + for (int j = 0; j < 2; j++) { length += NetStats[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + DownloadTotals.ToBytes(bytes, ref i); + bytes[i++] = (byte)MiscStats.Length; + for (int j = 0; j < MiscStats.Length; j++) { MiscStats[j].ToBytes(bytes, ref i); } + for (int j = 0; j < 2; j++) { NetStats[j].ToBytes(bytes, ref i); } + FailStats.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + return bytes; + } + + /// Serialize this packet to a stringA string containing the serialized packet + public override string ToString() + { + string output = "--- ViewerStats ---\n"; + output += DownloadTotals.ToString() + "\n"; + for (int j = 0; j < MiscStats.Length; j++) + { + output += MiscStats[j].ToString() + "\n"; + } + for (int j = 0; j < 2; j++) + { output += NetStats[j].ToString() + "\n"; - } - output += FailStats.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + } + output += FailStats.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ScriptAnswerYes packet + + /// ScriptAnswerYes packet public class ScriptAnswerYesPacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - /// TaskID field - public LLUUID TaskID; - /// ItemID field - public LLUUID ItemID; - /// Questions field - public int Questions; - - /// Length of this block serialized in bytes + { + /// TaskID field + public LLUUID TaskID; + /// ItemID field + public LLUUID ItemID; + /// Questions field + public int Questions; + + /// Length of this block serialized in bytes public int Length { get - { - return 36; + { + return 36; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { + { try - { - TaskID = new LLUUID(bytes, i); i += 16; - ItemID = new LLUUID(bytes, i); i += 16; - Questions = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + TaskID = new LLUUID(bytes, i); i += 16; + ItemID = new LLUUID(bytes, i); i += 16; + Questions = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(TaskID == null) { Console.WriteLine("Warning: TaskID is null, in " + this.GetType()); } - Array.Copy(TaskID.GetBytes(), 0, bytes, i, 16); i += 16; - if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } - Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(Questions % 256); - bytes[i++] = (byte)((Questions >> 8) % 256); - bytes[i++] = (byte)((Questions >> 16) % 256); - bytes[i++] = (byte)((Questions >> 24) % 256); + { + if(TaskID == null) { Console.WriteLine("Warning: TaskID is null, in " + this.GetType()); } + Array.Copy(TaskID.GetBytes(), 0, bytes, i, 16); i += 16; + if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } + Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(Questions % 256); + bytes[i++] = (byte)((Questions >> 8) % 256); + bytes[i++] = (byte)((Questions >> 16) % 256); + bytes[i++] = (byte)((Questions >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "TaskID: " + TaskID.ToString() + "\n"; - output += "ItemID: " + ItemID.ToString() + "\n"; - output += "Questions: " + Questions.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += "TaskID: " + TaskID.ToString() + "\n"; + output += "ItemID: " + ItemID.ToString() + "\n"; + output += "Questions: " + Questions.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ScriptAnswerYes - public override PacketType Type { get { return PacketType.ScriptAnswerYes; } } - /// Data block - public DataBlock Data; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ScriptAnswerYes + public override PacketType Type { get { return PacketType.ScriptAnswerYes; } } + /// Data block + public DataBlock Data; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ScriptAnswerYesPacket() - { - Header = new LowHeader(); - Header.ID = 173; - Header.Reliable = true; - Data = new DataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 173; + Header.Reliable = true; + Data = new DataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ScriptAnswerYesPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ScriptAnswerYesPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Data.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Data.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Data.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Data.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ScriptAnswerYes ---\n"; - output += Data.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- ScriptAnswerYes ---\n"; + output += Data.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// UserReport packet + + /// UserReport packet public class UserReportPacket : Packet - { - /// MeanCollision block + { + /// MeanCollision block public class MeanCollisionBlock - { - /// Mag field - public float Mag; - /// Time field - public uint Time; - /// Perp field - public LLUUID Perp; - /// Type field - public byte Type; - - /// Length of this block serialized in bytes + { + /// Mag field + public float Mag; + /// Time field + public uint Time; + /// Perp field + public LLUUID Perp; + /// Type field + public byte Type; + + /// Length of this block serialized in bytes public int Length { get - { - return 25; + { + return 25; } } - - /// Default constructor - public MeanCollisionBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public MeanCollisionBlock() { } + /// Constructor for building the block from a byte array public MeanCollisionBlock(byte[] bytes, ref int i) - { + { try - { - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - Mag = BitConverter.ToSingle(bytes, i); i += 4; - Time = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Perp = new LLUUID(bytes, i); i += 16; - Type = (byte)bytes[i++]; + { + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + Mag = BitConverter.ToSingle(bytes, i); i += 4; + Time = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Perp = new LLUUID(bytes, i); i += 16; + Type = (byte)bytes[i++]; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; + { + byte[] ba; ba = BitConverter.GetBytes(Mag); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - bytes[i++] = (byte)(Time % 256); - bytes[i++] = (byte)((Time >> 8) % 256); - bytes[i++] = (byte)((Time >> 16) % 256); - bytes[i++] = (byte)((Time >> 24) % 256); - if(Perp == null) { Console.WriteLine("Warning: Perp is null, in " + this.GetType()); } - Array.Copy(Perp.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = Type; + Array.Copy(ba, 0, bytes, i, 4); i += 4; + bytes[i++] = (byte)(Time % 256); + bytes[i++] = (byte)((Time >> 8) % 256); + bytes[i++] = (byte)((Time >> 16) % 256); + bytes[i++] = (byte)((Time >> 24) % 256); + if(Perp == null) { Console.WriteLine("Warning: Perp is null, in " + this.GetType()); } + Array.Copy(Perp.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = Type; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- MeanCollision --\n"; - output += "Mag: " + Mag.ToString() + "\n"; - output += "Time: " + Time.ToString() + "\n"; - output += "Perp: " + Perp.ToString() + "\n"; - output += "Type: " + Type.ToString() + "\n"; + { + string output = "-- MeanCollision --\n"; + output += "Mag: " + Mag.ToString() + "\n"; + output += "Time: " + Time.ToString() + "\n"; + output += "Perp: " + Perp.ToString() + "\n"; + output += "Type: " + Type.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// ReportData block + + /// ReportData block public class ReportDataBlock - { - /// ObjectID field - public LLUUID ObjectID; - private byte[] _details; - /// Details field + { + /// ObjectID field + public LLUUID ObjectID; + private byte[] _details; + /// Details field public byte[] Details - { - get { return _details; } + { + get { return _details; } set - { - if (value == null) { _details = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _details = new byte[value.Length]; Array.Copy(value, _details, value.Length); } + { + if (value == null) { _details = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _details = new byte[value.Length]; Array.Copy(value, _details, value.Length); } } - } - private byte[] _versionstring; - /// VersionString field + } + private byte[] _versionstring; + /// VersionString field public byte[] VersionString - { - get { return _versionstring; } + { + get { return _versionstring; } set - { - if (value == null) { _versionstring = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _versionstring = new byte[value.Length]; Array.Copy(value, _versionstring, value.Length); } + { + if (value == null) { _versionstring = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _versionstring = new byte[value.Length]; Array.Copy(value, _versionstring, value.Length); } } - } - /// CheckFlags field - public byte CheckFlags; - /// Category field - public byte Category; - private byte[] _summary; - /// Summary field + } + /// CheckFlags field + public byte CheckFlags; + /// Category field + public byte Category; + private byte[] _summary; + /// Summary field public byte[] Summary - { - get { return _summary; } + { + get { return _summary; } set - { - if (value == null) { _summary = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _summary = new byte[value.Length]; Array.Copy(value, _summary, value.Length); } + { + if (value == null) { _summary = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _summary = new byte[value.Length]; Array.Copy(value, _summary, value.Length); } } - } - /// ReportType field - public byte ReportType; - /// ScreenshotID field - public LLUUID ScreenshotID; - /// Position field - public LLVector3 Position; - - /// Length of this block serialized in bytes + } + /// ReportType field + public byte ReportType; + /// ScreenshotID field + public LLUUID ScreenshotID; + /// Position field + public LLVector3 Position; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 47; - if (Details != null) { length += 2 + Details.Length; } - if (VersionString != null) { length += 1 + VersionString.Length; } - if (Summary != null) { length += 1 + Summary.Length; } - return length; + { + int length = 47; + if (Details != null) { length += 2 + Details.Length; } + if (VersionString != null) { length += 1 + VersionString.Length; } + if (Summary != null) { length += 1 + Summary.Length; } + return length; } } - - /// Default constructor - public ReportDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ReportDataBlock() { } + /// Constructor for building the block from a byte array public ReportDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - ObjectID = new LLUUID(bytes, i); i += 16; - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _details = new byte[length]; - Array.Copy(bytes, i, _details, 0, length); i += length; - length = (ushort)bytes[i++]; - _versionstring = new byte[length]; - Array.Copy(bytes, i, _versionstring, 0, length); i += length; - CheckFlags = (byte)bytes[i++]; - Category = (byte)bytes[i++]; - length = (ushort)bytes[i++]; - _summary = new byte[length]; - Array.Copy(bytes, i, _summary, 0, length); i += length; - ReportType = (byte)bytes[i++]; - ScreenshotID = new LLUUID(bytes, i); i += 16; - Position = new LLVector3(bytes, i); i += 12; + { + ObjectID = new LLUUID(bytes, i); i += 16; + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _details = new byte[length]; + Array.Copy(bytes, i, _details, 0, length); i += length; + length = (ushort)bytes[i++]; + _versionstring = new byte[length]; + Array.Copy(bytes, i, _versionstring, 0, length); i += length; + CheckFlags = (byte)bytes[i++]; + Category = (byte)bytes[i++]; + length = (ushort)bytes[i++]; + _summary = new byte[length]; + Array.Copy(bytes, i, _summary, 0, length); i += length; + ReportType = (byte)bytes[i++]; + ScreenshotID = new LLUUID(bytes, i); i += 16; + Position = new LLVector3(bytes, i); i += 12; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } - Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; - if(Details == null) { Console.WriteLine("Warning: Details is null, in " + this.GetType()); } - bytes[i++] = (byte)(Details.Length % 256); - bytes[i++] = (byte)((Details.Length >> 8) % 256); - Array.Copy(Details, 0, bytes, i, Details.Length); i += Details.Length; - if(VersionString == null) { Console.WriteLine("Warning: VersionString is null, in " + this.GetType()); } - bytes[i++] = (byte)VersionString.Length; - Array.Copy(VersionString, 0, bytes, i, VersionString.Length); i += VersionString.Length; - bytes[i++] = CheckFlags; - bytes[i++] = Category; - if(Summary == null) { Console.WriteLine("Warning: Summary is null, in " + this.GetType()); } - bytes[i++] = (byte)Summary.Length; - Array.Copy(Summary, 0, bytes, i, Summary.Length); i += Summary.Length; - bytes[i++] = ReportType; - if(ScreenshotID == null) { Console.WriteLine("Warning: ScreenshotID is null, in " + this.GetType()); } - Array.Copy(ScreenshotID.GetBytes(), 0, bytes, i, 16); i += 16; - if(Position == null) { Console.WriteLine("Warning: Position is null, in " + this.GetType()); } - Array.Copy(Position.GetBytes(), 0, bytes, i, 12); i += 12; + { + if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } + Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; + if(Details == null) { Console.WriteLine("Warning: Details is null, in " + this.GetType()); } + bytes[i++] = (byte)(Details.Length % 256); + bytes[i++] = (byte)((Details.Length >> 8) % 256); + Array.Copy(Details, 0, bytes, i, Details.Length); i += Details.Length; + if(VersionString == null) { Console.WriteLine("Warning: VersionString is null, in " + this.GetType()); } + bytes[i++] = (byte)VersionString.Length; + Array.Copy(VersionString, 0, bytes, i, VersionString.Length); i += VersionString.Length; + bytes[i++] = CheckFlags; + bytes[i++] = Category; + if(Summary == null) { Console.WriteLine("Warning: Summary is null, in " + this.GetType()); } + bytes[i++] = (byte)Summary.Length; + Array.Copy(Summary, 0, bytes, i, Summary.Length); i += Summary.Length; + bytes[i++] = ReportType; + if(ScreenshotID == null) { Console.WriteLine("Warning: ScreenshotID is null, in " + this.GetType()); } + Array.Copy(ScreenshotID.GetBytes(), 0, bytes, i, 16); i += 16; + if(Position == null) { Console.WriteLine("Warning: Position is null, in " + this.GetType()); } + Array.Copy(Position.GetBytes(), 0, bytes, i, 12); i += 12; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ReportData --\n"; - output += "ObjectID: " + ObjectID.ToString() + "\n"; - output += Helpers.FieldToString(Details, "Details") + "\n"; - output += Helpers.FieldToString(VersionString, "VersionString") + "\n"; - output += "CheckFlags: " + CheckFlags.ToString() + "\n"; - output += "Category: " + Category.ToString() + "\n"; - output += Helpers.FieldToString(Summary, "Summary") + "\n"; - output += "ReportType: " + ReportType.ToString() + "\n"; - output += "ScreenshotID: " + ScreenshotID.ToString() + "\n"; - output += "Position: " + Position.ToString() + "\n"; + { + string output = "-- ReportData --\n"; + output += "ObjectID: " + ObjectID.ToString() + "\n"; + output += Helpers.FieldToString(Details, "Details") + "\n"; + output += Helpers.FieldToString(VersionString, "VersionString") + "\n"; + output += "CheckFlags: " + CheckFlags.ToString() + "\n"; + output += "Category: " + Category.ToString() + "\n"; + output += Helpers.FieldToString(Summary, "Summary") + "\n"; + output += "ReportType: " + ReportType.ToString() + "\n"; + output += "ScreenshotID: " + ScreenshotID.ToString() + "\n"; + output += "Position: " + Position.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.UserReport - public override PacketType Type { get { return PacketType.UserReport; } } - /// MeanCollision block - public MeanCollisionBlock[] MeanCollision; - /// ReportData block - public ReportDataBlock ReportData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.UserReport + public override PacketType Type { get { return PacketType.UserReport; } } + /// MeanCollision block + public MeanCollisionBlock[] MeanCollision; + /// ReportData block + public ReportDataBlock ReportData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public UserReportPacket() - { - Header = new LowHeader(); - Header.ID = 174; - Header.Reliable = true; - Header.Zerocoded = true; - MeanCollision = new MeanCollisionBlock[0]; - ReportData = new ReportDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 174; + Header.Reliable = true; + Header.Zerocoded = true; + MeanCollision = new MeanCollisionBlock[0]; + ReportData = new ReportDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public UserReportPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - MeanCollision = new MeanCollisionBlock[count]; - for (int j = 0; j < count; j++) - { MeanCollision[j] = new MeanCollisionBlock(bytes, ref i); } - ReportData = new ReportDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + MeanCollision = new MeanCollisionBlock[count]; + for (int j = 0; j < count; j++) + { MeanCollision[j] = new MeanCollisionBlock(bytes, ref i); } + ReportData = new ReportDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public UserReportPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - MeanCollision = new MeanCollisionBlock[count]; - for (int j = 0; j < count; j++) - { MeanCollision[j] = new MeanCollisionBlock(bytes, ref i); } - ReportData = new ReportDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + MeanCollision = new MeanCollisionBlock[count]; + for (int j = 0; j < count; j++) + { MeanCollision[j] = new MeanCollisionBlock(bytes, ref i); } + ReportData = new ReportDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += ReportData.Length; length += AgentData.Length;; - length++; - for (int j = 0; j < MeanCollision.Length; j++) { length += MeanCollision[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)MeanCollision.Length; - for (int j = 0; j < MeanCollision.Length; j++) { MeanCollision[j].ToBytes(bytes, ref i); } - ReportData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += ReportData.Length; length += AgentData.Length;; + length++; + for (int j = 0; j < MeanCollision.Length; j++) { length += MeanCollision[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)MeanCollision.Length; + for (int j = 0; j < MeanCollision.Length; j++) { MeanCollision[j].ToBytes(bytes, ref i); } + ReportData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- UserReport ---\n"; + { + string output = "--- UserReport ---\n"; for (int j = 0; j < MeanCollision.Length; j++) - { + { output += MeanCollision[j].ToString() + "\n"; - } - output += ReportData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + } + output += ReportData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// AlertMessage packet + + /// AlertMessage packet public class AlertMessagePacket : Packet - { - /// AlertData block + { + /// AlertData block public class AlertDataBlock - { - private byte[] _message; - /// Message field + { + private byte[] _message; + /// Message field public byte[] Message - { - get { return _message; } + { + get { return _message; } set - { - if (value == null) { _message = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _message = new byte[value.Length]; Array.Copy(value, _message, value.Length); } + { + if (value == null) { _message = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _message = new byte[value.Length]; Array.Copy(value, _message, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 0; - if (Message != null) { length += 1 + Message.Length; } - return length; + { + int length = 0; + if (Message != null) { length += 1 + Message.Length; } + return length; } } - - /// Default constructor - public AlertDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AlertDataBlock() { } + /// Constructor for building the block from a byte array public AlertDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _message = new byte[length]; - Array.Copy(bytes, i, _message, 0, length); i += length; + { + length = (ushort)bytes[i++]; + _message = new byte[length]; + Array.Copy(bytes, i, _message, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(Message == null) { Console.WriteLine("Warning: Message is null, in " + this.GetType()); } - bytes[i++] = (byte)Message.Length; - Array.Copy(Message, 0, bytes, i, Message.Length); i += Message.Length; + { + if(Message == null) { Console.WriteLine("Warning: Message is null, in " + this.GetType()); } + bytes[i++] = (byte)Message.Length; + Array.Copy(Message, 0, bytes, i, Message.Length); i += Message.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AlertData --\n"; - output += Helpers.FieldToString(Message, "Message") + "\n"; + { + string output = "-- AlertData --\n"; + output += Helpers.FieldToString(Message, "Message") + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AlertMessage - public override PacketType Type { get { return PacketType.AlertMessage; } } - /// AlertData block - public AlertDataBlock AlertData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AlertMessage + public override PacketType Type { get { return PacketType.AlertMessage; } } + /// AlertData block + public AlertDataBlock AlertData; + + /// Default constructor public AlertMessagePacket() - { - Header = new LowHeader(); - Header.ID = 175; - Header.Reliable = true; - AlertData = new AlertDataBlock(); + { + Header = new LowHeader(); + Header.ID = 175; + Header.Reliable = true; + AlertData = new AlertDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AlertMessagePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AlertData = new AlertDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AlertData = new AlertDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AlertMessagePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AlertData = new AlertDataBlock(bytes, ref i); + { + Header = head; + AlertData = new AlertDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AlertData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AlertData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AlertData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AlertData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AlertMessage ---\n"; - output += AlertData.ToString() + "\n"; + { + string output = "--- AlertMessage ---\n"; + output += AlertData.ToString() + "\n"; return output; } - + } - - /// AgentAlertMessage packet + + /// AgentAlertMessage packet public class AgentAlertMessagePacket : Packet - { - /// AlertData block + { + /// AlertData block public class AlertDataBlock - { - private byte[] _message; - /// Message field + { + private byte[] _message; + /// Message field public byte[] Message - { - get { return _message; } + { + get { return _message; } set - { - if (value == null) { _message = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _message = new byte[value.Length]; Array.Copy(value, _message, value.Length); } + { + if (value == null) { _message = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _message = new byte[value.Length]; Array.Copy(value, _message, value.Length); } } - } - /// Modal field - public bool Modal; - - /// Length of this block serialized in bytes + } + /// Modal field + public bool Modal; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 1; - if (Message != null) { length += 1 + Message.Length; } - return length; + { + int length = 1; + if (Message != null) { length += 1 + Message.Length; } + return length; } } - - /// Default constructor - public AlertDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AlertDataBlock() { } + /// Constructor for building the block from a byte array public AlertDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _message = new byte[length]; - Array.Copy(bytes, i, _message, 0, length); i += length; - Modal = (bytes[i++] != 0) ? (bool)true : (bool)false; + { + length = (ushort)bytes[i++]; + _message = new byte[length]; + Array.Copy(bytes, i, _message, 0, length); i += length; + Modal = (bytes[i++] != 0) ? (bool)true : (bool)false; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(Message == null) { Console.WriteLine("Warning: Message is null, in " + this.GetType()); } - bytes[i++] = (byte)Message.Length; - Array.Copy(Message, 0, bytes, i, Message.Length); i += Message.Length; - bytes[i++] = (byte)((Modal) ? 1 : 0); + { + if(Message == null) { Console.WriteLine("Warning: Message is null, in " + this.GetType()); } + bytes[i++] = (byte)Message.Length; + Array.Copy(Message, 0, bytes, i, Message.Length); i += Message.Length; + bytes[i++] = (byte)((Modal) ? 1 : 0); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AlertData --\n"; - output += Helpers.FieldToString(Message, "Message") + "\n"; - output += "Modal: " + Modal.ToString() + "\n"; + { + string output = "-- AlertData --\n"; + output += Helpers.FieldToString(Message, "Message") + "\n"; + output += "Modal: " + Modal.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AgentAlertMessage - public override PacketType Type { get { return PacketType.AgentAlertMessage; } } - /// AlertData block - public AlertDataBlock AlertData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AgentAlertMessage + public override PacketType Type { get { return PacketType.AgentAlertMessage; } } + /// AlertData block + public AlertDataBlock AlertData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public AgentAlertMessagePacket() - { - Header = new LowHeader(); - Header.ID = 176; - Header.Reliable = true; - AlertData = new AlertDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 176; + Header.Reliable = true; + AlertData = new AlertDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AgentAlertMessagePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AlertData = new AlertDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AlertData = new AlertDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AgentAlertMessagePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AlertData = new AlertDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + AlertData = new AlertDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AlertData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AlertData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AlertData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AlertData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AgentAlertMessage ---\n"; - output += AlertData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- AgentAlertMessage ---\n"; + output += AlertData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// MeanCollisionAlert packet + + /// MeanCollisionAlert packet public class MeanCollisionAlertPacket : Packet - { - /// MeanCollision block + { + /// MeanCollision block public class MeanCollisionBlock - { - /// Mag field - public float Mag; - /// Time field - public uint Time; - /// Perp field - public LLUUID Perp; - /// Type field - public byte Type; - /// Victim field - public LLUUID Victim; - - /// Length of this block serialized in bytes + { + /// Mag field + public float Mag; + /// Time field + public uint Time; + /// Perp field + public LLUUID Perp; + /// Type field + public byte Type; + /// Victim field + public LLUUID Victim; + + /// Length of this block serialized in bytes public int Length { get - { - return 41; + { + return 41; } } - - /// Default constructor - public MeanCollisionBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public MeanCollisionBlock() { } + /// Constructor for building the block from a byte array public MeanCollisionBlock(byte[] bytes, ref int i) - { + { try - { - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - Mag = BitConverter.ToSingle(bytes, i); i += 4; - Time = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Perp = new LLUUID(bytes, i); i += 16; - Type = (byte)bytes[i++]; - Victim = new LLUUID(bytes, i); i += 16; + { + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + Mag = BitConverter.ToSingle(bytes, i); i += 4; + Time = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Perp = new LLUUID(bytes, i); i += 16; + Type = (byte)bytes[i++]; + Victim = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; + { + byte[] ba; ba = BitConverter.GetBytes(Mag); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - bytes[i++] = (byte)(Time % 256); - bytes[i++] = (byte)((Time >> 8) % 256); - bytes[i++] = (byte)((Time >> 16) % 256); - bytes[i++] = (byte)((Time >> 24) % 256); - if(Perp == null) { Console.WriteLine("Warning: Perp is null, in " + this.GetType()); } - Array.Copy(Perp.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = Type; - if(Victim == null) { Console.WriteLine("Warning: Victim is null, in " + this.GetType()); } - Array.Copy(Victim.GetBytes(), 0, bytes, i, 16); i += 16; + Array.Copy(ba, 0, bytes, i, 4); i += 4; + bytes[i++] = (byte)(Time % 256); + bytes[i++] = (byte)((Time >> 8) % 256); + bytes[i++] = (byte)((Time >> 16) % 256); + bytes[i++] = (byte)((Time >> 24) % 256); + if(Perp == null) { Console.WriteLine("Warning: Perp is null, in " + this.GetType()); } + Array.Copy(Perp.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = Type; + if(Victim == null) { Console.WriteLine("Warning: Victim is null, in " + this.GetType()); } + Array.Copy(Victim.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- MeanCollision --\n"; - output += "Mag: " + Mag.ToString() + "\n"; - output += "Time: " + Time.ToString() + "\n"; - output += "Perp: " + Perp.ToString() + "\n"; - output += "Type: " + Type.ToString() + "\n"; - output += "Victim: " + Victim.ToString() + "\n"; + { + string output = "-- MeanCollision --\n"; + output += "Mag: " + Mag.ToString() + "\n"; + output += "Time: " + Time.ToString() + "\n"; + output += "Perp: " + Perp.ToString() + "\n"; + output += "Type: " + Type.ToString() + "\n"; + output += "Victim: " + Victim.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.MeanCollisionAlert - public override PacketType Type { get { return PacketType.MeanCollisionAlert; } } - /// MeanCollision block - public MeanCollisionBlock[] MeanCollision; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.MeanCollisionAlert + public override PacketType Type { get { return PacketType.MeanCollisionAlert; } } + /// MeanCollision block + public MeanCollisionBlock[] MeanCollision; + + /// Default constructor public MeanCollisionAlertPacket() - { - Header = new LowHeader(); - Header.ID = 177; - Header.Reliable = true; - Header.Zerocoded = true; - MeanCollision = new MeanCollisionBlock[0]; + { + Header = new LowHeader(); + Header.ID = 177; + Header.Reliable = true; + Header.Zerocoded = true; + MeanCollision = new MeanCollisionBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public MeanCollisionAlertPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - MeanCollision = new MeanCollisionBlock[count]; - for (int j = 0; j < count; j++) - { MeanCollision[j] = new MeanCollisionBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + MeanCollision = new MeanCollisionBlock[count]; + for (int j = 0; j < count; j++) + { MeanCollision[j] = new MeanCollisionBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public MeanCollisionAlertPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - MeanCollision = new MeanCollisionBlock[count]; - for (int j = 0; j < count; j++) - { MeanCollision[j] = new MeanCollisionBlock(bytes, ref i); } + { + Header = head; + int count = (int)bytes[i++]; + MeanCollision = new MeanCollisionBlock[count]; + for (int j = 0; j < count; j++) + { MeanCollision[j] = new MeanCollisionBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; -; - length++; - for (int j = 0; j < MeanCollision.Length; j++) { length += MeanCollision[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)MeanCollision.Length; - for (int j = 0; j < MeanCollision.Length; j++) { MeanCollision[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; +; + length++; + for (int j = 0; j < MeanCollision.Length; j++) { length += MeanCollision[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)MeanCollision.Length; + for (int j = 0; j < MeanCollision.Length; j++) { MeanCollision[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- MeanCollisionAlert ---\n"; + { + string output = "--- MeanCollisionAlert ---\n"; for (int j = 0; j < MeanCollision.Length; j++) - { + { output += MeanCollision[j].ToString() + "\n"; - } + } return output; } - + } - - /// ViewerFrozenMessage packet + + /// ViewerFrozenMessage packet public class ViewerFrozenMessagePacket : Packet - { - /// FrozenData block + { + /// FrozenData block public class FrozenDataBlock - { - /// Data field - public bool Data; - - /// Length of this block serialized in bytes + { + /// Data field + public bool Data; + + /// Length of this block serialized in bytes public int Length { get - { - return 1; + { + return 1; } } - - /// Default constructor - public FrozenDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public FrozenDataBlock() { } + /// Constructor for building the block from a byte array public FrozenDataBlock(byte[] bytes, ref int i) - { + { try - { - Data = (bytes[i++] != 0) ? (bool)true : (bool)false; + { + Data = (bytes[i++] != 0) ? (bool)true : (bool)false; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)((Data) ? 1 : 0); + { + bytes[i++] = (byte)((Data) ? 1 : 0); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- FrozenData --\n"; - output += "Data: " + Data.ToString() + "\n"; + { + string output = "-- FrozenData --\n"; + output += "Data: " + Data.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ViewerFrozenMessage - public override PacketType Type { get { return PacketType.ViewerFrozenMessage; } } - /// FrozenData block - public FrozenDataBlock FrozenData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ViewerFrozenMessage + public override PacketType Type { get { return PacketType.ViewerFrozenMessage; } } + /// FrozenData block + public FrozenDataBlock FrozenData; + + /// Default constructor public ViewerFrozenMessagePacket() - { - Header = new LowHeader(); - Header.ID = 178; - Header.Reliable = true; - FrozenData = new FrozenDataBlock(); + { + Header = new LowHeader(); + Header.ID = 178; + Header.Reliable = true; + FrozenData = new FrozenDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ViewerFrozenMessagePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - FrozenData = new FrozenDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + FrozenData = new FrozenDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ViewerFrozenMessagePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - FrozenData = new FrozenDataBlock(bytes, ref i); + { + Header = head; + FrozenData = new FrozenDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += FrozenData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - FrozenData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += FrozenData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + FrozenData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ViewerFrozenMessage ---\n"; - output += FrozenData.ToString() + "\n"; + { + string output = "--- ViewerFrozenMessage ---\n"; + output += FrozenData.ToString() + "\n"; return output; } - + } - - /// HealthMessage packet + + /// HealthMessage packet public class HealthMessagePacket : Packet - { - /// HealthData block + { + /// HealthData block public class HealthDataBlock - { - /// Health field - public float Health; - - /// Length of this block serialized in bytes + { + /// Health field + public float Health; + + /// Length of this block serialized in bytes public int Length { get - { - return 4; + { + return 4; } } - - /// Default constructor - public HealthDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public HealthDataBlock() { } + /// Constructor for building the block from a byte array public HealthDataBlock(byte[] bytes, ref int i) - { + { try - { - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - Health = BitConverter.ToSingle(bytes, i); i += 4; + { + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + Health = BitConverter.ToSingle(bytes, i); i += 4; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; + { + byte[] ba; ba = BitConverter.GetBytes(Health); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- HealthData --\n"; - output += "Health: " + Health.ToString() + "\n"; + { + string output = "-- HealthData --\n"; + output += "Health: " + Health.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.HealthMessage - public override PacketType Type { get { return PacketType.HealthMessage; } } - /// HealthData block - public HealthDataBlock HealthData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.HealthMessage + public override PacketType Type { get { return PacketType.HealthMessage; } } + /// HealthData block + public HealthDataBlock HealthData; + + /// Default constructor public HealthMessagePacket() - { - Header = new LowHeader(); - Header.ID = 179; - Header.Reliable = true; - Header.Zerocoded = true; - HealthData = new HealthDataBlock(); + { + Header = new LowHeader(); + Header.ID = 179; + Header.Reliable = true; + Header.Zerocoded = true; + HealthData = new HealthDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public HealthMessagePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - HealthData = new HealthDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + HealthData = new HealthDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public HealthMessagePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - HealthData = new HealthDataBlock(bytes, ref i); + { + Header = head; + HealthData = new HealthDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += HealthData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - HealthData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += HealthData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + HealthData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- HealthMessage ---\n"; - output += HealthData.ToString() + "\n"; + { + string output = "--- HealthMessage ---\n"; + output += HealthData.ToString() + "\n"; return output; } - + } - - /// ChatFromSimulator packet + + /// ChatFromSimulator packet public class ChatFromSimulatorPacket : Packet - { - /// ChatData block + { + /// ChatData block public class ChatDataBlock - { - private byte[] _message; - /// Message field + { + private byte[] _message; + /// Message field public byte[] Message - { - get { return _message; } + { + get { return _message; } set - { - if (value == null) { _message = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _message = new byte[value.Length]; Array.Copy(value, _message, value.Length); } + { + if (value == null) { _message = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _message = new byte[value.Length]; Array.Copy(value, _message, value.Length); } } - } - /// Audible field - public byte Audible; - /// ChatType field - public byte ChatType; - /// OwnerID field - public LLUUID OwnerID; - private byte[] _fromname; - /// FromName field + } + /// Audible field + public byte Audible; + /// ChatType field + public byte ChatType; + /// OwnerID field + public LLUUID OwnerID; + private byte[] _fromname; + /// FromName field public byte[] FromName - { - get { return _fromname; } + { + get { return _fromname; } set - { - if (value == null) { _fromname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _fromname = new byte[value.Length]; Array.Copy(value, _fromname, value.Length); } + { + if (value == null) { _fromname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _fromname = new byte[value.Length]; Array.Copy(value, _fromname, value.Length); } } - } - /// SourceType field - public byte SourceType; - /// SourceID field - public LLUUID SourceID; - /// Position field - public LLVector3 Position; - - /// Length of this block serialized in bytes + } + /// SourceType field + public byte SourceType; + /// SourceID field + public LLUUID SourceID; + /// Position field + public LLVector3 Position; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 47; - if (Message != null) { length += 2 + Message.Length; } - if (FromName != null) { length += 1 + FromName.Length; } - return length; + { + int length = 47; + if (Message != null) { length += 2 + Message.Length; } + if (FromName != null) { length += 1 + FromName.Length; } + return length; } } - - /// Default constructor - public ChatDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ChatDataBlock() { } + /// Constructor for building the block from a byte array public ChatDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _message = new byte[length]; - Array.Copy(bytes, i, _message, 0, length); i += length; - Audible = (byte)bytes[i++]; - ChatType = (byte)bytes[i++]; - OwnerID = new LLUUID(bytes, i); i += 16; - length = (ushort)bytes[i++]; - _fromname = new byte[length]; - Array.Copy(bytes, i, _fromname, 0, length); i += length; - SourceType = (byte)bytes[i++]; - SourceID = new LLUUID(bytes, i); i += 16; - Position = new LLVector3(bytes, i); i += 12; + { + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _message = new byte[length]; + Array.Copy(bytes, i, _message, 0, length); i += length; + Audible = (byte)bytes[i++]; + ChatType = (byte)bytes[i++]; + OwnerID = new LLUUID(bytes, i); i += 16; + length = (ushort)bytes[i++]; + _fromname = new byte[length]; + Array.Copy(bytes, i, _fromname, 0, length); i += length; + SourceType = (byte)bytes[i++]; + SourceID = new LLUUID(bytes, i); i += 16; + Position = new LLVector3(bytes, i); i += 12; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(Message == null) { Console.WriteLine("Warning: Message is null, in " + this.GetType()); } - bytes[i++] = (byte)(Message.Length % 256); - bytes[i++] = (byte)((Message.Length >> 8) % 256); - Array.Copy(Message, 0, bytes, i, Message.Length); i += Message.Length; - bytes[i++] = Audible; - bytes[i++] = ChatType; - if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } - Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; - if(FromName == null) { Console.WriteLine("Warning: FromName is null, in " + this.GetType()); } - bytes[i++] = (byte)FromName.Length; - Array.Copy(FromName, 0, bytes, i, FromName.Length); i += FromName.Length; - bytes[i++] = SourceType; - if(SourceID == null) { Console.WriteLine("Warning: SourceID is null, in " + this.GetType()); } - Array.Copy(SourceID.GetBytes(), 0, bytes, i, 16); i += 16; - if(Position == null) { Console.WriteLine("Warning: Position is null, in " + this.GetType()); } - Array.Copy(Position.GetBytes(), 0, bytes, i, 12); i += 12; + { + if(Message == null) { Console.WriteLine("Warning: Message is null, in " + this.GetType()); } + bytes[i++] = (byte)(Message.Length % 256); + bytes[i++] = (byte)((Message.Length >> 8) % 256); + Array.Copy(Message, 0, bytes, i, Message.Length); i += Message.Length; + bytes[i++] = Audible; + bytes[i++] = ChatType; + if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } + Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; + if(FromName == null) { Console.WriteLine("Warning: FromName is null, in " + this.GetType()); } + bytes[i++] = (byte)FromName.Length; + Array.Copy(FromName, 0, bytes, i, FromName.Length); i += FromName.Length; + bytes[i++] = SourceType; + if(SourceID == null) { Console.WriteLine("Warning: SourceID is null, in " + this.GetType()); } + Array.Copy(SourceID.GetBytes(), 0, bytes, i, 16); i += 16; + if(Position == null) { Console.WriteLine("Warning: Position is null, in " + this.GetType()); } + Array.Copy(Position.GetBytes(), 0, bytes, i, 12); i += 12; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ChatData --\n"; - output += Helpers.FieldToString(Message, "Message") + "\n"; - output += "Audible: " + Audible.ToString() + "\n"; - output += "ChatType: " + ChatType.ToString() + "\n"; - output += "OwnerID: " + OwnerID.ToString() + "\n"; - output += Helpers.FieldToString(FromName, "FromName") + "\n"; - output += "SourceType: " + SourceType.ToString() + "\n"; - output += "SourceID: " + SourceID.ToString() + "\n"; - output += "Position: " + Position.ToString() + "\n"; + { + string output = "-- ChatData --\n"; + output += Helpers.FieldToString(Message, "Message") + "\n"; + output += "Audible: " + Audible.ToString() + "\n"; + output += "ChatType: " + ChatType.ToString() + "\n"; + output += "OwnerID: " + OwnerID.ToString() + "\n"; + output += Helpers.FieldToString(FromName, "FromName") + "\n"; + output += "SourceType: " + SourceType.ToString() + "\n"; + output += "SourceID: " + SourceID.ToString() + "\n"; + output += "Position: " + Position.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ChatFromSimulator - public override PacketType Type { get { return PacketType.ChatFromSimulator; } } - /// ChatData block - public ChatDataBlock ChatData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ChatFromSimulator + public override PacketType Type { get { return PacketType.ChatFromSimulator; } } + /// ChatData block + public ChatDataBlock ChatData; + + /// Default constructor public ChatFromSimulatorPacket() - { - Header = new LowHeader(); - Header.ID = 180; - Header.Reliable = true; - ChatData = new ChatDataBlock(); + { + Header = new LowHeader(); + Header.ID = 180; + Header.Reliable = true; + ChatData = new ChatDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ChatFromSimulatorPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - ChatData = new ChatDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + ChatData = new ChatDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ChatFromSimulatorPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - ChatData = new ChatDataBlock(bytes, ref i); + { + Header = head; + ChatData = new ChatDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += ChatData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - ChatData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += ChatData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + ChatData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ChatFromSimulator ---\n"; - output += ChatData.ToString() + "\n"; + { + string output = "--- ChatFromSimulator ---\n"; + output += ChatData.ToString() + "\n"; return output; } - + } - - /// SimStats packet + + /// SimStats packet public class SimStatsPacket : Packet - { - /// Stat block + { + /// Stat block public class StatBlock - { - /// StatValue field - public float StatValue; - /// StatID field - public uint StatID; - - /// Length of this block serialized in bytes + { + /// StatValue field + public float StatValue; + /// StatID field + public uint StatID; + + /// Length of this block serialized in bytes public int Length { get - { - return 8; + { + return 8; } } - - /// Default constructor - public StatBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public StatBlock() { } + /// Constructor for building the block from a byte array public StatBlock(byte[] bytes, ref int i) - { + { try - { - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - StatValue = BitConverter.ToSingle(bytes, i); i += 4; - StatID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + StatValue = BitConverter.ToSingle(bytes, i); i += 4; + StatID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; + { + byte[] ba; ba = BitConverter.GetBytes(StatValue); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - bytes[i++] = (byte)(StatID % 256); - bytes[i++] = (byte)((StatID >> 8) % 256); - bytes[i++] = (byte)((StatID >> 16) % 256); - bytes[i++] = (byte)((StatID >> 24) % 256); + Array.Copy(ba, 0, bytes, i, 4); i += 4; + bytes[i++] = (byte)(StatID % 256); + bytes[i++] = (byte)((StatID >> 8) % 256); + bytes[i++] = (byte)((StatID >> 16) % 256); + bytes[i++] = (byte)((StatID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Stat --\n"; - output += "StatValue: " + StatValue.ToString() + "\n"; - output += "StatID: " + StatID.ToString() + "\n"; + { + string output = "-- Stat --\n"; + output += "StatValue: " + StatValue.ToString() + "\n"; + output += "StatID: " + StatID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// Region block + + /// Region block public class RegionBlock - { - /// RegionX field - public uint RegionX; - /// RegionY field - public uint RegionY; - /// RegionFlags field - public uint RegionFlags; - /// ObjectCapacity field - public uint ObjectCapacity; - - /// Length of this block serialized in bytes + { + /// RegionX field + public uint RegionX; + /// RegionY field + public uint RegionY; + /// RegionFlags field + public uint RegionFlags; + /// ObjectCapacity field + public uint ObjectCapacity; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public RegionBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public RegionBlock() { } + /// Constructor for building the block from a byte array public RegionBlock(byte[] bytes, ref int i) - { + { try - { - RegionX = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - RegionY = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - RegionFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - ObjectCapacity = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + RegionX = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + RegionY = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + RegionFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + ObjectCapacity = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(RegionX % 256); - bytes[i++] = (byte)((RegionX >> 8) % 256); - bytes[i++] = (byte)((RegionX >> 16) % 256); - bytes[i++] = (byte)((RegionX >> 24) % 256); - bytes[i++] = (byte)(RegionY % 256); - bytes[i++] = (byte)((RegionY >> 8) % 256); - bytes[i++] = (byte)((RegionY >> 16) % 256); - bytes[i++] = (byte)((RegionY >> 24) % 256); - bytes[i++] = (byte)(RegionFlags % 256); - bytes[i++] = (byte)((RegionFlags >> 8) % 256); - bytes[i++] = (byte)((RegionFlags >> 16) % 256); - bytes[i++] = (byte)((RegionFlags >> 24) % 256); - bytes[i++] = (byte)(ObjectCapacity % 256); - bytes[i++] = (byte)((ObjectCapacity >> 8) % 256); - bytes[i++] = (byte)((ObjectCapacity >> 16) % 256); - bytes[i++] = (byte)((ObjectCapacity >> 24) % 256); + { + bytes[i++] = (byte)(RegionX % 256); + bytes[i++] = (byte)((RegionX >> 8) % 256); + bytes[i++] = (byte)((RegionX >> 16) % 256); + bytes[i++] = (byte)((RegionX >> 24) % 256); + bytes[i++] = (byte)(RegionY % 256); + bytes[i++] = (byte)((RegionY >> 8) % 256); + bytes[i++] = (byte)((RegionY >> 16) % 256); + bytes[i++] = (byte)((RegionY >> 24) % 256); + bytes[i++] = (byte)(RegionFlags % 256); + bytes[i++] = (byte)((RegionFlags >> 8) % 256); + bytes[i++] = (byte)((RegionFlags >> 16) % 256); + bytes[i++] = (byte)((RegionFlags >> 24) % 256); + bytes[i++] = (byte)(ObjectCapacity % 256); + bytes[i++] = (byte)((ObjectCapacity >> 8) % 256); + bytes[i++] = (byte)((ObjectCapacity >> 16) % 256); + bytes[i++] = (byte)((ObjectCapacity >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Region --\n"; - output += "RegionX: " + RegionX.ToString() + "\n"; - output += "RegionY: " + RegionY.ToString() + "\n"; - output += "RegionFlags: " + RegionFlags.ToString() + "\n"; - output += "ObjectCapacity: " + ObjectCapacity.ToString() + "\n"; + { + string output = "-- Region --\n"; + output += "RegionX: " + RegionX.ToString() + "\n"; + output += "RegionY: " + RegionY.ToString() + "\n"; + output += "RegionFlags: " + RegionFlags.ToString() + "\n"; + output += "ObjectCapacity: " + ObjectCapacity.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.SimStats - public override PacketType Type { get { return PacketType.SimStats; } } - /// Stat block - public StatBlock[] Stat; - /// Region block - public RegionBlock Region; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.SimStats + public override PacketType Type { get { return PacketType.SimStats; } } + /// Stat block + public StatBlock[] Stat; + /// Region block + public RegionBlock Region; + + /// Default constructor public SimStatsPacket() - { - Header = new LowHeader(); - Header.ID = 181; - Header.Reliable = true; - Stat = new StatBlock[0]; - Region = new RegionBlock(); + { + Header = new LowHeader(); + Header.ID = 181; + Header.Reliable = true; + Stat = new StatBlock[0]; + Region = new RegionBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public SimStatsPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - Stat = new StatBlock[count]; - for (int j = 0; j < count; j++) - { Stat[j] = new StatBlock(bytes, ref i); } - Region = new RegionBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + Stat = new StatBlock[count]; + for (int j = 0; j < count; j++) + { Stat[j] = new StatBlock(bytes, ref i); } + Region = new RegionBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public SimStatsPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - Stat = new StatBlock[count]; - for (int j = 0; j < count; j++) - { Stat[j] = new StatBlock(bytes, ref i); } - Region = new RegionBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + Stat = new StatBlock[count]; + for (int j = 0; j < count; j++) + { Stat[j] = new StatBlock(bytes, ref i); } + Region = new RegionBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Region.Length;; - length++; - for (int j = 0; j < Stat.Length; j++) { length += Stat[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)Stat.Length; - for (int j = 0; j < Stat.Length; j++) { Stat[j].ToBytes(bytes, ref i); } - Region.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Region.Length;; + length++; + for (int j = 0; j < Stat.Length; j++) { length += Stat[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)Stat.Length; + for (int j = 0; j < Stat.Length; j++) { Stat[j].ToBytes(bytes, ref i); } + Region.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- SimStats ---\n"; + { + string output = "--- SimStats ---\n"; for (int j = 0; j < Stat.Length; j++) - { + { output += Stat[j].ToString() + "\n"; - } - output += Region.ToString() + "\n"; + } + output += Region.ToString() + "\n"; return output; } - + } - - /// RequestRegionInfo packet + + /// RequestRegionInfo packet public class RequestRegionInfoPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.RequestRegionInfo - public override PacketType Type { get { return PacketType.RequestRegionInfo; } } - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.RequestRegionInfo + public override PacketType Type { get { return PacketType.RequestRegionInfo; } } + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public RequestRegionInfoPacket() - { - Header = new LowHeader(); - Header.ID = 182; - Header.Reliable = true; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 182; + Header.Reliable = true; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public RequestRegionInfoPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public RequestRegionInfoPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- RequestRegionInfo ---\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- RequestRegionInfo ---\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// RegionInfo packet + + /// RegionInfo packet public class RegionInfoPacket : Packet - { - /// RegionInfo block + { + /// RegionInfo block public class RegionInfoBlock - { - /// BillableFactor field - public float BillableFactor; - /// ObjectBonusFactor field - public float ObjectBonusFactor; - /// RedirectGridX field - public int RedirectGridX; - /// RedirectGridY field - public int RedirectGridY; - private byte[] _simname; - /// SimName field + { + /// BillableFactor field + public float BillableFactor; + /// ObjectBonusFactor field + public float ObjectBonusFactor; + /// RedirectGridX field + public int RedirectGridX; + /// RedirectGridY field + public int RedirectGridY; + private byte[] _simname; + /// SimName field public byte[] SimName - { - get { return _simname; } + { + get { return _simname; } set - { - if (value == null) { _simname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _simname = new byte[value.Length]; Array.Copy(value, _simname, value.Length); } + { + if (value == null) { _simname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _simname = new byte[value.Length]; Array.Copy(value, _simname, value.Length); } } - } - /// PricePerMeter field - public int PricePerMeter; - /// RegionFlags field - public uint RegionFlags; - /// WaterHeight field - public float WaterHeight; - /// UseEstateSun field - public bool UseEstateSun; - /// SunHour field - public float SunHour; - /// MaxAgents field - public byte MaxAgents; - /// SimAccess field - public byte SimAccess; - /// TerrainLowerLimit field - public float TerrainLowerLimit; - /// ParentEstateID field - public uint ParentEstateID; - /// TerrainRaiseLimit field - public float TerrainRaiseLimit; - /// EstateID field - public uint EstateID; - - /// Length of this block serialized in bytes + } + /// PricePerMeter field + public int PricePerMeter; + /// RegionFlags field + public uint RegionFlags; + /// WaterHeight field + public float WaterHeight; + /// UseEstateSun field + public bool UseEstateSun; + /// SunHour field + public float SunHour; + /// MaxAgents field + public byte MaxAgents; + /// SimAccess field + public byte SimAccess; + /// TerrainLowerLimit field + public float TerrainLowerLimit; + /// ParentEstateID field + public uint ParentEstateID; + /// TerrainRaiseLimit field + public float TerrainRaiseLimit; + /// EstateID field + public uint EstateID; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 51; - if (SimName != null) { length += 1 + SimName.Length; } - return length; + { + int length = 51; + if (SimName != null) { length += 1 + SimName.Length; } + return length; } } - - /// Default constructor - public RegionInfoBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public RegionInfoBlock() { } + /// Constructor for building the block from a byte array public RegionInfoBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - BillableFactor = BitConverter.ToSingle(bytes, i); i += 4; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - ObjectBonusFactor = BitConverter.ToSingle(bytes, i); i += 4; - RedirectGridX = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - RedirectGridY = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _simname = new byte[length]; - Array.Copy(bytes, i, _simname, 0, length); i += length; - PricePerMeter = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - RegionFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - WaterHeight = BitConverter.ToSingle(bytes, i); i += 4; - UseEstateSun = (bytes[i++] != 0) ? (bool)true : (bool)false; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - SunHour = BitConverter.ToSingle(bytes, i); i += 4; - MaxAgents = (byte)bytes[i++]; - SimAccess = (byte)bytes[i++]; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - TerrainLowerLimit = BitConverter.ToSingle(bytes, i); i += 4; - ParentEstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - TerrainRaiseLimit = BitConverter.ToSingle(bytes, i); i += 4; - EstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + BillableFactor = BitConverter.ToSingle(bytes, i); i += 4; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + ObjectBonusFactor = BitConverter.ToSingle(bytes, i); i += 4; + RedirectGridX = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + RedirectGridY = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _simname = new byte[length]; + Array.Copy(bytes, i, _simname, 0, length); i += length; + PricePerMeter = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + RegionFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + WaterHeight = BitConverter.ToSingle(bytes, i); i += 4; + UseEstateSun = (bytes[i++] != 0) ? (bool)true : (bool)false; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + SunHour = BitConverter.ToSingle(bytes, i); i += 4; + MaxAgents = (byte)bytes[i++]; + SimAccess = (byte)bytes[i++]; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + TerrainLowerLimit = BitConverter.ToSingle(bytes, i); i += 4; + ParentEstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + TerrainRaiseLimit = BitConverter.ToSingle(bytes, i); i += 4; + EstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; + { + byte[] ba; ba = BitConverter.GetBytes(BillableFactor); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; ba = BitConverter.GetBytes(ObjectBonusFactor); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - bytes[i++] = (byte)(RedirectGridX % 256); - bytes[i++] = (byte)((RedirectGridX >> 8) % 256); - bytes[i++] = (byte)((RedirectGridX >> 16) % 256); - bytes[i++] = (byte)((RedirectGridX >> 24) % 256); - bytes[i++] = (byte)(RedirectGridY % 256); - bytes[i++] = (byte)((RedirectGridY >> 8) % 256); - bytes[i++] = (byte)((RedirectGridY >> 16) % 256); - bytes[i++] = (byte)((RedirectGridY >> 24) % 256); - if(SimName == null) { Console.WriteLine("Warning: SimName is null, in " + this.GetType()); } - bytes[i++] = (byte)SimName.Length; - Array.Copy(SimName, 0, bytes, i, SimName.Length); i += SimName.Length; - bytes[i++] = (byte)(PricePerMeter % 256); - bytes[i++] = (byte)((PricePerMeter >> 8) % 256); - bytes[i++] = (byte)((PricePerMeter >> 16) % 256); - bytes[i++] = (byte)((PricePerMeter >> 24) % 256); - bytes[i++] = (byte)(RegionFlags % 256); - bytes[i++] = (byte)((RegionFlags >> 8) % 256); - bytes[i++] = (byte)((RegionFlags >> 16) % 256); - bytes[i++] = (byte)((RegionFlags >> 24) % 256); + Array.Copy(ba, 0, bytes, i, 4); i += 4; + bytes[i++] = (byte)(RedirectGridX % 256); + bytes[i++] = (byte)((RedirectGridX >> 8) % 256); + bytes[i++] = (byte)((RedirectGridX >> 16) % 256); + bytes[i++] = (byte)((RedirectGridX >> 24) % 256); + bytes[i++] = (byte)(RedirectGridY % 256); + bytes[i++] = (byte)((RedirectGridY >> 8) % 256); + bytes[i++] = (byte)((RedirectGridY >> 16) % 256); + bytes[i++] = (byte)((RedirectGridY >> 24) % 256); + if(SimName == null) { Console.WriteLine("Warning: SimName is null, in " + this.GetType()); } + bytes[i++] = (byte)SimName.Length; + Array.Copy(SimName, 0, bytes, i, SimName.Length); i += SimName.Length; + bytes[i++] = (byte)(PricePerMeter % 256); + bytes[i++] = (byte)((PricePerMeter >> 8) % 256); + bytes[i++] = (byte)((PricePerMeter >> 16) % 256); + bytes[i++] = (byte)((PricePerMeter >> 24) % 256); + bytes[i++] = (byte)(RegionFlags % 256); + bytes[i++] = (byte)((RegionFlags >> 8) % 256); + bytes[i++] = (byte)((RegionFlags >> 16) % 256); + bytes[i++] = (byte)((RegionFlags >> 24) % 256); ba = BitConverter.GetBytes(WaterHeight); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - bytes[i++] = (byte)((UseEstateSun) ? 1 : 0); + Array.Copy(ba, 0, bytes, i, 4); i += 4; + bytes[i++] = (byte)((UseEstateSun) ? 1 : 0); ba = BitConverter.GetBytes(SunHour); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - bytes[i++] = MaxAgents; - bytes[i++] = SimAccess; + Array.Copy(ba, 0, bytes, i, 4); i += 4; + bytes[i++] = MaxAgents; + bytes[i++] = SimAccess; ba = BitConverter.GetBytes(TerrainLowerLimit); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - bytes[i++] = (byte)(ParentEstateID % 256); - bytes[i++] = (byte)((ParentEstateID >> 8) % 256); - bytes[i++] = (byte)((ParentEstateID >> 16) % 256); - bytes[i++] = (byte)((ParentEstateID >> 24) % 256); + Array.Copy(ba, 0, bytes, i, 4); i += 4; + bytes[i++] = (byte)(ParentEstateID % 256); + bytes[i++] = (byte)((ParentEstateID >> 8) % 256); + bytes[i++] = (byte)((ParentEstateID >> 16) % 256); + bytes[i++] = (byte)((ParentEstateID >> 24) % 256); ba = BitConverter.GetBytes(TerrainRaiseLimit); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - bytes[i++] = (byte)(EstateID % 256); - bytes[i++] = (byte)((EstateID >> 8) % 256); - bytes[i++] = (byte)((EstateID >> 16) % 256); - bytes[i++] = (byte)((EstateID >> 24) % 256); + Array.Copy(ba, 0, bytes, i, 4); i += 4; + bytes[i++] = (byte)(EstateID % 256); + bytes[i++] = (byte)((EstateID >> 8) % 256); + bytes[i++] = (byte)((EstateID >> 16) % 256); + bytes[i++] = (byte)((EstateID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- RegionInfo --\n"; - output += "BillableFactor: " + BillableFactor.ToString() + "\n"; - output += "ObjectBonusFactor: " + ObjectBonusFactor.ToString() + "\n"; - output += "RedirectGridX: " + RedirectGridX.ToString() + "\n"; - output += "RedirectGridY: " + RedirectGridY.ToString() + "\n"; - output += Helpers.FieldToString(SimName, "SimName") + "\n"; - output += "PricePerMeter: " + PricePerMeter.ToString() + "\n"; - output += "RegionFlags: " + RegionFlags.ToString() + "\n"; - output += "WaterHeight: " + WaterHeight.ToString() + "\n"; - output += "UseEstateSun: " + UseEstateSun.ToString() + "\n"; - output += "SunHour: " + SunHour.ToString() + "\n"; - output += "MaxAgents: " + MaxAgents.ToString() + "\n"; - output += "SimAccess: " + SimAccess.ToString() + "\n"; - output += "TerrainLowerLimit: " + TerrainLowerLimit.ToString() + "\n"; - output += "ParentEstateID: " + ParentEstateID.ToString() + "\n"; - output += "TerrainRaiseLimit: " + TerrainRaiseLimit.ToString() + "\n"; - output += "EstateID: " + EstateID.ToString() + "\n"; + { + string output = "-- RegionInfo --\n"; + output += "BillableFactor: " + BillableFactor.ToString() + "\n"; + output += "ObjectBonusFactor: " + ObjectBonusFactor.ToString() + "\n"; + output += "RedirectGridX: " + RedirectGridX.ToString() + "\n"; + output += "RedirectGridY: " + RedirectGridY.ToString() + "\n"; + output += Helpers.FieldToString(SimName, "SimName") + "\n"; + output += "PricePerMeter: " + PricePerMeter.ToString() + "\n"; + output += "RegionFlags: " + RegionFlags.ToString() + "\n"; + output += "WaterHeight: " + WaterHeight.ToString() + "\n"; + output += "UseEstateSun: " + UseEstateSun.ToString() + "\n"; + output += "SunHour: " + SunHour.ToString() + "\n"; + output += "MaxAgents: " + MaxAgents.ToString() + "\n"; + output += "SimAccess: " + SimAccess.ToString() + "\n"; + output += "TerrainLowerLimit: " + TerrainLowerLimit.ToString() + "\n"; + output += "ParentEstateID: " + ParentEstateID.ToString() + "\n"; + output += "TerrainRaiseLimit: " + TerrainRaiseLimit.ToString() + "\n"; + output += "EstateID: " + EstateID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.RegionInfo - public override PacketType Type { get { return PacketType.RegionInfo; } } - /// RegionInfo block - public RegionInfoBlock RegionInfo; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.RegionInfo + public override PacketType Type { get { return PacketType.RegionInfo; } } + /// RegionInfo block + public RegionInfoBlock RegionInfo; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public RegionInfoPacket() - { - Header = new LowHeader(); - Header.ID = 183; - Header.Reliable = true; - Header.Zerocoded = true; - RegionInfo = new RegionInfoBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 183; + Header.Reliable = true; + Header.Zerocoded = true; + RegionInfo = new RegionInfoBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public RegionInfoPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - RegionInfo = new RegionInfoBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + RegionInfo = new RegionInfoBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public RegionInfoPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - RegionInfo = new RegionInfoBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + RegionInfo = new RegionInfoBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += RegionInfo.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - RegionInfo.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += RegionInfo.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + RegionInfo.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- RegionInfo ---\n"; - output += RegionInfo.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- RegionInfo ---\n"; + output += RegionInfo.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// GodUpdateRegionInfo packet + + /// GodUpdateRegionInfo packet public class GodUpdateRegionInfoPacket : Packet - { - /// RegionInfo block + { + /// RegionInfo block public class RegionInfoBlock - { - /// BillableFactor field - public float BillableFactor; - /// RedirectGridX field - public int RedirectGridX; - /// RedirectGridY field - public int RedirectGridY; - private byte[] _simname; - /// SimName field + { + /// BillableFactor field + public float BillableFactor; + /// RedirectGridX field + public int RedirectGridX; + /// RedirectGridY field + public int RedirectGridY; + private byte[] _simname; + /// SimName field public byte[] SimName - { - get { return _simname; } + { + get { return _simname; } set - { - if (value == null) { _simname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _simname = new byte[value.Length]; Array.Copy(value, _simname, value.Length); } + { + if (value == null) { _simname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _simname = new byte[value.Length]; Array.Copy(value, _simname, value.Length); } } - } - /// PricePerMeter field - public int PricePerMeter; - /// RegionFlags field - public uint RegionFlags; - /// ParentEstateID field - public uint ParentEstateID; - /// EstateID field - public uint EstateID; - - /// Length of this block serialized in bytes + } + /// PricePerMeter field + public int PricePerMeter; + /// RegionFlags field + public uint RegionFlags; + /// ParentEstateID field + public uint ParentEstateID; + /// EstateID field + public uint EstateID; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 28; - if (SimName != null) { length += 1 + SimName.Length; } - return length; + { + int length = 28; + if (SimName != null) { length += 1 + SimName.Length; } + return length; } } - - /// Default constructor - public RegionInfoBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public RegionInfoBlock() { } + /// Constructor for building the block from a byte array public RegionInfoBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - BillableFactor = BitConverter.ToSingle(bytes, i); i += 4; - RedirectGridX = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - RedirectGridY = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _simname = new byte[length]; - Array.Copy(bytes, i, _simname, 0, length); i += length; - PricePerMeter = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - RegionFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - ParentEstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - EstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + BillableFactor = BitConverter.ToSingle(bytes, i); i += 4; + RedirectGridX = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + RedirectGridY = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _simname = new byte[length]; + Array.Copy(bytes, i, _simname, 0, length); i += length; + PricePerMeter = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + RegionFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + ParentEstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + EstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; + { + byte[] ba; ba = BitConverter.GetBytes(BillableFactor); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - bytes[i++] = (byte)(RedirectGridX % 256); - bytes[i++] = (byte)((RedirectGridX >> 8) % 256); - bytes[i++] = (byte)((RedirectGridX >> 16) % 256); - bytes[i++] = (byte)((RedirectGridX >> 24) % 256); - bytes[i++] = (byte)(RedirectGridY % 256); - bytes[i++] = (byte)((RedirectGridY >> 8) % 256); - bytes[i++] = (byte)((RedirectGridY >> 16) % 256); - bytes[i++] = (byte)((RedirectGridY >> 24) % 256); - if(SimName == null) { Console.WriteLine("Warning: SimName is null, in " + this.GetType()); } - bytes[i++] = (byte)SimName.Length; - Array.Copy(SimName, 0, bytes, i, SimName.Length); i += SimName.Length; - bytes[i++] = (byte)(PricePerMeter % 256); - bytes[i++] = (byte)((PricePerMeter >> 8) % 256); - bytes[i++] = (byte)((PricePerMeter >> 16) % 256); - bytes[i++] = (byte)((PricePerMeter >> 24) % 256); - bytes[i++] = (byte)(RegionFlags % 256); - bytes[i++] = (byte)((RegionFlags >> 8) % 256); - bytes[i++] = (byte)((RegionFlags >> 16) % 256); - bytes[i++] = (byte)((RegionFlags >> 24) % 256); - bytes[i++] = (byte)(ParentEstateID % 256); - bytes[i++] = (byte)((ParentEstateID >> 8) % 256); - bytes[i++] = (byte)((ParentEstateID >> 16) % 256); - bytes[i++] = (byte)((ParentEstateID >> 24) % 256); - bytes[i++] = (byte)(EstateID % 256); - bytes[i++] = (byte)((EstateID >> 8) % 256); - bytes[i++] = (byte)((EstateID >> 16) % 256); - bytes[i++] = (byte)((EstateID >> 24) % 256); + Array.Copy(ba, 0, bytes, i, 4); i += 4; + bytes[i++] = (byte)(RedirectGridX % 256); + bytes[i++] = (byte)((RedirectGridX >> 8) % 256); + bytes[i++] = (byte)((RedirectGridX >> 16) % 256); + bytes[i++] = (byte)((RedirectGridX >> 24) % 256); + bytes[i++] = (byte)(RedirectGridY % 256); + bytes[i++] = (byte)((RedirectGridY >> 8) % 256); + bytes[i++] = (byte)((RedirectGridY >> 16) % 256); + bytes[i++] = (byte)((RedirectGridY >> 24) % 256); + if(SimName == null) { Console.WriteLine("Warning: SimName is null, in " + this.GetType()); } + bytes[i++] = (byte)SimName.Length; + Array.Copy(SimName, 0, bytes, i, SimName.Length); i += SimName.Length; + bytes[i++] = (byte)(PricePerMeter % 256); + bytes[i++] = (byte)((PricePerMeter >> 8) % 256); + bytes[i++] = (byte)((PricePerMeter >> 16) % 256); + bytes[i++] = (byte)((PricePerMeter >> 24) % 256); + bytes[i++] = (byte)(RegionFlags % 256); + bytes[i++] = (byte)((RegionFlags >> 8) % 256); + bytes[i++] = (byte)((RegionFlags >> 16) % 256); + bytes[i++] = (byte)((RegionFlags >> 24) % 256); + bytes[i++] = (byte)(ParentEstateID % 256); + bytes[i++] = (byte)((ParentEstateID >> 8) % 256); + bytes[i++] = (byte)((ParentEstateID >> 16) % 256); + bytes[i++] = (byte)((ParentEstateID >> 24) % 256); + bytes[i++] = (byte)(EstateID % 256); + bytes[i++] = (byte)((EstateID >> 8) % 256); + bytes[i++] = (byte)((EstateID >> 16) % 256); + bytes[i++] = (byte)((EstateID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- RegionInfo --\n"; - output += "BillableFactor: " + BillableFactor.ToString() + "\n"; - output += "RedirectGridX: " + RedirectGridX.ToString() + "\n"; - output += "RedirectGridY: " + RedirectGridY.ToString() + "\n"; - output += Helpers.FieldToString(SimName, "SimName") + "\n"; - output += "PricePerMeter: " + PricePerMeter.ToString() + "\n"; - output += "RegionFlags: " + RegionFlags.ToString() + "\n"; - output += "ParentEstateID: " + ParentEstateID.ToString() + "\n"; - output += "EstateID: " + EstateID.ToString() + "\n"; + { + string output = "-- RegionInfo --\n"; + output += "BillableFactor: " + BillableFactor.ToString() + "\n"; + output += "RedirectGridX: " + RedirectGridX.ToString() + "\n"; + output += "RedirectGridY: " + RedirectGridY.ToString() + "\n"; + output += Helpers.FieldToString(SimName, "SimName") + "\n"; + output += "PricePerMeter: " + PricePerMeter.ToString() + "\n"; + output += "RegionFlags: " + RegionFlags.ToString() + "\n"; + output += "ParentEstateID: " + ParentEstateID.ToString() + "\n"; + output += "EstateID: " + EstateID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.GodUpdateRegionInfo - public override PacketType Type { get { return PacketType.GodUpdateRegionInfo; } } - /// RegionInfo block - public RegionInfoBlock RegionInfo; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.GodUpdateRegionInfo + public override PacketType Type { get { return PacketType.GodUpdateRegionInfo; } } + /// RegionInfo block + public RegionInfoBlock RegionInfo; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public GodUpdateRegionInfoPacket() - { - Header = new LowHeader(); - Header.ID = 184; - Header.Reliable = true; - Header.Zerocoded = true; - RegionInfo = new RegionInfoBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 184; + Header.Reliable = true; + Header.Zerocoded = true; + RegionInfo = new RegionInfoBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public GodUpdateRegionInfoPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - RegionInfo = new RegionInfoBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + RegionInfo = new RegionInfoBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public GodUpdateRegionInfoPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - RegionInfo = new RegionInfoBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + RegionInfo = new RegionInfoBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += RegionInfo.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - RegionInfo.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += RegionInfo.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + RegionInfo.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- GodUpdateRegionInfo ---\n"; - output += RegionInfo.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- GodUpdateRegionInfo ---\n"; + output += RegionInfo.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// NearestLandingRegionRequest packet + + /// NearestLandingRegionRequest packet public class NearestLandingRegionRequestPacket : Packet - { - /// RequestingRegionData block + { + /// RequestingRegionData block public class RequestingRegionDataBlock - { - /// RegionHandle field - public ulong RegionHandle; - - /// Length of this block serialized in bytes + { + /// RegionHandle field + public ulong RegionHandle; + + /// Length of this block serialized in bytes public int Length { get - { - return 8; + { + return 8; } } - - /// Default constructor - public RequestingRegionDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public RequestingRegionDataBlock() { } + /// Constructor for building the block from a byte array public RequestingRegionDataBlock(byte[] bytes, ref int i) - { + { try - { - RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + { + RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(RegionHandle % 256); - bytes[i++] = (byte)((RegionHandle >> 8) % 256); - bytes[i++] = (byte)((RegionHandle >> 16) % 256); - bytes[i++] = (byte)((RegionHandle >> 24) % 256); - bytes[i++] = (byte)((RegionHandle >> 32) % 256); - bytes[i++] = (byte)((RegionHandle >> 40) % 256); - bytes[i++] = (byte)((RegionHandle >> 48) % 256); - bytes[i++] = (byte)((RegionHandle >> 56) % 256); + { + bytes[i++] = (byte)(RegionHandle % 256); + bytes[i++] = (byte)((RegionHandle >> 8) % 256); + bytes[i++] = (byte)((RegionHandle >> 16) % 256); + bytes[i++] = (byte)((RegionHandle >> 24) % 256); + bytes[i++] = (byte)((RegionHandle >> 32) % 256); + bytes[i++] = (byte)((RegionHandle >> 40) % 256); + bytes[i++] = (byte)((RegionHandle >> 48) % 256); + bytes[i++] = (byte)((RegionHandle >> 56) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- RequestingRegionData --\n"; - output += "RegionHandle: " + RegionHandle.ToString() + "\n"; + { + string output = "-- RequestingRegionData --\n"; + output += "RegionHandle: " + RegionHandle.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.NearestLandingRegionRequest - public override PacketType Type { get { return PacketType.NearestLandingRegionRequest; } } - /// RequestingRegionData block - public RequestingRegionDataBlock RequestingRegionData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.NearestLandingRegionRequest + public override PacketType Type { get { return PacketType.NearestLandingRegionRequest; } } + /// RequestingRegionData block + public RequestingRegionDataBlock RequestingRegionData; + + /// Default constructor public NearestLandingRegionRequestPacket() - { - Header = new LowHeader(); - Header.ID = 185; - Header.Reliable = true; - RequestingRegionData = new RequestingRegionDataBlock(); + { + Header = new LowHeader(); + Header.ID = 185; + Header.Reliable = true; + RequestingRegionData = new RequestingRegionDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public NearestLandingRegionRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - RequestingRegionData = new RequestingRegionDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + RequestingRegionData = new RequestingRegionDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public NearestLandingRegionRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - RequestingRegionData = new RequestingRegionDataBlock(bytes, ref i); + { + Header = head; + RequestingRegionData = new RequestingRegionDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += RequestingRegionData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - RequestingRegionData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += RequestingRegionData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + RequestingRegionData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- NearestLandingRegionRequest ---\n"; - output += RequestingRegionData.ToString() + "\n"; + { + string output = "--- NearestLandingRegionRequest ---\n"; + output += RequestingRegionData.ToString() + "\n"; return output; } - + } - - /// NearestLandingRegionReply packet + + /// NearestLandingRegionReply packet public class NearestLandingRegionReplyPacket : Packet - { - /// LandingRegionData block + { + /// LandingRegionData block public class LandingRegionDataBlock - { - /// RegionHandle field - public ulong RegionHandle; - - /// Length of this block serialized in bytes + { + /// RegionHandle field + public ulong RegionHandle; + + /// Length of this block serialized in bytes public int Length { get - { - return 8; + { + return 8; } } - - /// Default constructor - public LandingRegionDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public LandingRegionDataBlock() { } + /// Constructor for building the block from a byte array public LandingRegionDataBlock(byte[] bytes, ref int i) - { + { try - { - RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + { + RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(RegionHandle % 256); - bytes[i++] = (byte)((RegionHandle >> 8) % 256); - bytes[i++] = (byte)((RegionHandle >> 16) % 256); - bytes[i++] = (byte)((RegionHandle >> 24) % 256); - bytes[i++] = (byte)((RegionHandle >> 32) % 256); - bytes[i++] = (byte)((RegionHandle >> 40) % 256); - bytes[i++] = (byte)((RegionHandle >> 48) % 256); - bytes[i++] = (byte)((RegionHandle >> 56) % 256); + { + bytes[i++] = (byte)(RegionHandle % 256); + bytes[i++] = (byte)((RegionHandle >> 8) % 256); + bytes[i++] = (byte)((RegionHandle >> 16) % 256); + bytes[i++] = (byte)((RegionHandle >> 24) % 256); + bytes[i++] = (byte)((RegionHandle >> 32) % 256); + bytes[i++] = (byte)((RegionHandle >> 40) % 256); + bytes[i++] = (byte)((RegionHandle >> 48) % 256); + bytes[i++] = (byte)((RegionHandle >> 56) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- LandingRegionData --\n"; - output += "RegionHandle: " + RegionHandle.ToString() + "\n"; + { + string output = "-- LandingRegionData --\n"; + output += "RegionHandle: " + RegionHandle.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.NearestLandingRegionReply - public override PacketType Type { get { return PacketType.NearestLandingRegionReply; } } - /// LandingRegionData block - public LandingRegionDataBlock LandingRegionData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.NearestLandingRegionReply + public override PacketType Type { get { return PacketType.NearestLandingRegionReply; } } + /// LandingRegionData block + public LandingRegionDataBlock LandingRegionData; + + /// Default constructor public NearestLandingRegionReplyPacket() - { - Header = new LowHeader(); - Header.ID = 186; - Header.Reliable = true; - LandingRegionData = new LandingRegionDataBlock(); + { + Header = new LowHeader(); + Header.ID = 186; + Header.Reliable = true; + LandingRegionData = new LandingRegionDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public NearestLandingRegionReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - LandingRegionData = new LandingRegionDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + LandingRegionData = new LandingRegionDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public NearestLandingRegionReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - LandingRegionData = new LandingRegionDataBlock(bytes, ref i); + { + Header = head; + LandingRegionData = new LandingRegionDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += LandingRegionData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - LandingRegionData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += LandingRegionData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + LandingRegionData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- NearestLandingRegionReply ---\n"; - output += LandingRegionData.ToString() + "\n"; + { + string output = "--- NearestLandingRegionReply ---\n"; + output += LandingRegionData.ToString() + "\n"; return output; } - + } - - /// NearestLandingRegionUpdated packet + + /// NearestLandingRegionUpdated packet public class NearestLandingRegionUpdatedPacket : Packet - { - /// RegionData block + { + /// RegionData block public class RegionDataBlock - { - /// RegionHandle field - public ulong RegionHandle; - - /// Length of this block serialized in bytes + { + /// RegionHandle field + public ulong RegionHandle; + + /// Length of this block serialized in bytes public int Length { get - { - return 8; + { + return 8; } } - - /// Default constructor - public RegionDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public RegionDataBlock() { } + /// Constructor for building the block from a byte array public RegionDataBlock(byte[] bytes, ref int i) - { + { try - { - RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + { + RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(RegionHandle % 256); - bytes[i++] = (byte)((RegionHandle >> 8) % 256); - bytes[i++] = (byte)((RegionHandle >> 16) % 256); - bytes[i++] = (byte)((RegionHandle >> 24) % 256); - bytes[i++] = (byte)((RegionHandle >> 32) % 256); - bytes[i++] = (byte)((RegionHandle >> 40) % 256); - bytes[i++] = (byte)((RegionHandle >> 48) % 256); - bytes[i++] = (byte)((RegionHandle >> 56) % 256); + { + bytes[i++] = (byte)(RegionHandle % 256); + bytes[i++] = (byte)((RegionHandle >> 8) % 256); + bytes[i++] = (byte)((RegionHandle >> 16) % 256); + bytes[i++] = (byte)((RegionHandle >> 24) % 256); + bytes[i++] = (byte)((RegionHandle >> 32) % 256); + bytes[i++] = (byte)((RegionHandle >> 40) % 256); + bytes[i++] = (byte)((RegionHandle >> 48) % 256); + bytes[i++] = (byte)((RegionHandle >> 56) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- RegionData --\n"; - output += "RegionHandle: " + RegionHandle.ToString() + "\n"; + { + string output = "-- RegionData --\n"; + output += "RegionHandle: " + RegionHandle.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.NearestLandingRegionUpdated - public override PacketType Type { get { return PacketType.NearestLandingRegionUpdated; } } - /// RegionData block - public RegionDataBlock RegionData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.NearestLandingRegionUpdated + public override PacketType Type { get { return PacketType.NearestLandingRegionUpdated; } } + /// RegionData block + public RegionDataBlock RegionData; + + /// Default constructor public NearestLandingRegionUpdatedPacket() - { - Header = new LowHeader(); - Header.ID = 187; - Header.Reliable = true; - RegionData = new RegionDataBlock(); + { + Header = new LowHeader(); + Header.ID = 187; + Header.Reliable = true; + RegionData = new RegionDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public NearestLandingRegionUpdatedPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - RegionData = new RegionDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + RegionData = new RegionDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public NearestLandingRegionUpdatedPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - RegionData = new RegionDataBlock(bytes, ref i); + { + Header = head; + RegionData = new RegionDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += RegionData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - RegionData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += RegionData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + RegionData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- NearestLandingRegionUpdated ---\n"; - output += RegionData.ToString() + "\n"; + { + string output = "--- NearestLandingRegionUpdated ---\n"; + output += RegionData.ToString() + "\n"; return output; } - + } - - /// TeleportLandingStatusChanged packet + + /// TeleportLandingStatusChanged packet public class TeleportLandingStatusChangedPacket : Packet - { - /// RegionData block + { + /// RegionData block public class RegionDataBlock - { - /// RegionHandle field - public ulong RegionHandle; - - /// Length of this block serialized in bytes + { + /// RegionHandle field + public ulong RegionHandle; + + /// Length of this block serialized in bytes public int Length { get - { - return 8; + { + return 8; } } - - /// Default constructor - public RegionDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public RegionDataBlock() { } + /// Constructor for building the block from a byte array public RegionDataBlock(byte[] bytes, ref int i) - { + { try - { - RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + { + RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(RegionHandle % 256); - bytes[i++] = (byte)((RegionHandle >> 8) % 256); - bytes[i++] = (byte)((RegionHandle >> 16) % 256); - bytes[i++] = (byte)((RegionHandle >> 24) % 256); - bytes[i++] = (byte)((RegionHandle >> 32) % 256); - bytes[i++] = (byte)((RegionHandle >> 40) % 256); - bytes[i++] = (byte)((RegionHandle >> 48) % 256); - bytes[i++] = (byte)((RegionHandle >> 56) % 256); + { + bytes[i++] = (byte)(RegionHandle % 256); + bytes[i++] = (byte)((RegionHandle >> 8) % 256); + bytes[i++] = (byte)((RegionHandle >> 16) % 256); + bytes[i++] = (byte)((RegionHandle >> 24) % 256); + bytes[i++] = (byte)((RegionHandle >> 32) % 256); + bytes[i++] = (byte)((RegionHandle >> 40) % 256); + bytes[i++] = (byte)((RegionHandle >> 48) % 256); + bytes[i++] = (byte)((RegionHandle >> 56) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- RegionData --\n"; - output += "RegionHandle: " + RegionHandle.ToString() + "\n"; + { + string output = "-- RegionData --\n"; + output += "RegionHandle: " + RegionHandle.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.TeleportLandingStatusChanged - public override PacketType Type { get { return PacketType.TeleportLandingStatusChanged; } } - /// RegionData block - public RegionDataBlock RegionData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.TeleportLandingStatusChanged + public override PacketType Type { get { return PacketType.TeleportLandingStatusChanged; } } + /// RegionData block + public RegionDataBlock RegionData; + + /// Default constructor public TeleportLandingStatusChangedPacket() - { - Header = new LowHeader(); - Header.ID = 188; - Header.Reliable = true; - RegionData = new RegionDataBlock(); + { + Header = new LowHeader(); + Header.ID = 188; + Header.Reliable = true; + RegionData = new RegionDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public TeleportLandingStatusChangedPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - RegionData = new RegionDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + RegionData = new RegionDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public TeleportLandingStatusChangedPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - RegionData = new RegionDataBlock(bytes, ref i); + { + Header = head; + RegionData = new RegionDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += RegionData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - RegionData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += RegionData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + RegionData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- TeleportLandingStatusChanged ---\n"; - output += RegionData.ToString() + "\n"; + { + string output = "--- TeleportLandingStatusChanged ---\n"; + output += RegionData.ToString() + "\n"; return output; } - + } - - /// RegionHandshake packet + + /// RegionHandshake packet public class RegionHandshakePacket : Packet - { - /// RegionInfo block + { + /// RegionInfo block public class RegionInfoBlock - { - /// BillableFactor field - public float BillableFactor; - /// TerrainHeightRange00 field - public float TerrainHeightRange00; - /// TerrainHeightRange01 field - public float TerrainHeightRange01; - /// TerrainHeightRange10 field - public float TerrainHeightRange10; - /// TerrainHeightRange11 field - public float TerrainHeightRange11; - private byte[] _simname; - /// SimName field + { + /// BillableFactor field + public float BillableFactor; + /// TerrainHeightRange00 field + public float TerrainHeightRange00; + /// TerrainHeightRange01 field + public float TerrainHeightRange01; + /// TerrainHeightRange10 field + public float TerrainHeightRange10; + /// TerrainHeightRange11 field + public float TerrainHeightRange11; + private byte[] _simname; + /// SimName field public byte[] SimName - { - get { return _simname; } + { + get { return _simname; } set - { - if (value == null) { _simname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _simname = new byte[value.Length]; Array.Copy(value, _simname, value.Length); } + { + if (value == null) { _simname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _simname = new byte[value.Length]; Array.Copy(value, _simname, value.Length); } } - } - /// RegionFlags field - public uint RegionFlags; - /// TerrainStartHeight00 field - public float TerrainStartHeight00; - /// TerrainStartHeight01 field - public float TerrainStartHeight01; - /// TerrainStartHeight10 field - public float TerrainStartHeight10; - /// TerrainStartHeight11 field - public float TerrainStartHeight11; - /// WaterHeight field - public float WaterHeight; - /// SimOwner field - public LLUUID SimOwner; - /// SimAccess field - public byte SimAccess; - /// TerrainBase0 field - public LLUUID TerrainBase0; - /// TerrainBase1 field - public LLUUID TerrainBase1; - /// TerrainBase2 field - public LLUUID TerrainBase2; - /// TerrainBase3 field - public LLUUID TerrainBase3; - /// TerrainDetail0 field - public LLUUID TerrainDetail0; - /// TerrainDetail1 field - public LLUUID TerrainDetail1; - /// TerrainDetail2 field - public LLUUID TerrainDetail2; - /// TerrainDetail3 field - public LLUUID TerrainDetail3; - /// IsEstateManager field - public bool IsEstateManager; - /// CacheID field - public LLUUID CacheID; - - /// Length of this block serialized in bytes + } + /// RegionFlags field + public uint RegionFlags; + /// TerrainStartHeight00 field + public float TerrainStartHeight00; + /// TerrainStartHeight01 field + public float TerrainStartHeight01; + /// TerrainStartHeight10 field + public float TerrainStartHeight10; + /// TerrainStartHeight11 field + public float TerrainStartHeight11; + /// WaterHeight field + public float WaterHeight; + /// SimOwner field + public LLUUID SimOwner; + /// SimAccess field + public byte SimAccess; + /// TerrainBase0 field + public LLUUID TerrainBase0; + /// TerrainBase1 field + public LLUUID TerrainBase1; + /// TerrainBase2 field + public LLUUID TerrainBase2; + /// TerrainBase3 field + public LLUUID TerrainBase3; + /// TerrainDetail0 field + public LLUUID TerrainDetail0; + /// TerrainDetail1 field + public LLUUID TerrainDetail1; + /// TerrainDetail2 field + public LLUUID TerrainDetail2; + /// TerrainDetail3 field + public LLUUID TerrainDetail3; + /// IsEstateManager field + public bool IsEstateManager; + /// CacheID field + public LLUUID CacheID; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 206; - if (SimName != null) { length += 1 + SimName.Length; } - return length; + { + int length = 206; + if (SimName != null) { length += 1 + SimName.Length; } + return length; } } - - /// Default constructor - public RegionInfoBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public RegionInfoBlock() { } + /// Constructor for building the block from a byte array public RegionInfoBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - BillableFactor = BitConverter.ToSingle(bytes, i); i += 4; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - TerrainHeightRange00 = BitConverter.ToSingle(bytes, i); i += 4; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - TerrainHeightRange01 = BitConverter.ToSingle(bytes, i); i += 4; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - TerrainHeightRange10 = BitConverter.ToSingle(bytes, i); i += 4; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - TerrainHeightRange11 = BitConverter.ToSingle(bytes, i); i += 4; - length = (ushort)bytes[i++]; - _simname = new byte[length]; - Array.Copy(bytes, i, _simname, 0, length); i += length; - RegionFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - TerrainStartHeight00 = BitConverter.ToSingle(bytes, i); i += 4; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - TerrainStartHeight01 = BitConverter.ToSingle(bytes, i); i += 4; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - TerrainStartHeight10 = BitConverter.ToSingle(bytes, i); i += 4; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - TerrainStartHeight11 = BitConverter.ToSingle(bytes, i); i += 4; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - WaterHeight = BitConverter.ToSingle(bytes, i); i += 4; - SimOwner = new LLUUID(bytes, i); i += 16; - SimAccess = (byte)bytes[i++]; - TerrainBase0 = new LLUUID(bytes, i); i += 16; - TerrainBase1 = new LLUUID(bytes, i); i += 16; - TerrainBase2 = new LLUUID(bytes, i); i += 16; - TerrainBase3 = new LLUUID(bytes, i); i += 16; - TerrainDetail0 = new LLUUID(bytes, i); i += 16; - TerrainDetail1 = new LLUUID(bytes, i); i += 16; - TerrainDetail2 = new LLUUID(bytes, i); i += 16; - TerrainDetail3 = new LLUUID(bytes, i); i += 16; - IsEstateManager = (bytes[i++] != 0) ? (bool)true : (bool)false; - CacheID = new LLUUID(bytes, i); i += 16; + { + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + BillableFactor = BitConverter.ToSingle(bytes, i); i += 4; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + TerrainHeightRange00 = BitConverter.ToSingle(bytes, i); i += 4; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + TerrainHeightRange01 = BitConverter.ToSingle(bytes, i); i += 4; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + TerrainHeightRange10 = BitConverter.ToSingle(bytes, i); i += 4; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + TerrainHeightRange11 = BitConverter.ToSingle(bytes, i); i += 4; + length = (ushort)bytes[i++]; + _simname = new byte[length]; + Array.Copy(bytes, i, _simname, 0, length); i += length; + RegionFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + TerrainStartHeight00 = BitConverter.ToSingle(bytes, i); i += 4; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + TerrainStartHeight01 = BitConverter.ToSingle(bytes, i); i += 4; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + TerrainStartHeight10 = BitConverter.ToSingle(bytes, i); i += 4; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + TerrainStartHeight11 = BitConverter.ToSingle(bytes, i); i += 4; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + WaterHeight = BitConverter.ToSingle(bytes, i); i += 4; + SimOwner = new LLUUID(bytes, i); i += 16; + SimAccess = (byte)bytes[i++]; + TerrainBase0 = new LLUUID(bytes, i); i += 16; + TerrainBase1 = new LLUUID(bytes, i); i += 16; + TerrainBase2 = new LLUUID(bytes, i); i += 16; + TerrainBase3 = new LLUUID(bytes, i); i += 16; + TerrainDetail0 = new LLUUID(bytes, i); i += 16; + TerrainDetail1 = new LLUUID(bytes, i); i += 16; + TerrainDetail2 = new LLUUID(bytes, i); i += 16; + TerrainDetail3 = new LLUUID(bytes, i); i += 16; + IsEstateManager = (bytes[i++] != 0) ? (bool)true : (bool)false; + CacheID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; + { + byte[] ba; ba = BitConverter.GetBytes(BillableFactor); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; ba = BitConverter.GetBytes(TerrainHeightRange00); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; ba = BitConverter.GetBytes(TerrainHeightRange01); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; ba = BitConverter.GetBytes(TerrainHeightRange10); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; ba = BitConverter.GetBytes(TerrainHeightRange11); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - if(SimName == null) { Console.WriteLine("Warning: SimName is null, in " + this.GetType()); } - bytes[i++] = (byte)SimName.Length; - Array.Copy(SimName, 0, bytes, i, SimName.Length); i += SimName.Length; - bytes[i++] = (byte)(RegionFlags % 256); - bytes[i++] = (byte)((RegionFlags >> 8) % 256); - bytes[i++] = (byte)((RegionFlags >> 16) % 256); - bytes[i++] = (byte)((RegionFlags >> 24) % 256); + Array.Copy(ba, 0, bytes, i, 4); i += 4; + if(SimName == null) { Console.WriteLine("Warning: SimName is null, in " + this.GetType()); } + bytes[i++] = (byte)SimName.Length; + Array.Copy(SimName, 0, bytes, i, SimName.Length); i += SimName.Length; + bytes[i++] = (byte)(RegionFlags % 256); + bytes[i++] = (byte)((RegionFlags >> 8) % 256); + bytes[i++] = (byte)((RegionFlags >> 16) % 256); + bytes[i++] = (byte)((RegionFlags >> 24) % 256); ba = BitConverter.GetBytes(TerrainStartHeight00); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; ba = BitConverter.GetBytes(TerrainStartHeight01); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; ba = BitConverter.GetBytes(TerrainStartHeight10); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; ba = BitConverter.GetBytes(TerrainStartHeight11); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; ba = BitConverter.GetBytes(WaterHeight); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - if(SimOwner == null) { Console.WriteLine("Warning: SimOwner is null, in " + this.GetType()); } - Array.Copy(SimOwner.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = SimAccess; - if(TerrainBase0 == null) { Console.WriteLine("Warning: TerrainBase0 is null, in " + this.GetType()); } - Array.Copy(TerrainBase0.GetBytes(), 0, bytes, i, 16); i += 16; - if(TerrainBase1 == null) { Console.WriteLine("Warning: TerrainBase1 is null, in " + this.GetType()); } - Array.Copy(TerrainBase1.GetBytes(), 0, bytes, i, 16); i += 16; - if(TerrainBase2 == null) { Console.WriteLine("Warning: TerrainBase2 is null, in " + this.GetType()); } - Array.Copy(TerrainBase2.GetBytes(), 0, bytes, i, 16); i += 16; - if(TerrainBase3 == null) { Console.WriteLine("Warning: TerrainBase3 is null, in " + this.GetType()); } - Array.Copy(TerrainBase3.GetBytes(), 0, bytes, i, 16); i += 16; - if(TerrainDetail0 == null) { Console.WriteLine("Warning: TerrainDetail0 is null, in " + this.GetType()); } - Array.Copy(TerrainDetail0.GetBytes(), 0, bytes, i, 16); i += 16; - if(TerrainDetail1 == null) { Console.WriteLine("Warning: TerrainDetail1 is null, in " + this.GetType()); } - Array.Copy(TerrainDetail1.GetBytes(), 0, bytes, i, 16); i += 16; - if(TerrainDetail2 == null) { Console.WriteLine("Warning: TerrainDetail2 is null, in " + this.GetType()); } - Array.Copy(TerrainDetail2.GetBytes(), 0, bytes, i, 16); i += 16; - if(TerrainDetail3 == null) { Console.WriteLine("Warning: TerrainDetail3 is null, in " + this.GetType()); } - Array.Copy(TerrainDetail3.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((IsEstateManager) ? 1 : 0); - if(CacheID == null) { Console.WriteLine("Warning: CacheID is null, in " + this.GetType()); } - Array.Copy(CacheID.GetBytes(), 0, bytes, i, 16); i += 16; + Array.Copy(ba, 0, bytes, i, 4); i += 4; + if(SimOwner == null) { Console.WriteLine("Warning: SimOwner is null, in " + this.GetType()); } + Array.Copy(SimOwner.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = SimAccess; + if(TerrainBase0 == null) { Console.WriteLine("Warning: TerrainBase0 is null, in " + this.GetType()); } + Array.Copy(TerrainBase0.GetBytes(), 0, bytes, i, 16); i += 16; + if(TerrainBase1 == null) { Console.WriteLine("Warning: TerrainBase1 is null, in " + this.GetType()); } + Array.Copy(TerrainBase1.GetBytes(), 0, bytes, i, 16); i += 16; + if(TerrainBase2 == null) { Console.WriteLine("Warning: TerrainBase2 is null, in " + this.GetType()); } + Array.Copy(TerrainBase2.GetBytes(), 0, bytes, i, 16); i += 16; + if(TerrainBase3 == null) { Console.WriteLine("Warning: TerrainBase3 is null, in " + this.GetType()); } + Array.Copy(TerrainBase3.GetBytes(), 0, bytes, i, 16); i += 16; + if(TerrainDetail0 == null) { Console.WriteLine("Warning: TerrainDetail0 is null, in " + this.GetType()); } + Array.Copy(TerrainDetail0.GetBytes(), 0, bytes, i, 16); i += 16; + if(TerrainDetail1 == null) { Console.WriteLine("Warning: TerrainDetail1 is null, in " + this.GetType()); } + Array.Copy(TerrainDetail1.GetBytes(), 0, bytes, i, 16); i += 16; + if(TerrainDetail2 == null) { Console.WriteLine("Warning: TerrainDetail2 is null, in " + this.GetType()); } + Array.Copy(TerrainDetail2.GetBytes(), 0, bytes, i, 16); i += 16; + if(TerrainDetail3 == null) { Console.WriteLine("Warning: TerrainDetail3 is null, in " + this.GetType()); } + Array.Copy(TerrainDetail3.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((IsEstateManager) ? 1 : 0); + if(CacheID == null) { Console.WriteLine("Warning: CacheID is null, in " + this.GetType()); } + Array.Copy(CacheID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- RegionInfo --\n"; - output += "BillableFactor: " + BillableFactor.ToString() + "\n"; - output += "TerrainHeightRange00: " + TerrainHeightRange00.ToString() + "\n"; - output += "TerrainHeightRange01: " + TerrainHeightRange01.ToString() + "\n"; - output += "TerrainHeightRange10: " + TerrainHeightRange10.ToString() + "\n"; - output += "TerrainHeightRange11: " + TerrainHeightRange11.ToString() + "\n"; - output += Helpers.FieldToString(SimName, "SimName") + "\n"; - output += "RegionFlags: " + RegionFlags.ToString() + "\n"; - output += "TerrainStartHeight00: " + TerrainStartHeight00.ToString() + "\n"; - output += "TerrainStartHeight01: " + TerrainStartHeight01.ToString() + "\n"; - output += "TerrainStartHeight10: " + TerrainStartHeight10.ToString() + "\n"; - output += "TerrainStartHeight11: " + TerrainStartHeight11.ToString() + "\n"; - output += "WaterHeight: " + WaterHeight.ToString() + "\n"; - output += "SimOwner: " + SimOwner.ToString() + "\n"; - output += "SimAccess: " + SimAccess.ToString() + "\n"; - output += "TerrainBase0: " + TerrainBase0.ToString() + "\n"; - output += "TerrainBase1: " + TerrainBase1.ToString() + "\n"; - output += "TerrainBase2: " + TerrainBase2.ToString() + "\n"; - output += "TerrainBase3: " + TerrainBase3.ToString() + "\n"; - output += "TerrainDetail0: " + TerrainDetail0.ToString() + "\n"; - output += "TerrainDetail1: " + TerrainDetail1.ToString() + "\n"; - output += "TerrainDetail2: " + TerrainDetail2.ToString() + "\n"; - output += "TerrainDetail3: " + TerrainDetail3.ToString() + "\n"; - output += "IsEstateManager: " + IsEstateManager.ToString() + "\n"; - output += "CacheID: " + CacheID.ToString() + "\n"; + { + string output = "-- RegionInfo --\n"; + output += "BillableFactor: " + BillableFactor.ToString() + "\n"; + output += "TerrainHeightRange00: " + TerrainHeightRange00.ToString() + "\n"; + output += "TerrainHeightRange01: " + TerrainHeightRange01.ToString() + "\n"; + output += "TerrainHeightRange10: " + TerrainHeightRange10.ToString() + "\n"; + output += "TerrainHeightRange11: " + TerrainHeightRange11.ToString() + "\n"; + output += Helpers.FieldToString(SimName, "SimName") + "\n"; + output += "RegionFlags: " + RegionFlags.ToString() + "\n"; + output += "TerrainStartHeight00: " + TerrainStartHeight00.ToString() + "\n"; + output += "TerrainStartHeight01: " + TerrainStartHeight01.ToString() + "\n"; + output += "TerrainStartHeight10: " + TerrainStartHeight10.ToString() + "\n"; + output += "TerrainStartHeight11: " + TerrainStartHeight11.ToString() + "\n"; + output += "WaterHeight: " + WaterHeight.ToString() + "\n"; + output += "SimOwner: " + SimOwner.ToString() + "\n"; + output += "SimAccess: " + SimAccess.ToString() + "\n"; + output += "TerrainBase0: " + TerrainBase0.ToString() + "\n"; + output += "TerrainBase1: " + TerrainBase1.ToString() + "\n"; + output += "TerrainBase2: " + TerrainBase2.ToString() + "\n"; + output += "TerrainBase3: " + TerrainBase3.ToString() + "\n"; + output += "TerrainDetail0: " + TerrainDetail0.ToString() + "\n"; + output += "TerrainDetail1: " + TerrainDetail1.ToString() + "\n"; + output += "TerrainDetail2: " + TerrainDetail2.ToString() + "\n"; + output += "TerrainDetail3: " + TerrainDetail3.ToString() + "\n"; + output += "IsEstateManager: " + IsEstateManager.ToString() + "\n"; + output += "CacheID: " + CacheID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.RegionHandshake - public override PacketType Type { get { return PacketType.RegionHandshake; } } - /// RegionInfo block - public RegionInfoBlock RegionInfo; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.RegionHandshake + public override PacketType Type { get { return PacketType.RegionHandshake; } } + /// RegionInfo block + public RegionInfoBlock RegionInfo; + + /// Default constructor public RegionHandshakePacket() - { - Header = new LowHeader(); - Header.ID = 189; - Header.Reliable = true; - Header.Zerocoded = true; - RegionInfo = new RegionInfoBlock(); + { + Header = new LowHeader(); + Header.ID = 189; + Header.Reliable = true; + Header.Zerocoded = true; + RegionInfo = new RegionInfoBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public RegionHandshakePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - RegionInfo = new RegionInfoBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + RegionInfo = new RegionInfoBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public RegionHandshakePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - RegionInfo = new RegionInfoBlock(bytes, ref i); + { + Header = head; + RegionInfo = new RegionInfoBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += RegionInfo.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - RegionInfo.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += RegionInfo.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + RegionInfo.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- RegionHandshake ---\n"; - output += RegionInfo.ToString() + "\n"; + { + string output = "--- RegionHandshake ---\n"; + output += RegionInfo.ToString() + "\n"; return output; } - + } - - /// RegionHandshakeReply packet + + /// RegionHandshakeReply packet public class RegionHandshakeReplyPacket : Packet - { - /// RegionInfo block + { + /// RegionInfo block public class RegionInfoBlock - { - /// Flags field - public uint Flags; - - /// Length of this block serialized in bytes + { + /// Flags field + public uint Flags; + + /// Length of this block serialized in bytes public int Length { get - { - return 4; + { + return 4; } } - - /// Default constructor - public RegionInfoBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public RegionInfoBlock() { } + /// Constructor for building the block from a byte array public RegionInfoBlock(byte[] bytes, ref int i) - { + { try - { - Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(Flags % 256); - bytes[i++] = (byte)((Flags >> 8) % 256); - bytes[i++] = (byte)((Flags >> 16) % 256); - bytes[i++] = (byte)((Flags >> 24) % 256); + { + bytes[i++] = (byte)(Flags % 256); + bytes[i++] = (byte)((Flags >> 8) % 256); + bytes[i++] = (byte)((Flags >> 16) % 256); + bytes[i++] = (byte)((Flags >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- RegionInfo --\n"; - output += "Flags: " + Flags.ToString() + "\n"; + { + string output = "-- RegionInfo --\n"; + output += "Flags: " + Flags.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.RegionHandshakeReply - public override PacketType Type { get { return PacketType.RegionHandshakeReply; } } - /// RegionInfo block - public RegionInfoBlock RegionInfo; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.RegionHandshakeReply + public override PacketType Type { get { return PacketType.RegionHandshakeReply; } } + /// RegionInfo block + public RegionInfoBlock RegionInfo; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public RegionHandshakeReplyPacket() - { - Header = new LowHeader(); - Header.ID = 190; - Header.Reliable = true; - Header.Zerocoded = true; - RegionInfo = new RegionInfoBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 190; + Header.Reliable = true; + Header.Zerocoded = true; + RegionInfo = new RegionInfoBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public RegionHandshakeReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - RegionInfo = new RegionInfoBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + RegionInfo = new RegionInfoBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public RegionHandshakeReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - RegionInfo = new RegionInfoBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + RegionInfo = new RegionInfoBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += RegionInfo.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - RegionInfo.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += RegionInfo.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + RegionInfo.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- RegionHandshakeReply ---\n"; - output += RegionInfo.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- RegionHandshakeReply ---\n"; + output += RegionInfo.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// SimulatorViewerTimeMessage packet + + /// SimulatorViewerTimeMessage packet public class SimulatorViewerTimeMessagePacket : Packet - { - /// TimeInfo block + { + /// TimeInfo block public class TimeInfoBlock - { - /// SecPerDay field - public uint SecPerDay; - /// UsecSinceStart field - public ulong UsecSinceStart; - /// SecPerYear field - public uint SecPerYear; - /// SunAngVelocity field - public LLVector3 SunAngVelocity; - /// SunPhase field - public float SunPhase; - /// SunDirection field - public LLVector3 SunDirection; - - /// Length of this block serialized in bytes + { + /// SecPerDay field + public uint SecPerDay; + /// UsecSinceStart field + public ulong UsecSinceStart; + /// SecPerYear field + public uint SecPerYear; + /// SunAngVelocity field + public LLVector3 SunAngVelocity; + /// SunPhase field + public float SunPhase; + /// SunDirection field + public LLVector3 SunDirection; + + /// Length of this block serialized in bytes public int Length { get - { - return 44; + { + return 44; } } - - /// Default constructor - public TimeInfoBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public TimeInfoBlock() { } + /// Constructor for building the block from a byte array public TimeInfoBlock(byte[] bytes, ref int i) - { + { try - { - SecPerDay = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - UsecSinceStart = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); - SecPerYear = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - SunAngVelocity = new LLVector3(bytes, i); i += 12; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - SunPhase = BitConverter.ToSingle(bytes, i); i += 4; - SunDirection = new LLVector3(bytes, i); i += 12; + { + SecPerDay = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + UsecSinceStart = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + SecPerYear = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + SunAngVelocity = new LLVector3(bytes, i); i += 12; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + SunPhase = BitConverter.ToSingle(bytes, i); i += 4; + SunDirection = new LLVector3(bytes, i); i += 12; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; - bytes[i++] = (byte)(SecPerDay % 256); - bytes[i++] = (byte)((SecPerDay >> 8) % 256); - bytes[i++] = (byte)((SecPerDay >> 16) % 256); - bytes[i++] = (byte)((SecPerDay >> 24) % 256); - bytes[i++] = (byte)(UsecSinceStart % 256); - bytes[i++] = (byte)((UsecSinceStart >> 8) % 256); - bytes[i++] = (byte)((UsecSinceStart >> 16) % 256); - bytes[i++] = (byte)((UsecSinceStart >> 24) % 256); - bytes[i++] = (byte)((UsecSinceStart >> 32) % 256); - bytes[i++] = (byte)((UsecSinceStart >> 40) % 256); - bytes[i++] = (byte)((UsecSinceStart >> 48) % 256); - bytes[i++] = (byte)((UsecSinceStart >> 56) % 256); - bytes[i++] = (byte)(SecPerYear % 256); - bytes[i++] = (byte)((SecPerYear >> 8) % 256); - bytes[i++] = (byte)((SecPerYear >> 16) % 256); - bytes[i++] = (byte)((SecPerYear >> 24) % 256); - if(SunAngVelocity == null) { Console.WriteLine("Warning: SunAngVelocity is null, in " + this.GetType()); } - Array.Copy(SunAngVelocity.GetBytes(), 0, bytes, i, 12); i += 12; + { + byte[] ba; + bytes[i++] = (byte)(SecPerDay % 256); + bytes[i++] = (byte)((SecPerDay >> 8) % 256); + bytes[i++] = (byte)((SecPerDay >> 16) % 256); + bytes[i++] = (byte)((SecPerDay >> 24) % 256); + bytes[i++] = (byte)(UsecSinceStart % 256); + bytes[i++] = (byte)((UsecSinceStart >> 8) % 256); + bytes[i++] = (byte)((UsecSinceStart >> 16) % 256); + bytes[i++] = (byte)((UsecSinceStart >> 24) % 256); + bytes[i++] = (byte)((UsecSinceStart >> 32) % 256); + bytes[i++] = (byte)((UsecSinceStart >> 40) % 256); + bytes[i++] = (byte)((UsecSinceStart >> 48) % 256); + bytes[i++] = (byte)((UsecSinceStart >> 56) % 256); + bytes[i++] = (byte)(SecPerYear % 256); + bytes[i++] = (byte)((SecPerYear >> 8) % 256); + bytes[i++] = (byte)((SecPerYear >> 16) % 256); + bytes[i++] = (byte)((SecPerYear >> 24) % 256); + if(SunAngVelocity == null) { Console.WriteLine("Warning: SunAngVelocity is null, in " + this.GetType()); } + Array.Copy(SunAngVelocity.GetBytes(), 0, bytes, i, 12); i += 12; ba = BitConverter.GetBytes(SunPhase); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - if(SunDirection == null) { Console.WriteLine("Warning: SunDirection is null, in " + this.GetType()); } - Array.Copy(SunDirection.GetBytes(), 0, bytes, i, 12); i += 12; + Array.Copy(ba, 0, bytes, i, 4); i += 4; + if(SunDirection == null) { Console.WriteLine("Warning: SunDirection is null, in " + this.GetType()); } + Array.Copy(SunDirection.GetBytes(), 0, bytes, i, 12); i += 12; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- TimeInfo --\n"; - output += "SecPerDay: " + SecPerDay.ToString() + "\n"; - output += "UsecSinceStart: " + UsecSinceStart.ToString() + "\n"; - output += "SecPerYear: " + SecPerYear.ToString() + "\n"; - output += "SunAngVelocity: " + SunAngVelocity.ToString() + "\n"; - output += "SunPhase: " + SunPhase.ToString() + "\n"; - output += "SunDirection: " + SunDirection.ToString() + "\n"; + { + string output = "-- TimeInfo --\n"; + output += "SecPerDay: " + SecPerDay.ToString() + "\n"; + output += "UsecSinceStart: " + UsecSinceStart.ToString() + "\n"; + output += "SecPerYear: " + SecPerYear.ToString() + "\n"; + output += "SunAngVelocity: " + SunAngVelocity.ToString() + "\n"; + output += "SunPhase: " + SunPhase.ToString() + "\n"; + output += "SunDirection: " + SunDirection.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.SimulatorViewerTimeMessage - public override PacketType Type { get { return PacketType.SimulatorViewerTimeMessage; } } - /// TimeInfo block - public TimeInfoBlock TimeInfo; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.SimulatorViewerTimeMessage + public override PacketType Type { get { return PacketType.SimulatorViewerTimeMessage; } } + /// TimeInfo block + public TimeInfoBlock TimeInfo; + + /// Default constructor public SimulatorViewerTimeMessagePacket() - { - Header = new LowHeader(); - Header.ID = 191; - Header.Reliable = true; - TimeInfo = new TimeInfoBlock(); + { + Header = new LowHeader(); + Header.ID = 191; + Header.Reliable = true; + TimeInfo = new TimeInfoBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public SimulatorViewerTimeMessagePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - TimeInfo = new TimeInfoBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + TimeInfo = new TimeInfoBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public SimulatorViewerTimeMessagePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - TimeInfo = new TimeInfoBlock(bytes, ref i); + { + Header = head; + TimeInfo = new TimeInfoBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += TimeInfo.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - TimeInfo.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += TimeInfo.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + TimeInfo.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- SimulatorViewerTimeMessage ---\n"; - output += TimeInfo.ToString() + "\n"; + { + string output = "--- SimulatorViewerTimeMessage ---\n"; + output += TimeInfo.ToString() + "\n"; return output; } - + } - - /// EnableSimulator packet + + /// EnableSimulator packet public class EnableSimulatorPacket : Packet - { - /// SimulatorInfo block + { + /// SimulatorInfo block public class SimulatorInfoBlock - { - /// IP field - public uint IP; - /// Port field - public ushort Port; - /// Handle field - public ulong Handle; - - /// Length of this block serialized in bytes + { + /// IP field + public uint IP; + /// Port field + public ushort Port; + /// Handle field + public ulong Handle; + + /// Length of this block serialized in bytes public int Length { get - { - return 14; + { + return 14; } } - - /// Default constructor - public SimulatorInfoBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public SimulatorInfoBlock() { } + /// Constructor for building the block from a byte array public SimulatorInfoBlock(byte[] bytes, ref int i) - { + { try - { - IP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Port = (ushort)((bytes[i++] << 8) + bytes[i++]); - Handle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + { + IP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Port = (ushort)((bytes[i++] << 8) + bytes[i++]); + Handle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(IP % 256); - bytes[i++] = (byte)((IP >> 8) % 256); - bytes[i++] = (byte)((IP >> 16) % 256); - bytes[i++] = (byte)((IP >> 24) % 256); - bytes[i++] = (byte)((Port >> 8) % 256); - bytes[i++] = (byte)(Port % 256); - bytes[i++] = (byte)(Handle % 256); - bytes[i++] = (byte)((Handle >> 8) % 256); - bytes[i++] = (byte)((Handle >> 16) % 256); - bytes[i++] = (byte)((Handle >> 24) % 256); - bytes[i++] = (byte)((Handle >> 32) % 256); - bytes[i++] = (byte)((Handle >> 40) % 256); - bytes[i++] = (byte)((Handle >> 48) % 256); - bytes[i++] = (byte)((Handle >> 56) % 256); + { + bytes[i++] = (byte)(IP % 256); + bytes[i++] = (byte)((IP >> 8) % 256); + bytes[i++] = (byte)((IP >> 16) % 256); + bytes[i++] = (byte)((IP >> 24) % 256); + bytes[i++] = (byte)((Port >> 8) % 256); + bytes[i++] = (byte)(Port % 256); + bytes[i++] = (byte)(Handle % 256); + bytes[i++] = (byte)((Handle >> 8) % 256); + bytes[i++] = (byte)((Handle >> 16) % 256); + bytes[i++] = (byte)((Handle >> 24) % 256); + bytes[i++] = (byte)((Handle >> 32) % 256); + bytes[i++] = (byte)((Handle >> 40) % 256); + bytes[i++] = (byte)((Handle >> 48) % 256); + bytes[i++] = (byte)((Handle >> 56) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- SimulatorInfo --\n"; - output += "IP: " + IP.ToString() + "\n"; - output += "Port: " + Port.ToString() + "\n"; - output += "Handle: " + Handle.ToString() + "\n"; + { + string output = "-- SimulatorInfo --\n"; + output += "IP: " + IP.ToString() + "\n"; + output += "Port: " + Port.ToString() + "\n"; + output += "Handle: " + Handle.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.EnableSimulator - public override PacketType Type { get { return PacketType.EnableSimulator; } } - /// SimulatorInfo block - public SimulatorInfoBlock SimulatorInfo; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.EnableSimulator + public override PacketType Type { get { return PacketType.EnableSimulator; } } + /// SimulatorInfo block + public SimulatorInfoBlock SimulatorInfo; + + /// Default constructor public EnableSimulatorPacket() - { - Header = new LowHeader(); - Header.ID = 192; - Header.Reliable = true; - SimulatorInfo = new SimulatorInfoBlock(); + { + Header = new LowHeader(); + Header.ID = 192; + Header.Reliable = true; + SimulatorInfo = new SimulatorInfoBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public EnableSimulatorPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - SimulatorInfo = new SimulatorInfoBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + SimulatorInfo = new SimulatorInfoBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public EnableSimulatorPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - SimulatorInfo = new SimulatorInfoBlock(bytes, ref i); + { + Header = head; + SimulatorInfo = new SimulatorInfoBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += SimulatorInfo.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - SimulatorInfo.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += SimulatorInfo.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + SimulatorInfo.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- EnableSimulator ---\n"; - output += SimulatorInfo.ToString() + "\n"; + { + string output = "--- EnableSimulator ---\n"; + output += SimulatorInfo.ToString() + "\n"; return output; } - + } - - /// DisableSimulator packet + + /// DisableSimulator packet public class DisableSimulatorPacket : Packet - { - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.DisableSimulator - public override PacketType Type { get { return PacketType.DisableSimulator; } } - - /// Default constructor + { + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.DisableSimulator + public override PacketType Type { get { return PacketType.DisableSimulator; } } + + /// Default constructor public DisableSimulatorPacket() - { - Header = new LowHeader(); - Header.ID = 193; - Header.Reliable = true; + { + Header = new LowHeader(); + Header.ID = 193; + Header.Reliable = true; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public DisableSimulatorPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public DisableSimulatorPacket(Header head, byte[] bytes, ref int i) - { - Header = head; + { + Header = head; } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; -; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; +; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- DisableSimulator ---\n"; + { + string output = "--- DisableSimulator ---\n"; return output; } - + } - - /// TransferRequest packet + + /// TransferRequest packet public class TransferRequestPacket : Packet - { - /// TransferInfo block + { + /// TransferInfo block public class TransferInfoBlock - { - /// TransferID field - public LLUUID TransferID; - private byte[] _params; - /// Params field + { + /// TransferID field + public LLUUID TransferID; + private byte[] _params; + /// Params field public byte[] Params - { - get { return _params; } + { + get { return _params; } set - { - if (value == null) { _params = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _params = new byte[value.Length]; Array.Copy(value, _params, value.Length); } + { + if (value == null) { _params = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _params = new byte[value.Length]; Array.Copy(value, _params, value.Length); } } - } - /// ChannelType field - public int ChannelType; - /// SourceType field - public int SourceType; - /// Priority field - public float Priority; - - /// Length of this block serialized in bytes + } + /// ChannelType field + public int ChannelType; + /// SourceType field + public int SourceType; + /// Priority field + public float Priority; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 28; - if (Params != null) { length += 2 + Params.Length; } - return length; + { + int length = 28; + if (Params != null) { length += 2 + Params.Length; } + return length; } } - - /// Default constructor - public TransferInfoBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public TransferInfoBlock() { } + /// Constructor for building the block from a byte array public TransferInfoBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - TransferID = new LLUUID(bytes, i); i += 16; - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _params = new byte[length]; - Array.Copy(bytes, i, _params, 0, length); i += length; - ChannelType = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - SourceType = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - Priority = BitConverter.ToSingle(bytes, i); i += 4; + { + TransferID = new LLUUID(bytes, i); i += 16; + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _params = new byte[length]; + Array.Copy(bytes, i, _params, 0, length); i += length; + ChannelType = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + SourceType = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + Priority = BitConverter.ToSingle(bytes, i); i += 4; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; - if(TransferID == null) { Console.WriteLine("Warning: TransferID is null, in " + this.GetType()); } - Array.Copy(TransferID.GetBytes(), 0, bytes, i, 16); i += 16; - if(Params == null) { Console.WriteLine("Warning: Params is null, in " + this.GetType()); } - bytes[i++] = (byte)(Params.Length % 256); - bytes[i++] = (byte)((Params.Length >> 8) % 256); - Array.Copy(Params, 0, bytes, i, Params.Length); i += Params.Length; - bytes[i++] = (byte)(ChannelType % 256); - bytes[i++] = (byte)((ChannelType >> 8) % 256); - bytes[i++] = (byte)((ChannelType >> 16) % 256); - bytes[i++] = (byte)((ChannelType >> 24) % 256); - bytes[i++] = (byte)(SourceType % 256); - bytes[i++] = (byte)((SourceType >> 8) % 256); - bytes[i++] = (byte)((SourceType >> 16) % 256); - bytes[i++] = (byte)((SourceType >> 24) % 256); + { + byte[] ba; + if(TransferID == null) { Console.WriteLine("Warning: TransferID is null, in " + this.GetType()); } + Array.Copy(TransferID.GetBytes(), 0, bytes, i, 16); i += 16; + if(Params == null) { Console.WriteLine("Warning: Params is null, in " + this.GetType()); } + bytes[i++] = (byte)(Params.Length % 256); + bytes[i++] = (byte)((Params.Length >> 8) % 256); + Array.Copy(Params, 0, bytes, i, Params.Length); i += Params.Length; + bytes[i++] = (byte)(ChannelType % 256); + bytes[i++] = (byte)((ChannelType >> 8) % 256); + bytes[i++] = (byte)((ChannelType >> 16) % 256); + bytes[i++] = (byte)((ChannelType >> 24) % 256); + bytes[i++] = (byte)(SourceType % 256); + bytes[i++] = (byte)((SourceType >> 8) % 256); + bytes[i++] = (byte)((SourceType >> 16) % 256); + bytes[i++] = (byte)((SourceType >> 24) % 256); ba = BitConverter.GetBytes(Priority); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- TransferInfo --\n"; - output += "TransferID: " + TransferID.ToString() + "\n"; - output += Helpers.FieldToString(Params, "Params") + "\n"; - output += "ChannelType: " + ChannelType.ToString() + "\n"; - output += "SourceType: " + SourceType.ToString() + "\n"; - output += "Priority: " + Priority.ToString() + "\n"; + { + string output = "-- TransferInfo --\n"; + output += "TransferID: " + TransferID.ToString() + "\n"; + output += Helpers.FieldToString(Params, "Params") + "\n"; + output += "ChannelType: " + ChannelType.ToString() + "\n"; + output += "SourceType: " + SourceType.ToString() + "\n"; + output += "Priority: " + Priority.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.TransferRequest - public override PacketType Type { get { return PacketType.TransferRequest; } } - /// TransferInfo block - public TransferInfoBlock TransferInfo; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.TransferRequest + public override PacketType Type { get { return PacketType.TransferRequest; } } + /// TransferInfo block + public TransferInfoBlock TransferInfo; + + /// Default constructor public TransferRequestPacket() - { - Header = new LowHeader(); - Header.ID = 194; - Header.Reliable = true; - Header.Zerocoded = true; - TransferInfo = new TransferInfoBlock(); + { + Header = new LowHeader(); + Header.ID = 194; + Header.Reliable = true; + Header.Zerocoded = true; + TransferInfo = new TransferInfoBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public TransferRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - TransferInfo = new TransferInfoBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + TransferInfo = new TransferInfoBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public TransferRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - TransferInfo = new TransferInfoBlock(bytes, ref i); + { + Header = head; + TransferInfo = new TransferInfoBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += TransferInfo.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - TransferInfo.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += TransferInfo.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + TransferInfo.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- TransferRequest ---\n"; - output += TransferInfo.ToString() + "\n"; + { + string output = "--- TransferRequest ---\n"; + output += TransferInfo.ToString() + "\n"; return output; } - + } - - /// TransferInfo packet + + /// TransferInfo packet public class TransferInfoPacket : Packet - { - /// TransferInfo block + { + /// TransferInfo block public class TransferInfoBlock - { - /// TransferID field - public LLUUID TransferID; - /// Size field - public int Size; - /// ChannelType field - public int ChannelType; - /// TargetType field - public int TargetType; - /// Status field - public int Status; - - /// Length of this block serialized in bytes + { + /// TransferID field + public LLUUID TransferID; + /// Size field + public int Size; + /// ChannelType field + public int ChannelType; + /// TargetType field + public int TargetType; + /// Status field + public int Status; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public TransferInfoBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public TransferInfoBlock() { } + /// Constructor for building the block from a byte array public TransferInfoBlock(byte[] bytes, ref int i) - { + { try - { - TransferID = new LLUUID(bytes, i); i += 16; - Size = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - ChannelType = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - TargetType = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Status = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + TransferID = new LLUUID(bytes, i); i += 16; + Size = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + ChannelType = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + TargetType = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Status = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(TransferID == null) { Console.WriteLine("Warning: TransferID is null, in " + this.GetType()); } - Array.Copy(TransferID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(Size % 256); - bytes[i++] = (byte)((Size >> 8) % 256); - bytes[i++] = (byte)((Size >> 16) % 256); - bytes[i++] = (byte)((Size >> 24) % 256); - bytes[i++] = (byte)(ChannelType % 256); - bytes[i++] = (byte)((ChannelType >> 8) % 256); - bytes[i++] = (byte)((ChannelType >> 16) % 256); - bytes[i++] = (byte)((ChannelType >> 24) % 256); - bytes[i++] = (byte)(TargetType % 256); - bytes[i++] = (byte)((TargetType >> 8) % 256); - bytes[i++] = (byte)((TargetType >> 16) % 256); - bytes[i++] = (byte)((TargetType >> 24) % 256); - bytes[i++] = (byte)(Status % 256); - bytes[i++] = (byte)((Status >> 8) % 256); - bytes[i++] = (byte)((Status >> 16) % 256); - bytes[i++] = (byte)((Status >> 24) % 256); + { + if(TransferID == null) { Console.WriteLine("Warning: TransferID is null, in " + this.GetType()); } + Array.Copy(TransferID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(Size % 256); + bytes[i++] = (byte)((Size >> 8) % 256); + bytes[i++] = (byte)((Size >> 16) % 256); + bytes[i++] = (byte)((Size >> 24) % 256); + bytes[i++] = (byte)(ChannelType % 256); + bytes[i++] = (byte)((ChannelType >> 8) % 256); + bytes[i++] = (byte)((ChannelType >> 16) % 256); + bytes[i++] = (byte)((ChannelType >> 24) % 256); + bytes[i++] = (byte)(TargetType % 256); + bytes[i++] = (byte)((TargetType >> 8) % 256); + bytes[i++] = (byte)((TargetType >> 16) % 256); + bytes[i++] = (byte)((TargetType >> 24) % 256); + bytes[i++] = (byte)(Status % 256); + bytes[i++] = (byte)((Status >> 8) % 256); + bytes[i++] = (byte)((Status >> 16) % 256); + bytes[i++] = (byte)((Status >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- TransferInfo --\n"; - output += "TransferID: " + TransferID.ToString() + "\n"; - output += "Size: " + Size.ToString() + "\n"; - output += "ChannelType: " + ChannelType.ToString() + "\n"; - output += "TargetType: " + TargetType.ToString() + "\n"; - output += "Status: " + Status.ToString() + "\n"; + { + string output = "-- TransferInfo --\n"; + output += "TransferID: " + TransferID.ToString() + "\n"; + output += "Size: " + Size.ToString() + "\n"; + output += "ChannelType: " + ChannelType.ToString() + "\n"; + output += "TargetType: " + TargetType.ToString() + "\n"; + output += "Status: " + Status.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.TransferInfo - public override PacketType Type { get { return PacketType.TransferInfo; } } - /// TransferInfo block - public TransferInfoBlock TransferInfo; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.TransferInfo + public override PacketType Type { get { return PacketType.TransferInfo; } } + /// TransferInfo block + public TransferInfoBlock TransferInfo; + + /// Default constructor public TransferInfoPacket() - { - Header = new LowHeader(); - Header.ID = 195; - Header.Reliable = true; - Header.Zerocoded = true; - TransferInfo = new TransferInfoBlock(); + { + Header = new LowHeader(); + Header.ID = 195; + Header.Reliable = true; + Header.Zerocoded = true; + TransferInfo = new TransferInfoBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public TransferInfoPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - TransferInfo = new TransferInfoBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + TransferInfo = new TransferInfoBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public TransferInfoPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - TransferInfo = new TransferInfoBlock(bytes, ref i); + { + Header = head; + TransferInfo = new TransferInfoBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += TransferInfo.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - TransferInfo.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += TransferInfo.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + TransferInfo.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- TransferInfo ---\n"; - output += TransferInfo.ToString() + "\n"; + { + string output = "--- TransferInfo ---\n"; + output += TransferInfo.ToString() + "\n"; return output; } - + } - - /// TransferAbort packet + + /// TransferAbort packet public class TransferAbortPacket : Packet - { - /// TransferInfo block + { + /// TransferInfo block public class TransferInfoBlock - { - /// TransferID field - public LLUUID TransferID; - /// ChannelType field - public int ChannelType; - - /// Length of this block serialized in bytes + { + /// TransferID field + public LLUUID TransferID; + /// ChannelType field + public int ChannelType; + + /// Length of this block serialized in bytes public int Length { get - { - return 20; + { + return 20; } } - - /// Default constructor - public TransferInfoBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public TransferInfoBlock() { } + /// Constructor for building the block from a byte array public TransferInfoBlock(byte[] bytes, ref int i) - { + { try - { - TransferID = new LLUUID(bytes, i); i += 16; - ChannelType = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + TransferID = new LLUUID(bytes, i); i += 16; + ChannelType = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(TransferID == null) { Console.WriteLine("Warning: TransferID is null, in " + this.GetType()); } - Array.Copy(TransferID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(ChannelType % 256); - bytes[i++] = (byte)((ChannelType >> 8) % 256); - bytes[i++] = (byte)((ChannelType >> 16) % 256); - bytes[i++] = (byte)((ChannelType >> 24) % 256); + { + if(TransferID == null) { Console.WriteLine("Warning: TransferID is null, in " + this.GetType()); } + Array.Copy(TransferID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(ChannelType % 256); + bytes[i++] = (byte)((ChannelType >> 8) % 256); + bytes[i++] = (byte)((ChannelType >> 16) % 256); + bytes[i++] = (byte)((ChannelType >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- TransferInfo --\n"; - output += "TransferID: " + TransferID.ToString() + "\n"; - output += "ChannelType: " + ChannelType.ToString() + "\n"; + { + string output = "-- TransferInfo --\n"; + output += "TransferID: " + TransferID.ToString() + "\n"; + output += "ChannelType: " + ChannelType.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.TransferAbort - public override PacketType Type { get { return PacketType.TransferAbort; } } - /// TransferInfo block - public TransferInfoBlock TransferInfo; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.TransferAbort + public override PacketType Type { get { return PacketType.TransferAbort; } } + /// TransferInfo block + public TransferInfoBlock TransferInfo; + + /// Default constructor public TransferAbortPacket() - { - Header = new LowHeader(); - Header.ID = 196; - Header.Reliable = true; - Header.Zerocoded = true; - TransferInfo = new TransferInfoBlock(); + { + Header = new LowHeader(); + Header.ID = 196; + Header.Reliable = true; + Header.Zerocoded = true; + TransferInfo = new TransferInfoBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public TransferAbortPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - TransferInfo = new TransferInfoBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + TransferInfo = new TransferInfoBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public TransferAbortPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - TransferInfo = new TransferInfoBlock(bytes, ref i); + { + Header = head; + TransferInfo = new TransferInfoBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += TransferInfo.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - TransferInfo.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += TransferInfo.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + TransferInfo.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- TransferAbort ---\n"; - output += TransferInfo.ToString() + "\n"; + { + string output = "--- TransferAbort ---\n"; + output += TransferInfo.ToString() + "\n"; return output; } - + } - - /// TransferPriority packet + + /// TransferPriority packet public class TransferPriorityPacket : Packet - { - /// TransferInfo block + { + /// TransferInfo block public class TransferInfoBlock - { - /// TransferID field - public LLUUID TransferID; - /// ChannelType field - public int ChannelType; - /// Priority field - public float Priority; - - /// Length of this block serialized in bytes + { + /// TransferID field + public LLUUID TransferID; + /// ChannelType field + public int ChannelType; + /// Priority field + public float Priority; + + /// Length of this block serialized in bytes public int Length { get - { - return 24; + { + return 24; } } - - /// Default constructor - public TransferInfoBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public TransferInfoBlock() { } + /// Constructor for building the block from a byte array public TransferInfoBlock(byte[] bytes, ref int i) - { + { try - { - TransferID = new LLUUID(bytes, i); i += 16; - ChannelType = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - Priority = BitConverter.ToSingle(bytes, i); i += 4; + { + TransferID = new LLUUID(bytes, i); i += 16; + ChannelType = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + Priority = BitConverter.ToSingle(bytes, i); i += 4; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; - if(TransferID == null) { Console.WriteLine("Warning: TransferID is null, in " + this.GetType()); } - Array.Copy(TransferID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(ChannelType % 256); - bytes[i++] = (byte)((ChannelType >> 8) % 256); - bytes[i++] = (byte)((ChannelType >> 16) % 256); - bytes[i++] = (byte)((ChannelType >> 24) % 256); + { + byte[] ba; + if(TransferID == null) { Console.WriteLine("Warning: TransferID is null, in " + this.GetType()); } + Array.Copy(TransferID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(ChannelType % 256); + bytes[i++] = (byte)((ChannelType >> 8) % 256); + bytes[i++] = (byte)((ChannelType >> 16) % 256); + bytes[i++] = (byte)((ChannelType >> 24) % 256); ba = BitConverter.GetBytes(Priority); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- TransferInfo --\n"; - output += "TransferID: " + TransferID.ToString() + "\n"; - output += "ChannelType: " + ChannelType.ToString() + "\n"; - output += "Priority: " + Priority.ToString() + "\n"; + { + string output = "-- TransferInfo --\n"; + output += "TransferID: " + TransferID.ToString() + "\n"; + output += "ChannelType: " + ChannelType.ToString() + "\n"; + output += "Priority: " + Priority.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.TransferPriority - public override PacketType Type { get { return PacketType.TransferPriority; } } - /// TransferInfo block - public TransferInfoBlock TransferInfo; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.TransferPriority + public override PacketType Type { get { return PacketType.TransferPriority; } } + /// TransferInfo block + public TransferInfoBlock TransferInfo; + + /// Default constructor public TransferPriorityPacket() - { - Header = new LowHeader(); - Header.ID = 197; - Header.Reliable = true; - Header.Zerocoded = true; - TransferInfo = new TransferInfoBlock(); + { + Header = new LowHeader(); + Header.ID = 197; + Header.Reliable = true; + Header.Zerocoded = true; + TransferInfo = new TransferInfoBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public TransferPriorityPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - TransferInfo = new TransferInfoBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + TransferInfo = new TransferInfoBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public TransferPriorityPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - TransferInfo = new TransferInfoBlock(bytes, ref i); + { + Header = head; + TransferInfo = new TransferInfoBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += TransferInfo.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - TransferInfo.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += TransferInfo.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + TransferInfo.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- TransferPriority ---\n"; - output += TransferInfo.ToString() + "\n"; + { + string output = "--- TransferPriority ---\n"; + output += TransferInfo.ToString() + "\n"; return output; } - + } - - /// RequestXfer packet + + /// RequestXfer packet public class RequestXferPacket : Packet - { - /// XferID block + { + /// XferID block public class XferIDBlock - { - /// ID field - public ulong ID; - /// UseBigPackets field - public bool UseBigPackets; - /// DeleteOnCompletion field - public bool DeleteOnCompletion; - /// FilePath field - public byte FilePath; - private byte[] _filename; - /// Filename field + { + /// ID field + public ulong ID; + /// UseBigPackets field + public bool UseBigPackets; + /// DeleteOnCompletion field + public bool DeleteOnCompletion; + /// FilePath field + public byte FilePath; + private byte[] _filename; + /// Filename field public byte[] Filename - { - get { return _filename; } + { + get { return _filename; } set - { - if (value == null) { _filename = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _filename = new byte[value.Length]; Array.Copy(value, _filename, value.Length); } + { + if (value == null) { _filename = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _filename = new byte[value.Length]; Array.Copy(value, _filename, value.Length); } } - } - /// VFileID field - public LLUUID VFileID; - /// VFileType field - public short VFileType; - - /// Length of this block serialized in bytes + } + /// VFileID field + public LLUUID VFileID; + /// VFileType field + public short VFileType; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 29; - if (Filename != null) { length += 1 + Filename.Length; } - return length; + { + int length = 29; + if (Filename != null) { length += 1 + Filename.Length; } + return length; } } - - /// Default constructor - public XferIDBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public XferIDBlock() { } + /// Constructor for building the block from a byte array public XferIDBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - ID = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); - UseBigPackets = (bytes[i++] != 0) ? (bool)true : (bool)false; - DeleteOnCompletion = (bytes[i++] != 0) ? (bool)true : (bool)false; - FilePath = (byte)bytes[i++]; - length = (ushort)bytes[i++]; - _filename = new byte[length]; - Array.Copy(bytes, i, _filename, 0, length); i += length; - VFileID = new LLUUID(bytes, i); i += 16; - VFileType = (short)(bytes[i++] + (bytes[i++] << 8)); + { + ID = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + UseBigPackets = (bytes[i++] != 0) ? (bool)true : (bool)false; + DeleteOnCompletion = (bytes[i++] != 0) ? (bool)true : (bool)false; + FilePath = (byte)bytes[i++]; + length = (ushort)bytes[i++]; + _filename = new byte[length]; + Array.Copy(bytes, i, _filename, 0, length); i += length; + VFileID = new LLUUID(bytes, i); i += 16; + VFileType = (short)(bytes[i++] + (bytes[i++] << 8)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(ID % 256); - bytes[i++] = (byte)((ID >> 8) % 256); - bytes[i++] = (byte)((ID >> 16) % 256); - bytes[i++] = (byte)((ID >> 24) % 256); - bytes[i++] = (byte)((ID >> 32) % 256); - bytes[i++] = (byte)((ID >> 40) % 256); - bytes[i++] = (byte)((ID >> 48) % 256); - bytes[i++] = (byte)((ID >> 56) % 256); - bytes[i++] = (byte)((UseBigPackets) ? 1 : 0); - bytes[i++] = (byte)((DeleteOnCompletion) ? 1 : 0); - bytes[i++] = FilePath; - if(Filename == null) { Console.WriteLine("Warning: Filename is null, in " + this.GetType()); } - bytes[i++] = (byte)Filename.Length; - Array.Copy(Filename, 0, bytes, i, Filename.Length); i += Filename.Length; - if(VFileID == null) { Console.WriteLine("Warning: VFileID is null, in " + this.GetType()); } - Array.Copy(VFileID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(VFileType % 256); - bytes[i++] = (byte)((VFileType >> 8) % 256); + { + bytes[i++] = (byte)(ID % 256); + bytes[i++] = (byte)((ID >> 8) % 256); + bytes[i++] = (byte)((ID >> 16) % 256); + bytes[i++] = (byte)((ID >> 24) % 256); + bytes[i++] = (byte)((ID >> 32) % 256); + bytes[i++] = (byte)((ID >> 40) % 256); + bytes[i++] = (byte)((ID >> 48) % 256); + bytes[i++] = (byte)((ID >> 56) % 256); + bytes[i++] = (byte)((UseBigPackets) ? 1 : 0); + bytes[i++] = (byte)((DeleteOnCompletion) ? 1 : 0); + bytes[i++] = FilePath; + if(Filename == null) { Console.WriteLine("Warning: Filename is null, in " + this.GetType()); } + bytes[i++] = (byte)Filename.Length; + Array.Copy(Filename, 0, bytes, i, Filename.Length); i += Filename.Length; + if(VFileID == null) { Console.WriteLine("Warning: VFileID is null, in " + this.GetType()); } + Array.Copy(VFileID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(VFileType % 256); + bytes[i++] = (byte)((VFileType >> 8) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- XferID --\n"; - output += "ID: " + ID.ToString() + "\n"; - output += "UseBigPackets: " + UseBigPackets.ToString() + "\n"; - output += "DeleteOnCompletion: " + DeleteOnCompletion.ToString() + "\n"; - output += "FilePath: " + FilePath.ToString() + "\n"; - output += Helpers.FieldToString(Filename, "Filename") + "\n"; - output += "VFileID: " + VFileID.ToString() + "\n"; - output += "VFileType: " + VFileType.ToString() + "\n"; + { + string output = "-- XferID --\n"; + output += "ID: " + ID.ToString() + "\n"; + output += "UseBigPackets: " + UseBigPackets.ToString() + "\n"; + output += "DeleteOnCompletion: " + DeleteOnCompletion.ToString() + "\n"; + output += "FilePath: " + FilePath.ToString() + "\n"; + output += Helpers.FieldToString(Filename, "Filename") + "\n"; + output += "VFileID: " + VFileID.ToString() + "\n"; + output += "VFileType: " + VFileType.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.RequestXfer - public override PacketType Type { get { return PacketType.RequestXfer; } } - /// XferID block - public XferIDBlock XferID; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.RequestXfer + public override PacketType Type { get { return PacketType.RequestXfer; } } + /// XferID block + public XferIDBlock XferID; + + /// Default constructor public RequestXferPacket() - { - Header = new LowHeader(); - Header.ID = 198; - Header.Reliable = true; - Header.Zerocoded = true; - XferID = new XferIDBlock(); + { + Header = new LowHeader(); + Header.ID = 198; + Header.Reliable = true; + Header.Zerocoded = true; + XferID = new XferIDBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public RequestXferPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - XferID = new XferIDBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + XferID = new XferIDBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public RequestXferPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - XferID = new XferIDBlock(bytes, ref i); + { + Header = head; + XferID = new XferIDBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += XferID.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - XferID.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += XferID.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + XferID.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- RequestXfer ---\n"; - output += XferID.ToString() + "\n"; + { + string output = "--- RequestXfer ---\n"; + output += XferID.ToString() + "\n"; return output; } - + } - - /// AbortXfer packet + + /// AbortXfer packet public class AbortXferPacket : Packet - { - /// XferID block + { + /// XferID block public class XferIDBlock - { - /// ID field - public ulong ID; - /// Result field - public int Result; - - /// Length of this block serialized in bytes + { + /// ID field + public ulong ID; + /// Result field + public int Result; + + /// Length of this block serialized in bytes public int Length { get - { - return 12; + { + return 12; } } - - /// Default constructor - public XferIDBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public XferIDBlock() { } + /// Constructor for building the block from a byte array public XferIDBlock(byte[] bytes, ref int i) - { + { try - { - ID = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); - Result = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + ID = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + Result = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(ID % 256); - bytes[i++] = (byte)((ID >> 8) % 256); - bytes[i++] = (byte)((ID >> 16) % 256); - bytes[i++] = (byte)((ID >> 24) % 256); - bytes[i++] = (byte)((ID >> 32) % 256); - bytes[i++] = (byte)((ID >> 40) % 256); - bytes[i++] = (byte)((ID >> 48) % 256); - bytes[i++] = (byte)((ID >> 56) % 256); - bytes[i++] = (byte)(Result % 256); - bytes[i++] = (byte)((Result >> 8) % 256); - bytes[i++] = (byte)((Result >> 16) % 256); - bytes[i++] = (byte)((Result >> 24) % 256); + { + bytes[i++] = (byte)(ID % 256); + bytes[i++] = (byte)((ID >> 8) % 256); + bytes[i++] = (byte)((ID >> 16) % 256); + bytes[i++] = (byte)((ID >> 24) % 256); + bytes[i++] = (byte)((ID >> 32) % 256); + bytes[i++] = (byte)((ID >> 40) % 256); + bytes[i++] = (byte)((ID >> 48) % 256); + bytes[i++] = (byte)((ID >> 56) % 256); + bytes[i++] = (byte)(Result % 256); + bytes[i++] = (byte)((Result >> 8) % 256); + bytes[i++] = (byte)((Result >> 16) % 256); + bytes[i++] = (byte)((Result >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- XferID --\n"; - output += "ID: " + ID.ToString() + "\n"; - output += "Result: " + Result.ToString() + "\n"; + { + string output = "-- XferID --\n"; + output += "ID: " + ID.ToString() + "\n"; + output += "Result: " + Result.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AbortXfer - public override PacketType Type { get { return PacketType.AbortXfer; } } - /// XferID block - public XferIDBlock XferID; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AbortXfer + public override PacketType Type { get { return PacketType.AbortXfer; } } + /// XferID block + public XferIDBlock XferID; + + /// Default constructor public AbortXferPacket() - { - Header = new LowHeader(); - Header.ID = 199; - Header.Reliable = true; - XferID = new XferIDBlock(); + { + Header = new LowHeader(); + Header.ID = 199; + Header.Reliable = true; + XferID = new XferIDBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AbortXferPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - XferID = new XferIDBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + XferID = new XferIDBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AbortXferPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - XferID = new XferIDBlock(bytes, ref i); + { + Header = head; + XferID = new XferIDBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += XferID.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - XferID.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += XferID.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + XferID.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AbortXfer ---\n"; - output += XferID.ToString() + "\n"; + { + string output = "--- AbortXfer ---\n"; + output += XferID.ToString() + "\n"; return output; } - + } - - /// RequestAvatarInfo packet + + /// RequestAvatarInfo packet public class RequestAvatarInfoPacket : Packet - { - /// DataBlock block + { + /// DataBlock block public class DataBlockBlock - { - /// FullID field - public LLUUID FullID; - - /// Length of this block serialized in bytes + { + /// FullID field + public LLUUID FullID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public DataBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlockBlock() { } + /// Constructor for building the block from a byte array public DataBlockBlock(byte[] bytes, ref int i) - { + { try - { - FullID = new LLUUID(bytes, i); i += 16; + { + FullID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(FullID == null) { Console.WriteLine("Warning: FullID is null, in " + this.GetType()); } - Array.Copy(FullID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(FullID == null) { Console.WriteLine("Warning: FullID is null, in " + this.GetType()); } + Array.Copy(FullID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- DataBlock --\n"; - output += "FullID: " + FullID.ToString() + "\n"; + { + string output = "-- DataBlock --\n"; + output += "FullID: " + FullID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.RequestAvatarInfo - public override PacketType Type { get { return PacketType.RequestAvatarInfo; } } - /// DataBlock block - public DataBlockBlock DataBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.RequestAvatarInfo + public override PacketType Type { get { return PacketType.RequestAvatarInfo; } } + /// DataBlock block + public DataBlockBlock DataBlock; + + /// Default constructor public RequestAvatarInfoPacket() - { - Header = new LowHeader(); - Header.ID = 200; - Header.Reliable = true; - DataBlock = new DataBlockBlock(); + { + Header = new LowHeader(); + Header.ID = 200; + Header.Reliable = true; + DataBlock = new DataBlockBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public RequestAvatarInfoPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - DataBlock = new DataBlockBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + DataBlock = new DataBlockBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public RequestAvatarInfoPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - DataBlock = new DataBlockBlock(bytes, ref i); + { + Header = head; + DataBlock = new DataBlockBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += DataBlock.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - DataBlock.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += DataBlock.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + DataBlock.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- RequestAvatarInfo ---\n"; - output += DataBlock.ToString() + "\n"; + { + string output = "--- RequestAvatarInfo ---\n"; + output += DataBlock.ToString() + "\n"; return output; } - + } - - /// AvatarAppearance packet + + /// AvatarAppearance packet public class AvatarAppearancePacket : Packet - { - /// VisualParam block + { + /// VisualParam block public class VisualParamBlock - { - /// ParamValue field - public byte ParamValue; - - /// Length of this block serialized in bytes + { + /// ParamValue field + public byte ParamValue; + + /// Length of this block serialized in bytes public int Length { get - { - return 1; + { + return 1; } } - - /// Default constructor - public VisualParamBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public VisualParamBlock() { } + /// Constructor for building the block from a byte array public VisualParamBlock(byte[] bytes, ref int i) - { + { try - { - ParamValue = (byte)bytes[i++]; + { + ParamValue = (byte)bytes[i++]; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = ParamValue; + { + bytes[i++] = ParamValue; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- VisualParam --\n"; - output += "ParamValue: " + ParamValue.ToString() + "\n"; + { + string output = "-- VisualParam --\n"; + output += "ParamValue: " + ParamValue.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// ObjectData block + + /// ObjectData block public class ObjectDataBlock - { - private byte[] _textureentry; - /// TextureEntry field + { + private byte[] _textureentry; + /// TextureEntry field public byte[] TextureEntry - { - get { return _textureentry; } + { + get { return _textureentry; } set - { - if (value == null) { _textureentry = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _textureentry = new byte[value.Length]; Array.Copy(value, _textureentry, value.Length); } + { + if (value == null) { _textureentry = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _textureentry = new byte[value.Length]; Array.Copy(value, _textureentry, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 0; - if (TextureEntry != null) { length += 2 + TextureEntry.Length; } - return length; + { + int length = 0; + if (TextureEntry != null) { length += 2 + TextureEntry.Length; } + return length; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _textureentry = new byte[length]; - Array.Copy(bytes, i, _textureentry, 0, length); i += length; + { + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _textureentry = new byte[length]; + Array.Copy(bytes, i, _textureentry, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(TextureEntry == null) { Console.WriteLine("Warning: TextureEntry is null, in " + this.GetType()); } - bytes[i++] = (byte)(TextureEntry.Length % 256); - bytes[i++] = (byte)((TextureEntry.Length >> 8) % 256); - Array.Copy(TextureEntry, 0, bytes, i, TextureEntry.Length); i += TextureEntry.Length; + { + if(TextureEntry == null) { Console.WriteLine("Warning: TextureEntry is null, in " + this.GetType()); } + bytes[i++] = (byte)(TextureEntry.Length % 256); + bytes[i++] = (byte)((TextureEntry.Length >> 8) % 256); + Array.Copy(TextureEntry, 0, bytes, i, TextureEntry.Length); i += TextureEntry.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += Helpers.FieldToString(TextureEntry, "TextureEntry") + "\n"; + { + string output = "-- ObjectData --\n"; + output += Helpers.FieldToString(TextureEntry, "TextureEntry") + "\n"; output = output.Trim(); return output; - } + } } - - /// Sender block + + /// Sender block public class SenderBlock - { - /// ID field - public LLUUID ID; - /// IsTrial field - public bool IsTrial; - - /// Length of this block serialized in bytes + { + /// ID field + public LLUUID ID; + /// IsTrial field + public bool IsTrial; + + /// Length of this block serialized in bytes public int Length { get - { - return 17; + { + return 17; } } - - /// Default constructor - public SenderBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public SenderBlock() { } + /// Constructor for building the block from a byte array public SenderBlock(byte[] bytes, ref int i) - { + { try - { - ID = new LLUUID(bytes, i); i += 16; - IsTrial = (bytes[i++] != 0) ? (bool)true : (bool)false; + { + ID = new LLUUID(bytes, i); i += 16; + IsTrial = (bytes[i++] != 0) ? (bool)true : (bool)false; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } - Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((IsTrial) ? 1 : 0); + { + if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } + Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((IsTrial) ? 1 : 0); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Sender --\n"; - output += "ID: " + ID.ToString() + "\n"; - output += "IsTrial: " + IsTrial.ToString() + "\n"; + { + string output = "-- Sender --\n"; + output += "ID: " + ID.ToString() + "\n"; + output += "IsTrial: " + IsTrial.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AvatarAppearance - public override PacketType Type { get { return PacketType.AvatarAppearance; } } - /// VisualParam block - public VisualParamBlock[] VisualParam; - /// ObjectData block - public ObjectDataBlock ObjectData; - /// Sender block - public SenderBlock Sender; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AvatarAppearance + public override PacketType Type { get { return PacketType.AvatarAppearance; } } + /// VisualParam block + public VisualParamBlock[] VisualParam; + /// ObjectData block + public ObjectDataBlock ObjectData; + /// Sender block + public SenderBlock Sender; + + /// Default constructor public AvatarAppearancePacket() - { - Header = new LowHeader(); - Header.ID = 201; - Header.Reliable = true; - Header.Zerocoded = true; - VisualParam = new VisualParamBlock[0]; - ObjectData = new ObjectDataBlock(); - Sender = new SenderBlock(); + { + Header = new LowHeader(); + Header.ID = 201; + Header.Reliable = true; + Header.Zerocoded = true; + VisualParam = new VisualParamBlock[0]; + ObjectData = new ObjectDataBlock(); + Sender = new SenderBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AvatarAppearancePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - VisualParam = new VisualParamBlock[count]; - for (int j = 0; j < count; j++) - { VisualParam[j] = new VisualParamBlock(bytes, ref i); } - ObjectData = new ObjectDataBlock(bytes, ref i); - Sender = new SenderBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + VisualParam = new VisualParamBlock[count]; + for (int j = 0; j < count; j++) + { VisualParam[j] = new VisualParamBlock(bytes, ref i); } + ObjectData = new ObjectDataBlock(bytes, ref i); + Sender = new SenderBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AvatarAppearancePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - VisualParam = new VisualParamBlock[count]; - for (int j = 0; j < count; j++) - { VisualParam[j] = new VisualParamBlock(bytes, ref i); } - ObjectData = new ObjectDataBlock(bytes, ref i); - Sender = new SenderBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + VisualParam = new VisualParamBlock[count]; + for (int j = 0; j < count; j++) + { VisualParam[j] = new VisualParamBlock(bytes, ref i); } + ObjectData = new ObjectDataBlock(bytes, ref i); + Sender = new SenderBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += ObjectData.Length; length += Sender.Length;; - length++; - for (int j = 0; j < VisualParam.Length; j++) { length += VisualParam[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)VisualParam.Length; - for (int j = 0; j < VisualParam.Length; j++) { VisualParam[j].ToBytes(bytes, ref i); } - ObjectData.ToBytes(bytes, ref i); - Sender.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += ObjectData.Length; length += Sender.Length;; + length++; + for (int j = 0; j < VisualParam.Length; j++) { length += VisualParam[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)VisualParam.Length; + for (int j = 0; j < VisualParam.Length; j++) { VisualParam[j].ToBytes(bytes, ref i); } + ObjectData.ToBytes(bytes, ref i); + Sender.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AvatarAppearance ---\n"; + { + string output = "--- AvatarAppearance ---\n"; for (int j = 0; j < VisualParam.Length; j++) - { + { output += VisualParam[j].ToString() + "\n"; - } - output += ObjectData.ToString() + "\n"; - output += Sender.ToString() + "\n"; + } + output += ObjectData.ToString() + "\n"; + output += Sender.ToString() + "\n"; return output; } - + } - - /// SetFollowCamProperties packet + + /// SetFollowCamProperties packet public class SetFollowCamPropertiesPacket : Packet - { - /// CameraProperty block + { + /// CameraProperty block public class CameraPropertyBlock - { - /// Type field - public int Type; - /// Value field - public float Value; - - /// Length of this block serialized in bytes + { + /// Type field + public int Type; + /// Value field + public float Value; + + /// Length of this block serialized in bytes public int Length { get - { - return 8; + { + return 8; } } - - /// Default constructor - public CameraPropertyBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public CameraPropertyBlock() { } + /// Constructor for building the block from a byte array public CameraPropertyBlock(byte[] bytes, ref int i) - { + { try - { - Type = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - Value = BitConverter.ToSingle(bytes, i); i += 4; + { + Type = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + Value = BitConverter.ToSingle(bytes, i); i += 4; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; - bytes[i++] = (byte)(Type % 256); - bytes[i++] = (byte)((Type >> 8) % 256); - bytes[i++] = (byte)((Type >> 16) % 256); - bytes[i++] = (byte)((Type >> 24) % 256); + { + byte[] ba; + bytes[i++] = (byte)(Type % 256); + bytes[i++] = (byte)((Type >> 8) % 256); + bytes[i++] = (byte)((Type >> 16) % 256); + bytes[i++] = (byte)((Type >> 24) % 256); ba = BitConverter.GetBytes(Value); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- CameraProperty --\n"; - output += "Type: " + Type.ToString() + "\n"; - output += "Value: " + Value.ToString() + "\n"; + { + string output = "-- CameraProperty --\n"; + output += "Type: " + Type.ToString() + "\n"; + output += "Value: " + Value.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// ObjectData block + + /// ObjectData block public class ObjectDataBlock - { - /// ObjectID field - public LLUUID ObjectID; - - /// Length of this block serialized in bytes + { + /// ObjectID field + public LLUUID ObjectID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { + { try - { - ObjectID = new LLUUID(bytes, i); i += 16; + { + ObjectID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } - Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } + Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += "ObjectID: " + ObjectID.ToString() + "\n"; + { + string output = "-- ObjectData --\n"; + output += "ObjectID: " + ObjectID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.SetFollowCamProperties - public override PacketType Type { get { return PacketType.SetFollowCamProperties; } } - /// CameraProperty block - public CameraPropertyBlock[] CameraProperty; - /// ObjectData block - public ObjectDataBlock ObjectData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.SetFollowCamProperties + public override PacketType Type { get { return PacketType.SetFollowCamProperties; } } + /// CameraProperty block + public CameraPropertyBlock[] CameraProperty; + /// ObjectData block + public ObjectDataBlock ObjectData; + + /// Default constructor public SetFollowCamPropertiesPacket() - { - Header = new LowHeader(); - Header.ID = 202; - Header.Reliable = true; - CameraProperty = new CameraPropertyBlock[0]; - ObjectData = new ObjectDataBlock(); + { + Header = new LowHeader(); + Header.ID = 202; + Header.Reliable = true; + CameraProperty = new CameraPropertyBlock[0]; + ObjectData = new ObjectDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public SetFollowCamPropertiesPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - CameraProperty = new CameraPropertyBlock[count]; - for (int j = 0; j < count; j++) - { CameraProperty[j] = new CameraPropertyBlock(bytes, ref i); } - ObjectData = new ObjectDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + CameraProperty = new CameraPropertyBlock[count]; + for (int j = 0; j < count; j++) + { CameraProperty[j] = new CameraPropertyBlock(bytes, ref i); } + ObjectData = new ObjectDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public SetFollowCamPropertiesPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - CameraProperty = new CameraPropertyBlock[count]; - for (int j = 0; j < count; j++) - { CameraProperty[j] = new CameraPropertyBlock(bytes, ref i); } - ObjectData = new ObjectDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + CameraProperty = new CameraPropertyBlock[count]; + for (int j = 0; j < count; j++) + { CameraProperty[j] = new CameraPropertyBlock(bytes, ref i); } + ObjectData = new ObjectDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += ObjectData.Length;; - length++; - for (int j = 0; j < CameraProperty.Length; j++) { length += CameraProperty[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)CameraProperty.Length; - for (int j = 0; j < CameraProperty.Length; j++) { CameraProperty[j].ToBytes(bytes, ref i); } - ObjectData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += ObjectData.Length;; + length++; + for (int j = 0; j < CameraProperty.Length; j++) { length += CameraProperty[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)CameraProperty.Length; + for (int j = 0; j < CameraProperty.Length; j++) { CameraProperty[j].ToBytes(bytes, ref i); } + ObjectData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- SetFollowCamProperties ---\n"; + { + string output = "--- SetFollowCamProperties ---\n"; for (int j = 0; j < CameraProperty.Length; j++) - { + { output += CameraProperty[j].ToString() + "\n"; - } - output += ObjectData.ToString() + "\n"; + } + output += ObjectData.ToString() + "\n"; return output; } - + } - - /// ClearFollowCamProperties packet + + /// ClearFollowCamProperties packet public class ClearFollowCamPropertiesPacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - /// ObjectID field - public LLUUID ObjectID; - - /// Length of this block serialized in bytes + { + /// ObjectID field + public LLUUID ObjectID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { + { try - { - ObjectID = new LLUUID(bytes, i); i += 16; + { + ObjectID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } - Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } + Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += "ObjectID: " + ObjectID.ToString() + "\n"; + { + string output = "-- ObjectData --\n"; + output += "ObjectID: " + ObjectID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ClearFollowCamProperties - public override PacketType Type { get { return PacketType.ClearFollowCamProperties; } } - /// ObjectData block - public ObjectDataBlock ObjectData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ClearFollowCamProperties + public override PacketType Type { get { return PacketType.ClearFollowCamProperties; } } + /// ObjectData block + public ObjectDataBlock ObjectData; + + /// Default constructor public ClearFollowCamPropertiesPacket() - { - Header = new LowHeader(); - Header.ID = 203; - Header.Reliable = true; - ObjectData = new ObjectDataBlock(); + { + Header = new LowHeader(); + Header.ID = 203; + Header.Reliable = true; + ObjectData = new ObjectDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ClearFollowCamPropertiesPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - ObjectData = new ObjectDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + ObjectData = new ObjectDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ClearFollowCamPropertiesPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - ObjectData = new ObjectDataBlock(bytes, ref i); + { + Header = head; + ObjectData = new ObjectDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += ObjectData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - ObjectData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += ObjectData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + ObjectData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ClearFollowCamProperties ---\n"; - output += ObjectData.ToString() + "\n"; + { + string output = "--- ClearFollowCamProperties ---\n"; + output += ObjectData.ToString() + "\n"; return output; } - + } - - /// RequestPayPrice packet + + /// RequestPayPrice packet public class RequestPayPricePacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - /// ObjectID field - public LLUUID ObjectID; - - /// Length of this block serialized in bytes + { + /// ObjectID field + public LLUUID ObjectID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { + { try - { - ObjectID = new LLUUID(bytes, i); i += 16; + { + ObjectID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } - Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } + Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += "ObjectID: " + ObjectID.ToString() + "\n"; + { + string output = "-- ObjectData --\n"; + output += "ObjectID: " + ObjectID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.RequestPayPrice - public override PacketType Type { get { return PacketType.RequestPayPrice; } } - /// ObjectData block - public ObjectDataBlock ObjectData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.RequestPayPrice + public override PacketType Type { get { return PacketType.RequestPayPrice; } } + /// ObjectData block + public ObjectDataBlock ObjectData; + + /// Default constructor public RequestPayPricePacket() - { - Header = new LowHeader(); - Header.ID = 204; - Header.Reliable = true; - ObjectData = new ObjectDataBlock(); + { + Header = new LowHeader(); + Header.ID = 204; + Header.Reliable = true; + ObjectData = new ObjectDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public RequestPayPricePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - ObjectData = new ObjectDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + ObjectData = new ObjectDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public RequestPayPricePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - ObjectData = new ObjectDataBlock(bytes, ref i); + { + Header = head; + ObjectData = new ObjectDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += ObjectData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - ObjectData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += ObjectData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + ObjectData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- RequestPayPrice ---\n"; - output += ObjectData.ToString() + "\n"; + { + string output = "--- RequestPayPrice ---\n"; + output += ObjectData.ToString() + "\n"; return output; } - + } - - /// PayPriceReply packet + + /// PayPriceReply packet public class PayPriceReplyPacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - /// ObjectID field - public LLUUID ObjectID; - /// DefaultPayPrice field - public int DefaultPayPrice; - - /// Length of this block serialized in bytes + { + /// ObjectID field + public LLUUID ObjectID; + /// DefaultPayPrice field + public int DefaultPayPrice; + + /// Length of this block serialized in bytes public int Length { get - { - return 20; + { + return 20; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { + { try - { - ObjectID = new LLUUID(bytes, i); i += 16; - DefaultPayPrice = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + ObjectID = new LLUUID(bytes, i); i += 16; + DefaultPayPrice = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } - Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(DefaultPayPrice % 256); - bytes[i++] = (byte)((DefaultPayPrice >> 8) % 256); - bytes[i++] = (byte)((DefaultPayPrice >> 16) % 256); - bytes[i++] = (byte)((DefaultPayPrice >> 24) % 256); + { + if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } + Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(DefaultPayPrice % 256); + bytes[i++] = (byte)((DefaultPayPrice >> 8) % 256); + bytes[i++] = (byte)((DefaultPayPrice >> 16) % 256); + bytes[i++] = (byte)((DefaultPayPrice >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += "ObjectID: " + ObjectID.ToString() + "\n"; - output += "DefaultPayPrice: " + DefaultPayPrice.ToString() + "\n"; + { + string output = "-- ObjectData --\n"; + output += "ObjectID: " + ObjectID.ToString() + "\n"; + output += "DefaultPayPrice: " + DefaultPayPrice.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// ButtonData block + + /// ButtonData block public class ButtonDataBlock - { - /// PayButton field - public int PayButton; - - /// Length of this block serialized in bytes + { + /// PayButton field + public int PayButton; + + /// Length of this block serialized in bytes public int Length { get - { - return 4; + { + return 4; } } - - /// Default constructor - public ButtonDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ButtonDataBlock() { } + /// Constructor for building the block from a byte array public ButtonDataBlock(byte[] bytes, ref int i) - { + { try - { - PayButton = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + PayButton = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(PayButton % 256); - bytes[i++] = (byte)((PayButton >> 8) % 256); - bytes[i++] = (byte)((PayButton >> 16) % 256); - bytes[i++] = (byte)((PayButton >> 24) % 256); + { + bytes[i++] = (byte)(PayButton % 256); + bytes[i++] = (byte)((PayButton >> 8) % 256); + bytes[i++] = (byte)((PayButton >> 16) % 256); + bytes[i++] = (byte)((PayButton >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ButtonData --\n"; - output += "PayButton: " + PayButton.ToString() + "\n"; + { + string output = "-- ButtonData --\n"; + output += "PayButton: " + PayButton.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.PayPriceReply - public override PacketType Type { get { return PacketType.PayPriceReply; } } - /// ObjectData block - public ObjectDataBlock ObjectData; - /// ButtonData block - public ButtonDataBlock[] ButtonData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.PayPriceReply + public override PacketType Type { get { return PacketType.PayPriceReply; } } + /// ObjectData block + public ObjectDataBlock ObjectData; + /// ButtonData block + public ButtonDataBlock[] ButtonData; + + /// Default constructor public PayPriceReplyPacket() - { - Header = new LowHeader(); - Header.ID = 205; - Header.Reliable = true; - ObjectData = new ObjectDataBlock(); - ButtonData = new ButtonDataBlock[0]; + { + Header = new LowHeader(); + Header.ID = 205; + Header.Reliable = true; + ObjectData = new ObjectDataBlock(); + ButtonData = new ButtonDataBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public PayPriceReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - ObjectData = new ObjectDataBlock(bytes, ref i); - int count = (int)bytes[i++]; - ButtonData = new ButtonDataBlock[count]; - for (int j = 0; j < count; j++) - { ButtonData[j] = new ButtonDataBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + ObjectData = new ObjectDataBlock(bytes, ref i); + int count = (int)bytes[i++]; + ButtonData = new ButtonDataBlock[count]; + for (int j = 0; j < count; j++) + { ButtonData[j] = new ButtonDataBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public PayPriceReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - ObjectData = new ObjectDataBlock(bytes, ref i); - int count = (int)bytes[i++]; - ButtonData = new ButtonDataBlock[count]; - for (int j = 0; j < count; j++) - { ButtonData[j] = new ButtonDataBlock(bytes, ref i); } + { + Header = head; + ObjectData = new ObjectDataBlock(bytes, ref i); + int count = (int)bytes[i++]; + ButtonData = new ButtonDataBlock[count]; + for (int j = 0; j < count; j++) + { ButtonData[j] = new ButtonDataBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += ObjectData.Length;; - length++; - for (int j = 0; j < ButtonData.Length; j++) { length += ButtonData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - ObjectData.ToBytes(bytes, ref i); - bytes[i++] = (byte)ButtonData.Length; - for (int j = 0; j < ButtonData.Length; j++) { ButtonData[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += ObjectData.Length;; + length++; + for (int j = 0; j < ButtonData.Length; j++) { length += ButtonData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + ObjectData.ToBytes(bytes, ref i); + bytes[i++] = (byte)ButtonData.Length; + for (int j = 0; j < ButtonData.Length; j++) { ButtonData[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- PayPriceReply ---\n"; - output += ObjectData.ToString() + "\n"; + { + string output = "--- PayPriceReply ---\n"; + output += ObjectData.ToString() + "\n"; for (int j = 0; j < ButtonData.Length; j++) - { + { output += ButtonData[j].ToString() + "\n"; - } + } return output; } - + } - - /// KickUser packet + + /// KickUser packet public class KickUserPacket : Packet - { - /// TargetBlock block + { + /// TargetBlock block public class TargetBlockBlock - { - /// TargetIP field - public uint TargetIP; - /// TargetPort field - public ushort TargetPort; - - /// Length of this block serialized in bytes + { + /// TargetIP field + public uint TargetIP; + /// TargetPort field + public ushort TargetPort; + + /// Length of this block serialized in bytes public int Length { get - { - return 6; + { + return 6; } } - - /// Default constructor - public TargetBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public TargetBlockBlock() { } + /// Constructor for building the block from a byte array public TargetBlockBlock(byte[] bytes, ref int i) - { + { try - { - TargetIP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - TargetPort = (ushort)((bytes[i++] << 8) + bytes[i++]); + { + TargetIP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + TargetPort = (ushort)((bytes[i++] << 8) + bytes[i++]); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(TargetIP % 256); - bytes[i++] = (byte)((TargetIP >> 8) % 256); - bytes[i++] = (byte)((TargetIP >> 16) % 256); - bytes[i++] = (byte)((TargetIP >> 24) % 256); - bytes[i++] = (byte)((TargetPort >> 8) % 256); - bytes[i++] = (byte)(TargetPort % 256); + { + bytes[i++] = (byte)(TargetIP % 256); + bytes[i++] = (byte)((TargetIP >> 8) % 256); + bytes[i++] = (byte)((TargetIP >> 16) % 256); + bytes[i++] = (byte)((TargetIP >> 24) % 256); + bytes[i++] = (byte)((TargetPort >> 8) % 256); + bytes[i++] = (byte)(TargetPort % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- TargetBlock --\n"; - output += "TargetIP: " + TargetIP.ToString() + "\n"; - output += "TargetPort: " + TargetPort.ToString() + "\n"; + { + string output = "-- TargetBlock --\n"; + output += "TargetIP: " + TargetIP.ToString() + "\n"; + output += "TargetPort: " + TargetPort.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// UserInfo block + + /// UserInfo block public class UserInfoBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - private byte[] _reason; - /// Reason field + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + private byte[] _reason; + /// Reason field public byte[] Reason - { - get { return _reason; } + { + get { return _reason; } set - { - if (value == null) { _reason = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _reason = new byte[value.Length]; Array.Copy(value, _reason, value.Length); } + { + if (value == null) { _reason = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _reason = new byte[value.Length]; Array.Copy(value, _reason, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 32; - if (Reason != null) { length += 2 + Reason.Length; } - return length; + { + int length = 32; + if (Reason != null) { length += 2 + Reason.Length; } + return length; } } - - /// Default constructor - public UserInfoBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public UserInfoBlock() { } + /// Constructor for building the block from a byte array public UserInfoBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _reason = new byte[length]; - Array.Copy(bytes, i, _reason, 0, length); i += length; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _reason = new byte[length]; + Array.Copy(bytes, i, _reason, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - if(Reason == null) { Console.WriteLine("Warning: Reason is null, in " + this.GetType()); } - bytes[i++] = (byte)(Reason.Length % 256); - bytes[i++] = (byte)((Reason.Length >> 8) % 256); - Array.Copy(Reason, 0, bytes, i, Reason.Length); i += Reason.Length; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + if(Reason == null) { Console.WriteLine("Warning: Reason is null, in " + this.GetType()); } + bytes[i++] = (byte)(Reason.Length % 256); + bytes[i++] = (byte)((Reason.Length >> 8) % 256); + Array.Copy(Reason, 0, bytes, i, Reason.Length); i += Reason.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- UserInfo --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += Helpers.FieldToString(Reason, "Reason") + "\n"; + { + string output = "-- UserInfo --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += Helpers.FieldToString(Reason, "Reason") + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.KickUser - public override PacketType Type { get { return PacketType.KickUser; } } - /// TargetBlock block - public TargetBlockBlock TargetBlock; - /// UserInfo block - public UserInfoBlock UserInfo; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.KickUser + public override PacketType Type { get { return PacketType.KickUser; } } + /// TargetBlock block + public TargetBlockBlock TargetBlock; + /// UserInfo block + public UserInfoBlock UserInfo; + + /// Default constructor public KickUserPacket() - { - Header = new LowHeader(); - Header.ID = 206; - Header.Reliable = true; - TargetBlock = new TargetBlockBlock(); - UserInfo = new UserInfoBlock(); + { + Header = new LowHeader(); + Header.ID = 206; + Header.Reliable = true; + TargetBlock = new TargetBlockBlock(); + UserInfo = new UserInfoBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public KickUserPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - TargetBlock = new TargetBlockBlock(bytes, ref i); - UserInfo = new UserInfoBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + TargetBlock = new TargetBlockBlock(bytes, ref i); + UserInfo = new UserInfoBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public KickUserPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - TargetBlock = new TargetBlockBlock(bytes, ref i); - UserInfo = new UserInfoBlock(bytes, ref i); + { + Header = head; + TargetBlock = new TargetBlockBlock(bytes, ref i); + UserInfo = new UserInfoBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += TargetBlock.Length; length += UserInfo.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - TargetBlock.ToBytes(bytes, ref i); - UserInfo.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += TargetBlock.Length; length += UserInfo.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + TargetBlock.ToBytes(bytes, ref i); + UserInfo.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- KickUser ---\n"; - output += TargetBlock.ToString() + "\n"; - output += UserInfo.ToString() + "\n"; + { + string output = "--- KickUser ---\n"; + output += TargetBlock.ToString() + "\n"; + output += UserInfo.ToString() + "\n"; return output; } - + } - - /// KickUserAck packet + + /// KickUserAck packet public class KickUserAckPacket : Packet - { - /// UserInfo block + { + /// UserInfo block public class UserInfoBlock - { - /// SessionID field - public LLUUID SessionID; - /// Flags field - public uint Flags; - - /// Length of this block serialized in bytes + { + /// SessionID field + public LLUUID SessionID; + /// Flags field + public uint Flags; + + /// Length of this block serialized in bytes public int Length { get - { - return 20; + { + return 20; } } - - /// Default constructor - public UserInfoBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public UserInfoBlock() { } + /// Constructor for building the block from a byte array public UserInfoBlock(byte[] bytes, ref int i) - { + { try - { - SessionID = new LLUUID(bytes, i); i += 16; - Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + SessionID = new LLUUID(bytes, i); i += 16; + Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(Flags % 256); - bytes[i++] = (byte)((Flags >> 8) % 256); - bytes[i++] = (byte)((Flags >> 16) % 256); - bytes[i++] = (byte)((Flags >> 24) % 256); + { + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(Flags % 256); + bytes[i++] = (byte)((Flags >> 8) % 256); + bytes[i++] = (byte)((Flags >> 16) % 256); + bytes[i++] = (byte)((Flags >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- UserInfo --\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "Flags: " + Flags.ToString() + "\n"; + { + string output = "-- UserInfo --\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "Flags: " + Flags.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.KickUserAck - public override PacketType Type { get { return PacketType.KickUserAck; } } - /// UserInfo block - public UserInfoBlock UserInfo; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.KickUserAck + public override PacketType Type { get { return PacketType.KickUserAck; } } + /// UserInfo block + public UserInfoBlock UserInfo; + + /// Default constructor public KickUserAckPacket() - { - Header = new LowHeader(); - Header.ID = 207; - Header.Reliable = true; - UserInfo = new UserInfoBlock(); + { + Header = new LowHeader(); + Header.ID = 207; + Header.Reliable = true; + UserInfo = new UserInfoBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public KickUserAckPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - UserInfo = new UserInfoBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + UserInfo = new UserInfoBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public KickUserAckPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - UserInfo = new UserInfoBlock(bytes, ref i); + { + Header = head; + UserInfo = new UserInfoBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += UserInfo.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - UserInfo.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += UserInfo.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + UserInfo.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- KickUserAck ---\n"; - output += UserInfo.ToString() + "\n"; + { + string output = "--- KickUserAck ---\n"; + output += UserInfo.ToString() + "\n"; return output; } - + } - - /// GodKickUser packet + + /// GodKickUser packet public class GodKickUserPacket : Packet - { - /// UserInfo block + { + /// UserInfo block public class UserInfoBlock - { - /// GodSessionID field - public LLUUID GodSessionID; - /// AgentID field - public LLUUID AgentID; - private byte[] _reason; - /// Reason field + { + /// GodSessionID field + public LLUUID GodSessionID; + /// AgentID field + public LLUUID AgentID; + private byte[] _reason; + /// Reason field public byte[] Reason - { - get { return _reason; } + { + get { return _reason; } set - { - if (value == null) { _reason = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _reason = new byte[value.Length]; Array.Copy(value, _reason, value.Length); } + { + if (value == null) { _reason = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _reason = new byte[value.Length]; Array.Copy(value, _reason, value.Length); } } - } - /// KickFlags field - public uint KickFlags; - /// GodID field - public LLUUID GodID; - - /// Length of this block serialized in bytes + } + /// KickFlags field + public uint KickFlags; + /// GodID field + public LLUUID GodID; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 52; - if (Reason != null) { length += 2 + Reason.Length; } - return length; + { + int length = 52; + if (Reason != null) { length += 2 + Reason.Length; } + return length; } } - - /// Default constructor - public UserInfoBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public UserInfoBlock() { } + /// Constructor for building the block from a byte array public UserInfoBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - GodSessionID = new LLUUID(bytes, i); i += 16; - AgentID = new LLUUID(bytes, i); i += 16; - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _reason = new byte[length]; - Array.Copy(bytes, i, _reason, 0, length); i += length; - KickFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - GodID = new LLUUID(bytes, i); i += 16; + { + GodSessionID = new LLUUID(bytes, i); i += 16; + AgentID = new LLUUID(bytes, i); i += 16; + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _reason = new byte[length]; + Array.Copy(bytes, i, _reason, 0, length); i += length; + KickFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + GodID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(GodSessionID == null) { Console.WriteLine("Warning: GodSessionID is null, in " + this.GetType()); } - Array.Copy(GodSessionID.GetBytes(), 0, bytes, i, 16); i += 16; - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(Reason == null) { Console.WriteLine("Warning: Reason is null, in " + this.GetType()); } - bytes[i++] = (byte)(Reason.Length % 256); - bytes[i++] = (byte)((Reason.Length >> 8) % 256); - Array.Copy(Reason, 0, bytes, i, Reason.Length); i += Reason.Length; - bytes[i++] = (byte)(KickFlags % 256); - bytes[i++] = (byte)((KickFlags >> 8) % 256); - bytes[i++] = (byte)((KickFlags >> 16) % 256); - bytes[i++] = (byte)((KickFlags >> 24) % 256); - if(GodID == null) { Console.WriteLine("Warning: GodID is null, in " + this.GetType()); } - Array.Copy(GodID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(GodSessionID == null) { Console.WriteLine("Warning: GodSessionID is null, in " + this.GetType()); } + Array.Copy(GodSessionID.GetBytes(), 0, bytes, i, 16); i += 16; + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(Reason == null) { Console.WriteLine("Warning: Reason is null, in " + this.GetType()); } + bytes[i++] = (byte)(Reason.Length % 256); + bytes[i++] = (byte)((Reason.Length >> 8) % 256); + Array.Copy(Reason, 0, bytes, i, Reason.Length); i += Reason.Length; + bytes[i++] = (byte)(KickFlags % 256); + bytes[i++] = (byte)((KickFlags >> 8) % 256); + bytes[i++] = (byte)((KickFlags >> 16) % 256); + bytes[i++] = (byte)((KickFlags >> 24) % 256); + if(GodID == null) { Console.WriteLine("Warning: GodID is null, in " + this.GetType()); } + Array.Copy(GodID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- UserInfo --\n"; - output += "GodSessionID: " + GodSessionID.ToString() + "\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += Helpers.FieldToString(Reason, "Reason") + "\n"; - output += "KickFlags: " + KickFlags.ToString() + "\n"; - output += "GodID: " + GodID.ToString() + "\n"; + { + string output = "-- UserInfo --\n"; + output += "GodSessionID: " + GodSessionID.ToString() + "\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += Helpers.FieldToString(Reason, "Reason") + "\n"; + output += "KickFlags: " + KickFlags.ToString() + "\n"; + output += "GodID: " + GodID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.GodKickUser - public override PacketType Type { get { return PacketType.GodKickUser; } } - /// UserInfo block - public UserInfoBlock UserInfo; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.GodKickUser + public override PacketType Type { get { return PacketType.GodKickUser; } } + /// UserInfo block + public UserInfoBlock UserInfo; + + /// Default constructor public GodKickUserPacket() - { - Header = new LowHeader(); - Header.ID = 208; - Header.Reliable = true; - UserInfo = new UserInfoBlock(); + { + Header = new LowHeader(); + Header.ID = 208; + Header.Reliable = true; + UserInfo = new UserInfoBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public GodKickUserPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - UserInfo = new UserInfoBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + UserInfo = new UserInfoBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public GodKickUserPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - UserInfo = new UserInfoBlock(bytes, ref i); + { + Header = head; + UserInfo = new UserInfoBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += UserInfo.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - UserInfo.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += UserInfo.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + UserInfo.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- GodKickUser ---\n"; - output += UserInfo.ToString() + "\n"; + { + string output = "--- GodKickUser ---\n"; + output += UserInfo.ToString() + "\n"; return output; } - + } - - /// SystemKickUser packet + + /// SystemKickUser packet public class SystemKickUserPacket : Packet - { - /// AgentInfo block + { + /// AgentInfo block public class AgentInfoBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentInfoBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentInfoBlock() { } + /// Constructor for building the block from a byte array public AgentInfoBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentInfo --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentInfo --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.SystemKickUser - public override PacketType Type { get { return PacketType.SystemKickUser; } } - /// AgentInfo block - public AgentInfoBlock[] AgentInfo; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.SystemKickUser + public override PacketType Type { get { return PacketType.SystemKickUser; } } + /// AgentInfo block + public AgentInfoBlock[] AgentInfo; + + /// Default constructor public SystemKickUserPacket() - { - Header = new LowHeader(); - Header.ID = 209; - Header.Reliable = true; - AgentInfo = new AgentInfoBlock[0]; + { + Header = new LowHeader(); + Header.ID = 209; + Header.Reliable = true; + AgentInfo = new AgentInfoBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public SystemKickUserPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - AgentInfo = new AgentInfoBlock[count]; - for (int j = 0; j < count; j++) - { AgentInfo[j] = new AgentInfoBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + AgentInfo = new AgentInfoBlock[count]; + for (int j = 0; j < count; j++) + { AgentInfo[j] = new AgentInfoBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public SystemKickUserPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - AgentInfo = new AgentInfoBlock[count]; - for (int j = 0; j < count; j++) - { AgentInfo[j] = new AgentInfoBlock(bytes, ref i); } + { + Header = head; + int count = (int)bytes[i++]; + AgentInfo = new AgentInfoBlock[count]; + for (int j = 0; j < count; j++) + { AgentInfo[j] = new AgentInfoBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; -; - length++; - for (int j = 0; j < AgentInfo.Length; j++) { length += AgentInfo[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)AgentInfo.Length; - for (int j = 0; j < AgentInfo.Length; j++) { AgentInfo[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; +; + length++; + for (int j = 0; j < AgentInfo.Length; j++) { length += AgentInfo[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)AgentInfo.Length; + for (int j = 0; j < AgentInfo.Length; j++) { AgentInfo[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- SystemKickUser ---\n"; + { + string output = "--- SystemKickUser ---\n"; for (int j = 0; j < AgentInfo.Length; j++) - { + { output += AgentInfo[j].ToString() + "\n"; - } + } return output; } - + } - - /// EjectUser packet + + /// EjectUser packet public class EjectUserPacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - /// TargetID field - public LLUUID TargetID; - /// Flags field - public uint Flags; - - /// Length of this block serialized in bytes + { + /// TargetID field + public LLUUID TargetID; + /// Flags field + public uint Flags; + + /// Length of this block serialized in bytes public int Length { get - { - return 20; + { + return 20; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { + { try - { - TargetID = new LLUUID(bytes, i); i += 16; - Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + TargetID = new LLUUID(bytes, i); i += 16; + Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(TargetID == null) { Console.WriteLine("Warning: TargetID is null, in " + this.GetType()); } - Array.Copy(TargetID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(Flags % 256); - bytes[i++] = (byte)((Flags >> 8) % 256); - bytes[i++] = (byte)((Flags >> 16) % 256); - bytes[i++] = (byte)((Flags >> 24) % 256); + { + if(TargetID == null) { Console.WriteLine("Warning: TargetID is null, in " + this.GetType()); } + Array.Copy(TargetID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(Flags % 256); + bytes[i++] = (byte)((Flags >> 8) % 256); + bytes[i++] = (byte)((Flags >> 16) % 256); + bytes[i++] = (byte)((Flags >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "TargetID: " + TargetID.ToString() + "\n"; - output += "Flags: " + Flags.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += "TargetID: " + TargetID.ToString() + "\n"; + output += "Flags: " + Flags.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.EjectUser - public override PacketType Type { get { return PacketType.EjectUser; } } - /// Data block - public DataBlock Data; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.EjectUser + public override PacketType Type { get { return PacketType.EjectUser; } } + /// Data block + public DataBlock Data; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public EjectUserPacket() - { - Header = new LowHeader(); - Header.ID = 210; - Header.Reliable = true; - Data = new DataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 210; + Header.Reliable = true; + Data = new DataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public EjectUserPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public EjectUserPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Data.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Data.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Data.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Data.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- EjectUser ---\n"; - output += Data.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- EjectUser ---\n"; + output += Data.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// FreezeUser packet + + /// FreezeUser packet public class FreezeUserPacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - /// TargetID field - public LLUUID TargetID; - /// Flags field - public uint Flags; - - /// Length of this block serialized in bytes + { + /// TargetID field + public LLUUID TargetID; + /// Flags field + public uint Flags; + + /// Length of this block serialized in bytes public int Length { get - { - return 20; + { + return 20; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { + { try - { - TargetID = new LLUUID(bytes, i); i += 16; - Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + TargetID = new LLUUID(bytes, i); i += 16; + Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(TargetID == null) { Console.WriteLine("Warning: TargetID is null, in " + this.GetType()); } - Array.Copy(TargetID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(Flags % 256); - bytes[i++] = (byte)((Flags >> 8) % 256); - bytes[i++] = (byte)((Flags >> 16) % 256); - bytes[i++] = (byte)((Flags >> 24) % 256); + { + if(TargetID == null) { Console.WriteLine("Warning: TargetID is null, in " + this.GetType()); } + Array.Copy(TargetID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(Flags % 256); + bytes[i++] = (byte)((Flags >> 8) % 256); + bytes[i++] = (byte)((Flags >> 16) % 256); + bytes[i++] = (byte)((Flags >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "TargetID: " + TargetID.ToString() + "\n"; - output += "Flags: " + Flags.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += "TargetID: " + TargetID.ToString() + "\n"; + output += "Flags: " + Flags.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.FreezeUser - public override PacketType Type { get { return PacketType.FreezeUser; } } - /// Data block - public DataBlock Data; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.FreezeUser + public override PacketType Type { get { return PacketType.FreezeUser; } } + /// Data block + public DataBlock Data; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public FreezeUserPacket() - { - Header = new LowHeader(); - Header.ID = 211; - Header.Reliable = true; - Data = new DataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 211; + Header.Reliable = true; + Data = new DataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public FreezeUserPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public FreezeUserPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Data.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Data.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Data.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Data.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- FreezeUser ---\n"; - output += Data.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- FreezeUser ---\n"; + output += Data.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// AvatarPropertiesRequest packet + + /// AvatarPropertiesRequest packet public class AvatarPropertiesRequestPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - /// AvatarID field - public LLUUID AvatarID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + /// AvatarID field + public LLUUID AvatarID; + + /// Length of this block serialized in bytes public int Length { get - { - return 48; + { + return 48; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; - AvatarID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; + AvatarID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - if(AvatarID == null) { Console.WriteLine("Warning: AvatarID is null, in " + this.GetType()); } - Array.Copy(AvatarID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + if(AvatarID == null) { Console.WriteLine("Warning: AvatarID is null, in " + this.GetType()); } + Array.Copy(AvatarID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "AvatarID: " + AvatarID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "AvatarID: " + AvatarID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AvatarPropertiesRequest - public override PacketType Type { get { return PacketType.AvatarPropertiesRequest; } } - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AvatarPropertiesRequest + public override PacketType Type { get { return PacketType.AvatarPropertiesRequest; } } + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public AvatarPropertiesRequestPacket() - { - Header = new LowHeader(); - Header.ID = 212; - Header.Reliable = true; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 212; + Header.Reliable = true; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AvatarPropertiesRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AvatarPropertiesRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AvatarPropertiesRequest ---\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- AvatarPropertiesRequest ---\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// AvatarPropertiesRequestBackend packet + + /// AvatarPropertiesRequestBackend packet public class AvatarPropertiesRequestBackendPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// GodLevel field - public byte GodLevel; - /// AvatarID field - public LLUUID AvatarID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// GodLevel field + public byte GodLevel; + /// AvatarID field + public LLUUID AvatarID; + + /// Length of this block serialized in bytes public int Length { get - { - return 33; + { + return 33; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - GodLevel = (byte)bytes[i++]; - AvatarID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + GodLevel = (byte)bytes[i++]; + AvatarID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = GodLevel; - if(AvatarID == null) { Console.WriteLine("Warning: AvatarID is null, in " + this.GetType()); } - Array.Copy(AvatarID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = GodLevel; + if(AvatarID == null) { Console.WriteLine("Warning: AvatarID is null, in " + this.GetType()); } + Array.Copy(AvatarID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "GodLevel: " + GodLevel.ToString() + "\n"; - output += "AvatarID: " + AvatarID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "GodLevel: " + GodLevel.ToString() + "\n"; + output += "AvatarID: " + AvatarID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AvatarPropertiesRequestBackend - public override PacketType Type { get { return PacketType.AvatarPropertiesRequestBackend; } } - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AvatarPropertiesRequestBackend + public override PacketType Type { get { return PacketType.AvatarPropertiesRequestBackend; } } + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public AvatarPropertiesRequestBackendPacket() - { - Header = new LowHeader(); - Header.ID = 213; - Header.Reliable = true; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 213; + Header.Reliable = true; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AvatarPropertiesRequestBackendPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AvatarPropertiesRequestBackendPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AvatarPropertiesRequestBackend ---\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- AvatarPropertiesRequestBackend ---\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// AvatarPropertiesReply packet + + /// AvatarPropertiesReply packet public class AvatarPropertiesReplyPacket : Packet - { - /// PropertiesData block + { + /// PropertiesData block public class PropertiesDataBlock - { - /// PartnerID field - public LLUUID PartnerID; - private byte[] _abouttext; - /// AboutText field + { + /// PartnerID field + public LLUUID PartnerID; + private byte[] _abouttext; + /// AboutText field public byte[] AboutText - { - get { return _abouttext; } + { + get { return _abouttext; } set - { - if (value == null) { _abouttext = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _abouttext = new byte[value.Length]; Array.Copy(value, _abouttext, value.Length); } + { + if (value == null) { _abouttext = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _abouttext = new byte[value.Length]; Array.Copy(value, _abouttext, value.Length); } } - } - /// Transacted field - public bool Transacted; - private byte[] _chartermember; - /// CharterMember field + } + /// Transacted field + public bool Transacted; + private byte[] _chartermember; + /// CharterMember field public byte[] CharterMember - { - get { return _chartermember; } + { + get { return _chartermember; } set - { - if (value == null) { _chartermember = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _chartermember = new byte[value.Length]; Array.Copy(value, _chartermember, value.Length); } + { + if (value == null) { _chartermember = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _chartermember = new byte[value.Length]; Array.Copy(value, _chartermember, value.Length); } } - } - private byte[] _flabouttext; - /// FLAboutText field + } + private byte[] _flabouttext; + /// FLAboutText field public byte[] FLAboutText - { - get { return _flabouttext; } + { + get { return _flabouttext; } set - { - if (value == null) { _flabouttext = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _flabouttext = new byte[value.Length]; Array.Copy(value, _flabouttext, value.Length); } + { + if (value == null) { _flabouttext = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _flabouttext = new byte[value.Length]; Array.Copy(value, _flabouttext, value.Length); } } - } - /// ImageID field - public LLUUID ImageID; - /// FLImageID field - public LLUUID FLImageID; - /// AllowPublish field - public bool AllowPublish; - /// WantToMask field - public uint WantToMask; - private byte[] _wanttotext; - /// WantToText field + } + /// ImageID field + public LLUUID ImageID; + /// FLImageID field + public LLUUID FLImageID; + /// AllowPublish field + public bool AllowPublish; + /// WantToMask field + public uint WantToMask; + private byte[] _wanttotext; + /// WantToText field public byte[] WantToText - { - get { return _wanttotext; } + { + get { return _wanttotext; } set - { - if (value == null) { _wanttotext = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _wanttotext = new byte[value.Length]; Array.Copy(value, _wanttotext, value.Length); } + { + if (value == null) { _wanttotext = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _wanttotext = new byte[value.Length]; Array.Copy(value, _wanttotext, value.Length); } } - } - /// SkillsMask field - public uint SkillsMask; - private byte[] _skillstext; - /// SkillsText field + } + /// SkillsMask field + public uint SkillsMask; + private byte[] _skillstext; + /// SkillsText field public byte[] SkillsText - { - get { return _skillstext; } + { + get { return _skillstext; } set - { - if (value == null) { _skillstext = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _skillstext = new byte[value.Length]; Array.Copy(value, _skillstext, value.Length); } + { + if (value == null) { _skillstext = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _skillstext = new byte[value.Length]; Array.Copy(value, _skillstext, value.Length); } } - } - /// Identified field - public bool Identified; - private byte[] _bornon; - /// BornOn field + } + /// Identified field + public bool Identified; + private byte[] _bornon; + /// BornOn field public byte[] BornOn - { - get { return _bornon; } + { + get { return _bornon; } set - { - if (value == null) { _bornon = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _bornon = new byte[value.Length]; Array.Copy(value, _bornon, value.Length); } + { + if (value == null) { _bornon = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _bornon = new byte[value.Length]; Array.Copy(value, _bornon, value.Length); } } - } - /// MaturePublish field - public bool MaturePublish; - - /// Length of this block serialized in bytes + } + /// MaturePublish field + public bool MaturePublish; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 60; - if (AboutText != null) { length += 2 + AboutText.Length; } - if (CharterMember != null) { length += 1 + CharterMember.Length; } - if (FLAboutText != null) { length += 1 + FLAboutText.Length; } - if (WantToText != null) { length += 1 + WantToText.Length; } - if (SkillsText != null) { length += 1 + SkillsText.Length; } - if (BornOn != null) { length += 1 + BornOn.Length; } - return length; + { + int length = 60; + if (AboutText != null) { length += 2 + AboutText.Length; } + if (CharterMember != null) { length += 1 + CharterMember.Length; } + if (FLAboutText != null) { length += 1 + FLAboutText.Length; } + if (WantToText != null) { length += 1 + WantToText.Length; } + if (SkillsText != null) { length += 1 + SkillsText.Length; } + if (BornOn != null) { length += 1 + BornOn.Length; } + return length; } } - - /// Default constructor - public PropertiesDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public PropertiesDataBlock() { } + /// Constructor for building the block from a byte array public PropertiesDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - PartnerID = new LLUUID(bytes, i); i += 16; - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _abouttext = new byte[length]; - Array.Copy(bytes, i, _abouttext, 0, length); i += length; - Transacted = (bytes[i++] != 0) ? (bool)true : (bool)false; - length = (ushort)bytes[i++]; - _chartermember = new byte[length]; - Array.Copy(bytes, i, _chartermember, 0, length); i += length; - length = (ushort)bytes[i++]; - _flabouttext = new byte[length]; - Array.Copy(bytes, i, _flabouttext, 0, length); i += length; - ImageID = new LLUUID(bytes, i); i += 16; - FLImageID = new LLUUID(bytes, i); i += 16; - AllowPublish = (bytes[i++] != 0) ? (bool)true : (bool)false; - WantToMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _wanttotext = new byte[length]; - Array.Copy(bytes, i, _wanttotext, 0, length); i += length; - SkillsMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _skillstext = new byte[length]; - Array.Copy(bytes, i, _skillstext, 0, length); i += length; - Identified = (bytes[i++] != 0) ? (bool)true : (bool)false; - length = (ushort)bytes[i++]; - _bornon = new byte[length]; - Array.Copy(bytes, i, _bornon, 0, length); i += length; - MaturePublish = (bytes[i++] != 0) ? (bool)true : (bool)false; + { + PartnerID = new LLUUID(bytes, i); i += 16; + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _abouttext = new byte[length]; + Array.Copy(bytes, i, _abouttext, 0, length); i += length; + Transacted = (bytes[i++] != 0) ? (bool)true : (bool)false; + length = (ushort)bytes[i++]; + _chartermember = new byte[length]; + Array.Copy(bytes, i, _chartermember, 0, length); i += length; + length = (ushort)bytes[i++]; + _flabouttext = new byte[length]; + Array.Copy(bytes, i, _flabouttext, 0, length); i += length; + ImageID = new LLUUID(bytes, i); i += 16; + FLImageID = new LLUUID(bytes, i); i += 16; + AllowPublish = (bytes[i++] != 0) ? (bool)true : (bool)false; + WantToMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _wanttotext = new byte[length]; + Array.Copy(bytes, i, _wanttotext, 0, length); i += length; + SkillsMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _skillstext = new byte[length]; + Array.Copy(bytes, i, _skillstext, 0, length); i += length; + Identified = (bytes[i++] != 0) ? (bool)true : (bool)false; + length = (ushort)bytes[i++]; + _bornon = new byte[length]; + Array.Copy(bytes, i, _bornon, 0, length); i += length; + MaturePublish = (bytes[i++] != 0) ? (bool)true : (bool)false; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(PartnerID == null) { Console.WriteLine("Warning: PartnerID is null, in " + this.GetType()); } - Array.Copy(PartnerID.GetBytes(), 0, bytes, i, 16); i += 16; - if(AboutText == null) { Console.WriteLine("Warning: AboutText is null, in " + this.GetType()); } - bytes[i++] = (byte)(AboutText.Length % 256); - bytes[i++] = (byte)((AboutText.Length >> 8) % 256); - Array.Copy(AboutText, 0, bytes, i, AboutText.Length); i += AboutText.Length; - bytes[i++] = (byte)((Transacted) ? 1 : 0); - if(CharterMember == null) { Console.WriteLine("Warning: CharterMember is null, in " + this.GetType()); } - bytes[i++] = (byte)CharterMember.Length; - Array.Copy(CharterMember, 0, bytes, i, CharterMember.Length); i += CharterMember.Length; - if(FLAboutText == null) { Console.WriteLine("Warning: FLAboutText is null, in " + this.GetType()); } - bytes[i++] = (byte)FLAboutText.Length; - Array.Copy(FLAboutText, 0, bytes, i, FLAboutText.Length); i += FLAboutText.Length; - if(ImageID == null) { Console.WriteLine("Warning: ImageID is null, in " + this.GetType()); } - Array.Copy(ImageID.GetBytes(), 0, bytes, i, 16); i += 16; - if(FLImageID == null) { Console.WriteLine("Warning: FLImageID is null, in " + this.GetType()); } - Array.Copy(FLImageID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((AllowPublish) ? 1 : 0); - bytes[i++] = (byte)(WantToMask % 256); - bytes[i++] = (byte)((WantToMask >> 8) % 256); - bytes[i++] = (byte)((WantToMask >> 16) % 256); - bytes[i++] = (byte)((WantToMask >> 24) % 256); - if(WantToText == null) { Console.WriteLine("Warning: WantToText is null, in " + this.GetType()); } - bytes[i++] = (byte)WantToText.Length; - Array.Copy(WantToText, 0, bytes, i, WantToText.Length); i += WantToText.Length; - bytes[i++] = (byte)(SkillsMask % 256); - bytes[i++] = (byte)((SkillsMask >> 8) % 256); - bytes[i++] = (byte)((SkillsMask >> 16) % 256); - bytes[i++] = (byte)((SkillsMask >> 24) % 256); - if(SkillsText == null) { Console.WriteLine("Warning: SkillsText is null, in " + this.GetType()); } - bytes[i++] = (byte)SkillsText.Length; - Array.Copy(SkillsText, 0, bytes, i, SkillsText.Length); i += SkillsText.Length; - bytes[i++] = (byte)((Identified) ? 1 : 0); - if(BornOn == null) { Console.WriteLine("Warning: BornOn is null, in " + this.GetType()); } - bytes[i++] = (byte)BornOn.Length; - Array.Copy(BornOn, 0, bytes, i, BornOn.Length); i += BornOn.Length; - bytes[i++] = (byte)((MaturePublish) ? 1 : 0); + { + if(PartnerID == null) { Console.WriteLine("Warning: PartnerID is null, in " + this.GetType()); } + Array.Copy(PartnerID.GetBytes(), 0, bytes, i, 16); i += 16; + if(AboutText == null) { Console.WriteLine("Warning: AboutText is null, in " + this.GetType()); } + bytes[i++] = (byte)(AboutText.Length % 256); + bytes[i++] = (byte)((AboutText.Length >> 8) % 256); + Array.Copy(AboutText, 0, bytes, i, AboutText.Length); i += AboutText.Length; + bytes[i++] = (byte)((Transacted) ? 1 : 0); + if(CharterMember == null) { Console.WriteLine("Warning: CharterMember is null, in " + this.GetType()); } + bytes[i++] = (byte)CharterMember.Length; + Array.Copy(CharterMember, 0, bytes, i, CharterMember.Length); i += CharterMember.Length; + if(FLAboutText == null) { Console.WriteLine("Warning: FLAboutText is null, in " + this.GetType()); } + bytes[i++] = (byte)FLAboutText.Length; + Array.Copy(FLAboutText, 0, bytes, i, FLAboutText.Length); i += FLAboutText.Length; + if(ImageID == null) { Console.WriteLine("Warning: ImageID is null, in " + this.GetType()); } + Array.Copy(ImageID.GetBytes(), 0, bytes, i, 16); i += 16; + if(FLImageID == null) { Console.WriteLine("Warning: FLImageID is null, in " + this.GetType()); } + Array.Copy(FLImageID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((AllowPublish) ? 1 : 0); + bytes[i++] = (byte)(WantToMask % 256); + bytes[i++] = (byte)((WantToMask >> 8) % 256); + bytes[i++] = (byte)((WantToMask >> 16) % 256); + bytes[i++] = (byte)((WantToMask >> 24) % 256); + if(WantToText == null) { Console.WriteLine("Warning: WantToText is null, in " + this.GetType()); } + bytes[i++] = (byte)WantToText.Length; + Array.Copy(WantToText, 0, bytes, i, WantToText.Length); i += WantToText.Length; + bytes[i++] = (byte)(SkillsMask % 256); + bytes[i++] = (byte)((SkillsMask >> 8) % 256); + bytes[i++] = (byte)((SkillsMask >> 16) % 256); + bytes[i++] = (byte)((SkillsMask >> 24) % 256); + if(SkillsText == null) { Console.WriteLine("Warning: SkillsText is null, in " + this.GetType()); } + bytes[i++] = (byte)SkillsText.Length; + Array.Copy(SkillsText, 0, bytes, i, SkillsText.Length); i += SkillsText.Length; + bytes[i++] = (byte)((Identified) ? 1 : 0); + if(BornOn == null) { Console.WriteLine("Warning: BornOn is null, in " + this.GetType()); } + bytes[i++] = (byte)BornOn.Length; + Array.Copy(BornOn, 0, bytes, i, BornOn.Length); i += BornOn.Length; + bytes[i++] = (byte)((MaturePublish) ? 1 : 0); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- PropertiesData --\n"; - output += "PartnerID: " + PartnerID.ToString() + "\n"; - output += Helpers.FieldToString(AboutText, "AboutText") + "\n"; - output += "Transacted: " + Transacted.ToString() + "\n"; - output += Helpers.FieldToString(CharterMember, "CharterMember") + "\n"; - output += Helpers.FieldToString(FLAboutText, "FLAboutText") + "\n"; - output += "ImageID: " + ImageID.ToString() + "\n"; - output += "FLImageID: " + FLImageID.ToString() + "\n"; - output += "AllowPublish: " + AllowPublish.ToString() + "\n"; - output += "WantToMask: " + WantToMask.ToString() + "\n"; - output += Helpers.FieldToString(WantToText, "WantToText") + "\n"; - output += "SkillsMask: " + SkillsMask.ToString() + "\n"; - output += Helpers.FieldToString(SkillsText, "SkillsText") + "\n"; - output += "Identified: " + Identified.ToString() + "\n"; - output += Helpers.FieldToString(BornOn, "BornOn") + "\n"; - output += "MaturePublish: " + MaturePublish.ToString() + "\n"; + { + string output = "-- PropertiesData --\n"; + output += "PartnerID: " + PartnerID.ToString() + "\n"; + output += Helpers.FieldToString(AboutText, "AboutText") + "\n"; + output += "Transacted: " + Transacted.ToString() + "\n"; + output += Helpers.FieldToString(CharterMember, "CharterMember") + "\n"; + output += Helpers.FieldToString(FLAboutText, "FLAboutText") + "\n"; + output += "ImageID: " + ImageID.ToString() + "\n"; + output += "FLImageID: " + FLImageID.ToString() + "\n"; + output += "AllowPublish: " + AllowPublish.ToString() + "\n"; + output += "WantToMask: " + WantToMask.ToString() + "\n"; + output += Helpers.FieldToString(WantToText, "WantToText") + "\n"; + output += "SkillsMask: " + SkillsMask.ToString() + "\n"; + output += Helpers.FieldToString(SkillsText, "SkillsText") + "\n"; + output += "Identified: " + Identified.ToString() + "\n"; + output += Helpers.FieldToString(BornOn, "BornOn") + "\n"; + output += "MaturePublish: " + MaturePublish.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// AvatarID field - public LLUUID AvatarID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// AvatarID field + public LLUUID AvatarID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - AvatarID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + AvatarID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(AvatarID == null) { Console.WriteLine("Warning: AvatarID is null, in " + this.GetType()); } - Array.Copy(AvatarID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(AvatarID == null) { Console.WriteLine("Warning: AvatarID is null, in " + this.GetType()); } + Array.Copy(AvatarID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "AvatarID: " + AvatarID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "AvatarID: " + AvatarID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AvatarPropertiesReply - public override PacketType Type { get { return PacketType.AvatarPropertiesReply; } } - /// PropertiesData block - public PropertiesDataBlock PropertiesData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AvatarPropertiesReply + public override PacketType Type { get { return PacketType.AvatarPropertiesReply; } } + /// PropertiesData block + public PropertiesDataBlock PropertiesData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public AvatarPropertiesReplyPacket() - { - Header = new LowHeader(); - Header.ID = 214; - Header.Reliable = true; - Header.Zerocoded = true; - PropertiesData = new PropertiesDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 214; + Header.Reliable = true; + Header.Zerocoded = true; + PropertiesData = new PropertiesDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AvatarPropertiesReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - PropertiesData = new PropertiesDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + PropertiesData = new PropertiesDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AvatarPropertiesReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - PropertiesData = new PropertiesDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + PropertiesData = new PropertiesDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += PropertiesData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - PropertiesData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += PropertiesData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + PropertiesData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AvatarPropertiesReply ---\n"; - output += PropertiesData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- AvatarPropertiesReply ---\n"; + output += PropertiesData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// AvatarGroupsReply packet + + /// AvatarGroupsReply packet public class AvatarGroupsReplyPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// AvatarID field - public LLUUID AvatarID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// AvatarID field + public LLUUID AvatarID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - AvatarID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + AvatarID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(AvatarID == null) { Console.WriteLine("Warning: AvatarID is null, in " + this.GetType()); } - Array.Copy(AvatarID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(AvatarID == null) { Console.WriteLine("Warning: AvatarID is null, in " + this.GetType()); } + Array.Copy(AvatarID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "AvatarID: " + AvatarID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "AvatarID: " + AvatarID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// GroupData block + + /// GroupData block public class GroupDataBlock - { - private byte[] _grouptitle; - /// GroupTitle field + { + private byte[] _grouptitle; + /// GroupTitle field public byte[] GroupTitle - { - get { return _grouptitle; } + { + get { return _grouptitle; } set - { - if (value == null) { _grouptitle = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _grouptitle = new byte[value.Length]; Array.Copy(value, _grouptitle, value.Length); } + { + if (value == null) { _grouptitle = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _grouptitle = new byte[value.Length]; Array.Copy(value, _grouptitle, value.Length); } } - } - /// GroupPowers field - public ulong GroupPowers; - /// GroupID field - public LLUUID GroupID; - /// GroupInsigniaID field - public LLUUID GroupInsigniaID; - /// AcceptNotices field - public bool AcceptNotices; - private byte[] _groupname; - /// GroupName field + } + /// GroupPowers field + public ulong GroupPowers; + /// GroupID field + public LLUUID GroupID; + /// GroupInsigniaID field + public LLUUID GroupInsigniaID; + /// AcceptNotices field + public bool AcceptNotices; + private byte[] _groupname; + /// GroupName field public byte[] GroupName - { - get { return _groupname; } + { + get { return _groupname; } set - { - if (value == null) { _groupname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _groupname = new byte[value.Length]; Array.Copy(value, _groupname, value.Length); } + { + if (value == null) { _groupname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _groupname = new byte[value.Length]; Array.Copy(value, _groupname, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 41; - if (GroupTitle != null) { length += 1 + GroupTitle.Length; } - if (GroupName != null) { length += 1 + GroupName.Length; } - return length; + { + int length = 41; + if (GroupTitle != null) { length += 1 + GroupTitle.Length; } + if (GroupName != null) { length += 1 + GroupName.Length; } + return length; } } - - /// Default constructor - public GroupDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public GroupDataBlock() { } + /// Constructor for building the block from a byte array public GroupDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _grouptitle = new byte[length]; - Array.Copy(bytes, i, _grouptitle, 0, length); i += length; - GroupPowers = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); - GroupID = new LLUUID(bytes, i); i += 16; - GroupInsigniaID = new LLUUID(bytes, i); i += 16; - AcceptNotices = (bytes[i++] != 0) ? (bool)true : (bool)false; - length = (ushort)bytes[i++]; - _groupname = new byte[length]; - Array.Copy(bytes, i, _groupname, 0, length); i += length; + { + length = (ushort)bytes[i++]; + _grouptitle = new byte[length]; + Array.Copy(bytes, i, _grouptitle, 0, length); i += length; + GroupPowers = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + GroupID = new LLUUID(bytes, i); i += 16; + GroupInsigniaID = new LLUUID(bytes, i); i += 16; + AcceptNotices = (bytes[i++] != 0) ? (bool)true : (bool)false; + length = (ushort)bytes[i++]; + _groupname = new byte[length]; + Array.Copy(bytes, i, _groupname, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(GroupTitle == null) { Console.WriteLine("Warning: GroupTitle is null, in " + this.GetType()); } - bytes[i++] = (byte)GroupTitle.Length; - Array.Copy(GroupTitle, 0, bytes, i, GroupTitle.Length); i += GroupTitle.Length; - bytes[i++] = (byte)(GroupPowers % 256); - bytes[i++] = (byte)((GroupPowers >> 8) % 256); - bytes[i++] = (byte)((GroupPowers >> 16) % 256); - bytes[i++] = (byte)((GroupPowers >> 24) % 256); - bytes[i++] = (byte)((GroupPowers >> 32) % 256); - bytes[i++] = (byte)((GroupPowers >> 40) % 256); - bytes[i++] = (byte)((GroupPowers >> 48) % 256); - bytes[i++] = (byte)((GroupPowers >> 56) % 256); - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; - if(GroupInsigniaID == null) { Console.WriteLine("Warning: GroupInsigniaID is null, in " + this.GetType()); } - Array.Copy(GroupInsigniaID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((AcceptNotices) ? 1 : 0); - if(GroupName == null) { Console.WriteLine("Warning: GroupName is null, in " + this.GetType()); } - bytes[i++] = (byte)GroupName.Length; - Array.Copy(GroupName, 0, bytes, i, GroupName.Length); i += GroupName.Length; + { + if(GroupTitle == null) { Console.WriteLine("Warning: GroupTitle is null, in " + this.GetType()); } + bytes[i++] = (byte)GroupTitle.Length; + Array.Copy(GroupTitle, 0, bytes, i, GroupTitle.Length); i += GroupTitle.Length; + bytes[i++] = (byte)(GroupPowers % 256); + bytes[i++] = (byte)((GroupPowers >> 8) % 256); + bytes[i++] = (byte)((GroupPowers >> 16) % 256); + bytes[i++] = (byte)((GroupPowers >> 24) % 256); + bytes[i++] = (byte)((GroupPowers >> 32) % 256); + bytes[i++] = (byte)((GroupPowers >> 40) % 256); + bytes[i++] = (byte)((GroupPowers >> 48) % 256); + bytes[i++] = (byte)((GroupPowers >> 56) % 256); + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + if(GroupInsigniaID == null) { Console.WriteLine("Warning: GroupInsigniaID is null, in " + this.GetType()); } + Array.Copy(GroupInsigniaID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((AcceptNotices) ? 1 : 0); + if(GroupName == null) { Console.WriteLine("Warning: GroupName is null, in " + this.GetType()); } + bytes[i++] = (byte)GroupName.Length; + Array.Copy(GroupName, 0, bytes, i, GroupName.Length); i += GroupName.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- GroupData --\n"; - output += Helpers.FieldToString(GroupTitle, "GroupTitle") + "\n"; - output += "GroupPowers: " + GroupPowers.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; - output += "GroupInsigniaID: " + GroupInsigniaID.ToString() + "\n"; - output += "AcceptNotices: " + AcceptNotices.ToString() + "\n"; - output += Helpers.FieldToString(GroupName, "GroupName") + "\n"; + { + string output = "-- GroupData --\n"; + output += Helpers.FieldToString(GroupTitle, "GroupTitle") + "\n"; + output += "GroupPowers: " + GroupPowers.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; + output += "GroupInsigniaID: " + GroupInsigniaID.ToString() + "\n"; + output += "AcceptNotices: " + AcceptNotices.ToString() + "\n"; + output += Helpers.FieldToString(GroupName, "GroupName") + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AvatarGroupsReply - public override PacketType Type { get { return PacketType.AvatarGroupsReply; } } - /// AgentData block - public AgentDataBlock AgentData; - /// GroupData block - public GroupDataBlock[] GroupData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AvatarGroupsReply + public override PacketType Type { get { return PacketType.AvatarGroupsReply; } } + /// AgentData block + public AgentDataBlock AgentData; + /// GroupData block + public GroupDataBlock[] GroupData; + + /// Default constructor public AvatarGroupsReplyPacket() - { - Header = new LowHeader(); - Header.ID = 215; - Header.Reliable = true; - Header.Zerocoded = true; - AgentData = new AgentDataBlock(); - GroupData = new GroupDataBlock[0]; + { + Header = new LowHeader(); + Header.ID = 215; + Header.Reliable = true; + Header.Zerocoded = true; + AgentData = new AgentDataBlock(); + GroupData = new GroupDataBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AvatarGroupsReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); - int count = (int)bytes[i++]; - GroupData = new GroupDataBlock[count]; - for (int j = 0; j < count; j++) - { GroupData[j] = new GroupDataBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); + int count = (int)bytes[i++]; + GroupData = new GroupDataBlock[count]; + for (int j = 0; j < count; j++) + { GroupData[j] = new GroupDataBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AvatarGroupsReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); - int count = (int)bytes[i++]; - GroupData = new GroupDataBlock[count]; - for (int j = 0; j < count; j++) - { GroupData[j] = new GroupDataBlock(bytes, ref i); } + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); + int count = (int)bytes[i++]; + GroupData = new GroupDataBlock[count]; + for (int j = 0; j < count; j++) + { GroupData[j] = new GroupDataBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < GroupData.Length; j++) { length += GroupData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - bytes[i++] = (byte)GroupData.Length; - for (int j = 0; j < GroupData.Length; j++) { GroupData[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < GroupData.Length; j++) { length += GroupData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + bytes[i++] = (byte)GroupData.Length; + for (int j = 0; j < GroupData.Length; j++) { GroupData[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AvatarGroupsReply ---\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- AvatarGroupsReply ---\n"; + output += AgentData.ToString() + "\n"; for (int j = 0; j < GroupData.Length; j++) - { + { output += GroupData[j].ToString() + "\n"; - } + } return output; } - + } - - /// AvatarPropertiesUpdate packet + + /// AvatarPropertiesUpdate packet public class AvatarPropertiesUpdatePacket : Packet - { - /// PropertiesData block + { + /// PropertiesData block public class PropertiesDataBlock - { - private byte[] _abouttext; - /// AboutText field + { + private byte[] _abouttext; + /// AboutText field public byte[] AboutText - { - get { return _abouttext; } + { + get { return _abouttext; } set - { - if (value == null) { _abouttext = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _abouttext = new byte[value.Length]; Array.Copy(value, _abouttext, value.Length); } + { + if (value == null) { _abouttext = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _abouttext = new byte[value.Length]; Array.Copy(value, _abouttext, value.Length); } } - } - private byte[] _flabouttext; - /// FLAboutText field + } + private byte[] _flabouttext; + /// FLAboutText field public byte[] FLAboutText - { - get { return _flabouttext; } + { + get { return _flabouttext; } set - { - if (value == null) { _flabouttext = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _flabouttext = new byte[value.Length]; Array.Copy(value, _flabouttext, value.Length); } + { + if (value == null) { _flabouttext = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _flabouttext = new byte[value.Length]; Array.Copy(value, _flabouttext, value.Length); } } - } - /// ImageID field - public LLUUID ImageID; - /// FLImageID field - public LLUUID FLImageID; - /// AllowPublish field - public bool AllowPublish; - /// WantToMask field - public uint WantToMask; - private byte[] _wanttotext; - /// WantToText field + } + /// ImageID field + public LLUUID ImageID; + /// FLImageID field + public LLUUID FLImageID; + /// AllowPublish field + public bool AllowPublish; + /// WantToMask field + public uint WantToMask; + private byte[] _wanttotext; + /// WantToText field public byte[] WantToText - { - get { return _wanttotext; } + { + get { return _wanttotext; } set - { - if (value == null) { _wanttotext = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _wanttotext = new byte[value.Length]; Array.Copy(value, _wanttotext, value.Length); } + { + if (value == null) { _wanttotext = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _wanttotext = new byte[value.Length]; Array.Copy(value, _wanttotext, value.Length); } } - } - /// SkillsMask field - public uint SkillsMask; - private byte[] _skillstext; - /// SkillsText field + } + /// SkillsMask field + public uint SkillsMask; + private byte[] _skillstext; + /// SkillsText field public byte[] SkillsText - { - get { return _skillstext; } + { + get { return _skillstext; } set - { - if (value == null) { _skillstext = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _skillstext = new byte[value.Length]; Array.Copy(value, _skillstext, value.Length); } + { + if (value == null) { _skillstext = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _skillstext = new byte[value.Length]; Array.Copy(value, _skillstext, value.Length); } } - } - /// MaturePublish field - public bool MaturePublish; - - /// Length of this block serialized in bytes + } + /// MaturePublish field + public bool MaturePublish; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 42; - if (AboutText != null) { length += 2 + AboutText.Length; } - if (FLAboutText != null) { length += 1 + FLAboutText.Length; } - if (WantToText != null) { length += 1 + WantToText.Length; } - if (SkillsText != null) { length += 1 + SkillsText.Length; } - return length; + { + int length = 42; + if (AboutText != null) { length += 2 + AboutText.Length; } + if (FLAboutText != null) { length += 1 + FLAboutText.Length; } + if (WantToText != null) { length += 1 + WantToText.Length; } + if (SkillsText != null) { length += 1 + SkillsText.Length; } + return length; } } - - /// Default constructor - public PropertiesDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public PropertiesDataBlock() { } + /// Constructor for building the block from a byte array public PropertiesDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _abouttext = new byte[length]; - Array.Copy(bytes, i, _abouttext, 0, length); i += length; - length = (ushort)bytes[i++]; - _flabouttext = new byte[length]; - Array.Copy(bytes, i, _flabouttext, 0, length); i += length; - ImageID = new LLUUID(bytes, i); i += 16; - FLImageID = new LLUUID(bytes, i); i += 16; - AllowPublish = (bytes[i++] != 0) ? (bool)true : (bool)false; - WantToMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _wanttotext = new byte[length]; - Array.Copy(bytes, i, _wanttotext, 0, length); i += length; - SkillsMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _skillstext = new byte[length]; - Array.Copy(bytes, i, _skillstext, 0, length); i += length; - MaturePublish = (bytes[i++] != 0) ? (bool)true : (bool)false; + { + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _abouttext = new byte[length]; + Array.Copy(bytes, i, _abouttext, 0, length); i += length; + length = (ushort)bytes[i++]; + _flabouttext = new byte[length]; + Array.Copy(bytes, i, _flabouttext, 0, length); i += length; + ImageID = new LLUUID(bytes, i); i += 16; + FLImageID = new LLUUID(bytes, i); i += 16; + AllowPublish = (bytes[i++] != 0) ? (bool)true : (bool)false; + WantToMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _wanttotext = new byte[length]; + Array.Copy(bytes, i, _wanttotext, 0, length); i += length; + SkillsMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _skillstext = new byte[length]; + Array.Copy(bytes, i, _skillstext, 0, length); i += length; + MaturePublish = (bytes[i++] != 0) ? (bool)true : (bool)false; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AboutText == null) { Console.WriteLine("Warning: AboutText is null, in " + this.GetType()); } - bytes[i++] = (byte)(AboutText.Length % 256); - bytes[i++] = (byte)((AboutText.Length >> 8) % 256); - Array.Copy(AboutText, 0, bytes, i, AboutText.Length); i += AboutText.Length; - if(FLAboutText == null) { Console.WriteLine("Warning: FLAboutText is null, in " + this.GetType()); } - bytes[i++] = (byte)FLAboutText.Length; - Array.Copy(FLAboutText, 0, bytes, i, FLAboutText.Length); i += FLAboutText.Length; - if(ImageID == null) { Console.WriteLine("Warning: ImageID is null, in " + this.GetType()); } - Array.Copy(ImageID.GetBytes(), 0, bytes, i, 16); i += 16; - if(FLImageID == null) { Console.WriteLine("Warning: FLImageID is null, in " + this.GetType()); } - Array.Copy(FLImageID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((AllowPublish) ? 1 : 0); - bytes[i++] = (byte)(WantToMask % 256); - bytes[i++] = (byte)((WantToMask >> 8) % 256); - bytes[i++] = (byte)((WantToMask >> 16) % 256); - bytes[i++] = (byte)((WantToMask >> 24) % 256); - if(WantToText == null) { Console.WriteLine("Warning: WantToText is null, in " + this.GetType()); } - bytes[i++] = (byte)WantToText.Length; - Array.Copy(WantToText, 0, bytes, i, WantToText.Length); i += WantToText.Length; - bytes[i++] = (byte)(SkillsMask % 256); - bytes[i++] = (byte)((SkillsMask >> 8) % 256); - bytes[i++] = (byte)((SkillsMask >> 16) % 256); - bytes[i++] = (byte)((SkillsMask >> 24) % 256); - if(SkillsText == null) { Console.WriteLine("Warning: SkillsText is null, in " + this.GetType()); } - bytes[i++] = (byte)SkillsText.Length; - Array.Copy(SkillsText, 0, bytes, i, SkillsText.Length); i += SkillsText.Length; - bytes[i++] = (byte)((MaturePublish) ? 1 : 0); + { + if(AboutText == null) { Console.WriteLine("Warning: AboutText is null, in " + this.GetType()); } + bytes[i++] = (byte)(AboutText.Length % 256); + bytes[i++] = (byte)((AboutText.Length >> 8) % 256); + Array.Copy(AboutText, 0, bytes, i, AboutText.Length); i += AboutText.Length; + if(FLAboutText == null) { Console.WriteLine("Warning: FLAboutText is null, in " + this.GetType()); } + bytes[i++] = (byte)FLAboutText.Length; + Array.Copy(FLAboutText, 0, bytes, i, FLAboutText.Length); i += FLAboutText.Length; + if(ImageID == null) { Console.WriteLine("Warning: ImageID is null, in " + this.GetType()); } + Array.Copy(ImageID.GetBytes(), 0, bytes, i, 16); i += 16; + if(FLImageID == null) { Console.WriteLine("Warning: FLImageID is null, in " + this.GetType()); } + Array.Copy(FLImageID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((AllowPublish) ? 1 : 0); + bytes[i++] = (byte)(WantToMask % 256); + bytes[i++] = (byte)((WantToMask >> 8) % 256); + bytes[i++] = (byte)((WantToMask >> 16) % 256); + bytes[i++] = (byte)((WantToMask >> 24) % 256); + if(WantToText == null) { Console.WriteLine("Warning: WantToText is null, in " + this.GetType()); } + bytes[i++] = (byte)WantToText.Length; + Array.Copy(WantToText, 0, bytes, i, WantToText.Length); i += WantToText.Length; + bytes[i++] = (byte)(SkillsMask % 256); + bytes[i++] = (byte)((SkillsMask >> 8) % 256); + bytes[i++] = (byte)((SkillsMask >> 16) % 256); + bytes[i++] = (byte)((SkillsMask >> 24) % 256); + if(SkillsText == null) { Console.WriteLine("Warning: SkillsText is null, in " + this.GetType()); } + bytes[i++] = (byte)SkillsText.Length; + Array.Copy(SkillsText, 0, bytes, i, SkillsText.Length); i += SkillsText.Length; + bytes[i++] = (byte)((MaturePublish) ? 1 : 0); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- PropertiesData --\n"; - output += Helpers.FieldToString(AboutText, "AboutText") + "\n"; - output += Helpers.FieldToString(FLAboutText, "FLAboutText") + "\n"; - output += "ImageID: " + ImageID.ToString() + "\n"; - output += "FLImageID: " + FLImageID.ToString() + "\n"; - output += "AllowPublish: " + AllowPublish.ToString() + "\n"; - output += "WantToMask: " + WantToMask.ToString() + "\n"; - output += Helpers.FieldToString(WantToText, "WantToText") + "\n"; - output += "SkillsMask: " + SkillsMask.ToString() + "\n"; - output += Helpers.FieldToString(SkillsText, "SkillsText") + "\n"; - output += "MaturePublish: " + MaturePublish.ToString() + "\n"; + { + string output = "-- PropertiesData --\n"; + output += Helpers.FieldToString(AboutText, "AboutText") + "\n"; + output += Helpers.FieldToString(FLAboutText, "FLAboutText") + "\n"; + output += "ImageID: " + ImageID.ToString() + "\n"; + output += "FLImageID: " + FLImageID.ToString() + "\n"; + output += "AllowPublish: " + AllowPublish.ToString() + "\n"; + output += "WantToMask: " + WantToMask.ToString() + "\n"; + output += Helpers.FieldToString(WantToText, "WantToText") + "\n"; + output += "SkillsMask: " + SkillsMask.ToString() + "\n"; + output += Helpers.FieldToString(SkillsText, "SkillsText") + "\n"; + output += "MaturePublish: " + MaturePublish.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AvatarPropertiesUpdate - public override PacketType Type { get { return PacketType.AvatarPropertiesUpdate; } } - /// PropertiesData block - public PropertiesDataBlock PropertiesData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AvatarPropertiesUpdate + public override PacketType Type { get { return PacketType.AvatarPropertiesUpdate; } } + /// PropertiesData block + public PropertiesDataBlock PropertiesData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public AvatarPropertiesUpdatePacket() - { - Header = new LowHeader(); - Header.ID = 216; - Header.Reliable = true; - Header.Zerocoded = true; - PropertiesData = new PropertiesDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 216; + Header.Reliable = true; + Header.Zerocoded = true; + PropertiesData = new PropertiesDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AvatarPropertiesUpdatePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - PropertiesData = new PropertiesDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + PropertiesData = new PropertiesDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AvatarPropertiesUpdatePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - PropertiesData = new PropertiesDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + PropertiesData = new PropertiesDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += PropertiesData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - PropertiesData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += PropertiesData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + PropertiesData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AvatarPropertiesUpdate ---\n"; - output += PropertiesData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- AvatarPropertiesUpdate ---\n"; + output += PropertiesData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// AvatarStatisticsReply packet + + /// AvatarStatisticsReply packet public class AvatarStatisticsReplyPacket : Packet - { - /// StatisticsData block + { + /// StatisticsData block public class StatisticsDataBlock - { - private byte[] _name; - /// Name field + { + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - /// Negative field - public int Negative; - /// Positive field - public int Positive; - - /// Length of this block serialized in bytes + } + /// Negative field + public int Negative; + /// Positive field + public int Positive; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 8; - if (Name != null) { length += 1 + Name.Length; } - return length; + { + int length = 8; + if (Name != null) { length += 1 + Name.Length; } + return length; } } - - /// Default constructor - public StatisticsDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public StatisticsDataBlock() { } + /// Constructor for building the block from a byte array public StatisticsDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; - Negative = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Positive = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; + Negative = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Positive = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; - bytes[i++] = (byte)(Negative % 256); - bytes[i++] = (byte)((Negative >> 8) % 256); - bytes[i++] = (byte)((Negative >> 16) % 256); - bytes[i++] = (byte)((Negative >> 24) % 256); - bytes[i++] = (byte)(Positive % 256); - bytes[i++] = (byte)((Positive >> 8) % 256); - bytes[i++] = (byte)((Positive >> 16) % 256); - bytes[i++] = (byte)((Positive >> 24) % 256); + { + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + bytes[i++] = (byte)(Negative % 256); + bytes[i++] = (byte)((Negative >> 8) % 256); + bytes[i++] = (byte)((Negative >> 16) % 256); + bytes[i++] = (byte)((Negative >> 24) % 256); + bytes[i++] = (byte)(Positive % 256); + bytes[i++] = (byte)((Positive >> 8) % 256); + bytes[i++] = (byte)((Positive >> 16) % 256); + bytes[i++] = (byte)((Positive >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- StatisticsData --\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; - output += "Negative: " + Negative.ToString() + "\n"; - output += "Positive: " + Positive.ToString() + "\n"; + { + string output = "-- StatisticsData --\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; + output += "Negative: " + Negative.ToString() + "\n"; + output += "Positive: " + Positive.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AvatarData block + + /// AvatarData block public class AvatarDataBlock - { - /// AvatarID field - public LLUUID AvatarID; - - /// Length of this block serialized in bytes + { + /// AvatarID field + public LLUUID AvatarID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AvatarDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AvatarDataBlock() { } + /// Constructor for building the block from a byte array public AvatarDataBlock(byte[] bytes, ref int i) - { + { try - { - AvatarID = new LLUUID(bytes, i); i += 16; + { + AvatarID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AvatarID == null) { Console.WriteLine("Warning: AvatarID is null, in " + this.GetType()); } - Array.Copy(AvatarID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AvatarID == null) { Console.WriteLine("Warning: AvatarID is null, in " + this.GetType()); } + Array.Copy(AvatarID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AvatarData --\n"; - output += "AvatarID: " + AvatarID.ToString() + "\n"; + { + string output = "-- AvatarData --\n"; + output += "AvatarID: " + AvatarID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AvatarStatisticsReply - public override PacketType Type { get { return PacketType.AvatarStatisticsReply; } } - /// StatisticsData block - public StatisticsDataBlock[] StatisticsData; - /// AvatarData block - public AvatarDataBlock AvatarData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AvatarStatisticsReply + public override PacketType Type { get { return PacketType.AvatarStatisticsReply; } } + /// StatisticsData block + public StatisticsDataBlock[] StatisticsData; + /// AvatarData block + public AvatarDataBlock AvatarData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public AvatarStatisticsReplyPacket() - { - Header = new LowHeader(); - Header.ID = 217; - Header.Reliable = true; - Header.Zerocoded = true; - StatisticsData = new StatisticsDataBlock[0]; - AvatarData = new AvatarDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 217; + Header.Reliable = true; + Header.Zerocoded = true; + StatisticsData = new StatisticsDataBlock[0]; + AvatarData = new AvatarDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AvatarStatisticsReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - StatisticsData = new StatisticsDataBlock[count]; - for (int j = 0; j < count; j++) - { StatisticsData[j] = new StatisticsDataBlock(bytes, ref i); } - AvatarData = new AvatarDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + StatisticsData = new StatisticsDataBlock[count]; + for (int j = 0; j < count; j++) + { StatisticsData[j] = new StatisticsDataBlock(bytes, ref i); } + AvatarData = new AvatarDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AvatarStatisticsReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - StatisticsData = new StatisticsDataBlock[count]; - for (int j = 0; j < count; j++) - { StatisticsData[j] = new StatisticsDataBlock(bytes, ref i); } - AvatarData = new AvatarDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + StatisticsData = new StatisticsDataBlock[count]; + for (int j = 0; j < count; j++) + { StatisticsData[j] = new StatisticsDataBlock(bytes, ref i); } + AvatarData = new AvatarDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AvatarData.Length; length += AgentData.Length;; - length++; - for (int j = 0; j < StatisticsData.Length; j++) { length += StatisticsData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)StatisticsData.Length; - for (int j = 0; j < StatisticsData.Length; j++) { StatisticsData[j].ToBytes(bytes, ref i); } - AvatarData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AvatarData.Length; length += AgentData.Length;; + length++; + for (int j = 0; j < StatisticsData.Length; j++) { length += StatisticsData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)StatisticsData.Length; + for (int j = 0; j < StatisticsData.Length; j++) { StatisticsData[j].ToBytes(bytes, ref i); } + AvatarData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AvatarStatisticsReply ---\n"; + { + string output = "--- AvatarStatisticsReply ---\n"; for (int j = 0; j < StatisticsData.Length; j++) - { + { output += StatisticsData[j].ToString() + "\n"; - } - output += AvatarData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + } + output += AvatarData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// AvatarNotesReply packet + + /// AvatarNotesReply packet public class AvatarNotesReplyPacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - /// TargetID field - public LLUUID TargetID; - private byte[] _notes; - /// Notes field + { + /// TargetID field + public LLUUID TargetID; + private byte[] _notes; + /// Notes field public byte[] Notes - { - get { return _notes; } + { + get { return _notes; } set - { - if (value == null) { _notes = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _notes = new byte[value.Length]; Array.Copy(value, _notes, value.Length); } + { + if (value == null) { _notes = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _notes = new byte[value.Length]; Array.Copy(value, _notes, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 16; - if (Notes != null) { length += 2 + Notes.Length; } - return length; + { + int length = 16; + if (Notes != null) { length += 2 + Notes.Length; } + return length; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - TargetID = new LLUUID(bytes, i); i += 16; - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _notes = new byte[length]; - Array.Copy(bytes, i, _notes, 0, length); i += length; + { + TargetID = new LLUUID(bytes, i); i += 16; + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _notes = new byte[length]; + Array.Copy(bytes, i, _notes, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(TargetID == null) { Console.WriteLine("Warning: TargetID is null, in " + this.GetType()); } - Array.Copy(TargetID.GetBytes(), 0, bytes, i, 16); i += 16; - if(Notes == null) { Console.WriteLine("Warning: Notes is null, in " + this.GetType()); } - bytes[i++] = (byte)(Notes.Length % 256); - bytes[i++] = (byte)((Notes.Length >> 8) % 256); - Array.Copy(Notes, 0, bytes, i, Notes.Length); i += Notes.Length; + { + if(TargetID == null) { Console.WriteLine("Warning: TargetID is null, in " + this.GetType()); } + Array.Copy(TargetID.GetBytes(), 0, bytes, i, 16); i += 16; + if(Notes == null) { Console.WriteLine("Warning: Notes is null, in " + this.GetType()); } + bytes[i++] = (byte)(Notes.Length % 256); + bytes[i++] = (byte)((Notes.Length >> 8) % 256); + Array.Copy(Notes, 0, bytes, i, Notes.Length); i += Notes.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "TargetID: " + TargetID.ToString() + "\n"; - output += Helpers.FieldToString(Notes, "Notes") + "\n"; + { + string output = "-- Data --\n"; + output += "TargetID: " + TargetID.ToString() + "\n"; + output += Helpers.FieldToString(Notes, "Notes") + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AvatarNotesReply - public override PacketType Type { get { return PacketType.AvatarNotesReply; } } - /// Data block - public DataBlock Data; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AvatarNotesReply + public override PacketType Type { get { return PacketType.AvatarNotesReply; } } + /// Data block + public DataBlock Data; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public AvatarNotesReplyPacket() - { - Header = new LowHeader(); - Header.ID = 218; - Header.Reliable = true; - Data = new DataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 218; + Header.Reliable = true; + Data = new DataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AvatarNotesReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AvatarNotesReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Data.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Data.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Data.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Data.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AvatarNotesReply ---\n"; - output += Data.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- AvatarNotesReply ---\n"; + output += Data.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// AvatarNotesUpdate packet + + /// AvatarNotesUpdate packet public class AvatarNotesUpdatePacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - /// TargetID field - public LLUUID TargetID; - private byte[] _notes; - /// Notes field + { + /// TargetID field + public LLUUID TargetID; + private byte[] _notes; + /// Notes field public byte[] Notes - { - get { return _notes; } + { + get { return _notes; } set - { - if (value == null) { _notes = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _notes = new byte[value.Length]; Array.Copy(value, _notes, value.Length); } + { + if (value == null) { _notes = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _notes = new byte[value.Length]; Array.Copy(value, _notes, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 16; - if (Notes != null) { length += 2 + Notes.Length; } - return length; + { + int length = 16; + if (Notes != null) { length += 2 + Notes.Length; } + return length; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - TargetID = new LLUUID(bytes, i); i += 16; - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _notes = new byte[length]; - Array.Copy(bytes, i, _notes, 0, length); i += length; + { + TargetID = new LLUUID(bytes, i); i += 16; + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _notes = new byte[length]; + Array.Copy(bytes, i, _notes, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(TargetID == null) { Console.WriteLine("Warning: TargetID is null, in " + this.GetType()); } - Array.Copy(TargetID.GetBytes(), 0, bytes, i, 16); i += 16; - if(Notes == null) { Console.WriteLine("Warning: Notes is null, in " + this.GetType()); } - bytes[i++] = (byte)(Notes.Length % 256); - bytes[i++] = (byte)((Notes.Length >> 8) % 256); - Array.Copy(Notes, 0, bytes, i, Notes.Length); i += Notes.Length; + { + if(TargetID == null) { Console.WriteLine("Warning: TargetID is null, in " + this.GetType()); } + Array.Copy(TargetID.GetBytes(), 0, bytes, i, 16); i += 16; + if(Notes == null) { Console.WriteLine("Warning: Notes is null, in " + this.GetType()); } + bytes[i++] = (byte)(Notes.Length % 256); + bytes[i++] = (byte)((Notes.Length >> 8) % 256); + Array.Copy(Notes, 0, bytes, i, Notes.Length); i += Notes.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "TargetID: " + TargetID.ToString() + "\n"; - output += Helpers.FieldToString(Notes, "Notes") + "\n"; + { + string output = "-- Data --\n"; + output += "TargetID: " + TargetID.ToString() + "\n"; + output += Helpers.FieldToString(Notes, "Notes") + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AvatarNotesUpdate - public override PacketType Type { get { return PacketType.AvatarNotesUpdate; } } - /// Data block - public DataBlock Data; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AvatarNotesUpdate + public override PacketType Type { get { return PacketType.AvatarNotesUpdate; } } + /// Data block + public DataBlock Data; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public AvatarNotesUpdatePacket() - { - Header = new LowHeader(); - Header.ID = 219; - Header.Reliable = true; - Data = new DataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 219; + Header.Reliable = true; + Data = new DataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AvatarNotesUpdatePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AvatarNotesUpdatePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Data.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Data.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Data.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Data.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AvatarNotesUpdate ---\n"; - output += Data.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- AvatarNotesUpdate ---\n"; + output += Data.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// AvatarPicksReply packet + + /// AvatarPicksReply packet public class AvatarPicksReplyPacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - private byte[] _pickname; - /// PickName field + { + private byte[] _pickname; + /// PickName field public byte[] PickName - { - get { return _pickname; } + { + get { return _pickname; } set - { - if (value == null) { _pickname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _pickname = new byte[value.Length]; Array.Copy(value, _pickname, value.Length); } + { + if (value == null) { _pickname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _pickname = new byte[value.Length]; Array.Copy(value, _pickname, value.Length); } } - } - /// PickID field - public LLUUID PickID; - - /// Length of this block serialized in bytes + } + /// PickID field + public LLUUID PickID; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 16; - if (PickName != null) { length += 1 + PickName.Length; } - return length; + { + int length = 16; + if (PickName != null) { length += 1 + PickName.Length; } + return length; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _pickname = new byte[length]; - Array.Copy(bytes, i, _pickname, 0, length); i += length; - PickID = new LLUUID(bytes, i); i += 16; + { + length = (ushort)bytes[i++]; + _pickname = new byte[length]; + Array.Copy(bytes, i, _pickname, 0, length); i += length; + PickID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(PickName == null) { Console.WriteLine("Warning: PickName is null, in " + this.GetType()); } - bytes[i++] = (byte)PickName.Length; - Array.Copy(PickName, 0, bytes, i, PickName.Length); i += PickName.Length; - if(PickID == null) { Console.WriteLine("Warning: PickID is null, in " + this.GetType()); } - Array.Copy(PickID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(PickName == null) { Console.WriteLine("Warning: PickName is null, in " + this.GetType()); } + bytes[i++] = (byte)PickName.Length; + Array.Copy(PickName, 0, bytes, i, PickName.Length); i += PickName.Length; + if(PickID == null) { Console.WriteLine("Warning: PickID is null, in " + this.GetType()); } + Array.Copy(PickID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += Helpers.FieldToString(PickName, "PickName") + "\n"; - output += "PickID: " + PickID.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += Helpers.FieldToString(PickName, "PickName") + "\n"; + output += "PickID: " + PickID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// TargetID field - public LLUUID TargetID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// TargetID field + public LLUUID TargetID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - TargetID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + TargetID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(TargetID == null) { Console.WriteLine("Warning: TargetID is null, in " + this.GetType()); } - Array.Copy(TargetID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(TargetID == null) { Console.WriteLine("Warning: TargetID is null, in " + this.GetType()); } + Array.Copy(TargetID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "TargetID: " + TargetID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "TargetID: " + TargetID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AvatarPicksReply - public override PacketType Type { get { return PacketType.AvatarPicksReply; } } - /// Data block - public DataBlock[] Data; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AvatarPicksReply + public override PacketType Type { get { return PacketType.AvatarPicksReply; } } + /// Data block + public DataBlock[] Data; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public AvatarPicksReplyPacket() - { - Header = new LowHeader(); - Header.ID = 220; - Header.Reliable = true; - Data = new DataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 220; + Header.Reliable = true; + Data = new DataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AvatarPicksReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - Data = new DataBlock[count]; - for (int j = 0; j < count; j++) - { Data[j] = new DataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + Data = new DataBlock[count]; + for (int j = 0; j < count; j++) + { Data[j] = new DataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AvatarPicksReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - Data = new DataBlock[count]; - for (int j = 0; j < count; j++) - { Data[j] = new DataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + Data = new DataBlock[count]; + for (int j = 0; j < count; j++) + { Data[j] = new DataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < Data.Length; j++) { length += Data[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)Data.Length; - for (int j = 0; j < Data.Length; j++) { Data[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < Data.Length; j++) { length += Data[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)Data.Length; + for (int j = 0; j < Data.Length; j++) { Data[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AvatarPicksReply ---\n"; + { + string output = "--- AvatarPicksReply ---\n"; for (int j = 0; j < Data.Length; j++) - { + { output += Data[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// EventInfoRequest packet + + /// EventInfoRequest packet public class EventInfoRequestPacket : Packet - { - /// EventData block + { + /// EventData block public class EventDataBlock - { - /// EventID field - public uint EventID; - - /// Length of this block serialized in bytes + { + /// EventID field + public uint EventID; + + /// Length of this block serialized in bytes public int Length { get - { - return 4; + { + return 4; } } - - /// Default constructor - public EventDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public EventDataBlock() { } + /// Constructor for building the block from a byte array public EventDataBlock(byte[] bytes, ref int i) - { + { try - { - EventID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + EventID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(EventID % 256); - bytes[i++] = (byte)((EventID >> 8) % 256); - bytes[i++] = (byte)((EventID >> 16) % 256); - bytes[i++] = (byte)((EventID >> 24) % 256); + { + bytes[i++] = (byte)(EventID % 256); + bytes[i++] = (byte)((EventID >> 8) % 256); + bytes[i++] = (byte)((EventID >> 16) % 256); + bytes[i++] = (byte)((EventID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- EventData --\n"; - output += "EventID: " + EventID.ToString() + "\n"; + { + string output = "-- EventData --\n"; + output += "EventID: " + EventID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.EventInfoRequest - public override PacketType Type { get { return PacketType.EventInfoRequest; } } - /// EventData block - public EventDataBlock EventData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.EventInfoRequest + public override PacketType Type { get { return PacketType.EventInfoRequest; } } + /// EventData block + public EventDataBlock EventData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public EventInfoRequestPacket() - { - Header = new LowHeader(); - Header.ID = 221; - Header.Reliable = true; - EventData = new EventDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 221; + Header.Reliable = true; + EventData = new EventDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public EventInfoRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - EventData = new EventDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + EventData = new EventDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public EventInfoRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - EventData = new EventDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + EventData = new EventDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += EventData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - EventData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += EventData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + EventData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- EventInfoRequest ---\n"; - output += EventData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- EventInfoRequest ---\n"; + output += EventData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// EventInfoReply packet + + /// EventInfoReply packet public class EventInfoReplyPacket : Packet - { - /// EventData block + { + /// EventData block public class EventDataBlock - { - /// Duration field - public uint Duration; - /// DateUTC field - public uint DateUTC; - private byte[] _simname; - /// SimName field + { + /// Duration field + public uint Duration; + /// DateUTC field + public uint DateUTC; + private byte[] _simname; + /// SimName field public byte[] SimName - { - get { return _simname; } + { + get { return _simname; } set - { - if (value == null) { _simname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _simname = new byte[value.Length]; Array.Copy(value, _simname, value.Length); } + { + if (value == null) { _simname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _simname = new byte[value.Length]; Array.Copy(value, _simname, value.Length); } } - } - /// GlobalPos field - public LLVector3d GlobalPos; - private byte[] _creator; - /// Creator field + } + /// GlobalPos field + public LLVector3d GlobalPos; + private byte[] _creator; + /// Creator field public byte[] Creator - { - get { return _creator; } + { + get { return _creator; } set - { - if (value == null) { _creator = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _creator = new byte[value.Length]; Array.Copy(value, _creator, value.Length); } + { + if (value == null) { _creator = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _creator = new byte[value.Length]; Array.Copy(value, _creator, value.Length); } } - } - private byte[] _name; - /// Name field + } + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - private byte[] _date; - /// Date field + } + private byte[] _date; + /// Date field public byte[] Date - { - get { return _date; } + { + get { return _date; } set - { - if (value == null) { _date = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _date = new byte[value.Length]; Array.Copy(value, _date, value.Length); } + { + if (value == null) { _date = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _date = new byte[value.Length]; Array.Copy(value, _date, value.Length); } } - } - private byte[] _desc; - /// Desc field + } + private byte[] _desc; + /// Desc field public byte[] Desc - { - get { return _desc; } + { + get { return _desc; } set - { - if (value == null) { _desc = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _desc = new byte[value.Length]; Array.Copy(value, _desc, value.Length); } + { + if (value == null) { _desc = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _desc = new byte[value.Length]; Array.Copy(value, _desc, value.Length); } } - } - /// EventID field - public uint EventID; - private byte[] _category; - /// Category field + } + /// EventID field + public uint EventID; + private byte[] _category; + /// Category field public byte[] Category - { - get { return _category; } + { + get { return _category; } set - { - if (value == null) { _category = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _category = new byte[value.Length]; Array.Copy(value, _category, value.Length); } + { + if (value == null) { _category = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _category = new byte[value.Length]; Array.Copy(value, _category, value.Length); } } - } - /// EventFlags field - public uint EventFlags; - /// Amount field - public uint Amount; - /// Cover field - public uint Cover; - - /// Length of this block serialized in bytes + } + /// EventFlags field + public uint EventFlags; + /// Amount field + public uint Amount; + /// Cover field + public uint Cover; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 48; - if (SimName != null) { length += 1 + SimName.Length; } - if (Creator != null) { length += 1 + Creator.Length; } - if (Name != null) { length += 1 + Name.Length; } - if (Date != null) { length += 1 + Date.Length; } - if (Desc != null) { length += 2 + Desc.Length; } - if (Category != null) { length += 1 + Category.Length; } - return length; + { + int length = 48; + if (SimName != null) { length += 1 + SimName.Length; } + if (Creator != null) { length += 1 + Creator.Length; } + if (Name != null) { length += 1 + Name.Length; } + if (Date != null) { length += 1 + Date.Length; } + if (Desc != null) { length += 2 + Desc.Length; } + if (Category != null) { length += 1 + Category.Length; } + return length; } } - - /// Default constructor - public EventDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public EventDataBlock() { } + /// Constructor for building the block from a byte array public EventDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - Duration = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - DateUTC = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _simname = new byte[length]; - Array.Copy(bytes, i, _simname, 0, length); i += length; - GlobalPos = new LLVector3d(bytes, i); i += 24; - length = (ushort)bytes[i++]; - _creator = new byte[length]; - Array.Copy(bytes, i, _creator, 0, length); i += length; - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; - length = (ushort)bytes[i++]; - _date = new byte[length]; - Array.Copy(bytes, i, _date, 0, length); i += length; - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _desc = new byte[length]; - Array.Copy(bytes, i, _desc, 0, length); i += length; - EventID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _category = new byte[length]; - Array.Copy(bytes, i, _category, 0, length); i += length; - EventFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Amount = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Cover = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + Duration = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + DateUTC = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _simname = new byte[length]; + Array.Copy(bytes, i, _simname, 0, length); i += length; + GlobalPos = new LLVector3d(bytes, i); i += 24; + length = (ushort)bytes[i++]; + _creator = new byte[length]; + Array.Copy(bytes, i, _creator, 0, length); i += length; + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; + length = (ushort)bytes[i++]; + _date = new byte[length]; + Array.Copy(bytes, i, _date, 0, length); i += length; + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _desc = new byte[length]; + Array.Copy(bytes, i, _desc, 0, length); i += length; + EventID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _category = new byte[length]; + Array.Copy(bytes, i, _category, 0, length); i += length; + EventFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Amount = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Cover = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(Duration % 256); - bytes[i++] = (byte)((Duration >> 8) % 256); - bytes[i++] = (byte)((Duration >> 16) % 256); - bytes[i++] = (byte)((Duration >> 24) % 256); - bytes[i++] = (byte)(DateUTC % 256); - bytes[i++] = (byte)((DateUTC >> 8) % 256); - bytes[i++] = (byte)((DateUTC >> 16) % 256); - bytes[i++] = (byte)((DateUTC >> 24) % 256); - if(SimName == null) { Console.WriteLine("Warning: SimName is null, in " + this.GetType()); } - bytes[i++] = (byte)SimName.Length; - Array.Copy(SimName, 0, bytes, i, SimName.Length); i += SimName.Length; - if(GlobalPos == null) { Console.WriteLine("Warning: GlobalPos is null, in " + this.GetType()); } - Array.Copy(GlobalPos.GetBytes(), 0, bytes, i, 24); i += 24; - if(Creator == null) { Console.WriteLine("Warning: Creator is null, in " + this.GetType()); } - bytes[i++] = (byte)Creator.Length; - Array.Copy(Creator, 0, bytes, i, Creator.Length); i += Creator.Length; - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; - if(Date == null) { Console.WriteLine("Warning: Date is null, in " + this.GetType()); } - bytes[i++] = (byte)Date.Length; - Array.Copy(Date, 0, bytes, i, Date.Length); i += Date.Length; - if(Desc == null) { Console.WriteLine("Warning: Desc is null, in " + this.GetType()); } - bytes[i++] = (byte)(Desc.Length % 256); - bytes[i++] = (byte)((Desc.Length >> 8) % 256); - Array.Copy(Desc, 0, bytes, i, Desc.Length); i += Desc.Length; - bytes[i++] = (byte)(EventID % 256); - bytes[i++] = (byte)((EventID >> 8) % 256); - bytes[i++] = (byte)((EventID >> 16) % 256); - bytes[i++] = (byte)((EventID >> 24) % 256); - if(Category == null) { Console.WriteLine("Warning: Category is null, in " + this.GetType()); } - bytes[i++] = (byte)Category.Length; - Array.Copy(Category, 0, bytes, i, Category.Length); i += Category.Length; - bytes[i++] = (byte)(EventFlags % 256); - bytes[i++] = (byte)((EventFlags >> 8) % 256); - bytes[i++] = (byte)((EventFlags >> 16) % 256); - bytes[i++] = (byte)((EventFlags >> 24) % 256); - bytes[i++] = (byte)(Amount % 256); - bytes[i++] = (byte)((Amount >> 8) % 256); - bytes[i++] = (byte)((Amount >> 16) % 256); - bytes[i++] = (byte)((Amount >> 24) % 256); - bytes[i++] = (byte)(Cover % 256); - bytes[i++] = (byte)((Cover >> 8) % 256); - bytes[i++] = (byte)((Cover >> 16) % 256); - bytes[i++] = (byte)((Cover >> 24) % 256); + { + bytes[i++] = (byte)(Duration % 256); + bytes[i++] = (byte)((Duration >> 8) % 256); + bytes[i++] = (byte)((Duration >> 16) % 256); + bytes[i++] = (byte)((Duration >> 24) % 256); + bytes[i++] = (byte)(DateUTC % 256); + bytes[i++] = (byte)((DateUTC >> 8) % 256); + bytes[i++] = (byte)((DateUTC >> 16) % 256); + bytes[i++] = (byte)((DateUTC >> 24) % 256); + if(SimName == null) { Console.WriteLine("Warning: SimName is null, in " + this.GetType()); } + bytes[i++] = (byte)SimName.Length; + Array.Copy(SimName, 0, bytes, i, SimName.Length); i += SimName.Length; + if(GlobalPos == null) { Console.WriteLine("Warning: GlobalPos is null, in " + this.GetType()); } + Array.Copy(GlobalPos.GetBytes(), 0, bytes, i, 24); i += 24; + if(Creator == null) { Console.WriteLine("Warning: Creator is null, in " + this.GetType()); } + bytes[i++] = (byte)Creator.Length; + Array.Copy(Creator, 0, bytes, i, Creator.Length); i += Creator.Length; + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + if(Date == null) { Console.WriteLine("Warning: Date is null, in " + this.GetType()); } + bytes[i++] = (byte)Date.Length; + Array.Copy(Date, 0, bytes, i, Date.Length); i += Date.Length; + if(Desc == null) { Console.WriteLine("Warning: Desc is null, in " + this.GetType()); } + bytes[i++] = (byte)(Desc.Length % 256); + bytes[i++] = (byte)((Desc.Length >> 8) % 256); + Array.Copy(Desc, 0, bytes, i, Desc.Length); i += Desc.Length; + bytes[i++] = (byte)(EventID % 256); + bytes[i++] = (byte)((EventID >> 8) % 256); + bytes[i++] = (byte)((EventID >> 16) % 256); + bytes[i++] = (byte)((EventID >> 24) % 256); + if(Category == null) { Console.WriteLine("Warning: Category is null, in " + this.GetType()); } + bytes[i++] = (byte)Category.Length; + Array.Copy(Category, 0, bytes, i, Category.Length); i += Category.Length; + bytes[i++] = (byte)(EventFlags % 256); + bytes[i++] = (byte)((EventFlags >> 8) % 256); + bytes[i++] = (byte)((EventFlags >> 16) % 256); + bytes[i++] = (byte)((EventFlags >> 24) % 256); + bytes[i++] = (byte)(Amount % 256); + bytes[i++] = (byte)((Amount >> 8) % 256); + bytes[i++] = (byte)((Amount >> 16) % 256); + bytes[i++] = (byte)((Amount >> 24) % 256); + bytes[i++] = (byte)(Cover % 256); + bytes[i++] = (byte)((Cover >> 8) % 256); + bytes[i++] = (byte)((Cover >> 16) % 256); + bytes[i++] = (byte)((Cover >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- EventData --\n"; - output += "Duration: " + Duration.ToString() + "\n"; - output += "DateUTC: " + DateUTC.ToString() + "\n"; - output += Helpers.FieldToString(SimName, "SimName") + "\n"; - output += "GlobalPos: " + GlobalPos.ToString() + "\n"; - output += Helpers.FieldToString(Creator, "Creator") + "\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; - output += Helpers.FieldToString(Date, "Date") + "\n"; - output += Helpers.FieldToString(Desc, "Desc") + "\n"; - output += "EventID: " + EventID.ToString() + "\n"; - output += Helpers.FieldToString(Category, "Category") + "\n"; - output += "EventFlags: " + EventFlags.ToString() + "\n"; - output += "Amount: " + Amount.ToString() + "\n"; - output += "Cover: " + Cover.ToString() + "\n"; + { + string output = "-- EventData --\n"; + output += "Duration: " + Duration.ToString() + "\n"; + output += "DateUTC: " + DateUTC.ToString() + "\n"; + output += Helpers.FieldToString(SimName, "SimName") + "\n"; + output += "GlobalPos: " + GlobalPos.ToString() + "\n"; + output += Helpers.FieldToString(Creator, "Creator") + "\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; + output += Helpers.FieldToString(Date, "Date") + "\n"; + output += Helpers.FieldToString(Desc, "Desc") + "\n"; + output += "EventID: " + EventID.ToString() + "\n"; + output += Helpers.FieldToString(Category, "Category") + "\n"; + output += "EventFlags: " + EventFlags.ToString() + "\n"; + output += "Amount: " + Amount.ToString() + "\n"; + output += "Cover: " + Cover.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.EventInfoReply - public override PacketType Type { get { return PacketType.EventInfoReply; } } - /// EventData block - public EventDataBlock EventData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.EventInfoReply + public override PacketType Type { get { return PacketType.EventInfoReply; } } + /// EventData block + public EventDataBlock EventData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public EventInfoReplyPacket() - { - Header = new LowHeader(); - Header.ID = 222; - Header.Reliable = true; - EventData = new EventDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 222; + Header.Reliable = true; + EventData = new EventDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public EventInfoReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - EventData = new EventDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + EventData = new EventDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public EventInfoReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - EventData = new EventDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + EventData = new EventDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += EventData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - EventData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += EventData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + EventData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- EventInfoReply ---\n"; - output += EventData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- EventInfoReply ---\n"; + output += EventData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// EventNotificationAddRequest packet + + /// EventNotificationAddRequest packet public class EventNotificationAddRequestPacket : Packet - { - /// EventData block + { + /// EventData block public class EventDataBlock - { - /// EventID field - public uint EventID; - - /// Length of this block serialized in bytes + { + /// EventID field + public uint EventID; + + /// Length of this block serialized in bytes public int Length { get - { - return 4; + { + return 4; } } - - /// Default constructor - public EventDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public EventDataBlock() { } + /// Constructor for building the block from a byte array public EventDataBlock(byte[] bytes, ref int i) - { + { try - { - EventID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + EventID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(EventID % 256); - bytes[i++] = (byte)((EventID >> 8) % 256); - bytes[i++] = (byte)((EventID >> 16) % 256); - bytes[i++] = (byte)((EventID >> 24) % 256); + { + bytes[i++] = (byte)(EventID % 256); + bytes[i++] = (byte)((EventID >> 8) % 256); + bytes[i++] = (byte)((EventID >> 16) % 256); + bytes[i++] = (byte)((EventID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- EventData --\n"; - output += "EventID: " + EventID.ToString() + "\n"; + { + string output = "-- EventData --\n"; + output += "EventID: " + EventID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.EventNotificationAddRequest - public override PacketType Type { get { return PacketType.EventNotificationAddRequest; } } - /// EventData block - public EventDataBlock EventData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.EventNotificationAddRequest + public override PacketType Type { get { return PacketType.EventNotificationAddRequest; } } + /// EventData block + public EventDataBlock EventData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public EventNotificationAddRequestPacket() - { - Header = new LowHeader(); - Header.ID = 223; - Header.Reliable = true; - EventData = new EventDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 223; + Header.Reliable = true; + EventData = new EventDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public EventNotificationAddRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - EventData = new EventDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + EventData = new EventDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public EventNotificationAddRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - EventData = new EventDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + EventData = new EventDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += EventData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - EventData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += EventData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + EventData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- EventNotificationAddRequest ---\n"; - output += EventData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- EventNotificationAddRequest ---\n"; + output += EventData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// EventNotificationRemoveRequest packet + + /// EventNotificationRemoveRequest packet public class EventNotificationRemoveRequestPacket : Packet - { - /// EventData block + { + /// EventData block public class EventDataBlock - { - /// EventID field - public uint EventID; - - /// Length of this block serialized in bytes + { + /// EventID field + public uint EventID; + + /// Length of this block serialized in bytes public int Length { get - { - return 4; + { + return 4; } } - - /// Default constructor - public EventDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public EventDataBlock() { } + /// Constructor for building the block from a byte array public EventDataBlock(byte[] bytes, ref int i) - { + { try - { - EventID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + EventID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(EventID % 256); - bytes[i++] = (byte)((EventID >> 8) % 256); - bytes[i++] = (byte)((EventID >> 16) % 256); - bytes[i++] = (byte)((EventID >> 24) % 256); + { + bytes[i++] = (byte)(EventID % 256); + bytes[i++] = (byte)((EventID >> 8) % 256); + bytes[i++] = (byte)((EventID >> 16) % 256); + bytes[i++] = (byte)((EventID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- EventData --\n"; - output += "EventID: " + EventID.ToString() + "\n"; + { + string output = "-- EventData --\n"; + output += "EventID: " + EventID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.EventNotificationRemoveRequest - public override PacketType Type { get { return PacketType.EventNotificationRemoveRequest; } } - /// EventData block - public EventDataBlock EventData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.EventNotificationRemoveRequest + public override PacketType Type { get { return PacketType.EventNotificationRemoveRequest; } } + /// EventData block + public EventDataBlock EventData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public EventNotificationRemoveRequestPacket() - { - Header = new LowHeader(); - Header.ID = 224; - Header.Reliable = true; - EventData = new EventDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 224; + Header.Reliable = true; + EventData = new EventDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public EventNotificationRemoveRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - EventData = new EventDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + EventData = new EventDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public EventNotificationRemoveRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - EventData = new EventDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + EventData = new EventDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += EventData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - EventData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += EventData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + EventData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- EventNotificationRemoveRequest ---\n"; - output += EventData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- EventNotificationRemoveRequest ---\n"; + output += EventData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// EventGodDelete packet + + /// EventGodDelete packet public class EventGodDeletePacket : Packet - { - /// EventData block + { + /// EventData block public class EventDataBlock - { - /// EventID field - public uint EventID; - - /// Length of this block serialized in bytes + { + /// EventID field + public uint EventID; + + /// Length of this block serialized in bytes public int Length { get - { - return 4; + { + return 4; } } - - /// Default constructor - public EventDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public EventDataBlock() { } + /// Constructor for building the block from a byte array public EventDataBlock(byte[] bytes, ref int i) - { + { try - { - EventID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + EventID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(EventID % 256); - bytes[i++] = (byte)((EventID >> 8) % 256); - bytes[i++] = (byte)((EventID >> 16) % 256); - bytes[i++] = (byte)((EventID >> 24) % 256); + { + bytes[i++] = (byte)(EventID % 256); + bytes[i++] = (byte)((EventID >> 8) % 256); + bytes[i++] = (byte)((EventID >> 16) % 256); + bytes[i++] = (byte)((EventID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- EventData --\n"; - output += "EventID: " + EventID.ToString() + "\n"; + { + string output = "-- EventData --\n"; + output += "EventID: " + EventID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// QueryData block + + /// QueryData block public class QueryDataBlock - { - /// QueryID field - public LLUUID QueryID; - /// QueryFlags field - public uint QueryFlags; - /// QueryStart field - public int QueryStart; - private byte[] _querytext; - /// QueryText field + { + /// QueryID field + public LLUUID QueryID; + /// QueryFlags field + public uint QueryFlags; + /// QueryStart field + public int QueryStart; + private byte[] _querytext; + /// QueryText field public byte[] QueryText - { - get { return _querytext; } + { + get { return _querytext; } set - { - if (value == null) { _querytext = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _querytext = new byte[value.Length]; Array.Copy(value, _querytext, value.Length); } + { + if (value == null) { _querytext = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _querytext = new byte[value.Length]; Array.Copy(value, _querytext, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 24; - if (QueryText != null) { length += 1 + QueryText.Length; } - return length; + { + int length = 24; + if (QueryText != null) { length += 1 + QueryText.Length; } + return length; } } - - /// Default constructor - public QueryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public QueryDataBlock() { } + /// Constructor for building the block from a byte array public QueryDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - QueryID = new LLUUID(bytes, i); i += 16; - QueryFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - QueryStart = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _querytext = new byte[length]; - Array.Copy(bytes, i, _querytext, 0, length); i += length; + { + QueryID = new LLUUID(bytes, i); i += 16; + QueryFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + QueryStart = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _querytext = new byte[length]; + Array.Copy(bytes, i, _querytext, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } - Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(QueryFlags % 256); - bytes[i++] = (byte)((QueryFlags >> 8) % 256); - bytes[i++] = (byte)((QueryFlags >> 16) % 256); - bytes[i++] = (byte)((QueryFlags >> 24) % 256); - bytes[i++] = (byte)(QueryStart % 256); - bytes[i++] = (byte)((QueryStart >> 8) % 256); - bytes[i++] = (byte)((QueryStart >> 16) % 256); - bytes[i++] = (byte)((QueryStart >> 24) % 256); - if(QueryText == null) { Console.WriteLine("Warning: QueryText is null, in " + this.GetType()); } - bytes[i++] = (byte)QueryText.Length; - Array.Copy(QueryText, 0, bytes, i, QueryText.Length); i += QueryText.Length; + { + if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } + Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(QueryFlags % 256); + bytes[i++] = (byte)((QueryFlags >> 8) % 256); + bytes[i++] = (byte)((QueryFlags >> 16) % 256); + bytes[i++] = (byte)((QueryFlags >> 24) % 256); + bytes[i++] = (byte)(QueryStart % 256); + bytes[i++] = (byte)((QueryStart >> 8) % 256); + bytes[i++] = (byte)((QueryStart >> 16) % 256); + bytes[i++] = (byte)((QueryStart >> 24) % 256); + if(QueryText == null) { Console.WriteLine("Warning: QueryText is null, in " + this.GetType()); } + bytes[i++] = (byte)QueryText.Length; + Array.Copy(QueryText, 0, bytes, i, QueryText.Length); i += QueryText.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- QueryData --\n"; - output += "QueryID: " + QueryID.ToString() + "\n"; - output += "QueryFlags: " + QueryFlags.ToString() + "\n"; - output += "QueryStart: " + QueryStart.ToString() + "\n"; - output += Helpers.FieldToString(QueryText, "QueryText") + "\n"; + { + string output = "-- QueryData --\n"; + output += "QueryID: " + QueryID.ToString() + "\n"; + output += "QueryFlags: " + QueryFlags.ToString() + "\n"; + output += "QueryStart: " + QueryStart.ToString() + "\n"; + output += Helpers.FieldToString(QueryText, "QueryText") + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.EventGodDelete - public override PacketType Type { get { return PacketType.EventGodDelete; } } - /// EventData block - public EventDataBlock EventData; - /// QueryData block - public QueryDataBlock QueryData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.EventGodDelete + public override PacketType Type { get { return PacketType.EventGodDelete; } } + /// EventData block + public EventDataBlock EventData; + /// QueryData block + public QueryDataBlock QueryData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public EventGodDeletePacket() - { - Header = new LowHeader(); - Header.ID = 225; - Header.Reliable = true; - EventData = new EventDataBlock(); - QueryData = new QueryDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 225; + Header.Reliable = true; + EventData = new EventDataBlock(); + QueryData = new QueryDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public EventGodDeletePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - EventData = new EventDataBlock(bytes, ref i); - QueryData = new QueryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + EventData = new EventDataBlock(bytes, ref i); + QueryData = new QueryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public EventGodDeletePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - EventData = new EventDataBlock(bytes, ref i); - QueryData = new QueryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + EventData = new EventDataBlock(bytes, ref i); + QueryData = new QueryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += EventData.Length; length += QueryData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - EventData.ToBytes(bytes, ref i); - QueryData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += EventData.Length; length += QueryData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + EventData.ToBytes(bytes, ref i); + QueryData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- EventGodDelete ---\n"; - output += EventData.ToString() + "\n"; - output += QueryData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- EventGodDelete ---\n"; + output += EventData.ToString() + "\n"; + output += QueryData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// PickInfoRequest packet + + /// PickInfoRequest packet public class PickInfoRequestPacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - /// PickID field - public LLUUID PickID; - - /// Length of this block serialized in bytes + { + /// PickID field + public LLUUID PickID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { + { try - { - PickID = new LLUUID(bytes, i); i += 16; + { + PickID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(PickID == null) { Console.WriteLine("Warning: PickID is null, in " + this.GetType()); } - Array.Copy(PickID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(PickID == null) { Console.WriteLine("Warning: PickID is null, in " + this.GetType()); } + Array.Copy(PickID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "PickID: " + PickID.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += "PickID: " + PickID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.PickInfoRequest - public override PacketType Type { get { return PacketType.PickInfoRequest; } } - /// Data block - public DataBlock Data; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.PickInfoRequest + public override PacketType Type { get { return PacketType.PickInfoRequest; } } + /// Data block + public DataBlock Data; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public PickInfoRequestPacket() - { - Header = new LowHeader(); - Header.ID = 226; - Header.Reliable = true; - Header.Zerocoded = true; - Data = new DataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 226; + Header.Reliable = true; + Header.Zerocoded = true; + Data = new DataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public PickInfoRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public PickInfoRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Data.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Data.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Data.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Data.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- PickInfoRequest ---\n"; - output += Data.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- PickInfoRequest ---\n"; + output += Data.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// PickInfoReply packet + + /// PickInfoReply packet public class PickInfoReplyPacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - private byte[] _originalname; - /// OriginalName field + { + private byte[] _originalname; + /// OriginalName field public byte[] OriginalName - { - get { return _originalname; } + { + get { return _originalname; } set - { - if (value == null) { _originalname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _originalname = new byte[value.Length]; Array.Copy(value, _originalname, value.Length); } + { + if (value == null) { _originalname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _originalname = new byte[value.Length]; Array.Copy(value, _originalname, value.Length); } } - } - private byte[] _simname; - /// SimName field + } + private byte[] _simname; + /// SimName field public byte[] SimName - { - get { return _simname; } + { + get { return _simname; } set - { - if (value == null) { _simname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _simname = new byte[value.Length]; Array.Copy(value, _simname, value.Length); } + { + if (value == null) { _simname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _simname = new byte[value.Length]; Array.Copy(value, _simname, value.Length); } } - } - /// Enabled field - public bool Enabled; - /// PosGlobal field - public LLVector3d PosGlobal; - /// TopPick field - public bool TopPick; - /// ParcelID field - public LLUUID ParcelID; - private byte[] _name; - /// Name field + } + /// Enabled field + public bool Enabled; + /// PosGlobal field + public LLVector3d PosGlobal; + /// TopPick field + public bool TopPick; + /// ParcelID field + public LLUUID ParcelID; + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - private byte[] _desc; - /// Desc field + } + private byte[] _desc; + /// Desc field public byte[] Desc - { - get { return _desc; } + { + get { return _desc; } set - { - if (value == null) { _desc = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _desc = new byte[value.Length]; Array.Copy(value, _desc, value.Length); } + { + if (value == null) { _desc = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _desc = new byte[value.Length]; Array.Copy(value, _desc, value.Length); } } - } - private byte[] _user; - /// User field + } + private byte[] _user; + /// User field public byte[] User - { - get { return _user; } + { + get { return _user; } set - { - if (value == null) { _user = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _user = new byte[value.Length]; Array.Copy(value, _user, value.Length); } + { + if (value == null) { _user = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _user = new byte[value.Length]; Array.Copy(value, _user, value.Length); } } - } - /// CreatorID field - public LLUUID CreatorID; - /// PickID field - public LLUUID PickID; - /// SnapshotID field - public LLUUID SnapshotID; - /// SortOrder field - public int SortOrder; - - /// Length of this block serialized in bytes + } + /// CreatorID field + public LLUUID CreatorID; + /// PickID field + public LLUUID PickID; + /// SnapshotID field + public LLUUID SnapshotID; + /// SortOrder field + public int SortOrder; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 94; - if (OriginalName != null) { length += 1 + OriginalName.Length; } - if (SimName != null) { length += 1 + SimName.Length; } - if (Name != null) { length += 1 + Name.Length; } - if (Desc != null) { length += 2 + Desc.Length; } - if (User != null) { length += 1 + User.Length; } - return length; + { + int length = 94; + if (OriginalName != null) { length += 1 + OriginalName.Length; } + if (SimName != null) { length += 1 + SimName.Length; } + if (Name != null) { length += 1 + Name.Length; } + if (Desc != null) { length += 2 + Desc.Length; } + if (User != null) { length += 1 + User.Length; } + return length; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _originalname = new byte[length]; - Array.Copy(bytes, i, _originalname, 0, length); i += length; - length = (ushort)bytes[i++]; - _simname = new byte[length]; - Array.Copy(bytes, i, _simname, 0, length); i += length; - Enabled = (bytes[i++] != 0) ? (bool)true : (bool)false; - PosGlobal = new LLVector3d(bytes, i); i += 24; - TopPick = (bytes[i++] != 0) ? (bool)true : (bool)false; - ParcelID = new LLUUID(bytes, i); i += 16; - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _desc = new byte[length]; - Array.Copy(bytes, i, _desc, 0, length); i += length; - length = (ushort)bytes[i++]; - _user = new byte[length]; - Array.Copy(bytes, i, _user, 0, length); i += length; - CreatorID = new LLUUID(bytes, i); i += 16; - PickID = new LLUUID(bytes, i); i += 16; - SnapshotID = new LLUUID(bytes, i); i += 16; - SortOrder = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + length = (ushort)bytes[i++]; + _originalname = new byte[length]; + Array.Copy(bytes, i, _originalname, 0, length); i += length; + length = (ushort)bytes[i++]; + _simname = new byte[length]; + Array.Copy(bytes, i, _simname, 0, length); i += length; + Enabled = (bytes[i++] != 0) ? (bool)true : (bool)false; + PosGlobal = new LLVector3d(bytes, i); i += 24; + TopPick = (bytes[i++] != 0) ? (bool)true : (bool)false; + ParcelID = new LLUUID(bytes, i); i += 16; + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _desc = new byte[length]; + Array.Copy(bytes, i, _desc, 0, length); i += length; + length = (ushort)bytes[i++]; + _user = new byte[length]; + Array.Copy(bytes, i, _user, 0, length); i += length; + CreatorID = new LLUUID(bytes, i); i += 16; + PickID = new LLUUID(bytes, i); i += 16; + SnapshotID = new LLUUID(bytes, i); i += 16; + SortOrder = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(OriginalName == null) { Console.WriteLine("Warning: OriginalName is null, in " + this.GetType()); } - bytes[i++] = (byte)OriginalName.Length; - Array.Copy(OriginalName, 0, bytes, i, OriginalName.Length); i += OriginalName.Length; - if(SimName == null) { Console.WriteLine("Warning: SimName is null, in " + this.GetType()); } - bytes[i++] = (byte)SimName.Length; - Array.Copy(SimName, 0, bytes, i, SimName.Length); i += SimName.Length; - bytes[i++] = (byte)((Enabled) ? 1 : 0); - if(PosGlobal == null) { Console.WriteLine("Warning: PosGlobal is null, in " + this.GetType()); } - Array.Copy(PosGlobal.GetBytes(), 0, bytes, i, 24); i += 24; - bytes[i++] = (byte)((TopPick) ? 1 : 0); - if(ParcelID == null) { Console.WriteLine("Warning: ParcelID is null, in " + this.GetType()); } - Array.Copy(ParcelID.GetBytes(), 0, bytes, i, 16); i += 16; - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; - if(Desc == null) { Console.WriteLine("Warning: Desc is null, in " + this.GetType()); } - bytes[i++] = (byte)(Desc.Length % 256); - bytes[i++] = (byte)((Desc.Length >> 8) % 256); - Array.Copy(Desc, 0, bytes, i, Desc.Length); i += Desc.Length; - if(User == null) { Console.WriteLine("Warning: User is null, in " + this.GetType()); } - bytes[i++] = (byte)User.Length; - Array.Copy(User, 0, bytes, i, User.Length); i += User.Length; - if(CreatorID == null) { Console.WriteLine("Warning: CreatorID is null, in " + this.GetType()); } - Array.Copy(CreatorID.GetBytes(), 0, bytes, i, 16); i += 16; - if(PickID == null) { Console.WriteLine("Warning: PickID is null, in " + this.GetType()); } - Array.Copy(PickID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SnapshotID == null) { Console.WriteLine("Warning: SnapshotID is null, in " + this.GetType()); } - Array.Copy(SnapshotID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(SortOrder % 256); - bytes[i++] = (byte)((SortOrder >> 8) % 256); - bytes[i++] = (byte)((SortOrder >> 16) % 256); - bytes[i++] = (byte)((SortOrder >> 24) % 256); + { + if(OriginalName == null) { Console.WriteLine("Warning: OriginalName is null, in " + this.GetType()); } + bytes[i++] = (byte)OriginalName.Length; + Array.Copy(OriginalName, 0, bytes, i, OriginalName.Length); i += OriginalName.Length; + if(SimName == null) { Console.WriteLine("Warning: SimName is null, in " + this.GetType()); } + bytes[i++] = (byte)SimName.Length; + Array.Copy(SimName, 0, bytes, i, SimName.Length); i += SimName.Length; + bytes[i++] = (byte)((Enabled) ? 1 : 0); + if(PosGlobal == null) { Console.WriteLine("Warning: PosGlobal is null, in " + this.GetType()); } + Array.Copy(PosGlobal.GetBytes(), 0, bytes, i, 24); i += 24; + bytes[i++] = (byte)((TopPick) ? 1 : 0); + if(ParcelID == null) { Console.WriteLine("Warning: ParcelID is null, in " + this.GetType()); } + Array.Copy(ParcelID.GetBytes(), 0, bytes, i, 16); i += 16; + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + if(Desc == null) { Console.WriteLine("Warning: Desc is null, in " + this.GetType()); } + bytes[i++] = (byte)(Desc.Length % 256); + bytes[i++] = (byte)((Desc.Length >> 8) % 256); + Array.Copy(Desc, 0, bytes, i, Desc.Length); i += Desc.Length; + if(User == null) { Console.WriteLine("Warning: User is null, in " + this.GetType()); } + bytes[i++] = (byte)User.Length; + Array.Copy(User, 0, bytes, i, User.Length); i += User.Length; + if(CreatorID == null) { Console.WriteLine("Warning: CreatorID is null, in " + this.GetType()); } + Array.Copy(CreatorID.GetBytes(), 0, bytes, i, 16); i += 16; + if(PickID == null) { Console.WriteLine("Warning: PickID is null, in " + this.GetType()); } + Array.Copy(PickID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SnapshotID == null) { Console.WriteLine("Warning: SnapshotID is null, in " + this.GetType()); } + Array.Copy(SnapshotID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(SortOrder % 256); + bytes[i++] = (byte)((SortOrder >> 8) % 256); + bytes[i++] = (byte)((SortOrder >> 16) % 256); + bytes[i++] = (byte)((SortOrder >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += Helpers.FieldToString(OriginalName, "OriginalName") + "\n"; - output += Helpers.FieldToString(SimName, "SimName") + "\n"; - output += "Enabled: " + Enabled.ToString() + "\n"; - output += "PosGlobal: " + PosGlobal.ToString() + "\n"; - output += "TopPick: " + TopPick.ToString() + "\n"; - output += "ParcelID: " + ParcelID.ToString() + "\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; - output += Helpers.FieldToString(Desc, "Desc") + "\n"; - output += Helpers.FieldToString(User, "User") + "\n"; - output += "CreatorID: " + CreatorID.ToString() + "\n"; - output += "PickID: " + PickID.ToString() + "\n"; - output += "SnapshotID: " + SnapshotID.ToString() + "\n"; - output += "SortOrder: " + SortOrder.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += Helpers.FieldToString(OriginalName, "OriginalName") + "\n"; + output += Helpers.FieldToString(SimName, "SimName") + "\n"; + output += "Enabled: " + Enabled.ToString() + "\n"; + output += "PosGlobal: " + PosGlobal.ToString() + "\n"; + output += "TopPick: " + TopPick.ToString() + "\n"; + output += "ParcelID: " + ParcelID.ToString() + "\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; + output += Helpers.FieldToString(Desc, "Desc") + "\n"; + output += Helpers.FieldToString(User, "User") + "\n"; + output += "CreatorID: " + CreatorID.ToString() + "\n"; + output += "PickID: " + PickID.ToString() + "\n"; + output += "SnapshotID: " + SnapshotID.ToString() + "\n"; + output += "SortOrder: " + SortOrder.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.PickInfoReply - public override PacketType Type { get { return PacketType.PickInfoReply; } } - /// Data block - public DataBlock Data; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.PickInfoReply + public override PacketType Type { get { return PacketType.PickInfoReply; } } + /// Data block + public DataBlock Data; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public PickInfoReplyPacket() - { - Header = new LowHeader(); - Header.ID = 227; - Header.Reliable = true; - Data = new DataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 227; + Header.Reliable = true; + Data = new DataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public PickInfoReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public PickInfoReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Data.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Data.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Data.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Data.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- PickInfoReply ---\n"; - output += Data.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- PickInfoReply ---\n"; + output += Data.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// PickInfoUpdate packet + + /// PickInfoUpdate packet public class PickInfoUpdatePacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - /// Enabled field - public bool Enabled; - /// PosGlobal field - public LLVector3d PosGlobal; - /// TopPick field - public bool TopPick; - /// ParcelID field - public LLUUID ParcelID; - private byte[] _name; - /// Name field + { + /// Enabled field + public bool Enabled; + /// PosGlobal field + public LLVector3d PosGlobal; + /// TopPick field + public bool TopPick; + /// ParcelID field + public LLUUID ParcelID; + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - private byte[] _desc; - /// Desc field + } + private byte[] _desc; + /// Desc field public byte[] Desc - { - get { return _desc; } + { + get { return _desc; } set - { - if (value == null) { _desc = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _desc = new byte[value.Length]; Array.Copy(value, _desc, value.Length); } + { + if (value == null) { _desc = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _desc = new byte[value.Length]; Array.Copy(value, _desc, value.Length); } } - } - /// CreatorID field - public LLUUID CreatorID; - /// PickID field - public LLUUID PickID; - /// SnapshotID field - public LLUUID SnapshotID; - /// SortOrder field - public int SortOrder; - - /// Length of this block serialized in bytes + } + /// CreatorID field + public LLUUID CreatorID; + /// PickID field + public LLUUID PickID; + /// SnapshotID field + public LLUUID SnapshotID; + /// SortOrder field + public int SortOrder; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 94; - if (Name != null) { length += 1 + Name.Length; } - if (Desc != null) { length += 2 + Desc.Length; } - return length; + { + int length = 94; + if (Name != null) { length += 1 + Name.Length; } + if (Desc != null) { length += 2 + Desc.Length; } + return length; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - Enabled = (bytes[i++] != 0) ? (bool)true : (bool)false; - PosGlobal = new LLVector3d(bytes, i); i += 24; - TopPick = (bytes[i++] != 0) ? (bool)true : (bool)false; - ParcelID = new LLUUID(bytes, i); i += 16; - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _desc = new byte[length]; - Array.Copy(bytes, i, _desc, 0, length); i += length; - CreatorID = new LLUUID(bytes, i); i += 16; - PickID = new LLUUID(bytes, i); i += 16; - SnapshotID = new LLUUID(bytes, i); i += 16; - SortOrder = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + Enabled = (bytes[i++] != 0) ? (bool)true : (bool)false; + PosGlobal = new LLVector3d(bytes, i); i += 24; + TopPick = (bytes[i++] != 0) ? (bool)true : (bool)false; + ParcelID = new LLUUID(bytes, i); i += 16; + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _desc = new byte[length]; + Array.Copy(bytes, i, _desc, 0, length); i += length; + CreatorID = new LLUUID(bytes, i); i += 16; + PickID = new LLUUID(bytes, i); i += 16; + SnapshotID = new LLUUID(bytes, i); i += 16; + SortOrder = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)((Enabled) ? 1 : 0); - if(PosGlobal == null) { Console.WriteLine("Warning: PosGlobal is null, in " + this.GetType()); } - Array.Copy(PosGlobal.GetBytes(), 0, bytes, i, 24); i += 24; - bytes[i++] = (byte)((TopPick) ? 1 : 0); - if(ParcelID == null) { Console.WriteLine("Warning: ParcelID is null, in " + this.GetType()); } - Array.Copy(ParcelID.GetBytes(), 0, bytes, i, 16); i += 16; - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; - if(Desc == null) { Console.WriteLine("Warning: Desc is null, in " + this.GetType()); } - bytes[i++] = (byte)(Desc.Length % 256); - bytes[i++] = (byte)((Desc.Length >> 8) % 256); - Array.Copy(Desc, 0, bytes, i, Desc.Length); i += Desc.Length; - if(CreatorID == null) { Console.WriteLine("Warning: CreatorID is null, in " + this.GetType()); } - Array.Copy(CreatorID.GetBytes(), 0, bytes, i, 16); i += 16; - if(PickID == null) { Console.WriteLine("Warning: PickID is null, in " + this.GetType()); } - Array.Copy(PickID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SnapshotID == null) { Console.WriteLine("Warning: SnapshotID is null, in " + this.GetType()); } - Array.Copy(SnapshotID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(SortOrder % 256); - bytes[i++] = (byte)((SortOrder >> 8) % 256); - bytes[i++] = (byte)((SortOrder >> 16) % 256); - bytes[i++] = (byte)((SortOrder >> 24) % 256); + { + bytes[i++] = (byte)((Enabled) ? 1 : 0); + if(PosGlobal == null) { Console.WriteLine("Warning: PosGlobal is null, in " + this.GetType()); } + Array.Copy(PosGlobal.GetBytes(), 0, bytes, i, 24); i += 24; + bytes[i++] = (byte)((TopPick) ? 1 : 0); + if(ParcelID == null) { Console.WriteLine("Warning: ParcelID is null, in " + this.GetType()); } + Array.Copy(ParcelID.GetBytes(), 0, bytes, i, 16); i += 16; + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + if(Desc == null) { Console.WriteLine("Warning: Desc is null, in " + this.GetType()); } + bytes[i++] = (byte)(Desc.Length % 256); + bytes[i++] = (byte)((Desc.Length >> 8) % 256); + Array.Copy(Desc, 0, bytes, i, Desc.Length); i += Desc.Length; + if(CreatorID == null) { Console.WriteLine("Warning: CreatorID is null, in " + this.GetType()); } + Array.Copy(CreatorID.GetBytes(), 0, bytes, i, 16); i += 16; + if(PickID == null) { Console.WriteLine("Warning: PickID is null, in " + this.GetType()); } + Array.Copy(PickID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SnapshotID == null) { Console.WriteLine("Warning: SnapshotID is null, in " + this.GetType()); } + Array.Copy(SnapshotID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(SortOrder % 256); + bytes[i++] = (byte)((SortOrder >> 8) % 256); + bytes[i++] = (byte)((SortOrder >> 16) % 256); + bytes[i++] = (byte)((SortOrder >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "Enabled: " + Enabled.ToString() + "\n"; - output += "PosGlobal: " + PosGlobal.ToString() + "\n"; - output += "TopPick: " + TopPick.ToString() + "\n"; - output += "ParcelID: " + ParcelID.ToString() + "\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; - output += Helpers.FieldToString(Desc, "Desc") + "\n"; - output += "CreatorID: " + CreatorID.ToString() + "\n"; - output += "PickID: " + PickID.ToString() + "\n"; - output += "SnapshotID: " + SnapshotID.ToString() + "\n"; - output += "SortOrder: " + SortOrder.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += "Enabled: " + Enabled.ToString() + "\n"; + output += "PosGlobal: " + PosGlobal.ToString() + "\n"; + output += "TopPick: " + TopPick.ToString() + "\n"; + output += "ParcelID: " + ParcelID.ToString() + "\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; + output += Helpers.FieldToString(Desc, "Desc") + "\n"; + output += "CreatorID: " + CreatorID.ToString() + "\n"; + output += "PickID: " + PickID.ToString() + "\n"; + output += "SnapshotID: " + SnapshotID.ToString() + "\n"; + output += "SortOrder: " + SortOrder.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.PickInfoUpdate - public override PacketType Type { get { return PacketType.PickInfoUpdate; } } - /// Data block - public DataBlock Data; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.PickInfoUpdate + public override PacketType Type { get { return PacketType.PickInfoUpdate; } } + /// Data block + public DataBlock Data; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public PickInfoUpdatePacket() - { - Header = new LowHeader(); - Header.ID = 228; - Header.Reliable = true; - Data = new DataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 228; + Header.Reliable = true; + Data = new DataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public PickInfoUpdatePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public PickInfoUpdatePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Data.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Data.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Data.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Data.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- PickInfoUpdate ---\n"; - output += Data.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- PickInfoUpdate ---\n"; + output += Data.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// PickDelete packet + + /// PickDelete packet public class PickDeletePacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - /// PickID field - public LLUUID PickID; - - /// Length of this block serialized in bytes + { + /// PickID field + public LLUUID PickID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { + { try - { - PickID = new LLUUID(bytes, i); i += 16; + { + PickID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(PickID == null) { Console.WriteLine("Warning: PickID is null, in " + this.GetType()); } - Array.Copy(PickID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(PickID == null) { Console.WriteLine("Warning: PickID is null, in " + this.GetType()); } + Array.Copy(PickID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "PickID: " + PickID.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += "PickID: " + PickID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.PickDelete - public override PacketType Type { get { return PacketType.PickDelete; } } - /// Data block - public DataBlock Data; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.PickDelete + public override PacketType Type { get { return PacketType.PickDelete; } } + /// Data block + public DataBlock Data; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public PickDeletePacket() - { - Header = new LowHeader(); - Header.ID = 229; - Header.Reliable = true; - Data = new DataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 229; + Header.Reliable = true; + Data = new DataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public PickDeletePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public PickDeletePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Data.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Data.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Data.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Data.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- PickDelete ---\n"; - output += Data.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- PickDelete ---\n"; + output += Data.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// PickGodDelete packet + + /// PickGodDelete packet public class PickGodDeletePacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - /// QueryID field - public LLUUID QueryID; - /// PickID field - public LLUUID PickID; - - /// Length of this block serialized in bytes + { + /// QueryID field + public LLUUID QueryID; + /// PickID field + public LLUUID PickID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { + { try - { - QueryID = new LLUUID(bytes, i); i += 16; - PickID = new LLUUID(bytes, i); i += 16; + { + QueryID = new LLUUID(bytes, i); i += 16; + PickID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } - Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; - if(PickID == null) { Console.WriteLine("Warning: PickID is null, in " + this.GetType()); } - Array.Copy(PickID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } + Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; + if(PickID == null) { Console.WriteLine("Warning: PickID is null, in " + this.GetType()); } + Array.Copy(PickID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "QueryID: " + QueryID.ToString() + "\n"; - output += "PickID: " + PickID.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += "QueryID: " + QueryID.ToString() + "\n"; + output += "PickID: " + PickID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.PickGodDelete - public override PacketType Type { get { return PacketType.PickGodDelete; } } - /// Data block - public DataBlock Data; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.PickGodDelete + public override PacketType Type { get { return PacketType.PickGodDelete; } } + /// Data block + public DataBlock Data; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public PickGodDeletePacket() - { - Header = new LowHeader(); - Header.ID = 230; - Header.Reliable = true; - Data = new DataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 230; + Header.Reliable = true; + Data = new DataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public PickGodDeletePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public PickGodDeletePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Data.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Data.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Data.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Data.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- PickGodDelete ---\n"; - output += Data.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- PickGodDelete ---\n"; + output += Data.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ScriptQuestion packet + + /// ScriptQuestion packet public class ScriptQuestionPacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - private byte[] _objectname; - /// ObjectName field + { + private byte[] _objectname; + /// ObjectName field public byte[] ObjectName - { - get { return _objectname; } + { + get { return _objectname; } set - { - if (value == null) { _objectname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _objectname = new byte[value.Length]; Array.Copy(value, _objectname, value.Length); } + { + if (value == null) { _objectname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _objectname = new byte[value.Length]; Array.Copy(value, _objectname, value.Length); } } - } - private byte[] _objectowner; - /// ObjectOwner field + } + private byte[] _objectowner; + /// ObjectOwner field public byte[] ObjectOwner - { - get { return _objectowner; } + { + get { return _objectowner; } set - { - if (value == null) { _objectowner = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _objectowner = new byte[value.Length]; Array.Copy(value, _objectowner, value.Length); } + { + if (value == null) { _objectowner = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _objectowner = new byte[value.Length]; Array.Copy(value, _objectowner, value.Length); } } - } - /// TaskID field - public LLUUID TaskID; - /// ItemID field - public LLUUID ItemID; - /// Questions field - public int Questions; - - /// Length of this block serialized in bytes + } + /// TaskID field + public LLUUID TaskID; + /// ItemID field + public LLUUID ItemID; + /// Questions field + public int Questions; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 36; - if (ObjectName != null) { length += 1 + ObjectName.Length; } - if (ObjectOwner != null) { length += 1 + ObjectOwner.Length; } - return length; + { + int length = 36; + if (ObjectName != null) { length += 1 + ObjectName.Length; } + if (ObjectOwner != null) { length += 1 + ObjectOwner.Length; } + return length; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _objectname = new byte[length]; - Array.Copy(bytes, i, _objectname, 0, length); i += length; - length = (ushort)bytes[i++]; - _objectowner = new byte[length]; - Array.Copy(bytes, i, _objectowner, 0, length); i += length; - TaskID = new LLUUID(bytes, i); i += 16; - ItemID = new LLUUID(bytes, i); i += 16; - Questions = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + length = (ushort)bytes[i++]; + _objectname = new byte[length]; + Array.Copy(bytes, i, _objectname, 0, length); i += length; + length = (ushort)bytes[i++]; + _objectowner = new byte[length]; + Array.Copy(bytes, i, _objectowner, 0, length); i += length; + TaskID = new LLUUID(bytes, i); i += 16; + ItemID = new LLUUID(bytes, i); i += 16; + Questions = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ObjectName == null) { Console.WriteLine("Warning: ObjectName is null, in " + this.GetType()); } - bytes[i++] = (byte)ObjectName.Length; - Array.Copy(ObjectName, 0, bytes, i, ObjectName.Length); i += ObjectName.Length; - if(ObjectOwner == null) { Console.WriteLine("Warning: ObjectOwner is null, in " + this.GetType()); } - bytes[i++] = (byte)ObjectOwner.Length; - Array.Copy(ObjectOwner, 0, bytes, i, ObjectOwner.Length); i += ObjectOwner.Length; - if(TaskID == null) { Console.WriteLine("Warning: TaskID is null, in " + this.GetType()); } - Array.Copy(TaskID.GetBytes(), 0, bytes, i, 16); i += 16; - if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } - Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(Questions % 256); - bytes[i++] = (byte)((Questions >> 8) % 256); - bytes[i++] = (byte)((Questions >> 16) % 256); - bytes[i++] = (byte)((Questions >> 24) % 256); + { + if(ObjectName == null) { Console.WriteLine("Warning: ObjectName is null, in " + this.GetType()); } + bytes[i++] = (byte)ObjectName.Length; + Array.Copy(ObjectName, 0, bytes, i, ObjectName.Length); i += ObjectName.Length; + if(ObjectOwner == null) { Console.WriteLine("Warning: ObjectOwner is null, in " + this.GetType()); } + bytes[i++] = (byte)ObjectOwner.Length; + Array.Copy(ObjectOwner, 0, bytes, i, ObjectOwner.Length); i += ObjectOwner.Length; + if(TaskID == null) { Console.WriteLine("Warning: TaskID is null, in " + this.GetType()); } + Array.Copy(TaskID.GetBytes(), 0, bytes, i, 16); i += 16; + if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } + Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(Questions % 256); + bytes[i++] = (byte)((Questions >> 8) % 256); + bytes[i++] = (byte)((Questions >> 16) % 256); + bytes[i++] = (byte)((Questions >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += Helpers.FieldToString(ObjectName, "ObjectName") + "\n"; - output += Helpers.FieldToString(ObjectOwner, "ObjectOwner") + "\n"; - output += "TaskID: " + TaskID.ToString() + "\n"; - output += "ItemID: " + ItemID.ToString() + "\n"; - output += "Questions: " + Questions.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += Helpers.FieldToString(ObjectName, "ObjectName") + "\n"; + output += Helpers.FieldToString(ObjectOwner, "ObjectOwner") + "\n"; + output += "TaskID: " + TaskID.ToString() + "\n"; + output += "ItemID: " + ItemID.ToString() + "\n"; + output += "Questions: " + Questions.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ScriptQuestion - public override PacketType Type { get { return PacketType.ScriptQuestion; } } - /// Data block - public DataBlock Data; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ScriptQuestion + public override PacketType Type { get { return PacketType.ScriptQuestion; } } + /// Data block + public DataBlock Data; + + /// Default constructor public ScriptQuestionPacket() - { - Header = new LowHeader(); - Header.ID = 231; - Header.Reliable = true; - Data = new DataBlock(); + { + Header = new LowHeader(); + Header.ID = 231; + Header.Reliable = true; + Data = new DataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ScriptQuestionPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Data = new DataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Data = new DataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ScriptQuestionPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Data = new DataBlock(bytes, ref i); + { + Header = head; + Data = new DataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Data.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Data.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Data.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Data.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ScriptQuestion ---\n"; - output += Data.ToString() + "\n"; + { + string output = "--- ScriptQuestion ---\n"; + output += Data.ToString() + "\n"; return output; } - + } - - /// ScriptControlChange packet + + /// ScriptControlChange packet public class ScriptControlChangePacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - /// PassToAgent field - public bool PassToAgent; - /// Controls field - public uint Controls; - /// TakeControls field - public bool TakeControls; - - /// Length of this block serialized in bytes + { + /// PassToAgent field + public bool PassToAgent; + /// Controls field + public uint Controls; + /// TakeControls field + public bool TakeControls; + + /// Length of this block serialized in bytes public int Length { get - { - return 6; + { + return 6; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { + { try - { - PassToAgent = (bytes[i++] != 0) ? (bool)true : (bool)false; - Controls = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - TakeControls = (bytes[i++] != 0) ? (bool)true : (bool)false; + { + PassToAgent = (bytes[i++] != 0) ? (bool)true : (bool)false; + Controls = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + TakeControls = (bytes[i++] != 0) ? (bool)true : (bool)false; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)((PassToAgent) ? 1 : 0); - bytes[i++] = (byte)(Controls % 256); - bytes[i++] = (byte)((Controls >> 8) % 256); - bytes[i++] = (byte)((Controls >> 16) % 256); - bytes[i++] = (byte)((Controls >> 24) % 256); - bytes[i++] = (byte)((TakeControls) ? 1 : 0); + { + bytes[i++] = (byte)((PassToAgent) ? 1 : 0); + bytes[i++] = (byte)(Controls % 256); + bytes[i++] = (byte)((Controls >> 8) % 256); + bytes[i++] = (byte)((Controls >> 16) % 256); + bytes[i++] = (byte)((Controls >> 24) % 256); + bytes[i++] = (byte)((TakeControls) ? 1 : 0); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "PassToAgent: " + PassToAgent.ToString() + "\n"; - output += "Controls: " + Controls.ToString() + "\n"; - output += "TakeControls: " + TakeControls.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += "PassToAgent: " + PassToAgent.ToString() + "\n"; + output += "Controls: " + Controls.ToString() + "\n"; + output += "TakeControls: " + TakeControls.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ScriptControlChange - public override PacketType Type { get { return PacketType.ScriptControlChange; } } - /// Data block - public DataBlock[] Data; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ScriptControlChange + public override PacketType Type { get { return PacketType.ScriptControlChange; } } + /// Data block + public DataBlock[] Data; + + /// Default constructor public ScriptControlChangePacket() - { - Header = new LowHeader(); - Header.ID = 232; - Header.Reliable = true; - Data = new DataBlock[0]; + { + Header = new LowHeader(); + Header.ID = 232; + Header.Reliable = true; + Data = new DataBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ScriptControlChangePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - Data = new DataBlock[count]; - for (int j = 0; j < count; j++) - { Data[j] = new DataBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + Data = new DataBlock[count]; + for (int j = 0; j < count; j++) + { Data[j] = new DataBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ScriptControlChangePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - Data = new DataBlock[count]; - for (int j = 0; j < count; j++) - { Data[j] = new DataBlock(bytes, ref i); } + { + Header = head; + int count = (int)bytes[i++]; + Data = new DataBlock[count]; + for (int j = 0; j < count; j++) + { Data[j] = new DataBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; -; - length++; - for (int j = 0; j < Data.Length; j++) { length += Data[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)Data.Length; - for (int j = 0; j < Data.Length; j++) { Data[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; +; + length++; + for (int j = 0; j < Data.Length; j++) { length += Data[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)Data.Length; + for (int j = 0; j < Data.Length; j++) { Data[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ScriptControlChange ---\n"; + { + string output = "--- ScriptControlChange ---\n"; for (int j = 0; j < Data.Length; j++) - { + { output += Data[j].ToString() + "\n"; - } + } return output; } - + } - - /// ScriptDialog packet + + /// ScriptDialog packet public class ScriptDialogPacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - private byte[] _objectname; - /// ObjectName field + { + private byte[] _objectname; + /// ObjectName field public byte[] ObjectName - { - get { return _objectname; } + { + get { return _objectname; } set - { - if (value == null) { _objectname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _objectname = new byte[value.Length]; Array.Copy(value, _objectname, value.Length); } + { + if (value == null) { _objectname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _objectname = new byte[value.Length]; Array.Copy(value, _objectname, value.Length); } } - } - /// ImageID field - public LLUUID ImageID; - /// ObjectID field - public LLUUID ObjectID; - private byte[] _message; - /// Message field + } + /// ImageID field + public LLUUID ImageID; + /// ObjectID field + public LLUUID ObjectID; + private byte[] _message; + /// Message field public byte[] Message - { - get { return _message; } + { + get { return _message; } set - { - if (value == null) { _message = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _message = new byte[value.Length]; Array.Copy(value, _message, value.Length); } + { + if (value == null) { _message = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _message = new byte[value.Length]; Array.Copy(value, _message, value.Length); } } - } - private byte[] _lastname; - /// LastName field + } + private byte[] _lastname; + /// LastName field public byte[] LastName - { - get { return _lastname; } + { + get { return _lastname; } set - { - if (value == null) { _lastname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _lastname = new byte[value.Length]; Array.Copy(value, _lastname, value.Length); } + { + if (value == null) { _lastname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _lastname = new byte[value.Length]; Array.Copy(value, _lastname, value.Length); } } - } - private byte[] _firstname; - /// FirstName field + } + private byte[] _firstname; + /// FirstName field public byte[] FirstName - { - get { return _firstname; } + { + get { return _firstname; } set - { - if (value == null) { _firstname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _firstname = new byte[value.Length]; Array.Copy(value, _firstname, value.Length); } + { + if (value == null) { _firstname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _firstname = new byte[value.Length]; Array.Copy(value, _firstname, value.Length); } } - } - /// ChatChannel field - public int ChatChannel; - - /// Length of this block serialized in bytes + } + /// ChatChannel field + public int ChatChannel; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 36; - if (ObjectName != null) { length += 1 + ObjectName.Length; } - if (Message != null) { length += 2 + Message.Length; } - if (LastName != null) { length += 1 + LastName.Length; } - if (FirstName != null) { length += 1 + FirstName.Length; } - return length; + { + int length = 36; + if (ObjectName != null) { length += 1 + ObjectName.Length; } + if (Message != null) { length += 2 + Message.Length; } + if (LastName != null) { length += 1 + LastName.Length; } + if (FirstName != null) { length += 1 + FirstName.Length; } + return length; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _objectname = new byte[length]; - Array.Copy(bytes, i, _objectname, 0, length); i += length; - ImageID = new LLUUID(bytes, i); i += 16; - ObjectID = new LLUUID(bytes, i); i += 16; - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _message = new byte[length]; - Array.Copy(bytes, i, _message, 0, length); i += length; - length = (ushort)bytes[i++]; - _lastname = new byte[length]; - Array.Copy(bytes, i, _lastname, 0, length); i += length; - length = (ushort)bytes[i++]; - _firstname = new byte[length]; - Array.Copy(bytes, i, _firstname, 0, length); i += length; - ChatChannel = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + length = (ushort)bytes[i++]; + _objectname = new byte[length]; + Array.Copy(bytes, i, _objectname, 0, length); i += length; + ImageID = new LLUUID(bytes, i); i += 16; + ObjectID = new LLUUID(bytes, i); i += 16; + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _message = new byte[length]; + Array.Copy(bytes, i, _message, 0, length); i += length; + length = (ushort)bytes[i++]; + _lastname = new byte[length]; + Array.Copy(bytes, i, _lastname, 0, length); i += length; + length = (ushort)bytes[i++]; + _firstname = new byte[length]; + Array.Copy(bytes, i, _firstname, 0, length); i += length; + ChatChannel = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ObjectName == null) { Console.WriteLine("Warning: ObjectName is null, in " + this.GetType()); } - bytes[i++] = (byte)ObjectName.Length; - Array.Copy(ObjectName, 0, bytes, i, ObjectName.Length); i += ObjectName.Length; - if(ImageID == null) { Console.WriteLine("Warning: ImageID is null, in " + this.GetType()); } - Array.Copy(ImageID.GetBytes(), 0, bytes, i, 16); i += 16; - if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } - Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; - if(Message == null) { Console.WriteLine("Warning: Message is null, in " + this.GetType()); } - bytes[i++] = (byte)(Message.Length % 256); - bytes[i++] = (byte)((Message.Length >> 8) % 256); - Array.Copy(Message, 0, bytes, i, Message.Length); i += Message.Length; - if(LastName == null) { Console.WriteLine("Warning: LastName is null, in " + this.GetType()); } - bytes[i++] = (byte)LastName.Length; - Array.Copy(LastName, 0, bytes, i, LastName.Length); i += LastName.Length; - if(FirstName == null) { Console.WriteLine("Warning: FirstName is null, in " + this.GetType()); } - bytes[i++] = (byte)FirstName.Length; - Array.Copy(FirstName, 0, bytes, i, FirstName.Length); i += FirstName.Length; - bytes[i++] = (byte)(ChatChannel % 256); - bytes[i++] = (byte)((ChatChannel >> 8) % 256); - bytes[i++] = (byte)((ChatChannel >> 16) % 256); - bytes[i++] = (byte)((ChatChannel >> 24) % 256); + { + if(ObjectName == null) { Console.WriteLine("Warning: ObjectName is null, in " + this.GetType()); } + bytes[i++] = (byte)ObjectName.Length; + Array.Copy(ObjectName, 0, bytes, i, ObjectName.Length); i += ObjectName.Length; + if(ImageID == null) { Console.WriteLine("Warning: ImageID is null, in " + this.GetType()); } + Array.Copy(ImageID.GetBytes(), 0, bytes, i, 16); i += 16; + if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } + Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; + if(Message == null) { Console.WriteLine("Warning: Message is null, in " + this.GetType()); } + bytes[i++] = (byte)(Message.Length % 256); + bytes[i++] = (byte)((Message.Length >> 8) % 256); + Array.Copy(Message, 0, bytes, i, Message.Length); i += Message.Length; + if(LastName == null) { Console.WriteLine("Warning: LastName is null, in " + this.GetType()); } + bytes[i++] = (byte)LastName.Length; + Array.Copy(LastName, 0, bytes, i, LastName.Length); i += LastName.Length; + if(FirstName == null) { Console.WriteLine("Warning: FirstName is null, in " + this.GetType()); } + bytes[i++] = (byte)FirstName.Length; + Array.Copy(FirstName, 0, bytes, i, FirstName.Length); i += FirstName.Length; + bytes[i++] = (byte)(ChatChannel % 256); + bytes[i++] = (byte)((ChatChannel >> 8) % 256); + bytes[i++] = (byte)((ChatChannel >> 16) % 256); + bytes[i++] = (byte)((ChatChannel >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += Helpers.FieldToString(ObjectName, "ObjectName") + "\n"; - output += "ImageID: " + ImageID.ToString() + "\n"; - output += "ObjectID: " + ObjectID.ToString() + "\n"; - output += Helpers.FieldToString(Message, "Message") + "\n"; - output += Helpers.FieldToString(LastName, "LastName") + "\n"; - output += Helpers.FieldToString(FirstName, "FirstName") + "\n"; - output += "ChatChannel: " + ChatChannel.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += Helpers.FieldToString(ObjectName, "ObjectName") + "\n"; + output += "ImageID: " + ImageID.ToString() + "\n"; + output += "ObjectID: " + ObjectID.ToString() + "\n"; + output += Helpers.FieldToString(Message, "Message") + "\n"; + output += Helpers.FieldToString(LastName, "LastName") + "\n"; + output += Helpers.FieldToString(FirstName, "FirstName") + "\n"; + output += "ChatChannel: " + ChatChannel.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// Buttons block + + /// Buttons block public class ButtonsBlock - { - private byte[] _buttonlabel; - /// ButtonLabel field + { + private byte[] _buttonlabel; + /// ButtonLabel field public byte[] ButtonLabel - { - get { return _buttonlabel; } + { + get { return _buttonlabel; } set - { - if (value == null) { _buttonlabel = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _buttonlabel = new byte[value.Length]; Array.Copy(value, _buttonlabel, value.Length); } + { + if (value == null) { _buttonlabel = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _buttonlabel = new byte[value.Length]; Array.Copy(value, _buttonlabel, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 0; - if (ButtonLabel != null) { length += 1 + ButtonLabel.Length; } - return length; + { + int length = 0; + if (ButtonLabel != null) { length += 1 + ButtonLabel.Length; } + return length; } } - - /// Default constructor - public ButtonsBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ButtonsBlock() { } + /// Constructor for building the block from a byte array public ButtonsBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _buttonlabel = new byte[length]; - Array.Copy(bytes, i, _buttonlabel, 0, length); i += length; + { + length = (ushort)bytes[i++]; + _buttonlabel = new byte[length]; + Array.Copy(bytes, i, _buttonlabel, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ButtonLabel == null) { Console.WriteLine("Warning: ButtonLabel is null, in " + this.GetType()); } - bytes[i++] = (byte)ButtonLabel.Length; - Array.Copy(ButtonLabel, 0, bytes, i, ButtonLabel.Length); i += ButtonLabel.Length; + { + if(ButtonLabel == null) { Console.WriteLine("Warning: ButtonLabel is null, in " + this.GetType()); } + bytes[i++] = (byte)ButtonLabel.Length; + Array.Copy(ButtonLabel, 0, bytes, i, ButtonLabel.Length); i += ButtonLabel.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Buttons --\n"; - output += Helpers.FieldToString(ButtonLabel, "ButtonLabel") + "\n"; + { + string output = "-- Buttons --\n"; + output += Helpers.FieldToString(ButtonLabel, "ButtonLabel") + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ScriptDialog - public override PacketType Type { get { return PacketType.ScriptDialog; } } - /// Data block - public DataBlock Data; - /// Buttons block - public ButtonsBlock[] Buttons; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ScriptDialog + public override PacketType Type { get { return PacketType.ScriptDialog; } } + /// Data block + public DataBlock Data; + /// Buttons block + public ButtonsBlock[] Buttons; + + /// Default constructor public ScriptDialogPacket() - { - Header = new LowHeader(); - Header.ID = 233; - Header.Reliable = true; - Header.Zerocoded = true; - Data = new DataBlock(); - Buttons = new ButtonsBlock[0]; + { + Header = new LowHeader(); + Header.ID = 233; + Header.Reliable = true; + Header.Zerocoded = true; + Data = new DataBlock(); + Buttons = new ButtonsBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ScriptDialogPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Data = new DataBlock(bytes, ref i); - int count = (int)bytes[i++]; - Buttons = new ButtonsBlock[count]; - for (int j = 0; j < count; j++) - { Buttons[j] = new ButtonsBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Data = new DataBlock(bytes, ref i); + int count = (int)bytes[i++]; + Buttons = new ButtonsBlock[count]; + for (int j = 0; j < count; j++) + { Buttons[j] = new ButtonsBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ScriptDialogPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Data = new DataBlock(bytes, ref i); - int count = (int)bytes[i++]; - Buttons = new ButtonsBlock[count]; - for (int j = 0; j < count; j++) - { Buttons[j] = new ButtonsBlock(bytes, ref i); } + { + Header = head; + Data = new DataBlock(bytes, ref i); + int count = (int)bytes[i++]; + Buttons = new ButtonsBlock[count]; + for (int j = 0; j < count; j++) + { Buttons[j] = new ButtonsBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Data.Length;; - length++; - for (int j = 0; j < Buttons.Length; j++) { length += Buttons[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Data.ToBytes(bytes, ref i); - bytes[i++] = (byte)Buttons.Length; - for (int j = 0; j < Buttons.Length; j++) { Buttons[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Data.Length;; + length++; + for (int j = 0; j < Buttons.Length; j++) { length += Buttons[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Data.ToBytes(bytes, ref i); + bytes[i++] = (byte)Buttons.Length; + for (int j = 0; j < Buttons.Length; j++) { Buttons[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ScriptDialog ---\n"; - output += Data.ToString() + "\n"; + { + string output = "--- ScriptDialog ---\n"; + output += Data.ToString() + "\n"; for (int j = 0; j < Buttons.Length; j++) - { + { output += Buttons[j].ToString() + "\n"; - } + } return output; } - + } - - /// ScriptDialogReply packet + + /// ScriptDialogReply packet public class ScriptDialogReplyPacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - /// ObjectID field - public LLUUID ObjectID; - private byte[] _buttonlabel; - /// ButtonLabel field + { + /// ObjectID field + public LLUUID ObjectID; + private byte[] _buttonlabel; + /// ButtonLabel field public byte[] ButtonLabel - { - get { return _buttonlabel; } + { + get { return _buttonlabel; } set - { - if (value == null) { _buttonlabel = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _buttonlabel = new byte[value.Length]; Array.Copy(value, _buttonlabel, value.Length); } + { + if (value == null) { _buttonlabel = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _buttonlabel = new byte[value.Length]; Array.Copy(value, _buttonlabel, value.Length); } } - } - /// ButtonIndex field - public int ButtonIndex; - /// ChatChannel field - public int ChatChannel; - - /// Length of this block serialized in bytes + } + /// ButtonIndex field + public int ButtonIndex; + /// ChatChannel field + public int ChatChannel; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 24; - if (ButtonLabel != null) { length += 1 + ButtonLabel.Length; } - return length; + { + int length = 24; + if (ButtonLabel != null) { length += 1 + ButtonLabel.Length; } + return length; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - ObjectID = new LLUUID(bytes, i); i += 16; - length = (ushort)bytes[i++]; - _buttonlabel = new byte[length]; - Array.Copy(bytes, i, _buttonlabel, 0, length); i += length; - ButtonIndex = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - ChatChannel = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + ObjectID = new LLUUID(bytes, i); i += 16; + length = (ushort)bytes[i++]; + _buttonlabel = new byte[length]; + Array.Copy(bytes, i, _buttonlabel, 0, length); i += length; + ButtonIndex = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + ChatChannel = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } - Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; - if(ButtonLabel == null) { Console.WriteLine("Warning: ButtonLabel is null, in " + this.GetType()); } - bytes[i++] = (byte)ButtonLabel.Length; - Array.Copy(ButtonLabel, 0, bytes, i, ButtonLabel.Length); i += ButtonLabel.Length; - bytes[i++] = (byte)(ButtonIndex % 256); - bytes[i++] = (byte)((ButtonIndex >> 8) % 256); - bytes[i++] = (byte)((ButtonIndex >> 16) % 256); - bytes[i++] = (byte)((ButtonIndex >> 24) % 256); - bytes[i++] = (byte)(ChatChannel % 256); - bytes[i++] = (byte)((ChatChannel >> 8) % 256); - bytes[i++] = (byte)((ChatChannel >> 16) % 256); - bytes[i++] = (byte)((ChatChannel >> 24) % 256); + { + if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } + Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; + if(ButtonLabel == null) { Console.WriteLine("Warning: ButtonLabel is null, in " + this.GetType()); } + bytes[i++] = (byte)ButtonLabel.Length; + Array.Copy(ButtonLabel, 0, bytes, i, ButtonLabel.Length); i += ButtonLabel.Length; + bytes[i++] = (byte)(ButtonIndex % 256); + bytes[i++] = (byte)((ButtonIndex >> 8) % 256); + bytes[i++] = (byte)((ButtonIndex >> 16) % 256); + bytes[i++] = (byte)((ButtonIndex >> 24) % 256); + bytes[i++] = (byte)(ChatChannel % 256); + bytes[i++] = (byte)((ChatChannel >> 8) % 256); + bytes[i++] = (byte)((ChatChannel >> 16) % 256); + bytes[i++] = (byte)((ChatChannel >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "ObjectID: " + ObjectID.ToString() + "\n"; - output += Helpers.FieldToString(ButtonLabel, "ButtonLabel") + "\n"; - output += "ButtonIndex: " + ButtonIndex.ToString() + "\n"; - output += "ChatChannel: " + ChatChannel.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += "ObjectID: " + ObjectID.ToString() + "\n"; + output += Helpers.FieldToString(ButtonLabel, "ButtonLabel") + "\n"; + output += "ButtonIndex: " + ButtonIndex.ToString() + "\n"; + output += "ChatChannel: " + ChatChannel.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ScriptDialogReply - public override PacketType Type { get { return PacketType.ScriptDialogReply; } } - /// Data block - public DataBlock Data; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ScriptDialogReply + public override PacketType Type { get { return PacketType.ScriptDialogReply; } } + /// Data block + public DataBlock Data; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ScriptDialogReplyPacket() - { - Header = new LowHeader(); - Header.ID = 234; - Header.Reliable = true; - Header.Zerocoded = true; - Data = new DataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 234; + Header.Reliable = true; + Header.Zerocoded = true; + Data = new DataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ScriptDialogReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ScriptDialogReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Data.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Data.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Data.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Data.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ScriptDialogReply ---\n"; - output += Data.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- ScriptDialogReply ---\n"; + output += Data.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ForceScriptControlRelease packet + + /// ForceScriptControlRelease packet public class ForceScriptControlReleasePacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ForceScriptControlRelease - public override PacketType Type { get { return PacketType.ForceScriptControlRelease; } } - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ForceScriptControlRelease + public override PacketType Type { get { return PacketType.ForceScriptControlRelease; } } + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ForceScriptControlReleasePacket() - { - Header = new LowHeader(); - Header.ID = 235; - Header.Reliable = true; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 235; + Header.Reliable = true; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ForceScriptControlReleasePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ForceScriptControlReleasePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ForceScriptControlRelease ---\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- ForceScriptControlRelease ---\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// RevokePermissions packet + + /// RevokePermissions packet public class RevokePermissionsPacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - /// ObjectPermissions field - public uint ObjectPermissions; - /// ObjectID field - public LLUUID ObjectID; - - /// Length of this block serialized in bytes + { + /// ObjectPermissions field + public uint ObjectPermissions; + /// ObjectID field + public LLUUID ObjectID; + + /// Length of this block serialized in bytes public int Length { get - { - return 20; + { + return 20; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { + { try - { - ObjectPermissions = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - ObjectID = new LLUUID(bytes, i); i += 16; + { + ObjectPermissions = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + ObjectID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(ObjectPermissions % 256); - bytes[i++] = (byte)((ObjectPermissions >> 8) % 256); - bytes[i++] = (byte)((ObjectPermissions >> 16) % 256); - bytes[i++] = (byte)((ObjectPermissions >> 24) % 256); - if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } - Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; + { + bytes[i++] = (byte)(ObjectPermissions % 256); + bytes[i++] = (byte)((ObjectPermissions >> 8) % 256); + bytes[i++] = (byte)((ObjectPermissions >> 16) % 256); + bytes[i++] = (byte)((ObjectPermissions >> 24) % 256); + if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } + Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "ObjectPermissions: " + ObjectPermissions.ToString() + "\n"; - output += "ObjectID: " + ObjectID.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += "ObjectPermissions: " + ObjectPermissions.ToString() + "\n"; + output += "ObjectID: " + ObjectID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.RevokePermissions - public override PacketType Type { get { return PacketType.RevokePermissions; } } - /// Data block - public DataBlock Data; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.RevokePermissions + public override PacketType Type { get { return PacketType.RevokePermissions; } } + /// Data block + public DataBlock Data; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public RevokePermissionsPacket() - { - Header = new LowHeader(); - Header.ID = 236; - Header.Reliable = true; - Data = new DataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 236; + Header.Reliable = true; + Data = new DataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public RevokePermissionsPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public RevokePermissionsPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Data.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Data.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Data.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Data.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- RevokePermissions ---\n"; - output += Data.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- RevokePermissions ---\n"; + output += Data.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// LoadURL packet + + /// LoadURL packet public class LoadURLPacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - private byte[] _url; - /// URL field + { + private byte[] _url; + /// URL field public byte[] URL - { - get { return _url; } + { + get { return _url; } set - { - if (value == null) { _url = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _url = new byte[value.Length]; Array.Copy(value, _url, value.Length); } + { + if (value == null) { _url = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _url = new byte[value.Length]; Array.Copy(value, _url, value.Length); } } - } - private byte[] _objectname; - /// ObjectName field + } + private byte[] _objectname; + /// ObjectName field public byte[] ObjectName - { - get { return _objectname; } + { + get { return _objectname; } set - { - if (value == null) { _objectname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _objectname = new byte[value.Length]; Array.Copy(value, _objectname, value.Length); } + { + if (value == null) { _objectname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _objectname = new byte[value.Length]; Array.Copy(value, _objectname, value.Length); } } - } - /// OwnerIsGroup field - public bool OwnerIsGroup; - /// ObjectID field - public LLUUID ObjectID; - private byte[] _message; - /// Message field + } + /// OwnerIsGroup field + public bool OwnerIsGroup; + /// ObjectID field + public LLUUID ObjectID; + private byte[] _message; + /// Message field public byte[] Message - { - get { return _message; } + { + get { return _message; } set - { - if (value == null) { _message = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _message = new byte[value.Length]; Array.Copy(value, _message, value.Length); } + { + if (value == null) { _message = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _message = new byte[value.Length]; Array.Copy(value, _message, value.Length); } } - } - /// OwnerID field - public LLUUID OwnerID; - - /// Length of this block serialized in bytes + } + /// OwnerID field + public LLUUID OwnerID; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 33; - if (URL != null) { length += 1 + URL.Length; } - if (ObjectName != null) { length += 1 + ObjectName.Length; } - if (Message != null) { length += 1 + Message.Length; } - return length; + { + int length = 33; + if (URL != null) { length += 1 + URL.Length; } + if (ObjectName != null) { length += 1 + ObjectName.Length; } + if (Message != null) { length += 1 + Message.Length; } + return length; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _url = new byte[length]; - Array.Copy(bytes, i, _url, 0, length); i += length; - length = (ushort)bytes[i++]; - _objectname = new byte[length]; - Array.Copy(bytes, i, _objectname, 0, length); i += length; - OwnerIsGroup = (bytes[i++] != 0) ? (bool)true : (bool)false; - ObjectID = new LLUUID(bytes, i); i += 16; - length = (ushort)bytes[i++]; - _message = new byte[length]; - Array.Copy(bytes, i, _message, 0, length); i += length; - OwnerID = new LLUUID(bytes, i); i += 16; + { + length = (ushort)bytes[i++]; + _url = new byte[length]; + Array.Copy(bytes, i, _url, 0, length); i += length; + length = (ushort)bytes[i++]; + _objectname = new byte[length]; + Array.Copy(bytes, i, _objectname, 0, length); i += length; + OwnerIsGroup = (bytes[i++] != 0) ? (bool)true : (bool)false; + ObjectID = new LLUUID(bytes, i); i += 16; + length = (ushort)bytes[i++]; + _message = new byte[length]; + Array.Copy(bytes, i, _message, 0, length); i += length; + OwnerID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(URL == null) { Console.WriteLine("Warning: URL is null, in " + this.GetType()); } - bytes[i++] = (byte)URL.Length; - Array.Copy(URL, 0, bytes, i, URL.Length); i += URL.Length; - if(ObjectName == null) { Console.WriteLine("Warning: ObjectName is null, in " + this.GetType()); } - bytes[i++] = (byte)ObjectName.Length; - Array.Copy(ObjectName, 0, bytes, i, ObjectName.Length); i += ObjectName.Length; - bytes[i++] = (byte)((OwnerIsGroup) ? 1 : 0); - if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } - Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; - if(Message == null) { Console.WriteLine("Warning: Message is null, in " + this.GetType()); } - bytes[i++] = (byte)Message.Length; - Array.Copy(Message, 0, bytes, i, Message.Length); i += Message.Length; - if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } - Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(URL == null) { Console.WriteLine("Warning: URL is null, in " + this.GetType()); } + bytes[i++] = (byte)URL.Length; + Array.Copy(URL, 0, bytes, i, URL.Length); i += URL.Length; + if(ObjectName == null) { Console.WriteLine("Warning: ObjectName is null, in " + this.GetType()); } + bytes[i++] = (byte)ObjectName.Length; + Array.Copy(ObjectName, 0, bytes, i, ObjectName.Length); i += ObjectName.Length; + bytes[i++] = (byte)((OwnerIsGroup) ? 1 : 0); + if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } + Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; + if(Message == null) { Console.WriteLine("Warning: Message is null, in " + this.GetType()); } + bytes[i++] = (byte)Message.Length; + Array.Copy(Message, 0, bytes, i, Message.Length); i += Message.Length; + if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } + Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += Helpers.FieldToString(URL, "URL") + "\n"; - output += Helpers.FieldToString(ObjectName, "ObjectName") + "\n"; - output += "OwnerIsGroup: " + OwnerIsGroup.ToString() + "\n"; - output += "ObjectID: " + ObjectID.ToString() + "\n"; - output += Helpers.FieldToString(Message, "Message") + "\n"; - output += "OwnerID: " + OwnerID.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += Helpers.FieldToString(URL, "URL") + "\n"; + output += Helpers.FieldToString(ObjectName, "ObjectName") + "\n"; + output += "OwnerIsGroup: " + OwnerIsGroup.ToString() + "\n"; + output += "ObjectID: " + ObjectID.ToString() + "\n"; + output += Helpers.FieldToString(Message, "Message") + "\n"; + output += "OwnerID: " + OwnerID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.LoadURL - public override PacketType Type { get { return PacketType.LoadURL; } } - /// Data block - public DataBlock Data; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.LoadURL + public override PacketType Type { get { return PacketType.LoadURL; } } + /// Data block + public DataBlock Data; + + /// Default constructor public LoadURLPacket() - { - Header = new LowHeader(); - Header.ID = 237; - Header.Reliable = true; - Data = new DataBlock(); + { + Header = new LowHeader(); + Header.ID = 237; + Header.Reliable = true; + Data = new DataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public LoadURLPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Data = new DataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Data = new DataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public LoadURLPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Data = new DataBlock(bytes, ref i); + { + Header = head; + Data = new DataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Data.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Data.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Data.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Data.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- LoadURL ---\n"; - output += Data.ToString() + "\n"; + { + string output = "--- LoadURL ---\n"; + output += Data.ToString() + "\n"; return output; } - + } - - /// ScriptTeleportRequest packet + + /// ScriptTeleportRequest packet public class ScriptTeleportRequestPacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - private byte[] _objectname; - /// ObjectName field + { + private byte[] _objectname; + /// ObjectName field public byte[] ObjectName - { - get { return _objectname; } + { + get { return _objectname; } set - { - if (value == null) { _objectname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _objectname = new byte[value.Length]; Array.Copy(value, _objectname, value.Length); } + { + if (value == null) { _objectname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _objectname = new byte[value.Length]; Array.Copy(value, _objectname, value.Length); } } - } - private byte[] _simname; - /// SimName field + } + private byte[] _simname; + /// SimName field public byte[] SimName - { - get { return _simname; } + { + get { return _simname; } set - { - if (value == null) { _simname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _simname = new byte[value.Length]; Array.Copy(value, _simname, value.Length); } + { + if (value == null) { _simname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _simname = new byte[value.Length]; Array.Copy(value, _simname, value.Length); } } - } - /// LookAt field - public LLVector3 LookAt; - /// SimPosition field - public LLVector3 SimPosition; - - /// Length of this block serialized in bytes + } + /// LookAt field + public LLVector3 LookAt; + /// SimPosition field + public LLVector3 SimPosition; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 24; - if (ObjectName != null) { length += 1 + ObjectName.Length; } - if (SimName != null) { length += 1 + SimName.Length; } - return length; + { + int length = 24; + if (ObjectName != null) { length += 1 + ObjectName.Length; } + if (SimName != null) { length += 1 + SimName.Length; } + return length; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _objectname = new byte[length]; - Array.Copy(bytes, i, _objectname, 0, length); i += length; - length = (ushort)bytes[i++]; - _simname = new byte[length]; - Array.Copy(bytes, i, _simname, 0, length); i += length; - LookAt = new LLVector3(bytes, i); i += 12; - SimPosition = new LLVector3(bytes, i); i += 12; + { + length = (ushort)bytes[i++]; + _objectname = new byte[length]; + Array.Copy(bytes, i, _objectname, 0, length); i += length; + length = (ushort)bytes[i++]; + _simname = new byte[length]; + Array.Copy(bytes, i, _simname, 0, length); i += length; + LookAt = new LLVector3(bytes, i); i += 12; + SimPosition = new LLVector3(bytes, i); i += 12; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ObjectName == null) { Console.WriteLine("Warning: ObjectName is null, in " + this.GetType()); } - bytes[i++] = (byte)ObjectName.Length; - Array.Copy(ObjectName, 0, bytes, i, ObjectName.Length); i += ObjectName.Length; - if(SimName == null) { Console.WriteLine("Warning: SimName is null, in " + this.GetType()); } - bytes[i++] = (byte)SimName.Length; - Array.Copy(SimName, 0, bytes, i, SimName.Length); i += SimName.Length; - if(LookAt == null) { Console.WriteLine("Warning: LookAt is null, in " + this.GetType()); } - Array.Copy(LookAt.GetBytes(), 0, bytes, i, 12); i += 12; - if(SimPosition == null) { Console.WriteLine("Warning: SimPosition is null, in " + this.GetType()); } - Array.Copy(SimPosition.GetBytes(), 0, bytes, i, 12); i += 12; + { + if(ObjectName == null) { Console.WriteLine("Warning: ObjectName is null, in " + this.GetType()); } + bytes[i++] = (byte)ObjectName.Length; + Array.Copy(ObjectName, 0, bytes, i, ObjectName.Length); i += ObjectName.Length; + if(SimName == null) { Console.WriteLine("Warning: SimName is null, in " + this.GetType()); } + bytes[i++] = (byte)SimName.Length; + Array.Copy(SimName, 0, bytes, i, SimName.Length); i += SimName.Length; + if(LookAt == null) { Console.WriteLine("Warning: LookAt is null, in " + this.GetType()); } + Array.Copy(LookAt.GetBytes(), 0, bytes, i, 12); i += 12; + if(SimPosition == null) { Console.WriteLine("Warning: SimPosition is null, in " + this.GetType()); } + Array.Copy(SimPosition.GetBytes(), 0, bytes, i, 12); i += 12; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += Helpers.FieldToString(ObjectName, "ObjectName") + "\n"; - output += Helpers.FieldToString(SimName, "SimName") + "\n"; - output += "LookAt: " + LookAt.ToString() + "\n"; - output += "SimPosition: " + SimPosition.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += Helpers.FieldToString(ObjectName, "ObjectName") + "\n"; + output += Helpers.FieldToString(SimName, "SimName") + "\n"; + output += "LookAt: " + LookAt.ToString() + "\n"; + output += "SimPosition: " + SimPosition.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ScriptTeleportRequest - public override PacketType Type { get { return PacketType.ScriptTeleportRequest; } } - /// Data block - public DataBlock Data; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ScriptTeleportRequest + public override PacketType Type { get { return PacketType.ScriptTeleportRequest; } } + /// Data block + public DataBlock Data; + + /// Default constructor public ScriptTeleportRequestPacket() - { - Header = new LowHeader(); - Header.ID = 238; - Header.Reliable = true; - Data = new DataBlock(); + { + Header = new LowHeader(); + Header.ID = 238; + Header.Reliable = true; + Data = new DataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ScriptTeleportRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Data = new DataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Data = new DataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ScriptTeleportRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Data = new DataBlock(bytes, ref i); + { + Header = head; + Data = new DataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Data.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Data.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Data.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Data.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ScriptTeleportRequest ---\n"; - output += Data.ToString() + "\n"; + { + string output = "--- ScriptTeleportRequest ---\n"; + output += Data.ToString() + "\n"; return output; } - + } - - /// ParcelOverlay packet + + /// ParcelOverlay packet public class ParcelOverlayPacket : Packet - { - /// ParcelData block + { + /// ParcelData block public class ParcelDataBlock - { - private byte[] _data; - /// Data field + { + private byte[] _data; + /// Data field public byte[] Data - { - get { return _data; } + { + get { return _data; } set - { - if (value == null) { _data = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _data = new byte[value.Length]; Array.Copy(value, _data, value.Length); } + { + if (value == null) { _data = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _data = new byte[value.Length]; Array.Copy(value, _data, value.Length); } } - } - /// SequenceID field - public int SequenceID; - - /// Length of this block serialized in bytes + } + /// SequenceID field + public int SequenceID; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 4; - if (Data != null) { length += 2 + Data.Length; } - return length; + { + int length = 4; + if (Data != null) { length += 2 + Data.Length; } + return length; } } - - /// Default constructor - public ParcelDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ParcelDataBlock() { } + /// Constructor for building the block from a byte array public ParcelDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _data = new byte[length]; - Array.Copy(bytes, i, _data, 0, length); i += length; - SequenceID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _data = new byte[length]; + Array.Copy(bytes, i, _data, 0, length); i += length; + SequenceID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(Data == null) { Console.WriteLine("Warning: Data is null, in " + this.GetType()); } - bytes[i++] = (byte)(Data.Length % 256); - bytes[i++] = (byte)((Data.Length >> 8) % 256); - Array.Copy(Data, 0, bytes, i, Data.Length); i += Data.Length; - bytes[i++] = (byte)(SequenceID % 256); - bytes[i++] = (byte)((SequenceID >> 8) % 256); - bytes[i++] = (byte)((SequenceID >> 16) % 256); - bytes[i++] = (byte)((SequenceID >> 24) % 256); + { + if(Data == null) { Console.WriteLine("Warning: Data is null, in " + this.GetType()); } + bytes[i++] = (byte)(Data.Length % 256); + bytes[i++] = (byte)((Data.Length >> 8) % 256); + Array.Copy(Data, 0, bytes, i, Data.Length); i += Data.Length; + bytes[i++] = (byte)(SequenceID % 256); + bytes[i++] = (byte)((SequenceID >> 8) % 256); + bytes[i++] = (byte)((SequenceID >> 16) % 256); + bytes[i++] = (byte)((SequenceID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ParcelData --\n"; - output += Helpers.FieldToString(Data, "Data") + "\n"; - output += "SequenceID: " + SequenceID.ToString() + "\n"; + { + string output = "-- ParcelData --\n"; + output += Helpers.FieldToString(Data, "Data") + "\n"; + output += "SequenceID: " + SequenceID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ParcelOverlay - public override PacketType Type { get { return PacketType.ParcelOverlay; } } - /// ParcelData block - public ParcelDataBlock ParcelData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ParcelOverlay + public override PacketType Type { get { return PacketType.ParcelOverlay; } } + /// ParcelData block + public ParcelDataBlock ParcelData; + + /// Default constructor public ParcelOverlayPacket() - { - Header = new LowHeader(); - Header.ID = 239; - Header.Reliable = true; - Header.Zerocoded = true; - ParcelData = new ParcelDataBlock(); + { + Header = new LowHeader(); + Header.ID = 239; + Header.Reliable = true; + Header.Zerocoded = true; + ParcelData = new ParcelDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ParcelOverlayPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - ParcelData = new ParcelDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + ParcelData = new ParcelDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ParcelOverlayPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - ParcelData = new ParcelDataBlock(bytes, ref i); + { + Header = head; + ParcelData = new ParcelDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += ParcelData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - ParcelData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += ParcelData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + ParcelData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ParcelOverlay ---\n"; - output += ParcelData.ToString() + "\n"; + { + string output = "--- ParcelOverlay ---\n"; + output += ParcelData.ToString() + "\n"; return output; } - + } - - /// ParcelPropertiesRequestByID packet + + /// ParcelPropertiesRequestByID packet public class ParcelPropertiesRequestByIDPacket : Packet - { - /// ParcelData block + { + /// ParcelData block public class ParcelDataBlock - { - /// LocalID field - public int LocalID; - /// SequenceID field - public int SequenceID; - - /// Length of this block serialized in bytes + { + /// LocalID field + public int LocalID; + /// SequenceID field + public int SequenceID; + + /// Length of this block serialized in bytes public int Length { get - { - return 8; + { + return 8; } } - - /// Default constructor - public ParcelDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ParcelDataBlock() { } + /// Constructor for building the block from a byte array public ParcelDataBlock(byte[] bytes, ref int i) - { + { try - { - LocalID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - SequenceID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + LocalID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + SequenceID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(LocalID % 256); - bytes[i++] = (byte)((LocalID >> 8) % 256); - bytes[i++] = (byte)((LocalID >> 16) % 256); - bytes[i++] = (byte)((LocalID >> 24) % 256); - bytes[i++] = (byte)(SequenceID % 256); - bytes[i++] = (byte)((SequenceID >> 8) % 256); - bytes[i++] = (byte)((SequenceID >> 16) % 256); - bytes[i++] = (byte)((SequenceID >> 24) % 256); + { + bytes[i++] = (byte)(LocalID % 256); + bytes[i++] = (byte)((LocalID >> 8) % 256); + bytes[i++] = (byte)((LocalID >> 16) % 256); + bytes[i++] = (byte)((LocalID >> 24) % 256); + bytes[i++] = (byte)(SequenceID % 256); + bytes[i++] = (byte)((SequenceID >> 8) % 256); + bytes[i++] = (byte)((SequenceID >> 16) % 256); + bytes[i++] = (byte)((SequenceID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ParcelData --\n"; - output += "LocalID: " + LocalID.ToString() + "\n"; - output += "SequenceID: " + SequenceID.ToString() + "\n"; + { + string output = "-- ParcelData --\n"; + output += "LocalID: " + LocalID.ToString() + "\n"; + output += "SequenceID: " + SequenceID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ParcelPropertiesRequestByID - public override PacketType Type { get { return PacketType.ParcelPropertiesRequestByID; } } - /// ParcelData block - public ParcelDataBlock ParcelData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ParcelPropertiesRequestByID + public override PacketType Type { get { return PacketType.ParcelPropertiesRequestByID; } } + /// ParcelData block + public ParcelDataBlock ParcelData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ParcelPropertiesRequestByIDPacket() - { - Header = new LowHeader(); - Header.ID = 240; - Header.Reliable = true; - Header.Zerocoded = true; - ParcelData = new ParcelDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 240; + Header.Reliable = true; + Header.Zerocoded = true; + ParcelData = new ParcelDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ParcelPropertiesRequestByIDPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - ParcelData = new ParcelDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + ParcelData = new ParcelDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ParcelPropertiesRequestByIDPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - ParcelData = new ParcelDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + ParcelData = new ParcelDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += ParcelData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - ParcelData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += ParcelData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + ParcelData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ParcelPropertiesRequestByID ---\n"; - output += ParcelData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- ParcelPropertiesRequestByID ---\n"; + output += ParcelData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ParcelPropertiesUpdate packet + + /// ParcelPropertiesUpdate packet public class ParcelPropertiesUpdatePacket : Packet - { - /// ParcelData block + { + /// ParcelData block public class ParcelDataBlock - { - /// MediaID field - public LLUUID MediaID; - /// UserLookAt field - public LLVector3 UserLookAt; - private byte[] _mediaurl; - /// MediaURL field + { + /// MediaID field + public LLUUID MediaID; + /// UserLookAt field + public LLVector3 UserLookAt; + private byte[] _mediaurl; + /// MediaURL field public byte[] MediaURL - { - get { return _mediaurl; } + { + get { return _mediaurl; } set - { - if (value == null) { _mediaurl = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _mediaurl = new byte[value.Length]; Array.Copy(value, _mediaurl, value.Length); } + { + if (value == null) { _mediaurl = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _mediaurl = new byte[value.Length]; Array.Copy(value, _mediaurl, value.Length); } } - } - /// LocalID field - public int LocalID; - /// UserLocation field - public LLVector3 UserLocation; - private byte[] _name; - /// Name field + } + /// LocalID field + public int LocalID; + /// UserLocation field + public LLVector3 UserLocation; + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - private byte[] _desc; - /// Desc field + } + private byte[] _desc; + /// Desc field public byte[] Desc - { - get { return _desc; } + { + get { return _desc; } set - { - if (value == null) { _desc = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _desc = new byte[value.Length]; Array.Copy(value, _desc, value.Length); } + { + if (value == null) { _desc = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _desc = new byte[value.Length]; Array.Copy(value, _desc, value.Length); } } - } - /// Category field - public byte Category; - /// GroupID field - public LLUUID GroupID; - /// SalePrice field - public int SalePrice; - /// SnapshotID field - public LLUUID SnapshotID; - /// Flags field - public uint Flags; - /// LandingType field - public byte LandingType; - /// AuthBuyerID field - public LLUUID AuthBuyerID; - /// PassHours field - public float PassHours; - /// ParcelFlags field - public uint ParcelFlags; - /// PassPrice field - public int PassPrice; - /// MediaAutoScale field - public byte MediaAutoScale; - private byte[] _musicurl; - /// MusicURL field + } + /// Category field + public byte Category; + /// GroupID field + public LLUUID GroupID; + /// SalePrice field + public int SalePrice; + /// SnapshotID field + public LLUUID SnapshotID; + /// Flags field + public uint Flags; + /// LandingType field + public byte LandingType; + /// AuthBuyerID field + public LLUUID AuthBuyerID; + /// PassHours field + public float PassHours; + /// ParcelFlags field + public uint ParcelFlags; + /// PassPrice field + public int PassPrice; + /// MediaAutoScale field + public byte MediaAutoScale; + private byte[] _musicurl; + /// MusicURL field public byte[] MusicURL - { - get { return _musicurl; } + { + get { return _musicurl; } set - { - if (value == null) { _musicurl = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _musicurl = new byte[value.Length]; Array.Copy(value, _musicurl, value.Length); } + { + if (value == null) { _musicurl = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _musicurl = new byte[value.Length]; Array.Copy(value, _musicurl, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 115; - if (MediaURL != null) { length += 1 + MediaURL.Length; } - if (Name != null) { length += 1 + Name.Length; } - if (Desc != null) { length += 1 + Desc.Length; } - if (MusicURL != null) { length += 1 + MusicURL.Length; } - return length; + { + int length = 115; + if (MediaURL != null) { length += 1 + MediaURL.Length; } + if (Name != null) { length += 1 + Name.Length; } + if (Desc != null) { length += 1 + Desc.Length; } + if (MusicURL != null) { length += 1 + MusicURL.Length; } + return length; } } - - /// Default constructor - public ParcelDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ParcelDataBlock() { } + /// Constructor for building the block from a byte array public ParcelDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - MediaID = new LLUUID(bytes, i); i += 16; - UserLookAt = new LLVector3(bytes, i); i += 12; - length = (ushort)bytes[i++]; - _mediaurl = new byte[length]; - Array.Copy(bytes, i, _mediaurl, 0, length); i += length; - LocalID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - UserLocation = new LLVector3(bytes, i); i += 12; - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; - length = (ushort)bytes[i++]; - _desc = new byte[length]; - Array.Copy(bytes, i, _desc, 0, length); i += length; - Category = (byte)bytes[i++]; - GroupID = new LLUUID(bytes, i); i += 16; - SalePrice = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - SnapshotID = new LLUUID(bytes, i); i += 16; - Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - LandingType = (byte)bytes[i++]; - AuthBuyerID = new LLUUID(bytes, i); i += 16; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - PassHours = BitConverter.ToSingle(bytes, i); i += 4; - ParcelFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - PassPrice = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - MediaAutoScale = (byte)bytes[i++]; - length = (ushort)bytes[i++]; - _musicurl = new byte[length]; - Array.Copy(bytes, i, _musicurl, 0, length); i += length; + { + MediaID = new LLUUID(bytes, i); i += 16; + UserLookAt = new LLVector3(bytes, i); i += 12; + length = (ushort)bytes[i++]; + _mediaurl = new byte[length]; + Array.Copy(bytes, i, _mediaurl, 0, length); i += length; + LocalID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + UserLocation = new LLVector3(bytes, i); i += 12; + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; + length = (ushort)bytes[i++]; + _desc = new byte[length]; + Array.Copy(bytes, i, _desc, 0, length); i += length; + Category = (byte)bytes[i++]; + GroupID = new LLUUID(bytes, i); i += 16; + SalePrice = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + SnapshotID = new LLUUID(bytes, i); i += 16; + Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + LandingType = (byte)bytes[i++]; + AuthBuyerID = new LLUUID(bytes, i); i += 16; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + PassHours = BitConverter.ToSingle(bytes, i); i += 4; + ParcelFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + PassPrice = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + MediaAutoScale = (byte)bytes[i++]; + length = (ushort)bytes[i++]; + _musicurl = new byte[length]; + Array.Copy(bytes, i, _musicurl, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; - if(MediaID == null) { Console.WriteLine("Warning: MediaID is null, in " + this.GetType()); } - Array.Copy(MediaID.GetBytes(), 0, bytes, i, 16); i += 16; - if(UserLookAt == null) { Console.WriteLine("Warning: UserLookAt is null, in " + this.GetType()); } - Array.Copy(UserLookAt.GetBytes(), 0, bytes, i, 12); i += 12; - if(MediaURL == null) { Console.WriteLine("Warning: MediaURL is null, in " + this.GetType()); } - bytes[i++] = (byte)MediaURL.Length; - Array.Copy(MediaURL, 0, bytes, i, MediaURL.Length); i += MediaURL.Length; - bytes[i++] = (byte)(LocalID % 256); - bytes[i++] = (byte)((LocalID >> 8) % 256); - bytes[i++] = (byte)((LocalID >> 16) % 256); - bytes[i++] = (byte)((LocalID >> 24) % 256); - if(UserLocation == null) { Console.WriteLine("Warning: UserLocation is null, in " + this.GetType()); } - Array.Copy(UserLocation.GetBytes(), 0, bytes, i, 12); i += 12; - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; - if(Desc == null) { Console.WriteLine("Warning: Desc is null, in " + this.GetType()); } - bytes[i++] = (byte)Desc.Length; - Array.Copy(Desc, 0, bytes, i, Desc.Length); i += Desc.Length; - bytes[i++] = Category; - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(SalePrice % 256); - bytes[i++] = (byte)((SalePrice >> 8) % 256); - bytes[i++] = (byte)((SalePrice >> 16) % 256); - bytes[i++] = (byte)((SalePrice >> 24) % 256); - if(SnapshotID == null) { Console.WriteLine("Warning: SnapshotID is null, in " + this.GetType()); } - Array.Copy(SnapshotID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(Flags % 256); - bytes[i++] = (byte)((Flags >> 8) % 256); - bytes[i++] = (byte)((Flags >> 16) % 256); - bytes[i++] = (byte)((Flags >> 24) % 256); - bytes[i++] = LandingType; - if(AuthBuyerID == null) { Console.WriteLine("Warning: AuthBuyerID is null, in " + this.GetType()); } - Array.Copy(AuthBuyerID.GetBytes(), 0, bytes, i, 16); i += 16; + { + byte[] ba; + if(MediaID == null) { Console.WriteLine("Warning: MediaID is null, in " + this.GetType()); } + Array.Copy(MediaID.GetBytes(), 0, bytes, i, 16); i += 16; + if(UserLookAt == null) { Console.WriteLine("Warning: UserLookAt is null, in " + this.GetType()); } + Array.Copy(UserLookAt.GetBytes(), 0, bytes, i, 12); i += 12; + if(MediaURL == null) { Console.WriteLine("Warning: MediaURL is null, in " + this.GetType()); } + bytes[i++] = (byte)MediaURL.Length; + Array.Copy(MediaURL, 0, bytes, i, MediaURL.Length); i += MediaURL.Length; + bytes[i++] = (byte)(LocalID % 256); + bytes[i++] = (byte)((LocalID >> 8) % 256); + bytes[i++] = (byte)((LocalID >> 16) % 256); + bytes[i++] = (byte)((LocalID >> 24) % 256); + if(UserLocation == null) { Console.WriteLine("Warning: UserLocation is null, in " + this.GetType()); } + Array.Copy(UserLocation.GetBytes(), 0, bytes, i, 12); i += 12; + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + if(Desc == null) { Console.WriteLine("Warning: Desc is null, in " + this.GetType()); } + bytes[i++] = (byte)Desc.Length; + Array.Copy(Desc, 0, bytes, i, Desc.Length); i += Desc.Length; + bytes[i++] = Category; + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(SalePrice % 256); + bytes[i++] = (byte)((SalePrice >> 8) % 256); + bytes[i++] = (byte)((SalePrice >> 16) % 256); + bytes[i++] = (byte)((SalePrice >> 24) % 256); + if(SnapshotID == null) { Console.WriteLine("Warning: SnapshotID is null, in " + this.GetType()); } + Array.Copy(SnapshotID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(Flags % 256); + bytes[i++] = (byte)((Flags >> 8) % 256); + bytes[i++] = (byte)((Flags >> 16) % 256); + bytes[i++] = (byte)((Flags >> 24) % 256); + bytes[i++] = LandingType; + if(AuthBuyerID == null) { Console.WriteLine("Warning: AuthBuyerID is null, in " + this.GetType()); } + Array.Copy(AuthBuyerID.GetBytes(), 0, bytes, i, 16); i += 16; ba = BitConverter.GetBytes(PassHours); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - bytes[i++] = (byte)(ParcelFlags % 256); - bytes[i++] = (byte)((ParcelFlags >> 8) % 256); - bytes[i++] = (byte)((ParcelFlags >> 16) % 256); - bytes[i++] = (byte)((ParcelFlags >> 24) % 256); - bytes[i++] = (byte)(PassPrice % 256); - bytes[i++] = (byte)((PassPrice >> 8) % 256); - bytes[i++] = (byte)((PassPrice >> 16) % 256); - bytes[i++] = (byte)((PassPrice >> 24) % 256); - bytes[i++] = MediaAutoScale; - if(MusicURL == null) { Console.WriteLine("Warning: MusicURL is null, in " + this.GetType()); } - bytes[i++] = (byte)MusicURL.Length; - Array.Copy(MusicURL, 0, bytes, i, MusicURL.Length); i += MusicURL.Length; + Array.Copy(ba, 0, bytes, i, 4); i += 4; + bytes[i++] = (byte)(ParcelFlags % 256); + bytes[i++] = (byte)((ParcelFlags >> 8) % 256); + bytes[i++] = (byte)((ParcelFlags >> 16) % 256); + bytes[i++] = (byte)((ParcelFlags >> 24) % 256); + bytes[i++] = (byte)(PassPrice % 256); + bytes[i++] = (byte)((PassPrice >> 8) % 256); + bytes[i++] = (byte)((PassPrice >> 16) % 256); + bytes[i++] = (byte)((PassPrice >> 24) % 256); + bytes[i++] = MediaAutoScale; + if(MusicURL == null) { Console.WriteLine("Warning: MusicURL is null, in " + this.GetType()); } + bytes[i++] = (byte)MusicURL.Length; + Array.Copy(MusicURL, 0, bytes, i, MusicURL.Length); i += MusicURL.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ParcelData --\n"; - output += "MediaID: " + MediaID.ToString() + "\n"; - output += "UserLookAt: " + UserLookAt.ToString() + "\n"; - output += Helpers.FieldToString(MediaURL, "MediaURL") + "\n"; - output += "LocalID: " + LocalID.ToString() + "\n"; - output += "UserLocation: " + UserLocation.ToString() + "\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; - output += Helpers.FieldToString(Desc, "Desc") + "\n"; - output += "Category: " + Category.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; - output += "SalePrice: " + SalePrice.ToString() + "\n"; - output += "SnapshotID: " + SnapshotID.ToString() + "\n"; - output += "Flags: " + Flags.ToString() + "\n"; - output += "LandingType: " + LandingType.ToString() + "\n"; - output += "AuthBuyerID: " + AuthBuyerID.ToString() + "\n"; - output += "PassHours: " + PassHours.ToString() + "\n"; - output += "ParcelFlags: " + ParcelFlags.ToString() + "\n"; - output += "PassPrice: " + PassPrice.ToString() + "\n"; - output += "MediaAutoScale: " + MediaAutoScale.ToString() + "\n"; - output += Helpers.FieldToString(MusicURL, "MusicURL") + "\n"; + { + string output = "-- ParcelData --\n"; + output += "MediaID: " + MediaID.ToString() + "\n"; + output += "UserLookAt: " + UserLookAt.ToString() + "\n"; + output += Helpers.FieldToString(MediaURL, "MediaURL") + "\n"; + output += "LocalID: " + LocalID.ToString() + "\n"; + output += "UserLocation: " + UserLocation.ToString() + "\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; + output += Helpers.FieldToString(Desc, "Desc") + "\n"; + output += "Category: " + Category.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; + output += "SalePrice: " + SalePrice.ToString() + "\n"; + output += "SnapshotID: " + SnapshotID.ToString() + "\n"; + output += "Flags: " + Flags.ToString() + "\n"; + output += "LandingType: " + LandingType.ToString() + "\n"; + output += "AuthBuyerID: " + AuthBuyerID.ToString() + "\n"; + output += "PassHours: " + PassHours.ToString() + "\n"; + output += "ParcelFlags: " + ParcelFlags.ToString() + "\n"; + output += "PassPrice: " + PassPrice.ToString() + "\n"; + output += "MediaAutoScale: " + MediaAutoScale.ToString() + "\n"; + output += Helpers.FieldToString(MusicURL, "MusicURL") + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ParcelPropertiesUpdate - public override PacketType Type { get { return PacketType.ParcelPropertiesUpdate; } } - /// ParcelData block - public ParcelDataBlock ParcelData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ParcelPropertiesUpdate + public override PacketType Type { get { return PacketType.ParcelPropertiesUpdate; } } + /// ParcelData block + public ParcelDataBlock ParcelData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ParcelPropertiesUpdatePacket() - { - Header = new LowHeader(); - Header.ID = 241; - Header.Reliable = true; - Header.Zerocoded = true; - ParcelData = new ParcelDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 241; + Header.Reliable = true; + Header.Zerocoded = true; + ParcelData = new ParcelDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ParcelPropertiesUpdatePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - ParcelData = new ParcelDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + ParcelData = new ParcelDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ParcelPropertiesUpdatePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - ParcelData = new ParcelDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + ParcelData = new ParcelDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += ParcelData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - ParcelData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += ParcelData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + ParcelData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ParcelPropertiesUpdate ---\n"; - output += ParcelData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- ParcelPropertiesUpdate ---\n"; + output += ParcelData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ParcelReturnObjects packet + + /// ParcelReturnObjects packet public class ParcelReturnObjectsPacket : Packet - { - /// TaskIDs block + { + /// TaskIDs block public class TaskIDsBlock - { - /// TaskID field - public LLUUID TaskID; - - /// Length of this block serialized in bytes + { + /// TaskID field + public LLUUID TaskID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public TaskIDsBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public TaskIDsBlock() { } + /// Constructor for building the block from a byte array public TaskIDsBlock(byte[] bytes, ref int i) - { + { try - { - TaskID = new LLUUID(bytes, i); i += 16; + { + TaskID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(TaskID == null) { Console.WriteLine("Warning: TaskID is null, in " + this.GetType()); } - Array.Copy(TaskID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(TaskID == null) { Console.WriteLine("Warning: TaskID is null, in " + this.GetType()); } + Array.Copy(TaskID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- TaskIDs --\n"; - output += "TaskID: " + TaskID.ToString() + "\n"; + { + string output = "-- TaskIDs --\n"; + output += "TaskID: " + TaskID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// ParcelData block + + /// ParcelData block public class ParcelDataBlock - { - /// LocalID field - public int LocalID; - /// ReturnType field - public uint ReturnType; - - /// Length of this block serialized in bytes + { + /// LocalID field + public int LocalID; + /// ReturnType field + public uint ReturnType; + + /// Length of this block serialized in bytes public int Length { get - { - return 8; + { + return 8; } } - - /// Default constructor - public ParcelDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ParcelDataBlock() { } + /// Constructor for building the block from a byte array public ParcelDataBlock(byte[] bytes, ref int i) - { + { try - { - LocalID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - ReturnType = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + LocalID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + ReturnType = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(LocalID % 256); - bytes[i++] = (byte)((LocalID >> 8) % 256); - bytes[i++] = (byte)((LocalID >> 16) % 256); - bytes[i++] = (byte)((LocalID >> 24) % 256); - bytes[i++] = (byte)(ReturnType % 256); - bytes[i++] = (byte)((ReturnType >> 8) % 256); - bytes[i++] = (byte)((ReturnType >> 16) % 256); - bytes[i++] = (byte)((ReturnType >> 24) % 256); + { + bytes[i++] = (byte)(LocalID % 256); + bytes[i++] = (byte)((LocalID >> 8) % 256); + bytes[i++] = (byte)((LocalID >> 16) % 256); + bytes[i++] = (byte)((LocalID >> 24) % 256); + bytes[i++] = (byte)(ReturnType % 256); + bytes[i++] = (byte)((ReturnType >> 8) % 256); + bytes[i++] = (byte)((ReturnType >> 16) % 256); + bytes[i++] = (byte)((ReturnType >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ParcelData --\n"; - output += "LocalID: " + LocalID.ToString() + "\n"; - output += "ReturnType: " + ReturnType.ToString() + "\n"; + { + string output = "-- ParcelData --\n"; + output += "LocalID: " + LocalID.ToString() + "\n"; + output += "ReturnType: " + ReturnType.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// OwnerIDs block + + /// OwnerIDs block public class OwnerIDsBlock - { - /// OwnerID field - public LLUUID OwnerID; - - /// Length of this block serialized in bytes + { + /// OwnerID field + public LLUUID OwnerID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public OwnerIDsBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public OwnerIDsBlock() { } + /// Constructor for building the block from a byte array public OwnerIDsBlock(byte[] bytes, ref int i) - { + { try - { - OwnerID = new LLUUID(bytes, i); i += 16; + { + OwnerID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } - Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } + Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- OwnerIDs --\n"; - output += "OwnerID: " + OwnerID.ToString() + "\n"; + { + string output = "-- OwnerIDs --\n"; + output += "OwnerID: " + OwnerID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ParcelReturnObjects - public override PacketType Type { get { return PacketType.ParcelReturnObjects; } } - /// TaskIDs block - public TaskIDsBlock[] TaskIDs; - /// ParcelData block - public ParcelDataBlock ParcelData; - /// AgentData block - public AgentDataBlock AgentData; - /// OwnerIDs block - public OwnerIDsBlock[] OwnerIDs; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ParcelReturnObjects + public override PacketType Type { get { return PacketType.ParcelReturnObjects; } } + /// TaskIDs block + public TaskIDsBlock[] TaskIDs; + /// ParcelData block + public ParcelDataBlock ParcelData; + /// AgentData block + public AgentDataBlock AgentData; + /// OwnerIDs block + public OwnerIDsBlock[] OwnerIDs; + + /// Default constructor public ParcelReturnObjectsPacket() - { - Header = new LowHeader(); - Header.ID = 242; - Header.Reliable = true; - Header.Zerocoded = true; - TaskIDs = new TaskIDsBlock[0]; - ParcelData = new ParcelDataBlock(); - AgentData = new AgentDataBlock(); - OwnerIDs = new OwnerIDsBlock[0]; + { + Header = new LowHeader(); + Header.ID = 242; + Header.Reliable = true; + Header.Zerocoded = true; + TaskIDs = new TaskIDsBlock[0]; + ParcelData = new ParcelDataBlock(); + AgentData = new AgentDataBlock(); + OwnerIDs = new OwnerIDsBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ParcelReturnObjectsPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - TaskIDs = new TaskIDsBlock[count]; - for (int j = 0; j < count; j++) - { TaskIDs[j] = new TaskIDsBlock(bytes, ref i); } - ParcelData = new ParcelDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); - count = (int)bytes[i++]; - OwnerIDs = new OwnerIDsBlock[count]; - for (int j = 0; j < count; j++) - { OwnerIDs[j] = new OwnerIDsBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + TaskIDs = new TaskIDsBlock[count]; + for (int j = 0; j < count; j++) + { TaskIDs[j] = new TaskIDsBlock(bytes, ref i); } + ParcelData = new ParcelDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); + count = (int)bytes[i++]; + OwnerIDs = new OwnerIDsBlock[count]; + for (int j = 0; j < count; j++) + { OwnerIDs[j] = new OwnerIDsBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ParcelReturnObjectsPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - TaskIDs = new TaskIDsBlock[count]; - for (int j = 0; j < count; j++) - { TaskIDs[j] = new TaskIDsBlock(bytes, ref i); } - ParcelData = new ParcelDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); - count = (int)bytes[i++]; - OwnerIDs = new OwnerIDsBlock[count]; - for (int j = 0; j < count; j++) - { OwnerIDs[j] = new OwnerIDsBlock(bytes, ref i); } + { + Header = head; + int count = (int)bytes[i++]; + TaskIDs = new TaskIDsBlock[count]; + for (int j = 0; j < count; j++) + { TaskIDs[j] = new TaskIDsBlock(bytes, ref i); } + ParcelData = new ParcelDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); + count = (int)bytes[i++]; + OwnerIDs = new OwnerIDsBlock[count]; + for (int j = 0; j < count; j++) + { OwnerIDs[j] = new OwnerIDsBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += ParcelData.Length; length += AgentData.Length;; - length++; - for (int j = 0; j < TaskIDs.Length; j++) { length += TaskIDs[j].Length; } - length++; - for (int j = 0; j < OwnerIDs.Length; j++) { length += OwnerIDs[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)TaskIDs.Length; - for (int j = 0; j < TaskIDs.Length; j++) { TaskIDs[j].ToBytes(bytes, ref i); } - ParcelData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - bytes[i++] = (byte)OwnerIDs.Length; - for (int j = 0; j < OwnerIDs.Length; j++) { OwnerIDs[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += ParcelData.Length; length += AgentData.Length;; + length++; + for (int j = 0; j < TaskIDs.Length; j++) { length += TaskIDs[j].Length; } + length++; + for (int j = 0; j < OwnerIDs.Length; j++) { length += OwnerIDs[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)TaskIDs.Length; + for (int j = 0; j < TaskIDs.Length; j++) { TaskIDs[j].ToBytes(bytes, ref i); } + ParcelData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + bytes[i++] = (byte)OwnerIDs.Length; + for (int j = 0; j < OwnerIDs.Length; j++) { OwnerIDs[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ParcelReturnObjects ---\n"; + { + string output = "--- ParcelReturnObjects ---\n"; for (int j = 0; j < TaskIDs.Length; j++) - { + { output += TaskIDs[j].ToString() + "\n"; - } - output += ParcelData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + } + output += ParcelData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; for (int j = 0; j < OwnerIDs.Length; j++) - { + { output += OwnerIDs[j].ToString() + "\n"; - } + } return output; } - + } - - /// ParcelSetOtherCleanTime packet + + /// ParcelSetOtherCleanTime packet public class ParcelSetOtherCleanTimePacket : Packet - { - /// ParcelData block + { + /// ParcelData block public class ParcelDataBlock - { - /// LocalID field - public int LocalID; - /// OtherCleanTime field - public int OtherCleanTime; - - /// Length of this block serialized in bytes + { + /// LocalID field + public int LocalID; + /// OtherCleanTime field + public int OtherCleanTime; + + /// Length of this block serialized in bytes public int Length { get - { - return 8; + { + return 8; } } - - /// Default constructor - public ParcelDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ParcelDataBlock() { } + /// Constructor for building the block from a byte array public ParcelDataBlock(byte[] bytes, ref int i) - { + { try - { - LocalID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - OtherCleanTime = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + LocalID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + OtherCleanTime = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(LocalID % 256); - bytes[i++] = (byte)((LocalID >> 8) % 256); - bytes[i++] = (byte)((LocalID >> 16) % 256); - bytes[i++] = (byte)((LocalID >> 24) % 256); - bytes[i++] = (byte)(OtherCleanTime % 256); - bytes[i++] = (byte)((OtherCleanTime >> 8) % 256); - bytes[i++] = (byte)((OtherCleanTime >> 16) % 256); - bytes[i++] = (byte)((OtherCleanTime >> 24) % 256); + { + bytes[i++] = (byte)(LocalID % 256); + bytes[i++] = (byte)((LocalID >> 8) % 256); + bytes[i++] = (byte)((LocalID >> 16) % 256); + bytes[i++] = (byte)((LocalID >> 24) % 256); + bytes[i++] = (byte)(OtherCleanTime % 256); + bytes[i++] = (byte)((OtherCleanTime >> 8) % 256); + bytes[i++] = (byte)((OtherCleanTime >> 16) % 256); + bytes[i++] = (byte)((OtherCleanTime >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ParcelData --\n"; - output += "LocalID: " + LocalID.ToString() + "\n"; - output += "OtherCleanTime: " + OtherCleanTime.ToString() + "\n"; + { + string output = "-- ParcelData --\n"; + output += "LocalID: " + LocalID.ToString() + "\n"; + output += "OtherCleanTime: " + OtherCleanTime.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ParcelSetOtherCleanTime - public override PacketType Type { get { return PacketType.ParcelSetOtherCleanTime; } } - /// ParcelData block - public ParcelDataBlock ParcelData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ParcelSetOtherCleanTime + public override PacketType Type { get { return PacketType.ParcelSetOtherCleanTime; } } + /// ParcelData block + public ParcelDataBlock ParcelData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ParcelSetOtherCleanTimePacket() - { - Header = new LowHeader(); - Header.ID = 243; - Header.Reliable = true; - Header.Zerocoded = true; - ParcelData = new ParcelDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 243; + Header.Reliable = true; + Header.Zerocoded = true; + ParcelData = new ParcelDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ParcelSetOtherCleanTimePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - ParcelData = new ParcelDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + ParcelData = new ParcelDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ParcelSetOtherCleanTimePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - ParcelData = new ParcelDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + ParcelData = new ParcelDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += ParcelData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - ParcelData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += ParcelData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + ParcelData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ParcelSetOtherCleanTime ---\n"; - output += ParcelData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- ParcelSetOtherCleanTime ---\n"; + output += ParcelData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ParcelDisableObjects packet + + /// ParcelDisableObjects packet public class ParcelDisableObjectsPacket : Packet - { - /// TaskIDs block + { + /// TaskIDs block public class TaskIDsBlock - { - /// TaskID field - public LLUUID TaskID; - - /// Length of this block serialized in bytes + { + /// TaskID field + public LLUUID TaskID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public TaskIDsBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public TaskIDsBlock() { } + /// Constructor for building the block from a byte array public TaskIDsBlock(byte[] bytes, ref int i) - { + { try - { - TaskID = new LLUUID(bytes, i); i += 16; + { + TaskID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(TaskID == null) { Console.WriteLine("Warning: TaskID is null, in " + this.GetType()); } - Array.Copy(TaskID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(TaskID == null) { Console.WriteLine("Warning: TaskID is null, in " + this.GetType()); } + Array.Copy(TaskID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- TaskIDs --\n"; - output += "TaskID: " + TaskID.ToString() + "\n"; + { + string output = "-- TaskIDs --\n"; + output += "TaskID: " + TaskID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// ParcelData block + + /// ParcelData block public class ParcelDataBlock - { - /// LocalID field - public int LocalID; - /// ReturnType field - public uint ReturnType; - - /// Length of this block serialized in bytes + { + /// LocalID field + public int LocalID; + /// ReturnType field + public uint ReturnType; + + /// Length of this block serialized in bytes public int Length { get - { - return 8; + { + return 8; } } - - /// Default constructor - public ParcelDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ParcelDataBlock() { } + /// Constructor for building the block from a byte array public ParcelDataBlock(byte[] bytes, ref int i) - { + { try - { - LocalID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - ReturnType = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + LocalID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + ReturnType = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(LocalID % 256); - bytes[i++] = (byte)((LocalID >> 8) % 256); - bytes[i++] = (byte)((LocalID >> 16) % 256); - bytes[i++] = (byte)((LocalID >> 24) % 256); - bytes[i++] = (byte)(ReturnType % 256); - bytes[i++] = (byte)((ReturnType >> 8) % 256); - bytes[i++] = (byte)((ReturnType >> 16) % 256); - bytes[i++] = (byte)((ReturnType >> 24) % 256); + { + bytes[i++] = (byte)(LocalID % 256); + bytes[i++] = (byte)((LocalID >> 8) % 256); + bytes[i++] = (byte)((LocalID >> 16) % 256); + bytes[i++] = (byte)((LocalID >> 24) % 256); + bytes[i++] = (byte)(ReturnType % 256); + bytes[i++] = (byte)((ReturnType >> 8) % 256); + bytes[i++] = (byte)((ReturnType >> 16) % 256); + bytes[i++] = (byte)((ReturnType >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ParcelData --\n"; - output += "LocalID: " + LocalID.ToString() + "\n"; - output += "ReturnType: " + ReturnType.ToString() + "\n"; + { + string output = "-- ParcelData --\n"; + output += "LocalID: " + LocalID.ToString() + "\n"; + output += "ReturnType: " + ReturnType.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// OwnerIDs block + + /// OwnerIDs block public class OwnerIDsBlock - { - /// OwnerID field - public LLUUID OwnerID; - - /// Length of this block serialized in bytes + { + /// OwnerID field + public LLUUID OwnerID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public OwnerIDsBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public OwnerIDsBlock() { } + /// Constructor for building the block from a byte array public OwnerIDsBlock(byte[] bytes, ref int i) - { + { try - { - OwnerID = new LLUUID(bytes, i); i += 16; + { + OwnerID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } - Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } + Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- OwnerIDs --\n"; - output += "OwnerID: " + OwnerID.ToString() + "\n"; + { + string output = "-- OwnerIDs --\n"; + output += "OwnerID: " + OwnerID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ParcelDisableObjects - public override PacketType Type { get { return PacketType.ParcelDisableObjects; } } - /// TaskIDs block - public TaskIDsBlock[] TaskIDs; - /// ParcelData block - public ParcelDataBlock ParcelData; - /// AgentData block - public AgentDataBlock AgentData; - /// OwnerIDs block - public OwnerIDsBlock[] OwnerIDs; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ParcelDisableObjects + public override PacketType Type { get { return PacketType.ParcelDisableObjects; } } + /// TaskIDs block + public TaskIDsBlock[] TaskIDs; + /// ParcelData block + public ParcelDataBlock ParcelData; + /// AgentData block + public AgentDataBlock AgentData; + /// OwnerIDs block + public OwnerIDsBlock[] OwnerIDs; + + /// Default constructor public ParcelDisableObjectsPacket() - { - Header = new LowHeader(); - Header.ID = 244; - Header.Reliable = true; - Header.Zerocoded = true; - TaskIDs = new TaskIDsBlock[0]; - ParcelData = new ParcelDataBlock(); - AgentData = new AgentDataBlock(); - OwnerIDs = new OwnerIDsBlock[0]; + { + Header = new LowHeader(); + Header.ID = 244; + Header.Reliable = true; + Header.Zerocoded = true; + TaskIDs = new TaskIDsBlock[0]; + ParcelData = new ParcelDataBlock(); + AgentData = new AgentDataBlock(); + OwnerIDs = new OwnerIDsBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ParcelDisableObjectsPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - TaskIDs = new TaskIDsBlock[count]; - for (int j = 0; j < count; j++) - { TaskIDs[j] = new TaskIDsBlock(bytes, ref i); } - ParcelData = new ParcelDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); - count = (int)bytes[i++]; - OwnerIDs = new OwnerIDsBlock[count]; - for (int j = 0; j < count; j++) - { OwnerIDs[j] = new OwnerIDsBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + TaskIDs = new TaskIDsBlock[count]; + for (int j = 0; j < count; j++) + { TaskIDs[j] = new TaskIDsBlock(bytes, ref i); } + ParcelData = new ParcelDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); + count = (int)bytes[i++]; + OwnerIDs = new OwnerIDsBlock[count]; + for (int j = 0; j < count; j++) + { OwnerIDs[j] = new OwnerIDsBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ParcelDisableObjectsPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - TaskIDs = new TaskIDsBlock[count]; - for (int j = 0; j < count; j++) - { TaskIDs[j] = new TaskIDsBlock(bytes, ref i); } - ParcelData = new ParcelDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); - count = (int)bytes[i++]; - OwnerIDs = new OwnerIDsBlock[count]; - for (int j = 0; j < count; j++) - { OwnerIDs[j] = new OwnerIDsBlock(bytes, ref i); } + { + Header = head; + int count = (int)bytes[i++]; + TaskIDs = new TaskIDsBlock[count]; + for (int j = 0; j < count; j++) + { TaskIDs[j] = new TaskIDsBlock(bytes, ref i); } + ParcelData = new ParcelDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); + count = (int)bytes[i++]; + OwnerIDs = new OwnerIDsBlock[count]; + for (int j = 0; j < count; j++) + { OwnerIDs[j] = new OwnerIDsBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += ParcelData.Length; length += AgentData.Length;; - length++; - for (int j = 0; j < TaskIDs.Length; j++) { length += TaskIDs[j].Length; } - length++; - for (int j = 0; j < OwnerIDs.Length; j++) { length += OwnerIDs[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)TaskIDs.Length; - for (int j = 0; j < TaskIDs.Length; j++) { TaskIDs[j].ToBytes(bytes, ref i); } - ParcelData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - bytes[i++] = (byte)OwnerIDs.Length; - for (int j = 0; j < OwnerIDs.Length; j++) { OwnerIDs[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += ParcelData.Length; length += AgentData.Length;; + length++; + for (int j = 0; j < TaskIDs.Length; j++) { length += TaskIDs[j].Length; } + length++; + for (int j = 0; j < OwnerIDs.Length; j++) { length += OwnerIDs[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)TaskIDs.Length; + for (int j = 0; j < TaskIDs.Length; j++) { TaskIDs[j].ToBytes(bytes, ref i); } + ParcelData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + bytes[i++] = (byte)OwnerIDs.Length; + for (int j = 0; j < OwnerIDs.Length; j++) { OwnerIDs[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ParcelDisableObjects ---\n"; + { + string output = "--- ParcelDisableObjects ---\n"; for (int j = 0; j < TaskIDs.Length; j++) - { + { output += TaskIDs[j].ToString() + "\n"; - } - output += ParcelData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + } + output += ParcelData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; for (int j = 0; j < OwnerIDs.Length; j++) - { + { output += OwnerIDs[j].ToString() + "\n"; - } + } return output; } - + } - - /// ParcelSelectObjects packet + + /// ParcelSelectObjects packet public class ParcelSelectObjectsPacket : Packet - { - /// ReturnIDs block + { + /// ReturnIDs block public class ReturnIDsBlock - { - /// ReturnID field - public LLUUID ReturnID; - - /// Length of this block serialized in bytes + { + /// ReturnID field + public LLUUID ReturnID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public ReturnIDsBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ReturnIDsBlock() { } + /// Constructor for building the block from a byte array public ReturnIDsBlock(byte[] bytes, ref int i) - { + { try - { - ReturnID = new LLUUID(bytes, i); i += 16; + { + ReturnID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ReturnID == null) { Console.WriteLine("Warning: ReturnID is null, in " + this.GetType()); } - Array.Copy(ReturnID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(ReturnID == null) { Console.WriteLine("Warning: ReturnID is null, in " + this.GetType()); } + Array.Copy(ReturnID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ReturnIDs --\n"; - output += "ReturnID: " + ReturnID.ToString() + "\n"; + { + string output = "-- ReturnIDs --\n"; + output += "ReturnID: " + ReturnID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// ParcelData block + + /// ParcelData block public class ParcelDataBlock - { - /// LocalID field - public int LocalID; - /// ReturnType field - public uint ReturnType; - - /// Length of this block serialized in bytes + { + /// LocalID field + public int LocalID; + /// ReturnType field + public uint ReturnType; + + /// Length of this block serialized in bytes public int Length { get - { - return 8; + { + return 8; } } - - /// Default constructor - public ParcelDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ParcelDataBlock() { } + /// Constructor for building the block from a byte array public ParcelDataBlock(byte[] bytes, ref int i) - { + { try - { - LocalID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - ReturnType = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + LocalID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + ReturnType = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(LocalID % 256); - bytes[i++] = (byte)((LocalID >> 8) % 256); - bytes[i++] = (byte)((LocalID >> 16) % 256); - bytes[i++] = (byte)((LocalID >> 24) % 256); - bytes[i++] = (byte)(ReturnType % 256); - bytes[i++] = (byte)((ReturnType >> 8) % 256); - bytes[i++] = (byte)((ReturnType >> 16) % 256); - bytes[i++] = (byte)((ReturnType >> 24) % 256); + { + bytes[i++] = (byte)(LocalID % 256); + bytes[i++] = (byte)((LocalID >> 8) % 256); + bytes[i++] = (byte)((LocalID >> 16) % 256); + bytes[i++] = (byte)((LocalID >> 24) % 256); + bytes[i++] = (byte)(ReturnType % 256); + bytes[i++] = (byte)((ReturnType >> 8) % 256); + bytes[i++] = (byte)((ReturnType >> 16) % 256); + bytes[i++] = (byte)((ReturnType >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ParcelData --\n"; - output += "LocalID: " + LocalID.ToString() + "\n"; - output += "ReturnType: " + ReturnType.ToString() + "\n"; + { + string output = "-- ParcelData --\n"; + output += "LocalID: " + LocalID.ToString() + "\n"; + output += "ReturnType: " + ReturnType.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ParcelSelectObjects - public override PacketType Type { get { return PacketType.ParcelSelectObjects; } } - /// ReturnIDs block - public ReturnIDsBlock[] ReturnIDs; - /// ParcelData block - public ParcelDataBlock ParcelData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ParcelSelectObjects + public override PacketType Type { get { return PacketType.ParcelSelectObjects; } } + /// ReturnIDs block + public ReturnIDsBlock[] ReturnIDs; + /// ParcelData block + public ParcelDataBlock ParcelData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ParcelSelectObjectsPacket() - { - Header = new LowHeader(); - Header.ID = 245; - Header.Reliable = true; - Header.Zerocoded = true; - ReturnIDs = new ReturnIDsBlock[0]; - ParcelData = new ParcelDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 245; + Header.Reliable = true; + Header.Zerocoded = true; + ReturnIDs = new ReturnIDsBlock[0]; + ParcelData = new ParcelDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ParcelSelectObjectsPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ReturnIDs = new ReturnIDsBlock[count]; - for (int j = 0; j < count; j++) - { ReturnIDs[j] = new ReturnIDsBlock(bytes, ref i); } - ParcelData = new ParcelDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ReturnIDs = new ReturnIDsBlock[count]; + for (int j = 0; j < count; j++) + { ReturnIDs[j] = new ReturnIDsBlock(bytes, ref i); } + ParcelData = new ParcelDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ParcelSelectObjectsPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ReturnIDs = new ReturnIDsBlock[count]; - for (int j = 0; j < count; j++) - { ReturnIDs[j] = new ReturnIDsBlock(bytes, ref i); } - ParcelData = new ParcelDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + ReturnIDs = new ReturnIDsBlock[count]; + for (int j = 0; j < count; j++) + { ReturnIDs[j] = new ReturnIDsBlock(bytes, ref i); } + ParcelData = new ParcelDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += ParcelData.Length; length += AgentData.Length;; - length++; - for (int j = 0; j < ReturnIDs.Length; j++) { length += ReturnIDs[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ReturnIDs.Length; - for (int j = 0; j < ReturnIDs.Length; j++) { ReturnIDs[j].ToBytes(bytes, ref i); } - ParcelData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += ParcelData.Length; length += AgentData.Length;; + length++; + for (int j = 0; j < ReturnIDs.Length; j++) { length += ReturnIDs[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ReturnIDs.Length; + for (int j = 0; j < ReturnIDs.Length; j++) { ReturnIDs[j].ToBytes(bytes, ref i); } + ParcelData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ParcelSelectObjects ---\n"; + { + string output = "--- ParcelSelectObjects ---\n"; for (int j = 0; j < ReturnIDs.Length; j++) - { + { output += ReturnIDs[j].ToString() + "\n"; - } - output += ParcelData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + } + output += ParcelData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// EstateCovenantRequest packet + + /// EstateCovenantRequest packet public class EstateCovenantRequestPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.EstateCovenantRequest - public override PacketType Type { get { return PacketType.EstateCovenantRequest; } } - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.EstateCovenantRequest + public override PacketType Type { get { return PacketType.EstateCovenantRequest; } } + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public EstateCovenantRequestPacket() - { - Header = new LowHeader(); - Header.ID = 246; - Header.Reliable = true; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 246; + Header.Reliable = true; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public EstateCovenantRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public EstateCovenantRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- EstateCovenantRequest ---\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- EstateCovenantRequest ---\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// EstateCovenantReply packet + + /// EstateCovenantReply packet public class EstateCovenantReplyPacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - /// CovenantID field - public LLUUID CovenantID; - /// CovenantTimestamp field - public uint CovenantTimestamp; - private byte[] _estatename; - /// EstateName field + { + /// CovenantID field + public LLUUID CovenantID; + /// CovenantTimestamp field + public uint CovenantTimestamp; + private byte[] _estatename; + /// EstateName field public byte[] EstateName - { - get { return _estatename; } + { + get { return _estatename; } set - { - if (value == null) { _estatename = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _estatename = new byte[value.Length]; Array.Copy(value, _estatename, value.Length); } + { + if (value == null) { _estatename = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _estatename = new byte[value.Length]; Array.Copy(value, _estatename, value.Length); } } - } - /// EstateOwnerID field - public LLUUID EstateOwnerID; - - /// Length of this block serialized in bytes + } + /// EstateOwnerID field + public LLUUID EstateOwnerID; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 36; - if (EstateName != null) { length += 1 + EstateName.Length; } - return length; + { + int length = 36; + if (EstateName != null) { length += 1 + EstateName.Length; } + return length; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - CovenantID = new LLUUID(bytes, i); i += 16; - CovenantTimestamp = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _estatename = new byte[length]; - Array.Copy(bytes, i, _estatename, 0, length); i += length; - EstateOwnerID = new LLUUID(bytes, i); i += 16; + { + CovenantID = new LLUUID(bytes, i); i += 16; + CovenantTimestamp = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _estatename = new byte[length]; + Array.Copy(bytes, i, _estatename, 0, length); i += length; + EstateOwnerID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(CovenantID == null) { Console.WriteLine("Warning: CovenantID is null, in " + this.GetType()); } - Array.Copy(CovenantID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(CovenantTimestamp % 256); - bytes[i++] = (byte)((CovenantTimestamp >> 8) % 256); - bytes[i++] = (byte)((CovenantTimestamp >> 16) % 256); - bytes[i++] = (byte)((CovenantTimestamp >> 24) % 256); - if(EstateName == null) { Console.WriteLine("Warning: EstateName is null, in " + this.GetType()); } - bytes[i++] = (byte)EstateName.Length; - Array.Copy(EstateName, 0, bytes, i, EstateName.Length); i += EstateName.Length; - if(EstateOwnerID == null) { Console.WriteLine("Warning: EstateOwnerID is null, in " + this.GetType()); } - Array.Copy(EstateOwnerID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(CovenantID == null) { Console.WriteLine("Warning: CovenantID is null, in " + this.GetType()); } + Array.Copy(CovenantID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(CovenantTimestamp % 256); + bytes[i++] = (byte)((CovenantTimestamp >> 8) % 256); + bytes[i++] = (byte)((CovenantTimestamp >> 16) % 256); + bytes[i++] = (byte)((CovenantTimestamp >> 24) % 256); + if(EstateName == null) { Console.WriteLine("Warning: EstateName is null, in " + this.GetType()); } + bytes[i++] = (byte)EstateName.Length; + Array.Copy(EstateName, 0, bytes, i, EstateName.Length); i += EstateName.Length; + if(EstateOwnerID == null) { Console.WriteLine("Warning: EstateOwnerID is null, in " + this.GetType()); } + Array.Copy(EstateOwnerID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "CovenantID: " + CovenantID.ToString() + "\n"; - output += "CovenantTimestamp: " + CovenantTimestamp.ToString() + "\n"; - output += Helpers.FieldToString(EstateName, "EstateName") + "\n"; - output += "EstateOwnerID: " + EstateOwnerID.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += "CovenantID: " + CovenantID.ToString() + "\n"; + output += "CovenantTimestamp: " + CovenantTimestamp.ToString() + "\n"; + output += Helpers.FieldToString(EstateName, "EstateName") + "\n"; + output += "EstateOwnerID: " + EstateOwnerID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.EstateCovenantReply - public override PacketType Type { get { return PacketType.EstateCovenantReply; } } - /// Data block - public DataBlock Data; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.EstateCovenantReply + public override PacketType Type { get { return PacketType.EstateCovenantReply; } } + /// Data block + public DataBlock Data; + + /// Default constructor public EstateCovenantReplyPacket() - { - Header = new LowHeader(); - Header.ID = 247; - Header.Reliable = true; - Data = new DataBlock(); + { + Header = new LowHeader(); + Header.ID = 247; + Header.Reliable = true; + Data = new DataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public EstateCovenantReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Data = new DataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Data = new DataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public EstateCovenantReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Data = new DataBlock(bytes, ref i); + { + Header = head; + Data = new DataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Data.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Data.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Data.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Data.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- EstateCovenantReply ---\n"; - output += Data.ToString() + "\n"; + { + string output = "--- EstateCovenantReply ---\n"; + output += Data.ToString() + "\n"; return output; } - + } - - /// ForceObjectSelect packet + + /// ForceObjectSelect packet public class ForceObjectSelectPacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - /// LocalID field - public uint LocalID; - - /// Length of this block serialized in bytes + { + /// LocalID field + public uint LocalID; + + /// Length of this block serialized in bytes public int Length { get - { - return 4; + { + return 4; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { + { try - { - LocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + LocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(LocalID % 256); - bytes[i++] = (byte)((LocalID >> 8) % 256); - bytes[i++] = (byte)((LocalID >> 16) % 256); - bytes[i++] = (byte)((LocalID >> 24) % 256); + { + bytes[i++] = (byte)(LocalID % 256); + bytes[i++] = (byte)((LocalID >> 8) % 256); + bytes[i++] = (byte)((LocalID >> 16) % 256); + bytes[i++] = (byte)((LocalID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "LocalID: " + LocalID.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += "LocalID: " + LocalID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// Header block + + /// Header block public class HeaderBlock - { - /// ResetList field - public bool ResetList; - - /// Length of this block serialized in bytes + { + /// ResetList field + public bool ResetList; + + /// Length of this block serialized in bytes public int Length { get - { - return 1; + { + return 1; } } - - /// Default constructor - public HeaderBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public HeaderBlock() { } + /// Constructor for building the block from a byte array public HeaderBlock(byte[] bytes, ref int i) - { + { try - { - ResetList = (bytes[i++] != 0) ? (bool)true : (bool)false; + { + ResetList = (bytes[i++] != 0) ? (bool)true : (bool)false; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)((ResetList) ? 1 : 0); + { + bytes[i++] = (byte)((ResetList) ? 1 : 0); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Header --\n"; - output += "ResetList: " + ResetList.ToString() + "\n"; + { + string output = "-- Header --\n"; + output += "ResetList: " + ResetList.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ForceObjectSelect - public override PacketType Type { get { return PacketType.ForceObjectSelect; } } - /// Data block - public DataBlock[] Data; - /// Header block - public HeaderBlock _Header; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ForceObjectSelect + public override PacketType Type { get { return PacketType.ForceObjectSelect; } } + /// Data block + public DataBlock[] Data; + /// Header block + public HeaderBlock _Header; + + /// Default constructor public ForceObjectSelectPacket() - { - Header = new LowHeader(); - Header.ID = 248; - Header.Reliable = true; - Data = new DataBlock[0]; - _Header = new HeaderBlock(); + { + Header = new LowHeader(); + Header.ID = 248; + Header.Reliable = true; + Data = new DataBlock[0]; + _Header = new HeaderBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ForceObjectSelectPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - Data = new DataBlock[count]; - for (int j = 0; j < count; j++) - { Data[j] = new DataBlock(bytes, ref i); } - _Header = new HeaderBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + Data = new DataBlock[count]; + for (int j = 0; j < count; j++) + { Data[j] = new DataBlock(bytes, ref i); } + _Header = new HeaderBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ForceObjectSelectPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - Data = new DataBlock[count]; - for (int j = 0; j < count; j++) - { Data[j] = new DataBlock(bytes, ref i); } - _Header = new HeaderBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + Data = new DataBlock[count]; + for (int j = 0; j < count; j++) + { Data[j] = new DataBlock(bytes, ref i); } + _Header = new HeaderBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += _Header.Length;; - length++; - for (int j = 0; j < Data.Length; j++) { length += Data[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)Data.Length; - for (int j = 0; j < Data.Length; j++) { Data[j].ToBytes(bytes, ref i); } - _Header.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += _Header.Length;; + length++; + for (int j = 0; j < Data.Length; j++) { length += Data[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)Data.Length; + for (int j = 0; j < Data.Length; j++) { Data[j].ToBytes(bytes, ref i); } + _Header.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ForceObjectSelect ---\n"; + { + string output = "--- ForceObjectSelect ---\n"; for (int j = 0; j < Data.Length; j++) - { + { output += Data[j].ToString() + "\n"; - } - output += _Header.ToString() + "\n"; + } + output += _Header.ToString() + "\n"; return output; } - + } - - /// ParcelBuyPass packet + + /// ParcelBuyPass packet public class ParcelBuyPassPacket : Packet - { - /// ParcelData block + { + /// ParcelData block public class ParcelDataBlock - { - /// LocalID field - public int LocalID; - - /// Length of this block serialized in bytes + { + /// LocalID field + public int LocalID; + + /// Length of this block serialized in bytes public int Length { get - { - return 4; + { + return 4; } } - - /// Default constructor - public ParcelDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ParcelDataBlock() { } + /// Constructor for building the block from a byte array public ParcelDataBlock(byte[] bytes, ref int i) - { + { try - { - LocalID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + LocalID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(LocalID % 256); - bytes[i++] = (byte)((LocalID >> 8) % 256); - bytes[i++] = (byte)((LocalID >> 16) % 256); - bytes[i++] = (byte)((LocalID >> 24) % 256); + { + bytes[i++] = (byte)(LocalID % 256); + bytes[i++] = (byte)((LocalID >> 8) % 256); + bytes[i++] = (byte)((LocalID >> 16) % 256); + bytes[i++] = (byte)((LocalID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ParcelData --\n"; - output += "LocalID: " + LocalID.ToString() + "\n"; + { + string output = "-- ParcelData --\n"; + output += "LocalID: " + LocalID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ParcelBuyPass - public override PacketType Type { get { return PacketType.ParcelBuyPass; } } - /// ParcelData block - public ParcelDataBlock ParcelData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ParcelBuyPass + public override PacketType Type { get { return PacketType.ParcelBuyPass; } } + /// ParcelData block + public ParcelDataBlock ParcelData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ParcelBuyPassPacket() - { - Header = new LowHeader(); - Header.ID = 249; - Header.Reliable = true; - ParcelData = new ParcelDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 249; + Header.Reliable = true; + ParcelData = new ParcelDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ParcelBuyPassPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - ParcelData = new ParcelDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + ParcelData = new ParcelDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ParcelBuyPassPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - ParcelData = new ParcelDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + ParcelData = new ParcelDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += ParcelData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - ParcelData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += ParcelData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + ParcelData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ParcelBuyPass ---\n"; - output += ParcelData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- ParcelBuyPass ---\n"; + output += ParcelData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ParcelDeedToGroup packet + + /// ParcelDeedToGroup packet public class ParcelDeedToGroupPacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - /// LocalID field - public int LocalID; - /// GroupID field - public LLUUID GroupID; - - /// Length of this block serialized in bytes + { + /// LocalID field + public int LocalID; + /// GroupID field + public LLUUID GroupID; + + /// Length of this block serialized in bytes public int Length { get - { - return 20; + { + return 20; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { + { try - { - LocalID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - GroupID = new LLUUID(bytes, i); i += 16; + { + LocalID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + GroupID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(LocalID % 256); - bytes[i++] = (byte)((LocalID >> 8) % 256); - bytes[i++] = (byte)((LocalID >> 16) % 256); - bytes[i++] = (byte)((LocalID >> 24) % 256); - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + { + bytes[i++] = (byte)(LocalID % 256); + bytes[i++] = (byte)((LocalID >> 8) % 256); + bytes[i++] = (byte)((LocalID >> 16) % 256); + bytes[i++] = (byte)((LocalID >> 24) % 256); + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "LocalID: " + LocalID.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += "LocalID: " + LocalID.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ParcelDeedToGroup - public override PacketType Type { get { return PacketType.ParcelDeedToGroup; } } - /// Data block - public DataBlock Data; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ParcelDeedToGroup + public override PacketType Type { get { return PacketType.ParcelDeedToGroup; } } + /// Data block + public DataBlock Data; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ParcelDeedToGroupPacket() - { - Header = new LowHeader(); - Header.ID = 250; - Header.Reliable = true; - Data = new DataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 250; + Header.Reliable = true; + Data = new DataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ParcelDeedToGroupPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ParcelDeedToGroupPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Data.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Data.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Data.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Data.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ParcelDeedToGroup ---\n"; - output += Data.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- ParcelDeedToGroup ---\n"; + output += Data.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ParcelReclaim packet + + /// ParcelReclaim packet public class ParcelReclaimPacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - /// LocalID field - public int LocalID; - - /// Length of this block serialized in bytes + { + /// LocalID field + public int LocalID; + + /// Length of this block serialized in bytes public int Length { get - { - return 4; + { + return 4; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { + { try - { - LocalID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + LocalID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(LocalID % 256); - bytes[i++] = (byte)((LocalID >> 8) % 256); - bytes[i++] = (byte)((LocalID >> 16) % 256); - bytes[i++] = (byte)((LocalID >> 24) % 256); + { + bytes[i++] = (byte)(LocalID % 256); + bytes[i++] = (byte)((LocalID >> 8) % 256); + bytes[i++] = (byte)((LocalID >> 16) % 256); + bytes[i++] = (byte)((LocalID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "LocalID: " + LocalID.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += "LocalID: " + LocalID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ParcelReclaim - public override PacketType Type { get { return PacketType.ParcelReclaim; } } - /// Data block - public DataBlock Data; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ParcelReclaim + public override PacketType Type { get { return PacketType.ParcelReclaim; } } + /// Data block + public DataBlock Data; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ParcelReclaimPacket() - { - Header = new LowHeader(); - Header.ID = 251; - Header.Reliable = true; - Data = new DataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 251; + Header.Reliable = true; + Data = new DataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ParcelReclaimPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ParcelReclaimPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Data.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Data.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Data.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Data.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ParcelReclaim ---\n"; - output += Data.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- ParcelReclaim ---\n"; + output += Data.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ParcelClaim packet + + /// ParcelClaim packet public class ParcelClaimPacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - /// IsGroupOwned field - public bool IsGroupOwned; - /// GroupID field - public LLUUID GroupID; - /// Final field - public bool Final; - - /// Length of this block serialized in bytes + { + /// IsGroupOwned field + public bool IsGroupOwned; + /// GroupID field + public LLUUID GroupID; + /// Final field + public bool Final; + + /// Length of this block serialized in bytes public int Length { get - { - return 18; + { + return 18; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { + { try - { - IsGroupOwned = (bytes[i++] != 0) ? (bool)true : (bool)false; - GroupID = new LLUUID(bytes, i); i += 16; - Final = (bytes[i++] != 0) ? (bool)true : (bool)false; + { + IsGroupOwned = (bytes[i++] != 0) ? (bool)true : (bool)false; + GroupID = new LLUUID(bytes, i); i += 16; + Final = (bytes[i++] != 0) ? (bool)true : (bool)false; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)((IsGroupOwned) ? 1 : 0); - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((Final) ? 1 : 0); + { + bytes[i++] = (byte)((IsGroupOwned) ? 1 : 0); + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((Final) ? 1 : 0); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "IsGroupOwned: " + IsGroupOwned.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; - output += "Final: " + Final.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += "IsGroupOwned: " + IsGroupOwned.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; + output += "Final: " + Final.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// ParcelData block + + /// ParcelData block public class ParcelDataBlock - { - /// East field - public float East; - /// West field - public float West; - /// North field - public float North; - /// South field - public float South; - - /// Length of this block serialized in bytes + { + /// East field + public float East; + /// West field + public float West; + /// North field + public float North; + /// South field + public float South; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public ParcelDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ParcelDataBlock() { } + /// Constructor for building the block from a byte array public ParcelDataBlock(byte[] bytes, ref int i) - { + { try - { - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - East = BitConverter.ToSingle(bytes, i); i += 4; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - West = BitConverter.ToSingle(bytes, i); i += 4; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - North = BitConverter.ToSingle(bytes, i); i += 4; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - South = BitConverter.ToSingle(bytes, i); i += 4; + { + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + East = BitConverter.ToSingle(bytes, i); i += 4; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + West = BitConverter.ToSingle(bytes, i); i += 4; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + North = BitConverter.ToSingle(bytes, i); i += 4; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + South = BitConverter.ToSingle(bytes, i); i += 4; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; + { + byte[] ba; ba = BitConverter.GetBytes(East); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; ba = BitConverter.GetBytes(West); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; ba = BitConverter.GetBytes(North); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; ba = BitConverter.GetBytes(South); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ParcelData --\n"; - output += "East: " + East.ToString() + "\n"; - output += "West: " + West.ToString() + "\n"; - output += "North: " + North.ToString() + "\n"; - output += "South: " + South.ToString() + "\n"; + { + string output = "-- ParcelData --\n"; + output += "East: " + East.ToString() + "\n"; + output += "West: " + West.ToString() + "\n"; + output += "North: " + North.ToString() + "\n"; + output += "South: " + South.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ParcelClaim - public override PacketType Type { get { return PacketType.ParcelClaim; } } - /// Data block - public DataBlock Data; - /// ParcelData block - public ParcelDataBlock[] ParcelData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ParcelClaim + public override PacketType Type { get { return PacketType.ParcelClaim; } } + /// Data block + public DataBlock Data; + /// ParcelData block + public ParcelDataBlock[] ParcelData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ParcelClaimPacket() - { - Header = new LowHeader(); - Header.ID = 252; - Header.Reliable = true; - Header.Zerocoded = true; - Data = new DataBlock(); - ParcelData = new ParcelDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 252; + Header.Reliable = true; + Header.Zerocoded = true; + Data = new DataBlock(); + ParcelData = new ParcelDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ParcelClaimPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Data = new DataBlock(bytes, ref i); - int count = (int)bytes[i++]; - ParcelData = new ParcelDataBlock[count]; - for (int j = 0; j < count; j++) - { ParcelData[j] = new ParcelDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Data = new DataBlock(bytes, ref i); + int count = (int)bytes[i++]; + ParcelData = new ParcelDataBlock[count]; + for (int j = 0; j < count; j++) + { ParcelData[j] = new ParcelDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ParcelClaimPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Data = new DataBlock(bytes, ref i); - int count = (int)bytes[i++]; - ParcelData = new ParcelDataBlock[count]; - for (int j = 0; j < count; j++) - { ParcelData[j] = new ParcelDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + Data = new DataBlock(bytes, ref i); + int count = (int)bytes[i++]; + ParcelData = new ParcelDataBlock[count]; + for (int j = 0; j < count; j++) + { ParcelData[j] = new ParcelDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Data.Length; length += AgentData.Length;; - length++; - for (int j = 0; j < ParcelData.Length; j++) { length += ParcelData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Data.ToBytes(bytes, ref i); - bytes[i++] = (byte)ParcelData.Length; - for (int j = 0; j < ParcelData.Length; j++) { ParcelData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Data.Length; length += AgentData.Length;; + length++; + for (int j = 0; j < ParcelData.Length; j++) { length += ParcelData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Data.ToBytes(bytes, ref i); + bytes[i++] = (byte)ParcelData.Length; + for (int j = 0; j < ParcelData.Length; j++) { ParcelData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ParcelClaim ---\n"; - output += Data.ToString() + "\n"; + { + string output = "--- ParcelClaim ---\n"; + output += Data.ToString() + "\n"; for (int j = 0; j < ParcelData.Length; j++) - { + { output += ParcelData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ParcelJoin packet + + /// ParcelJoin packet public class ParcelJoinPacket : Packet - { - /// ParcelData block + { + /// ParcelData block public class ParcelDataBlock - { - /// East field - public float East; - /// West field - public float West; - /// North field - public float North; - /// South field - public float South; - - /// Length of this block serialized in bytes + { + /// East field + public float East; + /// West field + public float West; + /// North field + public float North; + /// South field + public float South; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public ParcelDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ParcelDataBlock() { } + /// Constructor for building the block from a byte array public ParcelDataBlock(byte[] bytes, ref int i) - { + { try - { - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - East = BitConverter.ToSingle(bytes, i); i += 4; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - West = BitConverter.ToSingle(bytes, i); i += 4; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - North = BitConverter.ToSingle(bytes, i); i += 4; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - South = BitConverter.ToSingle(bytes, i); i += 4; + { + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + East = BitConverter.ToSingle(bytes, i); i += 4; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + West = BitConverter.ToSingle(bytes, i); i += 4; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + North = BitConverter.ToSingle(bytes, i); i += 4; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + South = BitConverter.ToSingle(bytes, i); i += 4; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; + { + byte[] ba; ba = BitConverter.GetBytes(East); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; ba = BitConverter.GetBytes(West); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; ba = BitConverter.GetBytes(North); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; ba = BitConverter.GetBytes(South); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ParcelData --\n"; - output += "East: " + East.ToString() + "\n"; - output += "West: " + West.ToString() + "\n"; - output += "North: " + North.ToString() + "\n"; - output += "South: " + South.ToString() + "\n"; + { + string output = "-- ParcelData --\n"; + output += "East: " + East.ToString() + "\n"; + output += "West: " + West.ToString() + "\n"; + output += "North: " + North.ToString() + "\n"; + output += "South: " + South.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ParcelJoin - public override PacketType Type { get { return PacketType.ParcelJoin; } } - /// ParcelData block - public ParcelDataBlock ParcelData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ParcelJoin + public override PacketType Type { get { return PacketType.ParcelJoin; } } + /// ParcelData block + public ParcelDataBlock ParcelData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ParcelJoinPacket() - { - Header = new LowHeader(); - Header.ID = 253; - Header.Reliable = true; - ParcelData = new ParcelDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 253; + Header.Reliable = true; + ParcelData = new ParcelDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ParcelJoinPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - ParcelData = new ParcelDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + ParcelData = new ParcelDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ParcelJoinPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - ParcelData = new ParcelDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + ParcelData = new ParcelDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += ParcelData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - ParcelData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += ParcelData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + ParcelData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ParcelJoin ---\n"; - output += ParcelData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- ParcelJoin ---\n"; + output += ParcelData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ParcelDivide packet + + /// ParcelDivide packet public class ParcelDividePacket : Packet - { - /// ParcelData block + { + /// ParcelData block public class ParcelDataBlock - { - /// East field - public float East; - /// West field - public float West; - /// North field - public float North; - /// South field - public float South; - - /// Length of this block serialized in bytes + { + /// East field + public float East; + /// West field + public float West; + /// North field + public float North; + /// South field + public float South; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public ParcelDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ParcelDataBlock() { } + /// Constructor for building the block from a byte array public ParcelDataBlock(byte[] bytes, ref int i) - { + { try - { - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - East = BitConverter.ToSingle(bytes, i); i += 4; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - West = BitConverter.ToSingle(bytes, i); i += 4; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - North = BitConverter.ToSingle(bytes, i); i += 4; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - South = BitConverter.ToSingle(bytes, i); i += 4; + { + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + East = BitConverter.ToSingle(bytes, i); i += 4; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + West = BitConverter.ToSingle(bytes, i); i += 4; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + North = BitConverter.ToSingle(bytes, i); i += 4; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + South = BitConverter.ToSingle(bytes, i); i += 4; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; + { + byte[] ba; ba = BitConverter.GetBytes(East); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; ba = BitConverter.GetBytes(West); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; ba = BitConverter.GetBytes(North); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; ba = BitConverter.GetBytes(South); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ParcelData --\n"; - output += "East: " + East.ToString() + "\n"; - output += "West: " + West.ToString() + "\n"; - output += "North: " + North.ToString() + "\n"; - output += "South: " + South.ToString() + "\n"; + { + string output = "-- ParcelData --\n"; + output += "East: " + East.ToString() + "\n"; + output += "West: " + West.ToString() + "\n"; + output += "North: " + North.ToString() + "\n"; + output += "South: " + South.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ParcelDivide - public override PacketType Type { get { return PacketType.ParcelDivide; } } - /// ParcelData block - public ParcelDataBlock ParcelData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ParcelDivide + public override PacketType Type { get { return PacketType.ParcelDivide; } } + /// ParcelData block + public ParcelDataBlock ParcelData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ParcelDividePacket() - { - Header = new LowHeader(); - Header.ID = 254; - Header.Reliable = true; - ParcelData = new ParcelDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 254; + Header.Reliable = true; + ParcelData = new ParcelDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ParcelDividePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - ParcelData = new ParcelDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + ParcelData = new ParcelDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ParcelDividePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - ParcelData = new ParcelDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + ParcelData = new ParcelDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += ParcelData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - ParcelData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += ParcelData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + ParcelData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ParcelDivide ---\n"; - output += ParcelData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- ParcelDivide ---\n"; + output += ParcelData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ParcelRelease packet + + /// ParcelRelease packet public class ParcelReleasePacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - /// LocalID field - public int LocalID; - - /// Length of this block serialized in bytes + { + /// LocalID field + public int LocalID; + + /// Length of this block serialized in bytes public int Length { get - { - return 4; + { + return 4; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { + { try - { - LocalID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + LocalID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(LocalID % 256); - bytes[i++] = (byte)((LocalID >> 8) % 256); - bytes[i++] = (byte)((LocalID >> 16) % 256); - bytes[i++] = (byte)((LocalID >> 24) % 256); + { + bytes[i++] = (byte)(LocalID % 256); + bytes[i++] = (byte)((LocalID >> 8) % 256); + bytes[i++] = (byte)((LocalID >> 16) % 256); + bytes[i++] = (byte)((LocalID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "LocalID: " + LocalID.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += "LocalID: " + LocalID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ParcelRelease - public override PacketType Type { get { return PacketType.ParcelRelease; } } - /// Data block - public DataBlock Data; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ParcelRelease + public override PacketType Type { get { return PacketType.ParcelRelease; } } + /// Data block + public DataBlock Data; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ParcelReleasePacket() - { - Header = new LowHeader(); - Header.ID = 255; - Header.Reliable = true; - Data = new DataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 255; + Header.Reliable = true; + Data = new DataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ParcelReleasePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ParcelReleasePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Data.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Data.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Data.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Data.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ParcelRelease ---\n"; - output += Data.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- ParcelRelease ---\n"; + output += Data.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ParcelBuy packet + + /// ParcelBuy packet public class ParcelBuyPacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - /// RemoveContribution field - public bool RemoveContribution; - /// LocalID field - public int LocalID; - /// IsGroupOwned field - public bool IsGroupOwned; - /// GroupID field - public LLUUID GroupID; - /// Final field - public bool Final; - - /// Length of this block serialized in bytes + { + /// RemoveContribution field + public bool RemoveContribution; + /// LocalID field + public int LocalID; + /// IsGroupOwned field + public bool IsGroupOwned; + /// GroupID field + public LLUUID GroupID; + /// Final field + public bool Final; + + /// Length of this block serialized in bytes public int Length { get - { - return 23; + { + return 23; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { + { try - { - RemoveContribution = (bytes[i++] != 0) ? (bool)true : (bool)false; - LocalID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - IsGroupOwned = (bytes[i++] != 0) ? (bool)true : (bool)false; - GroupID = new LLUUID(bytes, i); i += 16; - Final = (bytes[i++] != 0) ? (bool)true : (bool)false; + { + RemoveContribution = (bytes[i++] != 0) ? (bool)true : (bool)false; + LocalID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + IsGroupOwned = (bytes[i++] != 0) ? (bool)true : (bool)false; + GroupID = new LLUUID(bytes, i); i += 16; + Final = (bytes[i++] != 0) ? (bool)true : (bool)false; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)((RemoveContribution) ? 1 : 0); - bytes[i++] = (byte)(LocalID % 256); - bytes[i++] = (byte)((LocalID >> 8) % 256); - bytes[i++] = (byte)((LocalID >> 16) % 256); - bytes[i++] = (byte)((LocalID >> 24) % 256); - bytes[i++] = (byte)((IsGroupOwned) ? 1 : 0); - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((Final) ? 1 : 0); + { + bytes[i++] = (byte)((RemoveContribution) ? 1 : 0); + bytes[i++] = (byte)(LocalID % 256); + bytes[i++] = (byte)((LocalID >> 8) % 256); + bytes[i++] = (byte)((LocalID >> 16) % 256); + bytes[i++] = (byte)((LocalID >> 24) % 256); + bytes[i++] = (byte)((IsGroupOwned) ? 1 : 0); + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((Final) ? 1 : 0); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "RemoveContribution: " + RemoveContribution.ToString() + "\n"; - output += "LocalID: " + LocalID.ToString() + "\n"; - output += "IsGroupOwned: " + IsGroupOwned.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; - output += "Final: " + Final.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += "RemoveContribution: " + RemoveContribution.ToString() + "\n"; + output += "LocalID: " + LocalID.ToString() + "\n"; + output += "IsGroupOwned: " + IsGroupOwned.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; + output += "Final: " + Final.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ParcelBuy - public override PacketType Type { get { return PacketType.ParcelBuy; } } - /// Data block - public DataBlock Data; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ParcelBuy + public override PacketType Type { get { return PacketType.ParcelBuy; } } + /// Data block + public DataBlock Data; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ParcelBuyPacket() - { - Header = new LowHeader(); - Header.ID = 256; - Header.Reliable = true; - Header.Zerocoded = true; - Data = new DataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 256; + Header.Reliable = true; + Header.Zerocoded = true; + Data = new DataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ParcelBuyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ParcelBuyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Data.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Data.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Data.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Data.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ParcelBuy ---\n"; - output += Data.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- ParcelBuy ---\n"; + output += Data.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ParcelGodForceOwner packet + + /// ParcelGodForceOwner packet public class ParcelGodForceOwnerPacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - /// LocalID field - public int LocalID; - /// OwnerID field - public LLUUID OwnerID; - - /// Length of this block serialized in bytes + { + /// LocalID field + public int LocalID; + /// OwnerID field + public LLUUID OwnerID; + + /// Length of this block serialized in bytes public int Length { get - { - return 20; + { + return 20; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { + { try - { - LocalID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - OwnerID = new LLUUID(bytes, i); i += 16; + { + LocalID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + OwnerID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(LocalID % 256); - bytes[i++] = (byte)((LocalID >> 8) % 256); - bytes[i++] = (byte)((LocalID >> 16) % 256); - bytes[i++] = (byte)((LocalID >> 24) % 256); - if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } - Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; + { + bytes[i++] = (byte)(LocalID % 256); + bytes[i++] = (byte)((LocalID >> 8) % 256); + bytes[i++] = (byte)((LocalID >> 16) % 256); + bytes[i++] = (byte)((LocalID >> 24) % 256); + if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } + Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "LocalID: " + LocalID.ToString() + "\n"; - output += "OwnerID: " + OwnerID.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += "LocalID: " + LocalID.ToString() + "\n"; + output += "OwnerID: " + OwnerID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ParcelGodForceOwner - public override PacketType Type { get { return PacketType.ParcelGodForceOwner; } } - /// Data block - public DataBlock Data; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ParcelGodForceOwner + public override PacketType Type { get { return PacketType.ParcelGodForceOwner; } } + /// Data block + public DataBlock Data; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ParcelGodForceOwnerPacket() - { - Header = new LowHeader(); - Header.ID = 257; - Header.Reliable = true; - Header.Zerocoded = true; - Data = new DataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 257; + Header.Reliable = true; + Header.Zerocoded = true; + Data = new DataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ParcelGodForceOwnerPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ParcelGodForceOwnerPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Data.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Data.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Data.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Data.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ParcelGodForceOwner ---\n"; - output += Data.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- ParcelGodForceOwner ---\n"; + output += Data.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ParcelAccessListRequest packet + + /// ParcelAccessListRequest packet public class ParcelAccessListRequestPacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - /// LocalID field - public int LocalID; - /// SequenceID field - public int SequenceID; - /// Flags field - public uint Flags; - - /// Length of this block serialized in bytes + { + /// LocalID field + public int LocalID; + /// SequenceID field + public int SequenceID; + /// Flags field + public uint Flags; + + /// Length of this block serialized in bytes public int Length { get - { - return 12; + { + return 12; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { + { try - { - LocalID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - SequenceID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + LocalID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + SequenceID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(LocalID % 256); - bytes[i++] = (byte)((LocalID >> 8) % 256); - bytes[i++] = (byte)((LocalID >> 16) % 256); - bytes[i++] = (byte)((LocalID >> 24) % 256); - bytes[i++] = (byte)(SequenceID % 256); - bytes[i++] = (byte)((SequenceID >> 8) % 256); - bytes[i++] = (byte)((SequenceID >> 16) % 256); - bytes[i++] = (byte)((SequenceID >> 24) % 256); - bytes[i++] = (byte)(Flags % 256); - bytes[i++] = (byte)((Flags >> 8) % 256); - bytes[i++] = (byte)((Flags >> 16) % 256); - bytes[i++] = (byte)((Flags >> 24) % 256); + { + bytes[i++] = (byte)(LocalID % 256); + bytes[i++] = (byte)((LocalID >> 8) % 256); + bytes[i++] = (byte)((LocalID >> 16) % 256); + bytes[i++] = (byte)((LocalID >> 24) % 256); + bytes[i++] = (byte)(SequenceID % 256); + bytes[i++] = (byte)((SequenceID >> 8) % 256); + bytes[i++] = (byte)((SequenceID >> 16) % 256); + bytes[i++] = (byte)((SequenceID >> 24) % 256); + bytes[i++] = (byte)(Flags % 256); + bytes[i++] = (byte)((Flags >> 8) % 256); + bytes[i++] = (byte)((Flags >> 16) % 256); + bytes[i++] = (byte)((Flags >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "LocalID: " + LocalID.ToString() + "\n"; - output += "SequenceID: " + SequenceID.ToString() + "\n"; - output += "Flags: " + Flags.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += "LocalID: " + LocalID.ToString() + "\n"; + output += "SequenceID: " + SequenceID.ToString() + "\n"; + output += "Flags: " + Flags.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ParcelAccessListRequest - public override PacketType Type { get { return PacketType.ParcelAccessListRequest; } } - /// Data block - public DataBlock Data; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ParcelAccessListRequest + public override PacketType Type { get { return PacketType.ParcelAccessListRequest; } } + /// Data block + public DataBlock Data; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ParcelAccessListRequestPacket() - { - Header = new LowHeader(); - Header.ID = 258; - Header.Reliable = true; - Header.Zerocoded = true; - Data = new DataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 258; + Header.Reliable = true; + Header.Zerocoded = true; + Data = new DataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ParcelAccessListRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ParcelAccessListRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Data.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Data.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Data.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Data.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ParcelAccessListRequest ---\n"; - output += Data.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- ParcelAccessListRequest ---\n"; + output += Data.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ParcelAccessListReply packet + + /// ParcelAccessListReply packet public class ParcelAccessListReplyPacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - /// AgentID field - public LLUUID AgentID; - /// LocalID field - public int LocalID; - /// SequenceID field - public int SequenceID; - /// Flags field - public uint Flags; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// LocalID field + public int LocalID; + /// SequenceID field + public int SequenceID; + /// Flags field + public uint Flags; + + /// Length of this block serialized in bytes public int Length { get - { - return 28; + { + return 28; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - LocalID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - SequenceID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + AgentID = new LLUUID(bytes, i); i += 16; + LocalID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + SequenceID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(LocalID % 256); - bytes[i++] = (byte)((LocalID >> 8) % 256); - bytes[i++] = (byte)((LocalID >> 16) % 256); - bytes[i++] = (byte)((LocalID >> 24) % 256); - bytes[i++] = (byte)(SequenceID % 256); - bytes[i++] = (byte)((SequenceID >> 8) % 256); - bytes[i++] = (byte)((SequenceID >> 16) % 256); - bytes[i++] = (byte)((SequenceID >> 24) % 256); - bytes[i++] = (byte)(Flags % 256); - bytes[i++] = (byte)((Flags >> 8) % 256); - bytes[i++] = (byte)((Flags >> 16) % 256); - bytes[i++] = (byte)((Flags >> 24) % 256); + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(LocalID % 256); + bytes[i++] = (byte)((LocalID >> 8) % 256); + bytes[i++] = (byte)((LocalID >> 16) % 256); + bytes[i++] = (byte)((LocalID >> 24) % 256); + bytes[i++] = (byte)(SequenceID % 256); + bytes[i++] = (byte)((SequenceID >> 8) % 256); + bytes[i++] = (byte)((SequenceID >> 16) % 256); + bytes[i++] = (byte)((SequenceID >> 24) % 256); + bytes[i++] = (byte)(Flags % 256); + bytes[i++] = (byte)((Flags >> 8) % 256); + bytes[i++] = (byte)((Flags >> 16) % 256); + bytes[i++] = (byte)((Flags >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "LocalID: " + LocalID.ToString() + "\n"; - output += "SequenceID: " + SequenceID.ToString() + "\n"; - output += "Flags: " + Flags.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "LocalID: " + LocalID.ToString() + "\n"; + output += "SequenceID: " + SequenceID.ToString() + "\n"; + output += "Flags: " + Flags.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// List block + + /// List block public class ListBlock - { - /// ID field - public LLUUID ID; - /// Time field - public int Time; - /// Flags field - public uint Flags; - - /// Length of this block serialized in bytes + { + /// ID field + public LLUUID ID; + /// Time field + public int Time; + /// Flags field + public uint Flags; + + /// Length of this block serialized in bytes public int Length { get - { - return 24; + { + return 24; } } - - /// Default constructor - public ListBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ListBlock() { } + /// Constructor for building the block from a byte array public ListBlock(byte[] bytes, ref int i) - { + { try - { - ID = new LLUUID(bytes, i); i += 16; - Time = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + ID = new LLUUID(bytes, i); i += 16; + Time = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } - Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(Time % 256); - bytes[i++] = (byte)((Time >> 8) % 256); - bytes[i++] = (byte)((Time >> 16) % 256); - bytes[i++] = (byte)((Time >> 24) % 256); - bytes[i++] = (byte)(Flags % 256); - bytes[i++] = (byte)((Flags >> 8) % 256); - bytes[i++] = (byte)((Flags >> 16) % 256); - bytes[i++] = (byte)((Flags >> 24) % 256); + { + if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } + Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(Time % 256); + bytes[i++] = (byte)((Time >> 8) % 256); + bytes[i++] = (byte)((Time >> 16) % 256); + bytes[i++] = (byte)((Time >> 24) % 256); + bytes[i++] = (byte)(Flags % 256); + bytes[i++] = (byte)((Flags >> 8) % 256); + bytes[i++] = (byte)((Flags >> 16) % 256); + bytes[i++] = (byte)((Flags >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- List --\n"; - output += "ID: " + ID.ToString() + "\n"; - output += "Time: " + Time.ToString() + "\n"; - output += "Flags: " + Flags.ToString() + "\n"; + { + string output = "-- List --\n"; + output += "ID: " + ID.ToString() + "\n"; + output += "Time: " + Time.ToString() + "\n"; + output += "Flags: " + Flags.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ParcelAccessListReply - public override PacketType Type { get { return PacketType.ParcelAccessListReply; } } - /// Data block - public DataBlock Data; - /// List block - public ListBlock[] List; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ParcelAccessListReply + public override PacketType Type { get { return PacketType.ParcelAccessListReply; } } + /// Data block + public DataBlock Data; + /// List block + public ListBlock[] List; + + /// Default constructor public ParcelAccessListReplyPacket() - { - Header = new LowHeader(); - Header.ID = 259; - Header.Reliable = true; - Header.Zerocoded = true; - Data = new DataBlock(); - List = new ListBlock[0]; + { + Header = new LowHeader(); + Header.ID = 259; + Header.Reliable = true; + Header.Zerocoded = true; + Data = new DataBlock(); + List = new ListBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ParcelAccessListReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Data = new DataBlock(bytes, ref i); - int count = (int)bytes[i++]; - List = new ListBlock[count]; - for (int j = 0; j < count; j++) - { List[j] = new ListBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Data = new DataBlock(bytes, ref i); + int count = (int)bytes[i++]; + List = new ListBlock[count]; + for (int j = 0; j < count; j++) + { List[j] = new ListBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ParcelAccessListReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Data = new DataBlock(bytes, ref i); - int count = (int)bytes[i++]; - List = new ListBlock[count]; - for (int j = 0; j < count; j++) - { List[j] = new ListBlock(bytes, ref i); } + { + Header = head; + Data = new DataBlock(bytes, ref i); + int count = (int)bytes[i++]; + List = new ListBlock[count]; + for (int j = 0; j < count; j++) + { List[j] = new ListBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Data.Length;; - length++; - for (int j = 0; j < List.Length; j++) { length += List[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Data.ToBytes(bytes, ref i); - bytes[i++] = (byte)List.Length; - for (int j = 0; j < List.Length; j++) { List[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Data.Length;; + length++; + for (int j = 0; j < List.Length; j++) { length += List[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Data.ToBytes(bytes, ref i); + bytes[i++] = (byte)List.Length; + for (int j = 0; j < List.Length; j++) { List[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ParcelAccessListReply ---\n"; - output += Data.ToString() + "\n"; + { + string output = "--- ParcelAccessListReply ---\n"; + output += Data.ToString() + "\n"; for (int j = 0; j < List.Length; j++) - { + { output += List[j].ToString() + "\n"; - } + } return output; } - + } - - /// ParcelAccessListUpdate packet + + /// ParcelAccessListUpdate packet public class ParcelAccessListUpdatePacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - /// LocalID field - public int LocalID; - /// Sections field - public int Sections; - /// SequenceID field - public int SequenceID; - /// Flags field - public uint Flags; - /// TransactionID field - public LLUUID TransactionID; - - /// Length of this block serialized in bytes + { + /// LocalID field + public int LocalID; + /// Sections field + public int Sections; + /// SequenceID field + public int SequenceID; + /// Flags field + public uint Flags; + /// TransactionID field + public LLUUID TransactionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { + { try - { - LocalID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Sections = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - SequenceID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - TransactionID = new LLUUID(bytes, i); i += 16; + { + LocalID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Sections = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + SequenceID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + TransactionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(LocalID % 256); - bytes[i++] = (byte)((LocalID >> 8) % 256); - bytes[i++] = (byte)((LocalID >> 16) % 256); - bytes[i++] = (byte)((LocalID >> 24) % 256); - bytes[i++] = (byte)(Sections % 256); - bytes[i++] = (byte)((Sections >> 8) % 256); - bytes[i++] = (byte)((Sections >> 16) % 256); - bytes[i++] = (byte)((Sections >> 24) % 256); - bytes[i++] = (byte)(SequenceID % 256); - bytes[i++] = (byte)((SequenceID >> 8) % 256); - bytes[i++] = (byte)((SequenceID >> 16) % 256); - bytes[i++] = (byte)((SequenceID >> 24) % 256); - bytes[i++] = (byte)(Flags % 256); - bytes[i++] = (byte)((Flags >> 8) % 256); - bytes[i++] = (byte)((Flags >> 16) % 256); - bytes[i++] = (byte)((Flags >> 24) % 256); - if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } - Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + bytes[i++] = (byte)(LocalID % 256); + bytes[i++] = (byte)((LocalID >> 8) % 256); + bytes[i++] = (byte)((LocalID >> 16) % 256); + bytes[i++] = (byte)((LocalID >> 24) % 256); + bytes[i++] = (byte)(Sections % 256); + bytes[i++] = (byte)((Sections >> 8) % 256); + bytes[i++] = (byte)((Sections >> 16) % 256); + bytes[i++] = (byte)((Sections >> 24) % 256); + bytes[i++] = (byte)(SequenceID % 256); + bytes[i++] = (byte)((SequenceID >> 8) % 256); + bytes[i++] = (byte)((SequenceID >> 16) % 256); + bytes[i++] = (byte)((SequenceID >> 24) % 256); + bytes[i++] = (byte)(Flags % 256); + bytes[i++] = (byte)((Flags >> 8) % 256); + bytes[i++] = (byte)((Flags >> 16) % 256); + bytes[i++] = (byte)((Flags >> 24) % 256); + if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } + Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "LocalID: " + LocalID.ToString() + "\n"; - output += "Sections: " + Sections.ToString() + "\n"; - output += "SequenceID: " + SequenceID.ToString() + "\n"; - output += "Flags: " + Flags.ToString() + "\n"; - output += "TransactionID: " + TransactionID.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += "LocalID: " + LocalID.ToString() + "\n"; + output += "Sections: " + Sections.ToString() + "\n"; + output += "SequenceID: " + SequenceID.ToString() + "\n"; + output += "Flags: " + Flags.ToString() + "\n"; + output += "TransactionID: " + TransactionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// List block + + /// List block public class ListBlock - { - /// ID field - public LLUUID ID; - /// Time field - public int Time; - /// Flags field - public uint Flags; - - /// Length of this block serialized in bytes + { + /// ID field + public LLUUID ID; + /// Time field + public int Time; + /// Flags field + public uint Flags; + + /// Length of this block serialized in bytes public int Length { get - { - return 24; + { + return 24; } } - - /// Default constructor - public ListBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ListBlock() { } + /// Constructor for building the block from a byte array public ListBlock(byte[] bytes, ref int i) - { + { try - { - ID = new LLUUID(bytes, i); i += 16; - Time = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + ID = new LLUUID(bytes, i); i += 16; + Time = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } - Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(Time % 256); - bytes[i++] = (byte)((Time >> 8) % 256); - bytes[i++] = (byte)((Time >> 16) % 256); - bytes[i++] = (byte)((Time >> 24) % 256); - bytes[i++] = (byte)(Flags % 256); - bytes[i++] = (byte)((Flags >> 8) % 256); - bytes[i++] = (byte)((Flags >> 16) % 256); - bytes[i++] = (byte)((Flags >> 24) % 256); + { + if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } + Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(Time % 256); + bytes[i++] = (byte)((Time >> 8) % 256); + bytes[i++] = (byte)((Time >> 16) % 256); + bytes[i++] = (byte)((Time >> 24) % 256); + bytes[i++] = (byte)(Flags % 256); + bytes[i++] = (byte)((Flags >> 8) % 256); + bytes[i++] = (byte)((Flags >> 16) % 256); + bytes[i++] = (byte)((Flags >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- List --\n"; - output += "ID: " + ID.ToString() + "\n"; - output += "Time: " + Time.ToString() + "\n"; - output += "Flags: " + Flags.ToString() + "\n"; + { + string output = "-- List --\n"; + output += "ID: " + ID.ToString() + "\n"; + output += "Time: " + Time.ToString() + "\n"; + output += "Flags: " + Flags.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ParcelAccessListUpdate - public override PacketType Type { get { return PacketType.ParcelAccessListUpdate; } } - /// Data block - public DataBlock Data; - /// List block - public ListBlock[] List; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ParcelAccessListUpdate + public override PacketType Type { get { return PacketType.ParcelAccessListUpdate; } } + /// Data block + public DataBlock Data; + /// List block + public ListBlock[] List; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ParcelAccessListUpdatePacket() - { - Header = new LowHeader(); - Header.ID = 260; - Header.Reliable = true; - Header.Zerocoded = true; - Data = new DataBlock(); - List = new ListBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 260; + Header.Reliable = true; + Header.Zerocoded = true; + Data = new DataBlock(); + List = new ListBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ParcelAccessListUpdatePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Data = new DataBlock(bytes, ref i); - int count = (int)bytes[i++]; - List = new ListBlock[count]; - for (int j = 0; j < count; j++) - { List[j] = new ListBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Data = new DataBlock(bytes, ref i); + int count = (int)bytes[i++]; + List = new ListBlock[count]; + for (int j = 0; j < count; j++) + { List[j] = new ListBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ParcelAccessListUpdatePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Data = new DataBlock(bytes, ref i); - int count = (int)bytes[i++]; - List = new ListBlock[count]; - for (int j = 0; j < count; j++) - { List[j] = new ListBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + Data = new DataBlock(bytes, ref i); + int count = (int)bytes[i++]; + List = new ListBlock[count]; + for (int j = 0; j < count; j++) + { List[j] = new ListBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Data.Length; length += AgentData.Length;; - length++; - for (int j = 0; j < List.Length; j++) { length += List[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Data.ToBytes(bytes, ref i); - bytes[i++] = (byte)List.Length; - for (int j = 0; j < List.Length; j++) { List[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Data.Length; length += AgentData.Length;; + length++; + for (int j = 0; j < List.Length; j++) { length += List[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Data.ToBytes(bytes, ref i); + bytes[i++] = (byte)List.Length; + for (int j = 0; j < List.Length; j++) { List[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ParcelAccessListUpdate ---\n"; - output += Data.ToString() + "\n"; + { + string output = "--- ParcelAccessListUpdate ---\n"; + output += Data.ToString() + "\n"; for (int j = 0; j < List.Length; j++) - { + { output += List[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ParcelDwellRequest packet + + /// ParcelDwellRequest packet public class ParcelDwellRequestPacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - /// LocalID field - public int LocalID; - /// ParcelID field - public LLUUID ParcelID; - - /// Length of this block serialized in bytes + { + /// LocalID field + public int LocalID; + /// ParcelID field + public LLUUID ParcelID; + + /// Length of this block serialized in bytes public int Length { get - { - return 20; + { + return 20; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { + { try - { - LocalID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - ParcelID = new LLUUID(bytes, i); i += 16; + { + LocalID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + ParcelID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(LocalID % 256); - bytes[i++] = (byte)((LocalID >> 8) % 256); - bytes[i++] = (byte)((LocalID >> 16) % 256); - bytes[i++] = (byte)((LocalID >> 24) % 256); - if(ParcelID == null) { Console.WriteLine("Warning: ParcelID is null, in " + this.GetType()); } - Array.Copy(ParcelID.GetBytes(), 0, bytes, i, 16); i += 16; + { + bytes[i++] = (byte)(LocalID % 256); + bytes[i++] = (byte)((LocalID >> 8) % 256); + bytes[i++] = (byte)((LocalID >> 16) % 256); + bytes[i++] = (byte)((LocalID >> 24) % 256); + if(ParcelID == null) { Console.WriteLine("Warning: ParcelID is null, in " + this.GetType()); } + Array.Copy(ParcelID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "LocalID: " + LocalID.ToString() + "\n"; - output += "ParcelID: " + ParcelID.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += "LocalID: " + LocalID.ToString() + "\n"; + output += "ParcelID: " + ParcelID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ParcelDwellRequest - public override PacketType Type { get { return PacketType.ParcelDwellRequest; } } - /// Data block - public DataBlock Data; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ParcelDwellRequest + public override PacketType Type { get { return PacketType.ParcelDwellRequest; } } + /// Data block + public DataBlock Data; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ParcelDwellRequestPacket() - { - Header = new LowHeader(); - Header.ID = 261; - Header.Reliable = true; - Data = new DataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 261; + Header.Reliable = true; + Data = new DataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ParcelDwellRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ParcelDwellRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Data.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Data.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Data.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Data.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ParcelDwellRequest ---\n"; - output += Data.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- ParcelDwellRequest ---\n"; + output += Data.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ParcelDwellReply packet + + /// ParcelDwellReply packet public class ParcelDwellReplyPacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - /// LocalID field - public int LocalID; - /// ParcelID field - public LLUUID ParcelID; - /// Dwell field - public float Dwell; - - /// Length of this block serialized in bytes + { + /// LocalID field + public int LocalID; + /// ParcelID field + public LLUUID ParcelID; + /// Dwell field + public float Dwell; + + /// Length of this block serialized in bytes public int Length { get - { - return 24; + { + return 24; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { + { try - { - LocalID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - ParcelID = new LLUUID(bytes, i); i += 16; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - Dwell = BitConverter.ToSingle(bytes, i); i += 4; + { + LocalID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + ParcelID = new LLUUID(bytes, i); i += 16; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + Dwell = BitConverter.ToSingle(bytes, i); i += 4; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; - bytes[i++] = (byte)(LocalID % 256); - bytes[i++] = (byte)((LocalID >> 8) % 256); - bytes[i++] = (byte)((LocalID >> 16) % 256); - bytes[i++] = (byte)((LocalID >> 24) % 256); - if(ParcelID == null) { Console.WriteLine("Warning: ParcelID is null, in " + this.GetType()); } - Array.Copy(ParcelID.GetBytes(), 0, bytes, i, 16); i += 16; + { + byte[] ba; + bytes[i++] = (byte)(LocalID % 256); + bytes[i++] = (byte)((LocalID >> 8) % 256); + bytes[i++] = (byte)((LocalID >> 16) % 256); + bytes[i++] = (byte)((LocalID >> 24) % 256); + if(ParcelID == null) { Console.WriteLine("Warning: ParcelID is null, in " + this.GetType()); } + Array.Copy(ParcelID.GetBytes(), 0, bytes, i, 16); i += 16; ba = BitConverter.GetBytes(Dwell); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "LocalID: " + LocalID.ToString() + "\n"; - output += "ParcelID: " + ParcelID.ToString() + "\n"; - output += "Dwell: " + Dwell.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += "LocalID: " + LocalID.ToString() + "\n"; + output += "ParcelID: " + ParcelID.ToString() + "\n"; + output += "Dwell: " + Dwell.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ParcelDwellReply - public override PacketType Type { get { return PacketType.ParcelDwellReply; } } - /// Data block - public DataBlock Data; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ParcelDwellReply + public override PacketType Type { get { return PacketType.ParcelDwellReply; } } + /// Data block + public DataBlock Data; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ParcelDwellReplyPacket() - { - Header = new LowHeader(); - Header.ID = 262; - Header.Reliable = true; - Data = new DataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 262; + Header.Reliable = true; + Data = new DataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ParcelDwellReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ParcelDwellReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Data.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Data.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Data.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Data.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ParcelDwellReply ---\n"; - output += Data.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- ParcelDwellReply ---\n"; + output += Data.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// RequestParcelTransfer packet + + /// RequestParcelTransfer packet public class RequestParcelTransferPacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - /// ReservedNewbie field - public bool ReservedNewbie; - /// BillableArea field - public int BillableArea; - /// ActualArea field - public int ActualArea; - /// OwnerID field - public LLUUID OwnerID; - /// DestID field - public LLUUID DestID; - /// Amount field - public int Amount; - /// Flags field - public byte Flags; - /// Final field - public bool Final; - /// SourceID field - public LLUUID SourceID; - /// TransactionID field - public LLUUID TransactionID; - /// TransactionTime field - public uint TransactionTime; - /// TransactionType field - public int TransactionType; - - /// Length of this block serialized in bytes + { + /// ReservedNewbie field + public bool ReservedNewbie; + /// BillableArea field + public int BillableArea; + /// ActualArea field + public int ActualArea; + /// OwnerID field + public LLUUID OwnerID; + /// DestID field + public LLUUID DestID; + /// Amount field + public int Amount; + /// Flags field + public byte Flags; + /// Final field + public bool Final; + /// SourceID field + public LLUUID SourceID; + /// TransactionID field + public LLUUID TransactionID; + /// TransactionTime field + public uint TransactionTime; + /// TransactionType field + public int TransactionType; + + /// Length of this block serialized in bytes public int Length { get - { - return 87; + { + return 87; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { + { try - { - ReservedNewbie = (bytes[i++] != 0) ? (bool)true : (bool)false; - BillableArea = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - ActualArea = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - OwnerID = new LLUUID(bytes, i); i += 16; - DestID = new LLUUID(bytes, i); i += 16; - Amount = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Flags = (byte)bytes[i++]; - Final = (bytes[i++] != 0) ? (bool)true : (bool)false; - SourceID = new LLUUID(bytes, i); i += 16; - TransactionID = new LLUUID(bytes, i); i += 16; - TransactionTime = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - TransactionType = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + ReservedNewbie = (bytes[i++] != 0) ? (bool)true : (bool)false; + BillableArea = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + ActualArea = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + OwnerID = new LLUUID(bytes, i); i += 16; + DestID = new LLUUID(bytes, i); i += 16; + Amount = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Flags = (byte)bytes[i++]; + Final = (bytes[i++] != 0) ? (bool)true : (bool)false; + SourceID = new LLUUID(bytes, i); i += 16; + TransactionID = new LLUUID(bytes, i); i += 16; + TransactionTime = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + TransactionType = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)((ReservedNewbie) ? 1 : 0); - bytes[i++] = (byte)(BillableArea % 256); - bytes[i++] = (byte)((BillableArea >> 8) % 256); - bytes[i++] = (byte)((BillableArea >> 16) % 256); - bytes[i++] = (byte)((BillableArea >> 24) % 256); - bytes[i++] = (byte)(ActualArea % 256); - bytes[i++] = (byte)((ActualArea >> 8) % 256); - bytes[i++] = (byte)((ActualArea >> 16) % 256); - bytes[i++] = (byte)((ActualArea >> 24) % 256); - if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } - Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; - if(DestID == null) { Console.WriteLine("Warning: DestID is null, in " + this.GetType()); } - Array.Copy(DestID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(Amount % 256); - bytes[i++] = (byte)((Amount >> 8) % 256); - bytes[i++] = (byte)((Amount >> 16) % 256); - bytes[i++] = (byte)((Amount >> 24) % 256); - bytes[i++] = Flags; - bytes[i++] = (byte)((Final) ? 1 : 0); - if(SourceID == null) { Console.WriteLine("Warning: SourceID is null, in " + this.GetType()); } - Array.Copy(SourceID.GetBytes(), 0, bytes, i, 16); i += 16; - if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } - Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(TransactionTime % 256); - bytes[i++] = (byte)((TransactionTime >> 8) % 256); - bytes[i++] = (byte)((TransactionTime >> 16) % 256); - bytes[i++] = (byte)((TransactionTime >> 24) % 256); - bytes[i++] = (byte)(TransactionType % 256); - bytes[i++] = (byte)((TransactionType >> 8) % 256); - bytes[i++] = (byte)((TransactionType >> 16) % 256); - bytes[i++] = (byte)((TransactionType >> 24) % 256); + { + bytes[i++] = (byte)((ReservedNewbie) ? 1 : 0); + bytes[i++] = (byte)(BillableArea % 256); + bytes[i++] = (byte)((BillableArea >> 8) % 256); + bytes[i++] = (byte)((BillableArea >> 16) % 256); + bytes[i++] = (byte)((BillableArea >> 24) % 256); + bytes[i++] = (byte)(ActualArea % 256); + bytes[i++] = (byte)((ActualArea >> 8) % 256); + bytes[i++] = (byte)((ActualArea >> 16) % 256); + bytes[i++] = (byte)((ActualArea >> 24) % 256); + if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } + Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; + if(DestID == null) { Console.WriteLine("Warning: DestID is null, in " + this.GetType()); } + Array.Copy(DestID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(Amount % 256); + bytes[i++] = (byte)((Amount >> 8) % 256); + bytes[i++] = (byte)((Amount >> 16) % 256); + bytes[i++] = (byte)((Amount >> 24) % 256); + bytes[i++] = Flags; + bytes[i++] = (byte)((Final) ? 1 : 0); + if(SourceID == null) { Console.WriteLine("Warning: SourceID is null, in " + this.GetType()); } + Array.Copy(SourceID.GetBytes(), 0, bytes, i, 16); i += 16; + if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } + Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(TransactionTime % 256); + bytes[i++] = (byte)((TransactionTime >> 8) % 256); + bytes[i++] = (byte)((TransactionTime >> 16) % 256); + bytes[i++] = (byte)((TransactionTime >> 24) % 256); + bytes[i++] = (byte)(TransactionType % 256); + bytes[i++] = (byte)((TransactionType >> 8) % 256); + bytes[i++] = (byte)((TransactionType >> 16) % 256); + bytes[i++] = (byte)((TransactionType >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "ReservedNewbie: " + ReservedNewbie.ToString() + "\n"; - output += "BillableArea: " + BillableArea.ToString() + "\n"; - output += "ActualArea: " + ActualArea.ToString() + "\n"; - output += "OwnerID: " + OwnerID.ToString() + "\n"; - output += "DestID: " + DestID.ToString() + "\n"; - output += "Amount: " + Amount.ToString() + "\n"; - output += "Flags: " + Flags.ToString() + "\n"; - output += "Final: " + Final.ToString() + "\n"; - output += "SourceID: " + SourceID.ToString() + "\n"; - output += "TransactionID: " + TransactionID.ToString() + "\n"; - output += "TransactionTime: " + TransactionTime.ToString() + "\n"; - output += "TransactionType: " + TransactionType.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += "ReservedNewbie: " + ReservedNewbie.ToString() + "\n"; + output += "BillableArea: " + BillableArea.ToString() + "\n"; + output += "ActualArea: " + ActualArea.ToString() + "\n"; + output += "OwnerID: " + OwnerID.ToString() + "\n"; + output += "DestID: " + DestID.ToString() + "\n"; + output += "Amount: " + Amount.ToString() + "\n"; + output += "Flags: " + Flags.ToString() + "\n"; + output += "Final: " + Final.ToString() + "\n"; + output += "SourceID: " + SourceID.ToString() + "\n"; + output += "TransactionID: " + TransactionID.ToString() + "\n"; + output += "TransactionTime: " + TransactionTime.ToString() + "\n"; + output += "TransactionType: " + TransactionType.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.RequestParcelTransfer - public override PacketType Type { get { return PacketType.RequestParcelTransfer; } } - /// Data block - public DataBlock Data; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.RequestParcelTransfer + public override PacketType Type { get { return PacketType.RequestParcelTransfer; } } + /// Data block + public DataBlock Data; + + /// Default constructor public RequestParcelTransferPacket() - { - Header = new LowHeader(); - Header.ID = 263; - Header.Reliable = true; - Header.Zerocoded = true; - Data = new DataBlock(); + { + Header = new LowHeader(); + Header.ID = 263; + Header.Reliable = true; + Header.Zerocoded = true; + Data = new DataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public RequestParcelTransferPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Data = new DataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Data = new DataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public RequestParcelTransferPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Data = new DataBlock(bytes, ref i); + { + Header = head; + Data = new DataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Data.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Data.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Data.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Data.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- RequestParcelTransfer ---\n"; - output += Data.ToString() + "\n"; + { + string output = "--- RequestParcelTransfer ---\n"; + output += Data.ToString() + "\n"; return output; } - + } - - /// UpdateParcel packet + + /// UpdateParcel packet public class UpdateParcelPacket : Packet - { - /// ParcelData block + { + /// ParcelData block public class ParcelDataBlock - { - /// ReservedNewbie field - public bool ReservedNewbie; - /// GroupOwned field - public bool GroupOwned; - /// RegionX field - public float RegionX; - /// RegionY field - public float RegionY; - /// AllowPublish field - public bool AllowPublish; - /// BillableArea field - public int BillableArea; - /// ShowDir field - public bool ShowDir; - /// ActualArea field - public int ActualArea; - /// ParcelID field - public LLUUID ParcelID; - /// UserLocation field - public LLVector3 UserLocation; - private byte[] _name; - /// Name field + { + /// ReservedNewbie field + public bool ReservedNewbie; + /// GroupOwned field + public bool GroupOwned; + /// RegionX field + public float RegionX; + /// RegionY field + public float RegionY; + /// AllowPublish field + public bool AllowPublish; + /// BillableArea field + public int BillableArea; + /// ShowDir field + public bool ShowDir; + /// ActualArea field + public int ActualArea; + /// ParcelID field + public LLUUID ParcelID; + /// UserLocation field + public LLVector3 UserLocation; + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - /// RegionHandle field - public ulong RegionHandle; - /// Category field - public byte Category; - /// AuthorizedBuyerID field - public LLUUID AuthorizedBuyerID; - /// SalePrice field - public int SalePrice; - /// OwnerID field - public LLUUID OwnerID; - /// IsForSale field - public bool IsForSale; - /// Status field - public byte Status; - /// SnapshotID field - public LLUUID SnapshotID; - /// MaturePublish field - public bool MaturePublish; - private byte[] _description; - /// Description field + } + /// RegionHandle field + public ulong RegionHandle; + /// Category field + public byte Category; + /// AuthorizedBuyerID field + public LLUUID AuthorizedBuyerID; + /// SalePrice field + public int SalePrice; + /// OwnerID field + public LLUUID OwnerID; + /// IsForSale field + public bool IsForSale; + /// Status field + public byte Status; + /// SnapshotID field + public LLUUID SnapshotID; + /// MaturePublish field + public bool MaturePublish; + private byte[] _description; + /// Description field public byte[] Description - { - get { return _description; } + { + get { return _description; } set - { - if (value == null) { _description = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } + { + if (value == null) { _description = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } } - } - private byte[] _musicurl; - /// MusicURL field + } + private byte[] _musicurl; + /// MusicURL field public byte[] MusicURL - { - get { return _musicurl; } + { + get { return _musicurl; } set - { - if (value == null) { _musicurl = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _musicurl = new byte[value.Length]; Array.Copy(value, _musicurl, value.Length); } + { + if (value == null) { _musicurl = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _musicurl = new byte[value.Length]; Array.Copy(value, _musicurl, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 112; - if (Name != null) { length += 1 + Name.Length; } - if (Description != null) { length += 1 + Description.Length; } - if (MusicURL != null) { length += 1 + MusicURL.Length; } - return length; + { + int length = 112; + if (Name != null) { length += 1 + Name.Length; } + if (Description != null) { length += 1 + Description.Length; } + if (MusicURL != null) { length += 1 + MusicURL.Length; } + return length; } } - - /// Default constructor - public ParcelDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ParcelDataBlock() { } + /// Constructor for building the block from a byte array public ParcelDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - ReservedNewbie = (bytes[i++] != 0) ? (bool)true : (bool)false; - GroupOwned = (bytes[i++] != 0) ? (bool)true : (bool)false; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - RegionX = BitConverter.ToSingle(bytes, i); i += 4; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - RegionY = BitConverter.ToSingle(bytes, i); i += 4; - AllowPublish = (bytes[i++] != 0) ? (bool)true : (bool)false; - BillableArea = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - ShowDir = (bytes[i++] != 0) ? (bool)true : (bool)false; - ActualArea = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - ParcelID = new LLUUID(bytes, i); i += 16; - UserLocation = new LLVector3(bytes, i); i += 12; - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; - RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); - Category = (byte)bytes[i++]; - AuthorizedBuyerID = new LLUUID(bytes, i); i += 16; - SalePrice = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - OwnerID = new LLUUID(bytes, i); i += 16; - IsForSale = (bytes[i++] != 0) ? (bool)true : (bool)false; - Status = (byte)bytes[i++]; - SnapshotID = new LLUUID(bytes, i); i += 16; - MaturePublish = (bytes[i++] != 0) ? (bool)true : (bool)false; - length = (ushort)bytes[i++]; - _description = new byte[length]; - Array.Copy(bytes, i, _description, 0, length); i += length; - length = (ushort)bytes[i++]; - _musicurl = new byte[length]; - Array.Copy(bytes, i, _musicurl, 0, length); i += length; + { + ReservedNewbie = (bytes[i++] != 0) ? (bool)true : (bool)false; + GroupOwned = (bytes[i++] != 0) ? (bool)true : (bool)false; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + RegionX = BitConverter.ToSingle(bytes, i); i += 4; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + RegionY = BitConverter.ToSingle(bytes, i); i += 4; + AllowPublish = (bytes[i++] != 0) ? (bool)true : (bool)false; + BillableArea = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + ShowDir = (bytes[i++] != 0) ? (bool)true : (bool)false; + ActualArea = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + ParcelID = new LLUUID(bytes, i); i += 16; + UserLocation = new LLVector3(bytes, i); i += 12; + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; + RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + Category = (byte)bytes[i++]; + AuthorizedBuyerID = new LLUUID(bytes, i); i += 16; + SalePrice = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + OwnerID = new LLUUID(bytes, i); i += 16; + IsForSale = (bytes[i++] != 0) ? (bool)true : (bool)false; + Status = (byte)bytes[i++]; + SnapshotID = new LLUUID(bytes, i); i += 16; + MaturePublish = (bytes[i++] != 0) ? (bool)true : (bool)false; + length = (ushort)bytes[i++]; + _description = new byte[length]; + Array.Copy(bytes, i, _description, 0, length); i += length; + length = (ushort)bytes[i++]; + _musicurl = new byte[length]; + Array.Copy(bytes, i, _musicurl, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; - bytes[i++] = (byte)((ReservedNewbie) ? 1 : 0); - bytes[i++] = (byte)((GroupOwned) ? 1 : 0); + { + byte[] ba; + bytes[i++] = (byte)((ReservedNewbie) ? 1 : 0); + bytes[i++] = (byte)((GroupOwned) ? 1 : 0); ba = BitConverter.GetBytes(RegionX); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; ba = BitConverter.GetBytes(RegionY); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - bytes[i++] = (byte)((AllowPublish) ? 1 : 0); - bytes[i++] = (byte)(BillableArea % 256); - bytes[i++] = (byte)((BillableArea >> 8) % 256); - bytes[i++] = (byte)((BillableArea >> 16) % 256); - bytes[i++] = (byte)((BillableArea >> 24) % 256); - bytes[i++] = (byte)((ShowDir) ? 1 : 0); - bytes[i++] = (byte)(ActualArea % 256); - bytes[i++] = (byte)((ActualArea >> 8) % 256); - bytes[i++] = (byte)((ActualArea >> 16) % 256); - bytes[i++] = (byte)((ActualArea >> 24) % 256); - if(ParcelID == null) { Console.WriteLine("Warning: ParcelID is null, in " + this.GetType()); } - Array.Copy(ParcelID.GetBytes(), 0, bytes, i, 16); i += 16; - if(UserLocation == null) { Console.WriteLine("Warning: UserLocation is null, in " + this.GetType()); } - Array.Copy(UserLocation.GetBytes(), 0, bytes, i, 12); i += 12; - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; - bytes[i++] = (byte)(RegionHandle % 256); - bytes[i++] = (byte)((RegionHandle >> 8) % 256); - bytes[i++] = (byte)((RegionHandle >> 16) % 256); - bytes[i++] = (byte)((RegionHandle >> 24) % 256); - bytes[i++] = (byte)((RegionHandle >> 32) % 256); - bytes[i++] = (byte)((RegionHandle >> 40) % 256); - bytes[i++] = (byte)((RegionHandle >> 48) % 256); - bytes[i++] = (byte)((RegionHandle >> 56) % 256); - bytes[i++] = Category; - if(AuthorizedBuyerID == null) { Console.WriteLine("Warning: AuthorizedBuyerID is null, in " + this.GetType()); } - Array.Copy(AuthorizedBuyerID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(SalePrice % 256); - bytes[i++] = (byte)((SalePrice >> 8) % 256); - bytes[i++] = (byte)((SalePrice >> 16) % 256); - bytes[i++] = (byte)((SalePrice >> 24) % 256); - if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } - Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((IsForSale) ? 1 : 0); - bytes[i++] = Status; - if(SnapshotID == null) { Console.WriteLine("Warning: SnapshotID is null, in " + this.GetType()); } - Array.Copy(SnapshotID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((MaturePublish) ? 1 : 0); - if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } - bytes[i++] = (byte)Description.Length; - Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; - if(MusicURL == null) { Console.WriteLine("Warning: MusicURL is null, in " + this.GetType()); } - bytes[i++] = (byte)MusicURL.Length; - Array.Copy(MusicURL, 0, bytes, i, MusicURL.Length); i += MusicURL.Length; + Array.Copy(ba, 0, bytes, i, 4); i += 4; + bytes[i++] = (byte)((AllowPublish) ? 1 : 0); + bytes[i++] = (byte)(BillableArea % 256); + bytes[i++] = (byte)((BillableArea >> 8) % 256); + bytes[i++] = (byte)((BillableArea >> 16) % 256); + bytes[i++] = (byte)((BillableArea >> 24) % 256); + bytes[i++] = (byte)((ShowDir) ? 1 : 0); + bytes[i++] = (byte)(ActualArea % 256); + bytes[i++] = (byte)((ActualArea >> 8) % 256); + bytes[i++] = (byte)((ActualArea >> 16) % 256); + bytes[i++] = (byte)((ActualArea >> 24) % 256); + if(ParcelID == null) { Console.WriteLine("Warning: ParcelID is null, in " + this.GetType()); } + Array.Copy(ParcelID.GetBytes(), 0, bytes, i, 16); i += 16; + if(UserLocation == null) { Console.WriteLine("Warning: UserLocation is null, in " + this.GetType()); } + Array.Copy(UserLocation.GetBytes(), 0, bytes, i, 12); i += 12; + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + bytes[i++] = (byte)(RegionHandle % 256); + bytes[i++] = (byte)((RegionHandle >> 8) % 256); + bytes[i++] = (byte)((RegionHandle >> 16) % 256); + bytes[i++] = (byte)((RegionHandle >> 24) % 256); + bytes[i++] = (byte)((RegionHandle >> 32) % 256); + bytes[i++] = (byte)((RegionHandle >> 40) % 256); + bytes[i++] = (byte)((RegionHandle >> 48) % 256); + bytes[i++] = (byte)((RegionHandle >> 56) % 256); + bytes[i++] = Category; + if(AuthorizedBuyerID == null) { Console.WriteLine("Warning: AuthorizedBuyerID is null, in " + this.GetType()); } + Array.Copy(AuthorizedBuyerID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(SalePrice % 256); + bytes[i++] = (byte)((SalePrice >> 8) % 256); + bytes[i++] = (byte)((SalePrice >> 16) % 256); + bytes[i++] = (byte)((SalePrice >> 24) % 256); + if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } + Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((IsForSale) ? 1 : 0); + bytes[i++] = Status; + if(SnapshotID == null) { Console.WriteLine("Warning: SnapshotID is null, in " + this.GetType()); } + Array.Copy(SnapshotID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((MaturePublish) ? 1 : 0); + if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } + bytes[i++] = (byte)Description.Length; + Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; + if(MusicURL == null) { Console.WriteLine("Warning: MusicURL is null, in " + this.GetType()); } + bytes[i++] = (byte)MusicURL.Length; + Array.Copy(MusicURL, 0, bytes, i, MusicURL.Length); i += MusicURL.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ParcelData --\n"; - output += "ReservedNewbie: " + ReservedNewbie.ToString() + "\n"; - output += "GroupOwned: " + GroupOwned.ToString() + "\n"; - output += "RegionX: " + RegionX.ToString() + "\n"; - output += "RegionY: " + RegionY.ToString() + "\n"; - output += "AllowPublish: " + AllowPublish.ToString() + "\n"; - output += "BillableArea: " + BillableArea.ToString() + "\n"; - output += "ShowDir: " + ShowDir.ToString() + "\n"; - output += "ActualArea: " + ActualArea.ToString() + "\n"; - output += "ParcelID: " + ParcelID.ToString() + "\n"; - output += "UserLocation: " + UserLocation.ToString() + "\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; - output += "RegionHandle: " + RegionHandle.ToString() + "\n"; - output += "Category: " + Category.ToString() + "\n"; - output += "AuthorizedBuyerID: " + AuthorizedBuyerID.ToString() + "\n"; - output += "SalePrice: " + SalePrice.ToString() + "\n"; - output += "OwnerID: " + OwnerID.ToString() + "\n"; - output += "IsForSale: " + IsForSale.ToString() + "\n"; - output += "Status: " + Status.ToString() + "\n"; - output += "SnapshotID: " + SnapshotID.ToString() + "\n"; - output += "MaturePublish: " + MaturePublish.ToString() + "\n"; - output += Helpers.FieldToString(Description, "Description") + "\n"; - output += Helpers.FieldToString(MusicURL, "MusicURL") + "\n"; + { + string output = "-- ParcelData --\n"; + output += "ReservedNewbie: " + ReservedNewbie.ToString() + "\n"; + output += "GroupOwned: " + GroupOwned.ToString() + "\n"; + output += "RegionX: " + RegionX.ToString() + "\n"; + output += "RegionY: " + RegionY.ToString() + "\n"; + output += "AllowPublish: " + AllowPublish.ToString() + "\n"; + output += "BillableArea: " + BillableArea.ToString() + "\n"; + output += "ShowDir: " + ShowDir.ToString() + "\n"; + output += "ActualArea: " + ActualArea.ToString() + "\n"; + output += "ParcelID: " + ParcelID.ToString() + "\n"; + output += "UserLocation: " + UserLocation.ToString() + "\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; + output += "RegionHandle: " + RegionHandle.ToString() + "\n"; + output += "Category: " + Category.ToString() + "\n"; + output += "AuthorizedBuyerID: " + AuthorizedBuyerID.ToString() + "\n"; + output += "SalePrice: " + SalePrice.ToString() + "\n"; + output += "OwnerID: " + OwnerID.ToString() + "\n"; + output += "IsForSale: " + IsForSale.ToString() + "\n"; + output += "Status: " + Status.ToString() + "\n"; + output += "SnapshotID: " + SnapshotID.ToString() + "\n"; + output += "MaturePublish: " + MaturePublish.ToString() + "\n"; + output += Helpers.FieldToString(Description, "Description") + "\n"; + output += Helpers.FieldToString(MusicURL, "MusicURL") + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.UpdateParcel - public override PacketType Type { get { return PacketType.UpdateParcel; } } - /// ParcelData block - public ParcelDataBlock ParcelData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.UpdateParcel + public override PacketType Type { get { return PacketType.UpdateParcel; } } + /// ParcelData block + public ParcelDataBlock ParcelData; + + /// Default constructor public UpdateParcelPacket() - { - Header = new LowHeader(); - Header.ID = 264; - Header.Reliable = true; - Header.Zerocoded = true; - ParcelData = new ParcelDataBlock(); + { + Header = new LowHeader(); + Header.ID = 264; + Header.Reliable = true; + Header.Zerocoded = true; + ParcelData = new ParcelDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public UpdateParcelPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - ParcelData = new ParcelDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + ParcelData = new ParcelDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public UpdateParcelPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - ParcelData = new ParcelDataBlock(bytes, ref i); + { + Header = head; + ParcelData = new ParcelDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += ParcelData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - ParcelData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += ParcelData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + ParcelData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- UpdateParcel ---\n"; - output += ParcelData.ToString() + "\n"; + { + string output = "--- UpdateParcel ---\n"; + output += ParcelData.ToString() + "\n"; return output; } - + } - - /// RemoveParcel packet + + /// RemoveParcel packet public class RemoveParcelPacket : Packet - { - /// ParcelData block + { + /// ParcelData block public class ParcelDataBlock - { - /// ParcelID field - public LLUUID ParcelID; - - /// Length of this block serialized in bytes + { + /// ParcelID field + public LLUUID ParcelID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public ParcelDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ParcelDataBlock() { } + /// Constructor for building the block from a byte array public ParcelDataBlock(byte[] bytes, ref int i) - { + { try - { - ParcelID = new LLUUID(bytes, i); i += 16; + { + ParcelID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ParcelID == null) { Console.WriteLine("Warning: ParcelID is null, in " + this.GetType()); } - Array.Copy(ParcelID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(ParcelID == null) { Console.WriteLine("Warning: ParcelID is null, in " + this.GetType()); } + Array.Copy(ParcelID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ParcelData --\n"; - output += "ParcelID: " + ParcelID.ToString() + "\n"; + { + string output = "-- ParcelData --\n"; + output += "ParcelID: " + ParcelID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.RemoveParcel - public override PacketType Type { get { return PacketType.RemoveParcel; } } - /// ParcelData block - public ParcelDataBlock[] ParcelData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.RemoveParcel + public override PacketType Type { get { return PacketType.RemoveParcel; } } + /// ParcelData block + public ParcelDataBlock[] ParcelData; + + /// Default constructor public RemoveParcelPacket() - { - Header = new LowHeader(); - Header.ID = 265; - Header.Reliable = true; - ParcelData = new ParcelDataBlock[0]; + { + Header = new LowHeader(); + Header.ID = 265; + Header.Reliable = true; + ParcelData = new ParcelDataBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public RemoveParcelPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ParcelData = new ParcelDataBlock[count]; - for (int j = 0; j < count; j++) - { ParcelData[j] = new ParcelDataBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ParcelData = new ParcelDataBlock[count]; + for (int j = 0; j < count; j++) + { ParcelData[j] = new ParcelDataBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public RemoveParcelPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ParcelData = new ParcelDataBlock[count]; - for (int j = 0; j < count; j++) - { ParcelData[j] = new ParcelDataBlock(bytes, ref i); } + { + Header = head; + int count = (int)bytes[i++]; + ParcelData = new ParcelDataBlock[count]; + for (int j = 0; j < count; j++) + { ParcelData[j] = new ParcelDataBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; -; - length++; - for (int j = 0; j < ParcelData.Length; j++) { length += ParcelData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ParcelData.Length; - for (int j = 0; j < ParcelData.Length; j++) { ParcelData[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; +; + length++; + for (int j = 0; j < ParcelData.Length; j++) { length += ParcelData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ParcelData.Length; + for (int j = 0; j < ParcelData.Length; j++) { ParcelData[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- RemoveParcel ---\n"; + { + string output = "--- RemoveParcel ---\n"; for (int j = 0; j < ParcelData.Length; j++) - { + { output += ParcelData[j].ToString() + "\n"; - } + } return output; } - + } - - /// MergeParcel packet + + /// MergeParcel packet public class MergeParcelPacket : Packet - { - /// MasterParcelData block + { + /// MasterParcelData block public class MasterParcelDataBlock - { - /// MasterID field - public LLUUID MasterID; - - /// Length of this block serialized in bytes + { + /// MasterID field + public LLUUID MasterID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public MasterParcelDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public MasterParcelDataBlock() { } + /// Constructor for building the block from a byte array public MasterParcelDataBlock(byte[] bytes, ref int i) - { + { try - { - MasterID = new LLUUID(bytes, i); i += 16; + { + MasterID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(MasterID == null) { Console.WriteLine("Warning: MasterID is null, in " + this.GetType()); } - Array.Copy(MasterID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(MasterID == null) { Console.WriteLine("Warning: MasterID is null, in " + this.GetType()); } + Array.Copy(MasterID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- MasterParcelData --\n"; - output += "MasterID: " + MasterID.ToString() + "\n"; + { + string output = "-- MasterParcelData --\n"; + output += "MasterID: " + MasterID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// SlaveParcelData block + + /// SlaveParcelData block public class SlaveParcelDataBlock - { - /// SlaveID field - public LLUUID SlaveID; - - /// Length of this block serialized in bytes + { + /// SlaveID field + public LLUUID SlaveID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public SlaveParcelDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public SlaveParcelDataBlock() { } + /// Constructor for building the block from a byte array public SlaveParcelDataBlock(byte[] bytes, ref int i) - { + { try - { - SlaveID = new LLUUID(bytes, i); i += 16; + { + SlaveID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(SlaveID == null) { Console.WriteLine("Warning: SlaveID is null, in " + this.GetType()); } - Array.Copy(SlaveID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(SlaveID == null) { Console.WriteLine("Warning: SlaveID is null, in " + this.GetType()); } + Array.Copy(SlaveID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- SlaveParcelData --\n"; - output += "SlaveID: " + SlaveID.ToString() + "\n"; + { + string output = "-- SlaveParcelData --\n"; + output += "SlaveID: " + SlaveID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.MergeParcel - public override PacketType Type { get { return PacketType.MergeParcel; } } - /// MasterParcelData block - public MasterParcelDataBlock MasterParcelData; - /// SlaveParcelData block - public SlaveParcelDataBlock[] SlaveParcelData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.MergeParcel + public override PacketType Type { get { return PacketType.MergeParcel; } } + /// MasterParcelData block + public MasterParcelDataBlock MasterParcelData; + /// SlaveParcelData block + public SlaveParcelDataBlock[] SlaveParcelData; + + /// Default constructor public MergeParcelPacket() - { - Header = new LowHeader(); - Header.ID = 266; - Header.Reliable = true; - MasterParcelData = new MasterParcelDataBlock(); - SlaveParcelData = new SlaveParcelDataBlock[0]; + { + Header = new LowHeader(); + Header.ID = 266; + Header.Reliable = true; + MasterParcelData = new MasterParcelDataBlock(); + SlaveParcelData = new SlaveParcelDataBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public MergeParcelPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - MasterParcelData = new MasterParcelDataBlock(bytes, ref i); - int count = (int)bytes[i++]; - SlaveParcelData = new SlaveParcelDataBlock[count]; - for (int j = 0; j < count; j++) - { SlaveParcelData[j] = new SlaveParcelDataBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + MasterParcelData = new MasterParcelDataBlock(bytes, ref i); + int count = (int)bytes[i++]; + SlaveParcelData = new SlaveParcelDataBlock[count]; + for (int j = 0; j < count; j++) + { SlaveParcelData[j] = new SlaveParcelDataBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public MergeParcelPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - MasterParcelData = new MasterParcelDataBlock(bytes, ref i); - int count = (int)bytes[i++]; - SlaveParcelData = new SlaveParcelDataBlock[count]; - for (int j = 0; j < count; j++) - { SlaveParcelData[j] = new SlaveParcelDataBlock(bytes, ref i); } + { + Header = head; + MasterParcelData = new MasterParcelDataBlock(bytes, ref i); + int count = (int)bytes[i++]; + SlaveParcelData = new SlaveParcelDataBlock[count]; + for (int j = 0; j < count; j++) + { SlaveParcelData[j] = new SlaveParcelDataBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += MasterParcelData.Length;; - length++; - for (int j = 0; j < SlaveParcelData.Length; j++) { length += SlaveParcelData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - MasterParcelData.ToBytes(bytes, ref i); - bytes[i++] = (byte)SlaveParcelData.Length; - for (int j = 0; j < SlaveParcelData.Length; j++) { SlaveParcelData[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += MasterParcelData.Length;; + length++; + for (int j = 0; j < SlaveParcelData.Length; j++) { length += SlaveParcelData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + MasterParcelData.ToBytes(bytes, ref i); + bytes[i++] = (byte)SlaveParcelData.Length; + for (int j = 0; j < SlaveParcelData.Length; j++) { SlaveParcelData[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- MergeParcel ---\n"; - output += MasterParcelData.ToString() + "\n"; + { + string output = "--- MergeParcel ---\n"; + output += MasterParcelData.ToString() + "\n"; for (int j = 0; j < SlaveParcelData.Length; j++) - { + { output += SlaveParcelData[j].ToString() + "\n"; - } + } return output; } - + } - - /// LogParcelChanges packet + + /// LogParcelChanges packet public class LogParcelChangesPacket : Packet - { - /// ParcelData block + { + /// ParcelData block public class ParcelDataBlock - { - /// ActualArea field - public int ActualArea; - /// ParcelID field - public LLUUID ParcelID; - /// IsOwnerGroup field - public bool IsOwnerGroup; - /// OwnerID field - public LLUUID OwnerID; - /// Action field - public sbyte Action; - /// TransactionID field - public LLUUID TransactionID; - - /// Length of this block serialized in bytes + { + /// ActualArea field + public int ActualArea; + /// ParcelID field + public LLUUID ParcelID; + /// IsOwnerGroup field + public bool IsOwnerGroup; + /// OwnerID field + public LLUUID OwnerID; + /// Action field + public sbyte Action; + /// TransactionID field + public LLUUID TransactionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 54; + { + return 54; } } - - /// Default constructor - public ParcelDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ParcelDataBlock() { } + /// Constructor for building the block from a byte array public ParcelDataBlock(byte[] bytes, ref int i) - { + { try - { - ActualArea = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - ParcelID = new LLUUID(bytes, i); i += 16; - IsOwnerGroup = (bytes[i++] != 0) ? (bool)true : (bool)false; - OwnerID = new LLUUID(bytes, i); i += 16; - Action = (sbyte)bytes[i++]; - TransactionID = new LLUUID(bytes, i); i += 16; + { + ActualArea = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + ParcelID = new LLUUID(bytes, i); i += 16; + IsOwnerGroup = (bytes[i++] != 0) ? (bool)true : (bool)false; + OwnerID = new LLUUID(bytes, i); i += 16; + Action = (sbyte)bytes[i++]; + TransactionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(ActualArea % 256); - bytes[i++] = (byte)((ActualArea >> 8) % 256); - bytes[i++] = (byte)((ActualArea >> 16) % 256); - bytes[i++] = (byte)((ActualArea >> 24) % 256); - if(ParcelID == null) { Console.WriteLine("Warning: ParcelID is null, in " + this.GetType()); } - Array.Copy(ParcelID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((IsOwnerGroup) ? 1 : 0); - if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } - Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)Action; - if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } - Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + bytes[i++] = (byte)(ActualArea % 256); + bytes[i++] = (byte)((ActualArea >> 8) % 256); + bytes[i++] = (byte)((ActualArea >> 16) % 256); + bytes[i++] = (byte)((ActualArea >> 24) % 256); + if(ParcelID == null) { Console.WriteLine("Warning: ParcelID is null, in " + this.GetType()); } + Array.Copy(ParcelID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((IsOwnerGroup) ? 1 : 0); + if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } + Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)Action; + if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } + Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ParcelData --\n"; - output += "ActualArea: " + ActualArea.ToString() + "\n"; - output += "ParcelID: " + ParcelID.ToString() + "\n"; - output += "IsOwnerGroup: " + IsOwnerGroup.ToString() + "\n"; - output += "OwnerID: " + OwnerID.ToString() + "\n"; - output += "Action: " + Action.ToString() + "\n"; - output += "TransactionID: " + TransactionID.ToString() + "\n"; + { + string output = "-- ParcelData --\n"; + output += "ActualArea: " + ActualArea.ToString() + "\n"; + output += "ParcelID: " + ParcelID.ToString() + "\n"; + output += "IsOwnerGroup: " + IsOwnerGroup.ToString() + "\n"; + output += "OwnerID: " + OwnerID.ToString() + "\n"; + output += "Action: " + Action.ToString() + "\n"; + output += "TransactionID: " + TransactionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// RegionData block + + /// RegionData block public class RegionDataBlock - { - /// RegionHandle field - public ulong RegionHandle; - - /// Length of this block serialized in bytes + { + /// RegionHandle field + public ulong RegionHandle; + + /// Length of this block serialized in bytes public int Length { get - { - return 8; + { + return 8; } } - - /// Default constructor - public RegionDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public RegionDataBlock() { } + /// Constructor for building the block from a byte array public RegionDataBlock(byte[] bytes, ref int i) - { + { try - { - RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + { + RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(RegionHandle % 256); - bytes[i++] = (byte)((RegionHandle >> 8) % 256); - bytes[i++] = (byte)((RegionHandle >> 16) % 256); - bytes[i++] = (byte)((RegionHandle >> 24) % 256); - bytes[i++] = (byte)((RegionHandle >> 32) % 256); - bytes[i++] = (byte)((RegionHandle >> 40) % 256); - bytes[i++] = (byte)((RegionHandle >> 48) % 256); - bytes[i++] = (byte)((RegionHandle >> 56) % 256); + { + bytes[i++] = (byte)(RegionHandle % 256); + bytes[i++] = (byte)((RegionHandle >> 8) % 256); + bytes[i++] = (byte)((RegionHandle >> 16) % 256); + bytes[i++] = (byte)((RegionHandle >> 24) % 256); + bytes[i++] = (byte)((RegionHandle >> 32) % 256); + bytes[i++] = (byte)((RegionHandle >> 40) % 256); + bytes[i++] = (byte)((RegionHandle >> 48) % 256); + bytes[i++] = (byte)((RegionHandle >> 56) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- RegionData --\n"; - output += "RegionHandle: " + RegionHandle.ToString() + "\n"; + { + string output = "-- RegionData --\n"; + output += "RegionHandle: " + RegionHandle.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.LogParcelChanges - public override PacketType Type { get { return PacketType.LogParcelChanges; } } - /// ParcelData block - public ParcelDataBlock[] ParcelData; - /// RegionData block - public RegionDataBlock RegionData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.LogParcelChanges + public override PacketType Type { get { return PacketType.LogParcelChanges; } } + /// ParcelData block + public ParcelDataBlock[] ParcelData; + /// RegionData block + public RegionDataBlock RegionData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public LogParcelChangesPacket() - { - Header = new LowHeader(); - Header.ID = 267; - Header.Reliable = true; - Header.Zerocoded = true; - ParcelData = new ParcelDataBlock[0]; - RegionData = new RegionDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 267; + Header.Reliable = true; + Header.Zerocoded = true; + ParcelData = new ParcelDataBlock[0]; + RegionData = new RegionDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public LogParcelChangesPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ParcelData = new ParcelDataBlock[count]; - for (int j = 0; j < count; j++) - { ParcelData[j] = new ParcelDataBlock(bytes, ref i); } - RegionData = new RegionDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ParcelData = new ParcelDataBlock[count]; + for (int j = 0; j < count; j++) + { ParcelData[j] = new ParcelDataBlock(bytes, ref i); } + RegionData = new RegionDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public LogParcelChangesPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ParcelData = new ParcelDataBlock[count]; - for (int j = 0; j < count; j++) - { ParcelData[j] = new ParcelDataBlock(bytes, ref i); } - RegionData = new RegionDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + ParcelData = new ParcelDataBlock[count]; + for (int j = 0; j < count; j++) + { ParcelData[j] = new ParcelDataBlock(bytes, ref i); } + RegionData = new RegionDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += RegionData.Length; length += AgentData.Length;; - length++; - for (int j = 0; j < ParcelData.Length; j++) { length += ParcelData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ParcelData.Length; - for (int j = 0; j < ParcelData.Length; j++) { ParcelData[j].ToBytes(bytes, ref i); } - RegionData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += RegionData.Length; length += AgentData.Length;; + length++; + for (int j = 0; j < ParcelData.Length; j++) { length += ParcelData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ParcelData.Length; + for (int j = 0; j < ParcelData.Length; j++) { ParcelData[j].ToBytes(bytes, ref i); } + RegionData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- LogParcelChanges ---\n"; + { + string output = "--- LogParcelChanges ---\n"; for (int j = 0; j < ParcelData.Length; j++) - { + { output += ParcelData[j].ToString() + "\n"; - } - output += RegionData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + } + output += RegionData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// CheckParcelSales packet + + /// CheckParcelSales packet public class CheckParcelSalesPacket : Packet - { - /// RegionData block + { + /// RegionData block public class RegionDataBlock - { - /// RegionHandle field - public ulong RegionHandle; - - /// Length of this block serialized in bytes + { + /// RegionHandle field + public ulong RegionHandle; + + /// Length of this block serialized in bytes public int Length { get - { - return 8; + { + return 8; } } - - /// Default constructor - public RegionDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public RegionDataBlock() { } + /// Constructor for building the block from a byte array public RegionDataBlock(byte[] bytes, ref int i) - { + { try - { - RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + { + RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(RegionHandle % 256); - bytes[i++] = (byte)((RegionHandle >> 8) % 256); - bytes[i++] = (byte)((RegionHandle >> 16) % 256); - bytes[i++] = (byte)((RegionHandle >> 24) % 256); - bytes[i++] = (byte)((RegionHandle >> 32) % 256); - bytes[i++] = (byte)((RegionHandle >> 40) % 256); - bytes[i++] = (byte)((RegionHandle >> 48) % 256); - bytes[i++] = (byte)((RegionHandle >> 56) % 256); + { + bytes[i++] = (byte)(RegionHandle % 256); + bytes[i++] = (byte)((RegionHandle >> 8) % 256); + bytes[i++] = (byte)((RegionHandle >> 16) % 256); + bytes[i++] = (byte)((RegionHandle >> 24) % 256); + bytes[i++] = (byte)((RegionHandle >> 32) % 256); + bytes[i++] = (byte)((RegionHandle >> 40) % 256); + bytes[i++] = (byte)((RegionHandle >> 48) % 256); + bytes[i++] = (byte)((RegionHandle >> 56) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- RegionData --\n"; - output += "RegionHandle: " + RegionHandle.ToString() + "\n"; + { + string output = "-- RegionData --\n"; + output += "RegionHandle: " + RegionHandle.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.CheckParcelSales - public override PacketType Type { get { return PacketType.CheckParcelSales; } } - /// RegionData block - public RegionDataBlock[] RegionData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.CheckParcelSales + public override PacketType Type { get { return PacketType.CheckParcelSales; } } + /// RegionData block + public RegionDataBlock[] RegionData; + + /// Default constructor public CheckParcelSalesPacket() - { - Header = new LowHeader(); - Header.ID = 268; - Header.Reliable = true; - RegionData = new RegionDataBlock[0]; + { + Header = new LowHeader(); + Header.ID = 268; + Header.Reliable = true; + RegionData = new RegionDataBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public CheckParcelSalesPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - RegionData = new RegionDataBlock[count]; - for (int j = 0; j < count; j++) - { RegionData[j] = new RegionDataBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + RegionData = new RegionDataBlock[count]; + for (int j = 0; j < count; j++) + { RegionData[j] = new RegionDataBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public CheckParcelSalesPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - RegionData = new RegionDataBlock[count]; - for (int j = 0; j < count; j++) - { RegionData[j] = new RegionDataBlock(bytes, ref i); } + { + Header = head; + int count = (int)bytes[i++]; + RegionData = new RegionDataBlock[count]; + for (int j = 0; j < count; j++) + { RegionData[j] = new RegionDataBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; -; - length++; - for (int j = 0; j < RegionData.Length; j++) { length += RegionData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)RegionData.Length; - for (int j = 0; j < RegionData.Length; j++) { RegionData[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; +; + length++; + for (int j = 0; j < RegionData.Length; j++) { length += RegionData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)RegionData.Length; + for (int j = 0; j < RegionData.Length; j++) { RegionData[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- CheckParcelSales ---\n"; + { + string output = "--- CheckParcelSales ---\n"; for (int j = 0; j < RegionData.Length; j++) - { + { output += RegionData[j].ToString() + "\n"; - } + } return output; } - + } - - /// ParcelSales packet + + /// ParcelSales packet public class ParcelSalesPacket : Packet - { - /// ParcelData block + { + /// ParcelData block public class ParcelDataBlock - { - /// ParcelID field - public LLUUID ParcelID; - /// BuyerID field - public LLUUID BuyerID; - - /// Length of this block serialized in bytes + { + /// ParcelID field + public LLUUID ParcelID; + /// BuyerID field + public LLUUID BuyerID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public ParcelDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ParcelDataBlock() { } + /// Constructor for building the block from a byte array public ParcelDataBlock(byte[] bytes, ref int i) - { + { try - { - ParcelID = new LLUUID(bytes, i); i += 16; - BuyerID = new LLUUID(bytes, i); i += 16; + { + ParcelID = new LLUUID(bytes, i); i += 16; + BuyerID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ParcelID == null) { Console.WriteLine("Warning: ParcelID is null, in " + this.GetType()); } - Array.Copy(ParcelID.GetBytes(), 0, bytes, i, 16); i += 16; - if(BuyerID == null) { Console.WriteLine("Warning: BuyerID is null, in " + this.GetType()); } - Array.Copy(BuyerID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(ParcelID == null) { Console.WriteLine("Warning: ParcelID is null, in " + this.GetType()); } + Array.Copy(ParcelID.GetBytes(), 0, bytes, i, 16); i += 16; + if(BuyerID == null) { Console.WriteLine("Warning: BuyerID is null, in " + this.GetType()); } + Array.Copy(BuyerID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ParcelData --\n"; - output += "ParcelID: " + ParcelID.ToString() + "\n"; - output += "BuyerID: " + BuyerID.ToString() + "\n"; + { + string output = "-- ParcelData --\n"; + output += "ParcelID: " + ParcelID.ToString() + "\n"; + output += "BuyerID: " + BuyerID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ParcelSales - public override PacketType Type { get { return PacketType.ParcelSales; } } - /// ParcelData block - public ParcelDataBlock[] ParcelData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ParcelSales + public override PacketType Type { get { return PacketType.ParcelSales; } } + /// ParcelData block + public ParcelDataBlock[] ParcelData; + + /// Default constructor public ParcelSalesPacket() - { - Header = new LowHeader(); - Header.ID = 269; - Header.Reliable = true; - ParcelData = new ParcelDataBlock[0]; + { + Header = new LowHeader(); + Header.ID = 269; + Header.Reliable = true; + ParcelData = new ParcelDataBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ParcelSalesPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ParcelData = new ParcelDataBlock[count]; - for (int j = 0; j < count; j++) - { ParcelData[j] = new ParcelDataBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ParcelData = new ParcelDataBlock[count]; + for (int j = 0; j < count; j++) + { ParcelData[j] = new ParcelDataBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ParcelSalesPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ParcelData = new ParcelDataBlock[count]; - for (int j = 0; j < count; j++) - { ParcelData[j] = new ParcelDataBlock(bytes, ref i); } + { + Header = head; + int count = (int)bytes[i++]; + ParcelData = new ParcelDataBlock[count]; + for (int j = 0; j < count; j++) + { ParcelData[j] = new ParcelDataBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; -; - length++; - for (int j = 0; j < ParcelData.Length; j++) { length += ParcelData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ParcelData.Length; - for (int j = 0; j < ParcelData.Length; j++) { ParcelData[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; +; + length++; + for (int j = 0; j < ParcelData.Length; j++) { length += ParcelData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ParcelData.Length; + for (int j = 0; j < ParcelData.Length; j++) { ParcelData[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ParcelSales ---\n"; + { + string output = "--- ParcelSales ---\n"; for (int j = 0; j < ParcelData.Length; j++) - { + { output += ParcelData[j].ToString() + "\n"; - } + } return output; } - + } - - /// ParcelGodMarkAsContent packet + + /// ParcelGodMarkAsContent packet public class ParcelGodMarkAsContentPacket : Packet - { - /// ParcelData block + { + /// ParcelData block public class ParcelDataBlock - { - /// LocalID field - public int LocalID; - - /// Length of this block serialized in bytes + { + /// LocalID field + public int LocalID; + + /// Length of this block serialized in bytes public int Length { get - { - return 4; + { + return 4; } } - - /// Default constructor - public ParcelDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ParcelDataBlock() { } + /// Constructor for building the block from a byte array public ParcelDataBlock(byte[] bytes, ref int i) - { + { try - { - LocalID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + LocalID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(LocalID % 256); - bytes[i++] = (byte)((LocalID >> 8) % 256); - bytes[i++] = (byte)((LocalID >> 16) % 256); - bytes[i++] = (byte)((LocalID >> 24) % 256); + { + bytes[i++] = (byte)(LocalID % 256); + bytes[i++] = (byte)((LocalID >> 8) % 256); + bytes[i++] = (byte)((LocalID >> 16) % 256); + bytes[i++] = (byte)((LocalID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ParcelData --\n"; - output += "LocalID: " + LocalID.ToString() + "\n"; + { + string output = "-- ParcelData --\n"; + output += "LocalID: " + LocalID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ParcelGodMarkAsContent - public override PacketType Type { get { return PacketType.ParcelGodMarkAsContent; } } - /// ParcelData block - public ParcelDataBlock ParcelData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ParcelGodMarkAsContent + public override PacketType Type { get { return PacketType.ParcelGodMarkAsContent; } } + /// ParcelData block + public ParcelDataBlock ParcelData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ParcelGodMarkAsContentPacket() - { - Header = new LowHeader(); - Header.ID = 270; - Header.Reliable = true; - ParcelData = new ParcelDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 270; + Header.Reliable = true; + ParcelData = new ParcelDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ParcelGodMarkAsContentPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - ParcelData = new ParcelDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + ParcelData = new ParcelDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ParcelGodMarkAsContentPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - ParcelData = new ParcelDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + ParcelData = new ParcelDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += ParcelData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - ParcelData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += ParcelData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + ParcelData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ParcelGodMarkAsContent ---\n"; - output += ParcelData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- ParcelGodMarkAsContent ---\n"; + output += ParcelData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ParcelGodReserveForNewbie packet + + /// ParcelGodReserveForNewbie packet public class ParcelGodReserveForNewbiePacket : Packet - { - /// ParcelData block + { + /// ParcelData block public class ParcelDataBlock - { - /// LocalID field - public int LocalID; - /// SnapshotID field - public LLUUID SnapshotID; - - /// Length of this block serialized in bytes + { + /// LocalID field + public int LocalID; + /// SnapshotID field + public LLUUID SnapshotID; + + /// Length of this block serialized in bytes public int Length { get - { - return 20; + { + return 20; } } - - /// Default constructor - public ParcelDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ParcelDataBlock() { } + /// Constructor for building the block from a byte array public ParcelDataBlock(byte[] bytes, ref int i) - { + { try - { - LocalID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - SnapshotID = new LLUUID(bytes, i); i += 16; + { + LocalID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + SnapshotID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(LocalID % 256); - bytes[i++] = (byte)((LocalID >> 8) % 256); - bytes[i++] = (byte)((LocalID >> 16) % 256); - bytes[i++] = (byte)((LocalID >> 24) % 256); - if(SnapshotID == null) { Console.WriteLine("Warning: SnapshotID is null, in " + this.GetType()); } - Array.Copy(SnapshotID.GetBytes(), 0, bytes, i, 16); i += 16; + { + bytes[i++] = (byte)(LocalID % 256); + bytes[i++] = (byte)((LocalID >> 8) % 256); + bytes[i++] = (byte)((LocalID >> 16) % 256); + bytes[i++] = (byte)((LocalID >> 24) % 256); + if(SnapshotID == null) { Console.WriteLine("Warning: SnapshotID is null, in " + this.GetType()); } + Array.Copy(SnapshotID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ParcelData --\n"; - output += "LocalID: " + LocalID.ToString() + "\n"; - output += "SnapshotID: " + SnapshotID.ToString() + "\n"; + { + string output = "-- ParcelData --\n"; + output += "LocalID: " + LocalID.ToString() + "\n"; + output += "SnapshotID: " + SnapshotID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ParcelGodReserveForNewbie - public override PacketType Type { get { return PacketType.ParcelGodReserveForNewbie; } } - /// ParcelData block - public ParcelDataBlock ParcelData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ParcelGodReserveForNewbie + public override PacketType Type { get { return PacketType.ParcelGodReserveForNewbie; } } + /// ParcelData block + public ParcelDataBlock ParcelData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ParcelGodReserveForNewbiePacket() - { - Header = new LowHeader(); - Header.ID = 271; - Header.Reliable = true; - ParcelData = new ParcelDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 271; + Header.Reliable = true; + ParcelData = new ParcelDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ParcelGodReserveForNewbiePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - ParcelData = new ParcelDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + ParcelData = new ParcelDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ParcelGodReserveForNewbiePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - ParcelData = new ParcelDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + ParcelData = new ParcelDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += ParcelData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - ParcelData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += ParcelData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + ParcelData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ParcelGodReserveForNewbie ---\n"; - output += ParcelData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- ParcelGodReserveForNewbie ---\n"; + output += ParcelData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ViewerStartAuction packet + + /// ViewerStartAuction packet public class ViewerStartAuctionPacket : Packet - { - /// ParcelData block + { + /// ParcelData block public class ParcelDataBlock - { - /// LocalID field - public int LocalID; - /// SnapshotID field - public LLUUID SnapshotID; - - /// Length of this block serialized in bytes + { + /// LocalID field + public int LocalID; + /// SnapshotID field + public LLUUID SnapshotID; + + /// Length of this block serialized in bytes public int Length { get - { - return 20; + { + return 20; } } - - /// Default constructor - public ParcelDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ParcelDataBlock() { } + /// Constructor for building the block from a byte array public ParcelDataBlock(byte[] bytes, ref int i) - { + { try - { - LocalID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - SnapshotID = new LLUUID(bytes, i); i += 16; + { + LocalID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + SnapshotID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(LocalID % 256); - bytes[i++] = (byte)((LocalID >> 8) % 256); - bytes[i++] = (byte)((LocalID >> 16) % 256); - bytes[i++] = (byte)((LocalID >> 24) % 256); - if(SnapshotID == null) { Console.WriteLine("Warning: SnapshotID is null, in " + this.GetType()); } - Array.Copy(SnapshotID.GetBytes(), 0, bytes, i, 16); i += 16; + { + bytes[i++] = (byte)(LocalID % 256); + bytes[i++] = (byte)((LocalID >> 8) % 256); + bytes[i++] = (byte)((LocalID >> 16) % 256); + bytes[i++] = (byte)((LocalID >> 24) % 256); + if(SnapshotID == null) { Console.WriteLine("Warning: SnapshotID is null, in " + this.GetType()); } + Array.Copy(SnapshotID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ParcelData --\n"; - output += "LocalID: " + LocalID.ToString() + "\n"; - output += "SnapshotID: " + SnapshotID.ToString() + "\n"; + { + string output = "-- ParcelData --\n"; + output += "LocalID: " + LocalID.ToString() + "\n"; + output += "SnapshotID: " + SnapshotID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ViewerStartAuction - public override PacketType Type { get { return PacketType.ViewerStartAuction; } } - /// ParcelData block - public ParcelDataBlock ParcelData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ViewerStartAuction + public override PacketType Type { get { return PacketType.ViewerStartAuction; } } + /// ParcelData block + public ParcelDataBlock ParcelData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ViewerStartAuctionPacket() - { - Header = new LowHeader(); - Header.ID = 272; - Header.Reliable = true; - ParcelData = new ParcelDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 272; + Header.Reliable = true; + ParcelData = new ParcelDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ViewerStartAuctionPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - ParcelData = new ParcelDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + ParcelData = new ParcelDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ViewerStartAuctionPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - ParcelData = new ParcelDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + ParcelData = new ParcelDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += ParcelData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - ParcelData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += ParcelData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + ParcelData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ViewerStartAuction ---\n"; - output += ParcelData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- ViewerStartAuction ---\n"; + output += ParcelData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// StartAuction packet + + /// StartAuction packet public class StartAuctionPacket : Packet - { - /// ParcelData block + { + /// ParcelData block public class ParcelDataBlock - { - /// ParcelID field - public LLUUID ParcelID; - private byte[] _name; - /// Name field + { + /// ParcelID field + public LLUUID ParcelID; + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - /// SnapshotID field - public LLUUID SnapshotID; - - /// Length of this block serialized in bytes + } + /// SnapshotID field + public LLUUID SnapshotID; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 32; - if (Name != null) { length += 1 + Name.Length; } - return length; + { + int length = 32; + if (Name != null) { length += 1 + Name.Length; } + return length; } } - - /// Default constructor - public ParcelDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ParcelDataBlock() { } + /// Constructor for building the block from a byte array public ParcelDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - ParcelID = new LLUUID(bytes, i); i += 16; - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; - SnapshotID = new LLUUID(bytes, i); i += 16; + { + ParcelID = new LLUUID(bytes, i); i += 16; + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; + SnapshotID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ParcelID == null) { Console.WriteLine("Warning: ParcelID is null, in " + this.GetType()); } - Array.Copy(ParcelID.GetBytes(), 0, bytes, i, 16); i += 16; - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; - if(SnapshotID == null) { Console.WriteLine("Warning: SnapshotID is null, in " + this.GetType()); } - Array.Copy(SnapshotID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(ParcelID == null) { Console.WriteLine("Warning: ParcelID is null, in " + this.GetType()); } + Array.Copy(ParcelID.GetBytes(), 0, bytes, i, 16); i += 16; + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + if(SnapshotID == null) { Console.WriteLine("Warning: SnapshotID is null, in " + this.GetType()); } + Array.Copy(SnapshotID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ParcelData --\n"; - output += "ParcelID: " + ParcelID.ToString() + "\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; - output += "SnapshotID: " + SnapshotID.ToString() + "\n"; + { + string output = "-- ParcelData --\n"; + output += "ParcelID: " + ParcelID.ToString() + "\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; + output += "SnapshotID: " + SnapshotID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.StartAuction - public override PacketType Type { get { return PacketType.StartAuction; } } - /// ParcelData block - public ParcelDataBlock ParcelData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.StartAuction + public override PacketType Type { get { return PacketType.StartAuction; } } + /// ParcelData block + public ParcelDataBlock ParcelData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public StartAuctionPacket() - { - Header = new LowHeader(); - Header.ID = 273; - Header.Reliable = true; - ParcelData = new ParcelDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 273; + Header.Reliable = true; + ParcelData = new ParcelDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public StartAuctionPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - ParcelData = new ParcelDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + ParcelData = new ParcelDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public StartAuctionPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - ParcelData = new ParcelDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + ParcelData = new ParcelDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += ParcelData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - ParcelData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += ParcelData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + ParcelData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- StartAuction ---\n"; - output += ParcelData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- StartAuction ---\n"; + output += ParcelData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ConfirmAuctionStart packet + + /// ConfirmAuctionStart packet public class ConfirmAuctionStartPacket : Packet - { - /// AuctionData block + { + /// AuctionData block public class AuctionDataBlock - { - /// ParcelID field - public LLUUID ParcelID; - /// AuctionID field - public uint AuctionID; - - /// Length of this block serialized in bytes + { + /// ParcelID field + public LLUUID ParcelID; + /// AuctionID field + public uint AuctionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 20; + { + return 20; } } - - /// Default constructor - public AuctionDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AuctionDataBlock() { } + /// Constructor for building the block from a byte array public AuctionDataBlock(byte[] bytes, ref int i) - { + { try - { - ParcelID = new LLUUID(bytes, i); i += 16; - AuctionID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + ParcelID = new LLUUID(bytes, i); i += 16; + AuctionID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ParcelID == null) { Console.WriteLine("Warning: ParcelID is null, in " + this.GetType()); } - Array.Copy(ParcelID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(AuctionID % 256); - bytes[i++] = (byte)((AuctionID >> 8) % 256); - bytes[i++] = (byte)((AuctionID >> 16) % 256); - bytes[i++] = (byte)((AuctionID >> 24) % 256); + { + if(ParcelID == null) { Console.WriteLine("Warning: ParcelID is null, in " + this.GetType()); } + Array.Copy(ParcelID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(AuctionID % 256); + bytes[i++] = (byte)((AuctionID >> 8) % 256); + bytes[i++] = (byte)((AuctionID >> 16) % 256); + bytes[i++] = (byte)((AuctionID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AuctionData --\n"; - output += "ParcelID: " + ParcelID.ToString() + "\n"; - output += "AuctionID: " + AuctionID.ToString() + "\n"; + { + string output = "-- AuctionData --\n"; + output += "ParcelID: " + ParcelID.ToString() + "\n"; + output += "AuctionID: " + AuctionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ConfirmAuctionStart - public override PacketType Type { get { return PacketType.ConfirmAuctionStart; } } - /// AuctionData block - public AuctionDataBlock AuctionData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ConfirmAuctionStart + public override PacketType Type { get { return PacketType.ConfirmAuctionStart; } } + /// AuctionData block + public AuctionDataBlock AuctionData; + + /// Default constructor public ConfirmAuctionStartPacket() - { - Header = new LowHeader(); - Header.ID = 274; - Header.Reliable = true; - AuctionData = new AuctionDataBlock(); + { + Header = new LowHeader(); + Header.ID = 274; + Header.Reliable = true; + AuctionData = new AuctionDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ConfirmAuctionStartPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AuctionData = new AuctionDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AuctionData = new AuctionDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ConfirmAuctionStartPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AuctionData = new AuctionDataBlock(bytes, ref i); + { + Header = head; + AuctionData = new AuctionDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AuctionData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AuctionData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AuctionData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AuctionData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ConfirmAuctionStart ---\n"; - output += AuctionData.ToString() + "\n"; + { + string output = "--- ConfirmAuctionStart ---\n"; + output += AuctionData.ToString() + "\n"; return output; } - + } - - /// CompleteAuction packet + + /// CompleteAuction packet public class CompleteAuctionPacket : Packet - { - /// ParcelData block + { + /// ParcelData block public class ParcelDataBlock - { - /// ParcelID field - public LLUUID ParcelID; - - /// Length of this block serialized in bytes + { + /// ParcelID field + public LLUUID ParcelID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public ParcelDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ParcelDataBlock() { } + /// Constructor for building the block from a byte array public ParcelDataBlock(byte[] bytes, ref int i) - { + { try - { - ParcelID = new LLUUID(bytes, i); i += 16; + { + ParcelID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ParcelID == null) { Console.WriteLine("Warning: ParcelID is null, in " + this.GetType()); } - Array.Copy(ParcelID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(ParcelID == null) { Console.WriteLine("Warning: ParcelID is null, in " + this.GetType()); } + Array.Copy(ParcelID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ParcelData --\n"; - output += "ParcelID: " + ParcelID.ToString() + "\n"; + { + string output = "-- ParcelData --\n"; + output += "ParcelID: " + ParcelID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.CompleteAuction - public override PacketType Type { get { return PacketType.CompleteAuction; } } - /// ParcelData block - public ParcelDataBlock[] ParcelData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.CompleteAuction + public override PacketType Type { get { return PacketType.CompleteAuction; } } + /// ParcelData block + public ParcelDataBlock[] ParcelData; + + /// Default constructor public CompleteAuctionPacket() - { - Header = new LowHeader(); - Header.ID = 275; - Header.Reliable = true; - ParcelData = new ParcelDataBlock[0]; + { + Header = new LowHeader(); + Header.ID = 275; + Header.Reliable = true; + ParcelData = new ParcelDataBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public CompleteAuctionPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ParcelData = new ParcelDataBlock[count]; - for (int j = 0; j < count; j++) - { ParcelData[j] = new ParcelDataBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ParcelData = new ParcelDataBlock[count]; + for (int j = 0; j < count; j++) + { ParcelData[j] = new ParcelDataBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public CompleteAuctionPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ParcelData = new ParcelDataBlock[count]; - for (int j = 0; j < count; j++) - { ParcelData[j] = new ParcelDataBlock(bytes, ref i); } + { + Header = head; + int count = (int)bytes[i++]; + ParcelData = new ParcelDataBlock[count]; + for (int j = 0; j < count; j++) + { ParcelData[j] = new ParcelDataBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; -; - length++; - for (int j = 0; j < ParcelData.Length; j++) { length += ParcelData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ParcelData.Length; - for (int j = 0; j < ParcelData.Length; j++) { ParcelData[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; +; + length++; + for (int j = 0; j < ParcelData.Length; j++) { length += ParcelData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ParcelData.Length; + for (int j = 0; j < ParcelData.Length; j++) { ParcelData[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- CompleteAuction ---\n"; + { + string output = "--- CompleteAuction ---\n"; for (int j = 0; j < ParcelData.Length; j++) - { + { output += ParcelData[j].ToString() + "\n"; - } + } return output; } - + } - - /// CancelAuction packet + + /// CancelAuction packet public class CancelAuctionPacket : Packet - { - /// ParcelData block + { + /// ParcelData block public class ParcelDataBlock - { - /// ParcelID field - public LLUUID ParcelID; - - /// Length of this block serialized in bytes + { + /// ParcelID field + public LLUUID ParcelID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public ParcelDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ParcelDataBlock() { } + /// Constructor for building the block from a byte array public ParcelDataBlock(byte[] bytes, ref int i) - { + { try - { - ParcelID = new LLUUID(bytes, i); i += 16; + { + ParcelID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ParcelID == null) { Console.WriteLine("Warning: ParcelID is null, in " + this.GetType()); } - Array.Copy(ParcelID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(ParcelID == null) { Console.WriteLine("Warning: ParcelID is null, in " + this.GetType()); } + Array.Copy(ParcelID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ParcelData --\n"; - output += "ParcelID: " + ParcelID.ToString() + "\n"; + { + string output = "-- ParcelData --\n"; + output += "ParcelID: " + ParcelID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.CancelAuction - public override PacketType Type { get { return PacketType.CancelAuction; } } - /// ParcelData block - public ParcelDataBlock[] ParcelData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.CancelAuction + public override PacketType Type { get { return PacketType.CancelAuction; } } + /// ParcelData block + public ParcelDataBlock[] ParcelData; + + /// Default constructor public CancelAuctionPacket() - { - Header = new LowHeader(); - Header.ID = 276; - Header.Reliable = true; - ParcelData = new ParcelDataBlock[0]; + { + Header = new LowHeader(); + Header.ID = 276; + Header.Reliable = true; + ParcelData = new ParcelDataBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public CancelAuctionPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ParcelData = new ParcelDataBlock[count]; - for (int j = 0; j < count; j++) - { ParcelData[j] = new ParcelDataBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ParcelData = new ParcelDataBlock[count]; + for (int j = 0; j < count; j++) + { ParcelData[j] = new ParcelDataBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public CancelAuctionPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ParcelData = new ParcelDataBlock[count]; - for (int j = 0; j < count; j++) - { ParcelData[j] = new ParcelDataBlock(bytes, ref i); } + { + Header = head; + int count = (int)bytes[i++]; + ParcelData = new ParcelDataBlock[count]; + for (int j = 0; j < count; j++) + { ParcelData[j] = new ParcelDataBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; -; - length++; - for (int j = 0; j < ParcelData.Length; j++) { length += ParcelData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ParcelData.Length; - for (int j = 0; j < ParcelData.Length; j++) { ParcelData[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; +; + length++; + for (int j = 0; j < ParcelData.Length; j++) { length += ParcelData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ParcelData.Length; + for (int j = 0; j < ParcelData.Length; j++) { ParcelData[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- CancelAuction ---\n"; + { + string output = "--- CancelAuction ---\n"; for (int j = 0; j < ParcelData.Length; j++) - { + { output += ParcelData[j].ToString() + "\n"; - } + } return output; } - + } - - /// CheckParcelAuctions packet + + /// CheckParcelAuctions packet public class CheckParcelAuctionsPacket : Packet - { - /// RegionData block + { + /// RegionData block public class RegionDataBlock - { - /// RegionHandle field - public ulong RegionHandle; - - /// Length of this block serialized in bytes + { + /// RegionHandle field + public ulong RegionHandle; + + /// Length of this block serialized in bytes public int Length { get - { - return 8; + { + return 8; } } - - /// Default constructor - public RegionDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public RegionDataBlock() { } + /// Constructor for building the block from a byte array public RegionDataBlock(byte[] bytes, ref int i) - { + { try - { - RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + { + RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(RegionHandle % 256); - bytes[i++] = (byte)((RegionHandle >> 8) % 256); - bytes[i++] = (byte)((RegionHandle >> 16) % 256); - bytes[i++] = (byte)((RegionHandle >> 24) % 256); - bytes[i++] = (byte)((RegionHandle >> 32) % 256); - bytes[i++] = (byte)((RegionHandle >> 40) % 256); - bytes[i++] = (byte)((RegionHandle >> 48) % 256); - bytes[i++] = (byte)((RegionHandle >> 56) % 256); + { + bytes[i++] = (byte)(RegionHandle % 256); + bytes[i++] = (byte)((RegionHandle >> 8) % 256); + bytes[i++] = (byte)((RegionHandle >> 16) % 256); + bytes[i++] = (byte)((RegionHandle >> 24) % 256); + bytes[i++] = (byte)((RegionHandle >> 32) % 256); + bytes[i++] = (byte)((RegionHandle >> 40) % 256); + bytes[i++] = (byte)((RegionHandle >> 48) % 256); + bytes[i++] = (byte)((RegionHandle >> 56) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- RegionData --\n"; - output += "RegionHandle: " + RegionHandle.ToString() + "\n"; + { + string output = "-- RegionData --\n"; + output += "RegionHandle: " + RegionHandle.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.CheckParcelAuctions - public override PacketType Type { get { return PacketType.CheckParcelAuctions; } } - /// RegionData block - public RegionDataBlock[] RegionData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.CheckParcelAuctions + public override PacketType Type { get { return PacketType.CheckParcelAuctions; } } + /// RegionData block + public RegionDataBlock[] RegionData; + + /// Default constructor public CheckParcelAuctionsPacket() - { - Header = new LowHeader(); - Header.ID = 277; - Header.Reliable = true; - RegionData = new RegionDataBlock[0]; + { + Header = new LowHeader(); + Header.ID = 277; + Header.Reliable = true; + RegionData = new RegionDataBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public CheckParcelAuctionsPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - RegionData = new RegionDataBlock[count]; - for (int j = 0; j < count; j++) - { RegionData[j] = new RegionDataBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + RegionData = new RegionDataBlock[count]; + for (int j = 0; j < count; j++) + { RegionData[j] = new RegionDataBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public CheckParcelAuctionsPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - RegionData = new RegionDataBlock[count]; - for (int j = 0; j < count; j++) - { RegionData[j] = new RegionDataBlock(bytes, ref i); } + { + Header = head; + int count = (int)bytes[i++]; + RegionData = new RegionDataBlock[count]; + for (int j = 0; j < count; j++) + { RegionData[j] = new RegionDataBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; -; - length++; - for (int j = 0; j < RegionData.Length; j++) { length += RegionData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)RegionData.Length; - for (int j = 0; j < RegionData.Length; j++) { RegionData[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; +; + length++; + for (int j = 0; j < RegionData.Length; j++) { length += RegionData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)RegionData.Length; + for (int j = 0; j < RegionData.Length; j++) { RegionData[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- CheckParcelAuctions ---\n"; + { + string output = "--- CheckParcelAuctions ---\n"; for (int j = 0; j < RegionData.Length; j++) - { + { output += RegionData[j].ToString() + "\n"; - } + } return output; } - + } - - /// ParcelAuctions packet + + /// ParcelAuctions packet public class ParcelAuctionsPacket : Packet - { - /// ParcelData block + { + /// ParcelData block public class ParcelDataBlock - { - /// ParcelID field - public LLUUID ParcelID; - /// WinnerID field - public LLUUID WinnerID; - - /// Length of this block serialized in bytes + { + /// ParcelID field + public LLUUID ParcelID; + /// WinnerID field + public LLUUID WinnerID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public ParcelDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ParcelDataBlock() { } + /// Constructor for building the block from a byte array public ParcelDataBlock(byte[] bytes, ref int i) - { + { try - { - ParcelID = new LLUUID(bytes, i); i += 16; - WinnerID = new LLUUID(bytes, i); i += 16; + { + ParcelID = new LLUUID(bytes, i); i += 16; + WinnerID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ParcelID == null) { Console.WriteLine("Warning: ParcelID is null, in " + this.GetType()); } - Array.Copy(ParcelID.GetBytes(), 0, bytes, i, 16); i += 16; - if(WinnerID == null) { Console.WriteLine("Warning: WinnerID is null, in " + this.GetType()); } - Array.Copy(WinnerID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(ParcelID == null) { Console.WriteLine("Warning: ParcelID is null, in " + this.GetType()); } + Array.Copy(ParcelID.GetBytes(), 0, bytes, i, 16); i += 16; + if(WinnerID == null) { Console.WriteLine("Warning: WinnerID is null, in " + this.GetType()); } + Array.Copy(WinnerID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ParcelData --\n"; - output += "ParcelID: " + ParcelID.ToString() + "\n"; - output += "WinnerID: " + WinnerID.ToString() + "\n"; + { + string output = "-- ParcelData --\n"; + output += "ParcelID: " + ParcelID.ToString() + "\n"; + output += "WinnerID: " + WinnerID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ParcelAuctions - public override PacketType Type { get { return PacketType.ParcelAuctions; } } - /// ParcelData block - public ParcelDataBlock[] ParcelData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ParcelAuctions + public override PacketType Type { get { return PacketType.ParcelAuctions; } } + /// ParcelData block + public ParcelDataBlock[] ParcelData; + + /// Default constructor public ParcelAuctionsPacket() - { - Header = new LowHeader(); - Header.ID = 278; - Header.Reliable = true; - ParcelData = new ParcelDataBlock[0]; + { + Header = new LowHeader(); + Header.ID = 278; + Header.Reliable = true; + ParcelData = new ParcelDataBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ParcelAuctionsPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ParcelData = new ParcelDataBlock[count]; - for (int j = 0; j < count; j++) - { ParcelData[j] = new ParcelDataBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ParcelData = new ParcelDataBlock[count]; + for (int j = 0; j < count; j++) + { ParcelData[j] = new ParcelDataBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ParcelAuctionsPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ParcelData = new ParcelDataBlock[count]; - for (int j = 0; j < count; j++) - { ParcelData[j] = new ParcelDataBlock(bytes, ref i); } + { + Header = head; + int count = (int)bytes[i++]; + ParcelData = new ParcelDataBlock[count]; + for (int j = 0; j < count; j++) + { ParcelData[j] = new ParcelDataBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; -; - length++; - for (int j = 0; j < ParcelData.Length; j++) { length += ParcelData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ParcelData.Length; - for (int j = 0; j < ParcelData.Length; j++) { ParcelData[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; +; + length++; + for (int j = 0; j < ParcelData.Length; j++) { length += ParcelData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ParcelData.Length; + for (int j = 0; j < ParcelData.Length; j++) { ParcelData[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ParcelAuctions ---\n"; + { + string output = "--- ParcelAuctions ---\n"; for (int j = 0; j < ParcelData.Length; j++) - { + { output += ParcelData[j].ToString() + "\n"; - } + } return output; } - + } - - /// UUIDNameRequest packet + + /// UUIDNameRequest packet public class UUIDNameRequestPacket : Packet - { - /// UUIDNameBlock block + { + /// UUIDNameBlock block public class UUIDNameBlockBlock - { - /// ID field - public LLUUID ID; - - /// Length of this block serialized in bytes + { + /// ID field + public LLUUID ID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public UUIDNameBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public UUIDNameBlockBlock() { } + /// Constructor for building the block from a byte array public UUIDNameBlockBlock(byte[] bytes, ref int i) - { + { try - { - ID = new LLUUID(bytes, i); i += 16; + { + ID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } - Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } + Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- UUIDNameBlock --\n"; - output += "ID: " + ID.ToString() + "\n"; + { + string output = "-- UUIDNameBlock --\n"; + output += "ID: " + ID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.UUIDNameRequest - public override PacketType Type { get { return PacketType.UUIDNameRequest; } } - /// UUIDNameBlock block - public UUIDNameBlockBlock[] UUIDNameBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.UUIDNameRequest + public override PacketType Type { get { return PacketType.UUIDNameRequest; } } + /// UUIDNameBlock block + public UUIDNameBlockBlock[] UUIDNameBlock; + + /// Default constructor public UUIDNameRequestPacket() - { - Header = new LowHeader(); - Header.ID = 279; - Header.Reliable = true; - UUIDNameBlock = new UUIDNameBlockBlock[0]; + { + Header = new LowHeader(); + Header.ID = 279; + Header.Reliable = true; + UUIDNameBlock = new UUIDNameBlockBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public UUIDNameRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - UUIDNameBlock = new UUIDNameBlockBlock[count]; - for (int j = 0; j < count; j++) - { UUIDNameBlock[j] = new UUIDNameBlockBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + UUIDNameBlock = new UUIDNameBlockBlock[count]; + for (int j = 0; j < count; j++) + { UUIDNameBlock[j] = new UUIDNameBlockBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public UUIDNameRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - UUIDNameBlock = new UUIDNameBlockBlock[count]; - for (int j = 0; j < count; j++) - { UUIDNameBlock[j] = new UUIDNameBlockBlock(bytes, ref i); } + { + Header = head; + int count = (int)bytes[i++]; + UUIDNameBlock = new UUIDNameBlockBlock[count]; + for (int j = 0; j < count; j++) + { UUIDNameBlock[j] = new UUIDNameBlockBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; -; - length++; - for (int j = 0; j < UUIDNameBlock.Length; j++) { length += UUIDNameBlock[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)UUIDNameBlock.Length; - for (int j = 0; j < UUIDNameBlock.Length; j++) { UUIDNameBlock[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; +; + length++; + for (int j = 0; j < UUIDNameBlock.Length; j++) { length += UUIDNameBlock[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)UUIDNameBlock.Length; + for (int j = 0; j < UUIDNameBlock.Length; j++) { UUIDNameBlock[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- UUIDNameRequest ---\n"; + { + string output = "--- UUIDNameRequest ---\n"; for (int j = 0; j < UUIDNameBlock.Length; j++) - { + { output += UUIDNameBlock[j].ToString() + "\n"; - } + } return output; } - + } - - /// UUIDNameReply packet + + /// UUIDNameReply packet public class UUIDNameReplyPacket : Packet - { - /// UUIDNameBlock block + { + /// UUIDNameBlock block public class UUIDNameBlockBlock - { - /// ID field - public LLUUID ID; - private byte[] _lastname; - /// LastName field + { + /// ID field + public LLUUID ID; + private byte[] _lastname; + /// LastName field public byte[] LastName - { - get { return _lastname; } + { + get { return _lastname; } set - { - if (value == null) { _lastname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _lastname = new byte[value.Length]; Array.Copy(value, _lastname, value.Length); } + { + if (value == null) { _lastname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _lastname = new byte[value.Length]; Array.Copy(value, _lastname, value.Length); } } - } - private byte[] _firstname; - /// FirstName field + } + private byte[] _firstname; + /// FirstName field public byte[] FirstName - { - get { return _firstname; } + { + get { return _firstname; } set - { - if (value == null) { _firstname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _firstname = new byte[value.Length]; Array.Copy(value, _firstname, value.Length); } + { + if (value == null) { _firstname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _firstname = new byte[value.Length]; Array.Copy(value, _firstname, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 16; - if (LastName != null) { length += 1 + LastName.Length; } - if (FirstName != null) { length += 1 + FirstName.Length; } - return length; + { + int length = 16; + if (LastName != null) { length += 1 + LastName.Length; } + if (FirstName != null) { length += 1 + FirstName.Length; } + return length; } } - - /// Default constructor - public UUIDNameBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public UUIDNameBlockBlock() { } + /// Constructor for building the block from a byte array public UUIDNameBlockBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - ID = new LLUUID(bytes, i); i += 16; - length = (ushort)bytes[i++]; - _lastname = new byte[length]; - Array.Copy(bytes, i, _lastname, 0, length); i += length; - length = (ushort)bytes[i++]; - _firstname = new byte[length]; - Array.Copy(bytes, i, _firstname, 0, length); i += length; + { + ID = new LLUUID(bytes, i); i += 16; + length = (ushort)bytes[i++]; + _lastname = new byte[length]; + Array.Copy(bytes, i, _lastname, 0, length); i += length; + length = (ushort)bytes[i++]; + _firstname = new byte[length]; + Array.Copy(bytes, i, _firstname, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } - Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; - if(LastName == null) { Console.WriteLine("Warning: LastName is null, in " + this.GetType()); } - bytes[i++] = (byte)LastName.Length; - Array.Copy(LastName, 0, bytes, i, LastName.Length); i += LastName.Length; - if(FirstName == null) { Console.WriteLine("Warning: FirstName is null, in " + this.GetType()); } - bytes[i++] = (byte)FirstName.Length; - Array.Copy(FirstName, 0, bytes, i, FirstName.Length); i += FirstName.Length; + { + if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } + Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; + if(LastName == null) { Console.WriteLine("Warning: LastName is null, in " + this.GetType()); } + bytes[i++] = (byte)LastName.Length; + Array.Copy(LastName, 0, bytes, i, LastName.Length); i += LastName.Length; + if(FirstName == null) { Console.WriteLine("Warning: FirstName is null, in " + this.GetType()); } + bytes[i++] = (byte)FirstName.Length; + Array.Copy(FirstName, 0, bytes, i, FirstName.Length); i += FirstName.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- UUIDNameBlock --\n"; - output += "ID: " + ID.ToString() + "\n"; - output += Helpers.FieldToString(LastName, "LastName") + "\n"; - output += Helpers.FieldToString(FirstName, "FirstName") + "\n"; + { + string output = "-- UUIDNameBlock --\n"; + output += "ID: " + ID.ToString() + "\n"; + output += Helpers.FieldToString(LastName, "LastName") + "\n"; + output += Helpers.FieldToString(FirstName, "FirstName") + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.UUIDNameReply - public override PacketType Type { get { return PacketType.UUIDNameReply; } } - /// UUIDNameBlock block - public UUIDNameBlockBlock[] UUIDNameBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.UUIDNameReply + public override PacketType Type { get { return PacketType.UUIDNameReply; } } + /// UUIDNameBlock block + public UUIDNameBlockBlock[] UUIDNameBlock; + + /// Default constructor public UUIDNameReplyPacket() - { - Header = new LowHeader(); - Header.ID = 280; - Header.Reliable = true; - UUIDNameBlock = new UUIDNameBlockBlock[0]; + { + Header = new LowHeader(); + Header.ID = 280; + Header.Reliable = true; + UUIDNameBlock = new UUIDNameBlockBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public UUIDNameReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - UUIDNameBlock = new UUIDNameBlockBlock[count]; - for (int j = 0; j < count; j++) - { UUIDNameBlock[j] = new UUIDNameBlockBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + UUIDNameBlock = new UUIDNameBlockBlock[count]; + for (int j = 0; j < count; j++) + { UUIDNameBlock[j] = new UUIDNameBlockBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public UUIDNameReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - UUIDNameBlock = new UUIDNameBlockBlock[count]; - for (int j = 0; j < count; j++) - { UUIDNameBlock[j] = new UUIDNameBlockBlock(bytes, ref i); } + { + Header = head; + int count = (int)bytes[i++]; + UUIDNameBlock = new UUIDNameBlockBlock[count]; + for (int j = 0; j < count; j++) + { UUIDNameBlock[j] = new UUIDNameBlockBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; -; - length++; - for (int j = 0; j < UUIDNameBlock.Length; j++) { length += UUIDNameBlock[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)UUIDNameBlock.Length; - for (int j = 0; j < UUIDNameBlock.Length; j++) { UUIDNameBlock[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; +; + length++; + for (int j = 0; j < UUIDNameBlock.Length; j++) { length += UUIDNameBlock[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)UUIDNameBlock.Length; + for (int j = 0; j < UUIDNameBlock.Length; j++) { UUIDNameBlock[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- UUIDNameReply ---\n"; + { + string output = "--- UUIDNameReply ---\n"; for (int j = 0; j < UUIDNameBlock.Length; j++) - { + { output += UUIDNameBlock[j].ToString() + "\n"; - } + } return output; } - + } - - /// UUIDGroupNameRequest packet + + /// UUIDGroupNameRequest packet public class UUIDGroupNameRequestPacket : Packet - { - /// UUIDNameBlock block + { + /// UUIDNameBlock block public class UUIDNameBlockBlock - { - /// ID field - public LLUUID ID; - - /// Length of this block serialized in bytes + { + /// ID field + public LLUUID ID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public UUIDNameBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public UUIDNameBlockBlock() { } + /// Constructor for building the block from a byte array public UUIDNameBlockBlock(byte[] bytes, ref int i) - { + { try - { - ID = new LLUUID(bytes, i); i += 16; + { + ID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } - Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } + Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- UUIDNameBlock --\n"; - output += "ID: " + ID.ToString() + "\n"; + { + string output = "-- UUIDNameBlock --\n"; + output += "ID: " + ID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.UUIDGroupNameRequest - public override PacketType Type { get { return PacketType.UUIDGroupNameRequest; } } - /// UUIDNameBlock block - public UUIDNameBlockBlock[] UUIDNameBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.UUIDGroupNameRequest + public override PacketType Type { get { return PacketType.UUIDGroupNameRequest; } } + /// UUIDNameBlock block + public UUIDNameBlockBlock[] UUIDNameBlock; + + /// Default constructor public UUIDGroupNameRequestPacket() - { - Header = new LowHeader(); - Header.ID = 281; - Header.Reliable = true; - UUIDNameBlock = new UUIDNameBlockBlock[0]; + { + Header = new LowHeader(); + Header.ID = 281; + Header.Reliable = true; + UUIDNameBlock = new UUIDNameBlockBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public UUIDGroupNameRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - UUIDNameBlock = new UUIDNameBlockBlock[count]; - for (int j = 0; j < count; j++) - { UUIDNameBlock[j] = new UUIDNameBlockBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + UUIDNameBlock = new UUIDNameBlockBlock[count]; + for (int j = 0; j < count; j++) + { UUIDNameBlock[j] = new UUIDNameBlockBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public UUIDGroupNameRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - UUIDNameBlock = new UUIDNameBlockBlock[count]; - for (int j = 0; j < count; j++) - { UUIDNameBlock[j] = new UUIDNameBlockBlock(bytes, ref i); } + { + Header = head; + int count = (int)bytes[i++]; + UUIDNameBlock = new UUIDNameBlockBlock[count]; + for (int j = 0; j < count; j++) + { UUIDNameBlock[j] = new UUIDNameBlockBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; -; - length++; - for (int j = 0; j < UUIDNameBlock.Length; j++) { length += UUIDNameBlock[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)UUIDNameBlock.Length; - for (int j = 0; j < UUIDNameBlock.Length; j++) { UUIDNameBlock[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; +; + length++; + for (int j = 0; j < UUIDNameBlock.Length; j++) { length += UUIDNameBlock[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)UUIDNameBlock.Length; + for (int j = 0; j < UUIDNameBlock.Length; j++) { UUIDNameBlock[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- UUIDGroupNameRequest ---\n"; + { + string output = "--- UUIDGroupNameRequest ---\n"; for (int j = 0; j < UUIDNameBlock.Length; j++) - { + { output += UUIDNameBlock[j].ToString() + "\n"; - } + } return output; } - + } - - /// UUIDGroupNameReply packet + + /// UUIDGroupNameReply packet public class UUIDGroupNameReplyPacket : Packet - { - /// UUIDNameBlock block + { + /// UUIDNameBlock block public class UUIDNameBlockBlock - { - /// ID field - public LLUUID ID; - private byte[] _groupname; - /// GroupName field + { + /// ID field + public LLUUID ID; + private byte[] _groupname; + /// GroupName field public byte[] GroupName - { - get { return _groupname; } + { + get { return _groupname; } set - { - if (value == null) { _groupname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _groupname = new byte[value.Length]; Array.Copy(value, _groupname, value.Length); } + { + if (value == null) { _groupname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _groupname = new byte[value.Length]; Array.Copy(value, _groupname, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 16; - if (GroupName != null) { length += 1 + GroupName.Length; } - return length; + { + int length = 16; + if (GroupName != null) { length += 1 + GroupName.Length; } + return length; } } - - /// Default constructor - public UUIDNameBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public UUIDNameBlockBlock() { } + /// Constructor for building the block from a byte array public UUIDNameBlockBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - ID = new LLUUID(bytes, i); i += 16; - length = (ushort)bytes[i++]; - _groupname = new byte[length]; - Array.Copy(bytes, i, _groupname, 0, length); i += length; + { + ID = new LLUUID(bytes, i); i += 16; + length = (ushort)bytes[i++]; + _groupname = new byte[length]; + Array.Copy(bytes, i, _groupname, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } - Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; - if(GroupName == null) { Console.WriteLine("Warning: GroupName is null, in " + this.GetType()); } - bytes[i++] = (byte)GroupName.Length; - Array.Copy(GroupName, 0, bytes, i, GroupName.Length); i += GroupName.Length; + { + if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } + Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; + if(GroupName == null) { Console.WriteLine("Warning: GroupName is null, in " + this.GetType()); } + bytes[i++] = (byte)GroupName.Length; + Array.Copy(GroupName, 0, bytes, i, GroupName.Length); i += GroupName.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- UUIDNameBlock --\n"; - output += "ID: " + ID.ToString() + "\n"; - output += Helpers.FieldToString(GroupName, "GroupName") + "\n"; + { + string output = "-- UUIDNameBlock --\n"; + output += "ID: " + ID.ToString() + "\n"; + output += Helpers.FieldToString(GroupName, "GroupName") + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.UUIDGroupNameReply - public override PacketType Type { get { return PacketType.UUIDGroupNameReply; } } - /// UUIDNameBlock block - public UUIDNameBlockBlock[] UUIDNameBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.UUIDGroupNameReply + public override PacketType Type { get { return PacketType.UUIDGroupNameReply; } } + /// UUIDNameBlock block + public UUIDNameBlockBlock[] UUIDNameBlock; + + /// Default constructor public UUIDGroupNameReplyPacket() - { - Header = new LowHeader(); - Header.ID = 282; - Header.Reliable = true; - UUIDNameBlock = new UUIDNameBlockBlock[0]; + { + Header = new LowHeader(); + Header.ID = 282; + Header.Reliable = true; + UUIDNameBlock = new UUIDNameBlockBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public UUIDGroupNameReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - UUIDNameBlock = new UUIDNameBlockBlock[count]; - for (int j = 0; j < count; j++) - { UUIDNameBlock[j] = new UUIDNameBlockBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + UUIDNameBlock = new UUIDNameBlockBlock[count]; + for (int j = 0; j < count; j++) + { UUIDNameBlock[j] = new UUIDNameBlockBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public UUIDGroupNameReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - UUIDNameBlock = new UUIDNameBlockBlock[count]; - for (int j = 0; j < count; j++) - { UUIDNameBlock[j] = new UUIDNameBlockBlock(bytes, ref i); } + { + Header = head; + int count = (int)bytes[i++]; + UUIDNameBlock = new UUIDNameBlockBlock[count]; + for (int j = 0; j < count; j++) + { UUIDNameBlock[j] = new UUIDNameBlockBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; -; - length++; - for (int j = 0; j < UUIDNameBlock.Length; j++) { length += UUIDNameBlock[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)UUIDNameBlock.Length; - for (int j = 0; j < UUIDNameBlock.Length; j++) { UUIDNameBlock[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; +; + length++; + for (int j = 0; j < UUIDNameBlock.Length; j++) { length += UUIDNameBlock[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)UUIDNameBlock.Length; + for (int j = 0; j < UUIDNameBlock.Length; j++) { UUIDNameBlock[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- UUIDGroupNameReply ---\n"; + { + string output = "--- UUIDGroupNameReply ---\n"; for (int j = 0; j < UUIDNameBlock.Length; j++) - { + { output += UUIDNameBlock[j].ToString() + "\n"; - } + } return output; } - + } - - /// ChatPass packet + + /// ChatPass packet public class ChatPassPacket : Packet - { - /// ChatData block + { + /// ChatData block public class ChatDataBlock - { - /// ID field - public LLUUID ID; - /// Channel field - public int Channel; - private byte[] _message; - /// Message field + { + /// ID field + public LLUUID ID; + /// Channel field + public int Channel; + private byte[] _message; + /// Message field public byte[] Message - { - get { return _message; } + { + get { return _message; } set - { - if (value == null) { _message = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _message = new byte[value.Length]; Array.Copy(value, _message, value.Length); } + { + if (value == null) { _message = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _message = new byte[value.Length]; Array.Copy(value, _message, value.Length); } } - } - private byte[] _name; - /// Name field + } + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - /// Type field - public byte Type; - /// OwnerID field - public LLUUID OwnerID; - /// SimAccess field - public byte SimAccess; - /// Radius field - public float Radius; - /// SourceType field - public byte SourceType; - /// Position field - public LLVector3 Position; - - /// Length of this block serialized in bytes + } + /// Type field + public byte Type; + /// OwnerID field + public LLUUID OwnerID; + /// SimAccess field + public byte SimAccess; + /// Radius field + public float Radius; + /// SourceType field + public byte SourceType; + /// Position field + public LLVector3 Position; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 55; - if (Message != null) { length += 2 + Message.Length; } - if (Name != null) { length += 1 + Name.Length; } - return length; + { + int length = 55; + if (Message != null) { length += 2 + Message.Length; } + if (Name != null) { length += 1 + Name.Length; } + return length; } } - - /// Default constructor - public ChatDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ChatDataBlock() { } + /// Constructor for building the block from a byte array public ChatDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - ID = new LLUUID(bytes, i); i += 16; - Channel = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _message = new byte[length]; - Array.Copy(bytes, i, _message, 0, length); i += length; - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; - Type = (byte)bytes[i++]; - OwnerID = new LLUUID(bytes, i); i += 16; - SimAccess = (byte)bytes[i++]; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - Radius = BitConverter.ToSingle(bytes, i); i += 4; - SourceType = (byte)bytes[i++]; - Position = new LLVector3(bytes, i); i += 12; + { + ID = new LLUUID(bytes, i); i += 16; + Channel = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _message = new byte[length]; + Array.Copy(bytes, i, _message, 0, length); i += length; + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; + Type = (byte)bytes[i++]; + OwnerID = new LLUUID(bytes, i); i += 16; + SimAccess = (byte)bytes[i++]; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + Radius = BitConverter.ToSingle(bytes, i); i += 4; + SourceType = (byte)bytes[i++]; + Position = new LLVector3(bytes, i); i += 12; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; - if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } - Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(Channel % 256); - bytes[i++] = (byte)((Channel >> 8) % 256); - bytes[i++] = (byte)((Channel >> 16) % 256); - bytes[i++] = (byte)((Channel >> 24) % 256); - if(Message == null) { Console.WriteLine("Warning: Message is null, in " + this.GetType()); } - bytes[i++] = (byte)(Message.Length % 256); - bytes[i++] = (byte)((Message.Length >> 8) % 256); - Array.Copy(Message, 0, bytes, i, Message.Length); i += Message.Length; - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; - bytes[i++] = Type; - if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } - Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = SimAccess; + { + byte[] ba; + if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } + Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(Channel % 256); + bytes[i++] = (byte)((Channel >> 8) % 256); + bytes[i++] = (byte)((Channel >> 16) % 256); + bytes[i++] = (byte)((Channel >> 24) % 256); + if(Message == null) { Console.WriteLine("Warning: Message is null, in " + this.GetType()); } + bytes[i++] = (byte)(Message.Length % 256); + bytes[i++] = (byte)((Message.Length >> 8) % 256); + Array.Copy(Message, 0, bytes, i, Message.Length); i += Message.Length; + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + bytes[i++] = Type; + if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } + Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = SimAccess; ba = BitConverter.GetBytes(Radius); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - bytes[i++] = SourceType; - if(Position == null) { Console.WriteLine("Warning: Position is null, in " + this.GetType()); } - Array.Copy(Position.GetBytes(), 0, bytes, i, 12); i += 12; + Array.Copy(ba, 0, bytes, i, 4); i += 4; + bytes[i++] = SourceType; + if(Position == null) { Console.WriteLine("Warning: Position is null, in " + this.GetType()); } + Array.Copy(Position.GetBytes(), 0, bytes, i, 12); i += 12; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ChatData --\n"; - output += "ID: " + ID.ToString() + "\n"; - output += "Channel: " + Channel.ToString() + "\n"; - output += Helpers.FieldToString(Message, "Message") + "\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; - output += "Type: " + Type.ToString() + "\n"; - output += "OwnerID: " + OwnerID.ToString() + "\n"; - output += "SimAccess: " + SimAccess.ToString() + "\n"; - output += "Radius: " + Radius.ToString() + "\n"; - output += "SourceType: " + SourceType.ToString() + "\n"; - output += "Position: " + Position.ToString() + "\n"; + { + string output = "-- ChatData --\n"; + output += "ID: " + ID.ToString() + "\n"; + output += "Channel: " + Channel.ToString() + "\n"; + output += Helpers.FieldToString(Message, "Message") + "\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; + output += "Type: " + Type.ToString() + "\n"; + output += "OwnerID: " + OwnerID.ToString() + "\n"; + output += "SimAccess: " + SimAccess.ToString() + "\n"; + output += "Radius: " + Radius.ToString() + "\n"; + output += "SourceType: " + SourceType.ToString() + "\n"; + output += "Position: " + Position.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ChatPass - public override PacketType Type { get { return PacketType.ChatPass; } } - /// ChatData block - public ChatDataBlock ChatData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ChatPass + public override PacketType Type { get { return PacketType.ChatPass; } } + /// ChatData block + public ChatDataBlock ChatData; + + /// Default constructor public ChatPassPacket() - { - Header = new LowHeader(); - Header.ID = 283; - Header.Reliable = true; - Header.Zerocoded = true; - ChatData = new ChatDataBlock(); + { + Header = new LowHeader(); + Header.ID = 283; + Header.Reliable = true; + Header.Zerocoded = true; + ChatData = new ChatDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ChatPassPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - ChatData = new ChatDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + ChatData = new ChatDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ChatPassPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - ChatData = new ChatDataBlock(bytes, ref i); + { + Header = head; + ChatData = new ChatDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += ChatData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - ChatData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += ChatData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + ChatData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ChatPass ---\n"; - output += ChatData.ToString() + "\n"; + { + string output = "--- ChatPass ---\n"; + output += ChatData.ToString() + "\n"; return output; } - + } - - /// ChildAgentDying packet + + /// ChildAgentDying packet public class ChildAgentDyingPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ChildAgentDying - public override PacketType Type { get { return PacketType.ChildAgentDying; } } - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ChildAgentDying + public override PacketType Type { get { return PacketType.ChildAgentDying; } } + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ChildAgentDyingPacket() - { - Header = new LowHeader(); - Header.ID = 284; - Header.Reliable = true; - Header.Zerocoded = true; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 284; + Header.Reliable = true; + Header.Zerocoded = true; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ChildAgentDyingPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ChildAgentDyingPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ChildAgentDying ---\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- ChildAgentDying ---\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ChildAgentUnknown packet + + /// ChildAgentUnknown packet public class ChildAgentUnknownPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ChildAgentUnknown - public override PacketType Type { get { return PacketType.ChildAgentUnknown; } } - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ChildAgentUnknown + public override PacketType Type { get { return PacketType.ChildAgentUnknown; } } + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ChildAgentUnknownPacket() - { - Header = new LowHeader(); - Header.ID = 285; - Header.Reliable = true; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 285; + Header.Reliable = true; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ChildAgentUnknownPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ChildAgentUnknownPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ChildAgentUnknown ---\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- ChildAgentUnknown ---\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// KillChildAgents packet + + /// KillChildAgents packet public class KillChildAgentsPacket : Packet - { - /// IDBlock block + { + /// IDBlock block public class IDBlockBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public IDBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public IDBlockBlock() { } + /// Constructor for building the block from a byte array public IDBlockBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- IDBlock --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- IDBlock --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.KillChildAgents - public override PacketType Type { get { return PacketType.KillChildAgents; } } - /// IDBlock block - public IDBlockBlock IDBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.KillChildAgents + public override PacketType Type { get { return PacketType.KillChildAgents; } } + /// IDBlock block + public IDBlockBlock IDBlock; + + /// Default constructor public KillChildAgentsPacket() - { - Header = new LowHeader(); - Header.ID = 286; - Header.Reliable = true; - IDBlock = new IDBlockBlock(); + { + Header = new LowHeader(); + Header.ID = 286; + Header.Reliable = true; + IDBlock = new IDBlockBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public KillChildAgentsPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - IDBlock = new IDBlockBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + IDBlock = new IDBlockBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public KillChildAgentsPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - IDBlock = new IDBlockBlock(bytes, ref i); + { + Header = head; + IDBlock = new IDBlockBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += IDBlock.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - IDBlock.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += IDBlock.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + IDBlock.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- KillChildAgents ---\n"; - output += IDBlock.ToString() + "\n"; + { + string output = "--- KillChildAgents ---\n"; + output += IDBlock.ToString() + "\n"; return output; } - + } - - /// GetScriptRunning packet + + /// GetScriptRunning packet public class GetScriptRunningPacket : Packet - { - /// Script block + { + /// Script block public class ScriptBlock - { - /// ObjectID field - public LLUUID ObjectID; - /// ItemID field - public LLUUID ItemID; - - /// Length of this block serialized in bytes + { + /// ObjectID field + public LLUUID ObjectID; + /// ItemID field + public LLUUID ItemID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public ScriptBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ScriptBlock() { } + /// Constructor for building the block from a byte array public ScriptBlock(byte[] bytes, ref int i) - { + { try - { - ObjectID = new LLUUID(bytes, i); i += 16; - ItemID = new LLUUID(bytes, i); i += 16; + { + ObjectID = new LLUUID(bytes, i); i += 16; + ItemID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } - Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; - if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } - Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } + Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; + if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } + Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Script --\n"; - output += "ObjectID: " + ObjectID.ToString() + "\n"; - output += "ItemID: " + ItemID.ToString() + "\n"; + { + string output = "-- Script --\n"; + output += "ObjectID: " + ObjectID.ToString() + "\n"; + output += "ItemID: " + ItemID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.GetScriptRunning - public override PacketType Type { get { return PacketType.GetScriptRunning; } } - /// Script block - public ScriptBlock Script; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.GetScriptRunning + public override PacketType Type { get { return PacketType.GetScriptRunning; } } + /// Script block + public ScriptBlock Script; + + /// Default constructor public GetScriptRunningPacket() - { - Header = new LowHeader(); - Header.ID = 287; - Header.Reliable = true; - Script = new ScriptBlock(); + { + Header = new LowHeader(); + Header.ID = 287; + Header.Reliable = true; + Script = new ScriptBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public GetScriptRunningPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Script = new ScriptBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Script = new ScriptBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public GetScriptRunningPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Script = new ScriptBlock(bytes, ref i); + { + Header = head; + Script = new ScriptBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Script.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Script.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Script.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Script.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- GetScriptRunning ---\n"; - output += Script.ToString() + "\n"; + { + string output = "--- GetScriptRunning ---\n"; + output += Script.ToString() + "\n"; return output; } - + } - - /// ScriptRunningReply packet + + /// ScriptRunningReply packet public class ScriptRunningReplyPacket : Packet - { - /// Script block + { + /// Script block public class ScriptBlock - { - /// ObjectID field - public LLUUID ObjectID; - /// Running field - public bool Running; - /// ItemID field - public LLUUID ItemID; - - /// Length of this block serialized in bytes + { + /// ObjectID field + public LLUUID ObjectID; + /// Running field + public bool Running; + /// ItemID field + public LLUUID ItemID; + + /// Length of this block serialized in bytes public int Length { get - { - return 33; + { + return 33; } } - - /// Default constructor - public ScriptBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ScriptBlock() { } + /// Constructor for building the block from a byte array public ScriptBlock(byte[] bytes, ref int i) - { + { try - { - ObjectID = new LLUUID(bytes, i); i += 16; - Running = (bytes[i++] != 0) ? (bool)true : (bool)false; - ItemID = new LLUUID(bytes, i); i += 16; + { + ObjectID = new LLUUID(bytes, i); i += 16; + Running = (bytes[i++] != 0) ? (bool)true : (bool)false; + ItemID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } - Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((Running) ? 1 : 0); - if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } - Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } + Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((Running) ? 1 : 0); + if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } + Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Script --\n"; - output += "ObjectID: " + ObjectID.ToString() + "\n"; - output += "Running: " + Running.ToString() + "\n"; - output += "ItemID: " + ItemID.ToString() + "\n"; + { + string output = "-- Script --\n"; + output += "ObjectID: " + ObjectID.ToString() + "\n"; + output += "Running: " + Running.ToString() + "\n"; + output += "ItemID: " + ItemID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ScriptRunningReply - public override PacketType Type { get { return PacketType.ScriptRunningReply; } } - /// Script block - public ScriptBlock Script; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ScriptRunningReply + public override PacketType Type { get { return PacketType.ScriptRunningReply; } } + /// Script block + public ScriptBlock Script; + + /// Default constructor public ScriptRunningReplyPacket() - { - Header = new LowHeader(); - Header.ID = 288; - Header.Reliable = true; - Script = new ScriptBlock(); + { + Header = new LowHeader(); + Header.ID = 288; + Header.Reliable = true; + Script = new ScriptBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ScriptRunningReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Script = new ScriptBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Script = new ScriptBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ScriptRunningReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Script = new ScriptBlock(bytes, ref i); + { + Header = head; + Script = new ScriptBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Script.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Script.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Script.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Script.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ScriptRunningReply ---\n"; - output += Script.ToString() + "\n"; + { + string output = "--- ScriptRunningReply ---\n"; + output += Script.ToString() + "\n"; return output; } - + } - - /// SetScriptRunning packet + + /// SetScriptRunning packet public class SetScriptRunningPacket : Packet - { - /// Script block + { + /// Script block public class ScriptBlock - { - /// ObjectID field - public LLUUID ObjectID; - /// Running field - public bool Running; - /// ItemID field - public LLUUID ItemID; - - /// Length of this block serialized in bytes + { + /// ObjectID field + public LLUUID ObjectID; + /// Running field + public bool Running; + /// ItemID field + public LLUUID ItemID; + + /// Length of this block serialized in bytes public int Length { get - { - return 33; + { + return 33; } } - - /// Default constructor - public ScriptBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ScriptBlock() { } + /// Constructor for building the block from a byte array public ScriptBlock(byte[] bytes, ref int i) - { + { try - { - ObjectID = new LLUUID(bytes, i); i += 16; - Running = (bytes[i++] != 0) ? (bool)true : (bool)false; - ItemID = new LLUUID(bytes, i); i += 16; + { + ObjectID = new LLUUID(bytes, i); i += 16; + Running = (bytes[i++] != 0) ? (bool)true : (bool)false; + ItemID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } - Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((Running) ? 1 : 0); - if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } - Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } + Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((Running) ? 1 : 0); + if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } + Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Script --\n"; - output += "ObjectID: " + ObjectID.ToString() + "\n"; - output += "Running: " + Running.ToString() + "\n"; - output += "ItemID: " + ItemID.ToString() + "\n"; + { + string output = "-- Script --\n"; + output += "ObjectID: " + ObjectID.ToString() + "\n"; + output += "Running: " + Running.ToString() + "\n"; + output += "ItemID: " + ItemID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.SetScriptRunning - public override PacketType Type { get { return PacketType.SetScriptRunning; } } - /// Script block - public ScriptBlock Script; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.SetScriptRunning + public override PacketType Type { get { return PacketType.SetScriptRunning; } } + /// Script block + public ScriptBlock Script; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public SetScriptRunningPacket() - { - Header = new LowHeader(); - Header.ID = 289; - Header.Reliable = true; - Script = new ScriptBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 289; + Header.Reliable = true; + Script = new ScriptBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public SetScriptRunningPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Script = new ScriptBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Script = new ScriptBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public SetScriptRunningPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Script = new ScriptBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + Script = new ScriptBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Script.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Script.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Script.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Script.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- SetScriptRunning ---\n"; - output += Script.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- SetScriptRunning ---\n"; + output += Script.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ScriptReset packet + + /// ScriptReset packet public class ScriptResetPacket : Packet - { - /// Script block + { + /// Script block public class ScriptBlock - { - /// ObjectID field - public LLUUID ObjectID; - /// ItemID field - public LLUUID ItemID; - - /// Length of this block serialized in bytes + { + /// ObjectID field + public LLUUID ObjectID; + /// ItemID field + public LLUUID ItemID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public ScriptBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ScriptBlock() { } + /// Constructor for building the block from a byte array public ScriptBlock(byte[] bytes, ref int i) - { + { try - { - ObjectID = new LLUUID(bytes, i); i += 16; - ItemID = new LLUUID(bytes, i); i += 16; + { + ObjectID = new LLUUID(bytes, i); i += 16; + ItemID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } - Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; - if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } - Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } + Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; + if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } + Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Script --\n"; - output += "ObjectID: " + ObjectID.ToString() + "\n"; - output += "ItemID: " + ItemID.ToString() + "\n"; + { + string output = "-- Script --\n"; + output += "ObjectID: " + ObjectID.ToString() + "\n"; + output += "ItemID: " + ItemID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ScriptReset - public override PacketType Type { get { return PacketType.ScriptReset; } } - /// Script block - public ScriptBlock Script; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ScriptReset + public override PacketType Type { get { return PacketType.ScriptReset; } } + /// Script block + public ScriptBlock Script; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ScriptResetPacket() - { - Header = new LowHeader(); - Header.ID = 290; - Header.Reliable = true; - Script = new ScriptBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 290; + Header.Reliable = true; + Script = new ScriptBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ScriptResetPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Script = new ScriptBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Script = new ScriptBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ScriptResetPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Script = new ScriptBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + Script = new ScriptBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Script.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Script.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Script.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Script.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ScriptReset ---\n"; - output += Script.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- ScriptReset ---\n"; + output += Script.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ScriptSensorRequest packet + + /// ScriptSensorRequest packet public class ScriptSensorRequestPacket : Packet - { - /// Requester block + { + /// Requester block public class RequesterBlock - { - /// Arc field - public float Arc; - /// RequestID field - public LLUUID RequestID; - /// SearchID field - public LLUUID SearchID; - private byte[] _searchname; - /// SearchName field + { + /// Arc field + public float Arc; + /// RequestID field + public LLUUID RequestID; + /// SearchID field + public LLUUID SearchID; + private byte[] _searchname; + /// SearchName field public byte[] SearchName - { - get { return _searchname; } + { + get { return _searchname; } set - { - if (value == null) { _searchname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _searchname = new byte[value.Length]; Array.Copy(value, _searchname, value.Length); } + { + if (value == null) { _searchname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _searchname = new byte[value.Length]; Array.Copy(value, _searchname, value.Length); } } - } - /// Type field - public int Type; - /// RegionHandle field - public ulong RegionHandle; - /// SearchDir field - public LLQuaternion SearchDir; - /// SearchRegions field - public byte SearchRegions; - /// SearchPos field - public LLVector3 SearchPos; - /// Range field - public float Range; - /// SourceID field - public LLUUID SourceID; - - /// Length of this block serialized in bytes + } + /// Type field + public int Type; + /// RegionHandle field + public ulong RegionHandle; + /// SearchDir field + public LLQuaternion SearchDir; + /// SearchRegions field + public byte SearchRegions; + /// SearchPos field + public LLVector3 SearchPos; + /// Range field + public float Range; + /// SourceID field + public LLUUID SourceID; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 93; - if (SearchName != null) { length += 1 + SearchName.Length; } - return length; + { + int length = 93; + if (SearchName != null) { length += 1 + SearchName.Length; } + return length; } } - - /// Default constructor - public RequesterBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public RequesterBlock() { } + /// Constructor for building the block from a byte array public RequesterBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - Arc = BitConverter.ToSingle(bytes, i); i += 4; - RequestID = new LLUUID(bytes, i); i += 16; - SearchID = new LLUUID(bytes, i); i += 16; - length = (ushort)bytes[i++]; - _searchname = new byte[length]; - Array.Copy(bytes, i, _searchname, 0, length); i += length; - Type = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); - SearchDir = new LLQuaternion(bytes, i, true); i += 12; - SearchRegions = (byte)bytes[i++]; - SearchPos = new LLVector3(bytes, i); i += 12; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - Range = BitConverter.ToSingle(bytes, i); i += 4; - SourceID = new LLUUID(bytes, i); i += 16; + { + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + Arc = BitConverter.ToSingle(bytes, i); i += 4; + RequestID = new LLUUID(bytes, i); i += 16; + SearchID = new LLUUID(bytes, i); i += 16; + length = (ushort)bytes[i++]; + _searchname = new byte[length]; + Array.Copy(bytes, i, _searchname, 0, length); i += length; + Type = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + SearchDir = new LLQuaternion(bytes, i, true); i += 12; + SearchRegions = (byte)bytes[i++]; + SearchPos = new LLVector3(bytes, i); i += 12; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + Range = BitConverter.ToSingle(bytes, i); i += 4; + SourceID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; + { + byte[] ba; ba = BitConverter.GetBytes(Arc); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - if(RequestID == null) { Console.WriteLine("Warning: RequestID is null, in " + this.GetType()); } - Array.Copy(RequestID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SearchID == null) { Console.WriteLine("Warning: SearchID is null, in " + this.GetType()); } - Array.Copy(SearchID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SearchName == null) { Console.WriteLine("Warning: SearchName is null, in " + this.GetType()); } - bytes[i++] = (byte)SearchName.Length; - Array.Copy(SearchName, 0, bytes, i, SearchName.Length); i += SearchName.Length; - bytes[i++] = (byte)(Type % 256); - bytes[i++] = (byte)((Type >> 8) % 256); - bytes[i++] = (byte)((Type >> 16) % 256); - bytes[i++] = (byte)((Type >> 24) % 256); - bytes[i++] = (byte)(RegionHandle % 256); - bytes[i++] = (byte)((RegionHandle >> 8) % 256); - bytes[i++] = (byte)((RegionHandle >> 16) % 256); - bytes[i++] = (byte)((RegionHandle >> 24) % 256); - bytes[i++] = (byte)((RegionHandle >> 32) % 256); - bytes[i++] = (byte)((RegionHandle >> 40) % 256); - bytes[i++] = (byte)((RegionHandle >> 48) % 256); - bytes[i++] = (byte)((RegionHandle >> 56) % 256); - if(SearchDir == null) { Console.WriteLine("Warning: SearchDir is null, in " + this.GetType()); } - Array.Copy(SearchDir.GetBytes(), 0, bytes, i, 12); i += 12; - bytes[i++] = SearchRegions; - if(SearchPos == null) { Console.WriteLine("Warning: SearchPos is null, in " + this.GetType()); } - Array.Copy(SearchPos.GetBytes(), 0, bytes, i, 12); i += 12; + Array.Copy(ba, 0, bytes, i, 4); i += 4; + if(RequestID == null) { Console.WriteLine("Warning: RequestID is null, in " + this.GetType()); } + Array.Copy(RequestID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SearchID == null) { Console.WriteLine("Warning: SearchID is null, in " + this.GetType()); } + Array.Copy(SearchID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SearchName == null) { Console.WriteLine("Warning: SearchName is null, in " + this.GetType()); } + bytes[i++] = (byte)SearchName.Length; + Array.Copy(SearchName, 0, bytes, i, SearchName.Length); i += SearchName.Length; + bytes[i++] = (byte)(Type % 256); + bytes[i++] = (byte)((Type >> 8) % 256); + bytes[i++] = (byte)((Type >> 16) % 256); + bytes[i++] = (byte)((Type >> 24) % 256); + bytes[i++] = (byte)(RegionHandle % 256); + bytes[i++] = (byte)((RegionHandle >> 8) % 256); + bytes[i++] = (byte)((RegionHandle >> 16) % 256); + bytes[i++] = (byte)((RegionHandle >> 24) % 256); + bytes[i++] = (byte)((RegionHandle >> 32) % 256); + bytes[i++] = (byte)((RegionHandle >> 40) % 256); + bytes[i++] = (byte)((RegionHandle >> 48) % 256); + bytes[i++] = (byte)((RegionHandle >> 56) % 256); + if(SearchDir == null) { Console.WriteLine("Warning: SearchDir is null, in " + this.GetType()); } + Array.Copy(SearchDir.GetBytes(), 0, bytes, i, 12); i += 12; + bytes[i++] = SearchRegions; + if(SearchPos == null) { Console.WriteLine("Warning: SearchPos is null, in " + this.GetType()); } + Array.Copy(SearchPos.GetBytes(), 0, bytes, i, 12); i += 12; ba = BitConverter.GetBytes(Range); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - if(SourceID == null) { Console.WriteLine("Warning: SourceID is null, in " + this.GetType()); } - Array.Copy(SourceID.GetBytes(), 0, bytes, i, 16); i += 16; + Array.Copy(ba, 0, bytes, i, 4); i += 4; + if(SourceID == null) { Console.WriteLine("Warning: SourceID is null, in " + this.GetType()); } + Array.Copy(SourceID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Requester --\n"; - output += "Arc: " + Arc.ToString() + "\n"; - output += "RequestID: " + RequestID.ToString() + "\n"; - output += "SearchID: " + SearchID.ToString() + "\n"; - output += Helpers.FieldToString(SearchName, "SearchName") + "\n"; - output += "Type: " + Type.ToString() + "\n"; - output += "RegionHandle: " + RegionHandle.ToString() + "\n"; - output += "SearchDir: " + SearchDir.ToString() + "\n"; - output += "SearchRegions: " + SearchRegions.ToString() + "\n"; - output += "SearchPos: " + SearchPos.ToString() + "\n"; - output += "Range: " + Range.ToString() + "\n"; - output += "SourceID: " + SourceID.ToString() + "\n"; + { + string output = "-- Requester --\n"; + output += "Arc: " + Arc.ToString() + "\n"; + output += "RequestID: " + RequestID.ToString() + "\n"; + output += "SearchID: " + SearchID.ToString() + "\n"; + output += Helpers.FieldToString(SearchName, "SearchName") + "\n"; + output += "Type: " + Type.ToString() + "\n"; + output += "RegionHandle: " + RegionHandle.ToString() + "\n"; + output += "SearchDir: " + SearchDir.ToString() + "\n"; + output += "SearchRegions: " + SearchRegions.ToString() + "\n"; + output += "SearchPos: " + SearchPos.ToString() + "\n"; + output += "Range: " + Range.ToString() + "\n"; + output += "SourceID: " + SourceID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ScriptSensorRequest - public override PacketType Type { get { return PacketType.ScriptSensorRequest; } } - /// Requester block - public RequesterBlock Requester; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ScriptSensorRequest + public override PacketType Type { get { return PacketType.ScriptSensorRequest; } } + /// Requester block + public RequesterBlock Requester; + + /// Default constructor public ScriptSensorRequestPacket() - { - Header = new LowHeader(); - Header.ID = 291; - Header.Reliable = true; - Header.Zerocoded = true; - Requester = new RequesterBlock(); + { + Header = new LowHeader(); + Header.ID = 291; + Header.Reliable = true; + Header.Zerocoded = true; + Requester = new RequesterBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ScriptSensorRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Requester = new RequesterBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Requester = new RequesterBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ScriptSensorRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Requester = new RequesterBlock(bytes, ref i); + { + Header = head; + Requester = new RequesterBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Requester.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Requester.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Requester.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Requester.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ScriptSensorRequest ---\n"; - output += Requester.ToString() + "\n"; + { + string output = "--- ScriptSensorRequest ---\n"; + output += Requester.ToString() + "\n"; return output; } - + } - - /// ScriptSensorReply packet + + /// ScriptSensorReply packet public class ScriptSensorReplyPacket : Packet - { - /// SensedData block + { + /// SensedData block public class SensedDataBlock - { - /// ObjectID field - public LLUUID ObjectID; - private byte[] _name; - /// Name field + { + /// ObjectID field + public LLUUID ObjectID; + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - /// Type field - public int Type; - /// GroupID field - public LLUUID GroupID; - /// OwnerID field - public LLUUID OwnerID; - /// Velocity field - public LLVector3 Velocity; - /// Range field - public float Range; - /// Rotation field - public LLQuaternion Rotation; - /// Position field - public LLVector3 Position; - - /// Length of this block serialized in bytes + } + /// Type field + public int Type; + /// GroupID field + public LLUUID GroupID; + /// OwnerID field + public LLUUID OwnerID; + /// Velocity field + public LLVector3 Velocity; + /// Range field + public float Range; + /// Rotation field + public LLQuaternion Rotation; + /// Position field + public LLVector3 Position; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 92; - if (Name != null) { length += 1 + Name.Length; } - return length; + { + int length = 92; + if (Name != null) { length += 1 + Name.Length; } + return length; } } - - /// Default constructor - public SensedDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public SensedDataBlock() { } + /// Constructor for building the block from a byte array public SensedDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - ObjectID = new LLUUID(bytes, i); i += 16; - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; - Type = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - GroupID = new LLUUID(bytes, i); i += 16; - OwnerID = new LLUUID(bytes, i); i += 16; - Velocity = new LLVector3(bytes, i); i += 12; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - Range = BitConverter.ToSingle(bytes, i); i += 4; - Rotation = new LLQuaternion(bytes, i, true); i += 12; - Position = new LLVector3(bytes, i); i += 12; + { + ObjectID = new LLUUID(bytes, i); i += 16; + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; + Type = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + GroupID = new LLUUID(bytes, i); i += 16; + OwnerID = new LLUUID(bytes, i); i += 16; + Velocity = new LLVector3(bytes, i); i += 12; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + Range = BitConverter.ToSingle(bytes, i); i += 4; + Rotation = new LLQuaternion(bytes, i, true); i += 12; + Position = new LLVector3(bytes, i); i += 12; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; - if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } - Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; - bytes[i++] = (byte)(Type % 256); - bytes[i++] = (byte)((Type >> 8) % 256); - bytes[i++] = (byte)((Type >> 16) % 256); - bytes[i++] = (byte)((Type >> 24) % 256); - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; - if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } - Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; - if(Velocity == null) { Console.WriteLine("Warning: Velocity is null, in " + this.GetType()); } - Array.Copy(Velocity.GetBytes(), 0, bytes, i, 12); i += 12; + { + byte[] ba; + if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } + Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + bytes[i++] = (byte)(Type % 256); + bytes[i++] = (byte)((Type >> 8) % 256); + bytes[i++] = (byte)((Type >> 16) % 256); + bytes[i++] = (byte)((Type >> 24) % 256); + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } + Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; + if(Velocity == null) { Console.WriteLine("Warning: Velocity is null, in " + this.GetType()); } + Array.Copy(Velocity.GetBytes(), 0, bytes, i, 12); i += 12; ba = BitConverter.GetBytes(Range); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - if(Rotation == null) { Console.WriteLine("Warning: Rotation is null, in " + this.GetType()); } - Array.Copy(Rotation.GetBytes(), 0, bytes, i, 12); i += 12; - if(Position == null) { Console.WriteLine("Warning: Position is null, in " + this.GetType()); } - Array.Copy(Position.GetBytes(), 0, bytes, i, 12); i += 12; + Array.Copy(ba, 0, bytes, i, 4); i += 4; + if(Rotation == null) { Console.WriteLine("Warning: Rotation is null, in " + this.GetType()); } + Array.Copy(Rotation.GetBytes(), 0, bytes, i, 12); i += 12; + if(Position == null) { Console.WriteLine("Warning: Position is null, in " + this.GetType()); } + Array.Copy(Position.GetBytes(), 0, bytes, i, 12); i += 12; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- SensedData --\n"; - output += "ObjectID: " + ObjectID.ToString() + "\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; - output += "Type: " + Type.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; - output += "OwnerID: " + OwnerID.ToString() + "\n"; - output += "Velocity: " + Velocity.ToString() + "\n"; - output += "Range: " + Range.ToString() + "\n"; - output += "Rotation: " + Rotation.ToString() + "\n"; - output += "Position: " + Position.ToString() + "\n"; + { + string output = "-- SensedData --\n"; + output += "ObjectID: " + ObjectID.ToString() + "\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; + output += "Type: " + Type.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; + output += "OwnerID: " + OwnerID.ToString() + "\n"; + output += "Velocity: " + Velocity.ToString() + "\n"; + output += "Range: " + Range.ToString() + "\n"; + output += "Rotation: " + Rotation.ToString() + "\n"; + output += "Position: " + Position.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// Requester block + + /// Requester block public class RequesterBlock - { - /// SourceID field - public LLUUID SourceID; - - /// Length of this block serialized in bytes + { + /// SourceID field + public LLUUID SourceID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public RequesterBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public RequesterBlock() { } + /// Constructor for building the block from a byte array public RequesterBlock(byte[] bytes, ref int i) - { + { try - { - SourceID = new LLUUID(bytes, i); i += 16; + { + SourceID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(SourceID == null) { Console.WriteLine("Warning: SourceID is null, in " + this.GetType()); } - Array.Copy(SourceID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(SourceID == null) { Console.WriteLine("Warning: SourceID is null, in " + this.GetType()); } + Array.Copy(SourceID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Requester --\n"; - output += "SourceID: " + SourceID.ToString() + "\n"; + { + string output = "-- Requester --\n"; + output += "SourceID: " + SourceID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ScriptSensorReply - public override PacketType Type { get { return PacketType.ScriptSensorReply; } } - /// SensedData block - public SensedDataBlock[] SensedData; - /// Requester block - public RequesterBlock Requester; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ScriptSensorReply + public override PacketType Type { get { return PacketType.ScriptSensorReply; } } + /// SensedData block + public SensedDataBlock[] SensedData; + /// Requester block + public RequesterBlock Requester; + + /// Default constructor public ScriptSensorReplyPacket() - { - Header = new LowHeader(); - Header.ID = 292; - Header.Reliable = true; - Header.Zerocoded = true; - SensedData = new SensedDataBlock[0]; - Requester = new RequesterBlock(); + { + Header = new LowHeader(); + Header.ID = 292; + Header.Reliable = true; + Header.Zerocoded = true; + SensedData = new SensedDataBlock[0]; + Requester = new RequesterBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ScriptSensorReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - SensedData = new SensedDataBlock[count]; - for (int j = 0; j < count; j++) - { SensedData[j] = new SensedDataBlock(bytes, ref i); } - Requester = new RequesterBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + SensedData = new SensedDataBlock[count]; + for (int j = 0; j < count; j++) + { SensedData[j] = new SensedDataBlock(bytes, ref i); } + Requester = new RequesterBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ScriptSensorReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - SensedData = new SensedDataBlock[count]; - for (int j = 0; j < count; j++) - { SensedData[j] = new SensedDataBlock(bytes, ref i); } - Requester = new RequesterBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + SensedData = new SensedDataBlock[count]; + for (int j = 0; j < count; j++) + { SensedData[j] = new SensedDataBlock(bytes, ref i); } + Requester = new RequesterBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Requester.Length;; - length++; - for (int j = 0; j < SensedData.Length; j++) { length += SensedData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)SensedData.Length; - for (int j = 0; j < SensedData.Length; j++) { SensedData[j].ToBytes(bytes, ref i); } - Requester.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Requester.Length;; + length++; + for (int j = 0; j < SensedData.Length; j++) { length += SensedData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)SensedData.Length; + for (int j = 0; j < SensedData.Length; j++) { SensedData[j].ToBytes(bytes, ref i); } + Requester.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ScriptSensorReply ---\n"; + { + string output = "--- ScriptSensorReply ---\n"; for (int j = 0; j < SensedData.Length; j++) - { + { output += SensedData[j].ToString() + "\n"; - } - output += Requester.ToString() + "\n"; + } + output += Requester.ToString() + "\n"; return output; } - + } - - /// CompleteAgentMovement packet + + /// CompleteAgentMovement packet public class CompleteAgentMovementPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - /// CircuitCode field - public uint CircuitCode; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + /// CircuitCode field + public uint CircuitCode; + + /// Length of this block serialized in bytes public int Length { get - { - return 36; + { + return 36; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; - CircuitCode = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; + CircuitCode = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(CircuitCode % 256); - bytes[i++] = (byte)((CircuitCode >> 8) % 256); - bytes[i++] = (byte)((CircuitCode >> 16) % 256); - bytes[i++] = (byte)((CircuitCode >> 24) % 256); + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(CircuitCode % 256); + bytes[i++] = (byte)((CircuitCode >> 8) % 256); + bytes[i++] = (byte)((CircuitCode >> 16) % 256); + bytes[i++] = (byte)((CircuitCode >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "CircuitCode: " + CircuitCode.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "CircuitCode: " + CircuitCode.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.CompleteAgentMovement - public override PacketType Type { get { return PacketType.CompleteAgentMovement; } } - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.CompleteAgentMovement + public override PacketType Type { get { return PacketType.CompleteAgentMovement; } } + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public CompleteAgentMovementPacket() - { - Header = new LowHeader(); - Header.ID = 293; - Header.Reliable = true; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 293; + Header.Reliable = true; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public CompleteAgentMovementPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public CompleteAgentMovementPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- CompleteAgentMovement ---\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- CompleteAgentMovement ---\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// AgentMovementComplete packet + + /// AgentMovementComplete packet public class AgentMovementCompletePacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - /// Timestamp field - public uint Timestamp; - /// RegionHandle field - public ulong RegionHandle; - /// LookAt field - public LLVector3 LookAt; - /// Position field - public LLVector3 Position; - - /// Length of this block serialized in bytes + { + /// Timestamp field + public uint Timestamp; + /// RegionHandle field + public ulong RegionHandle; + /// LookAt field + public LLVector3 LookAt; + /// Position field + public LLVector3 Position; + + /// Length of this block serialized in bytes public int Length { get - { - return 36; + { + return 36; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { + { try - { - Timestamp = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); - LookAt = new LLVector3(bytes, i); i += 12; - Position = new LLVector3(bytes, i); i += 12; + { + Timestamp = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + LookAt = new LLVector3(bytes, i); i += 12; + Position = new LLVector3(bytes, i); i += 12; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(Timestamp % 256); - bytes[i++] = (byte)((Timestamp >> 8) % 256); - bytes[i++] = (byte)((Timestamp >> 16) % 256); - bytes[i++] = (byte)((Timestamp >> 24) % 256); - bytes[i++] = (byte)(RegionHandle % 256); - bytes[i++] = (byte)((RegionHandle >> 8) % 256); - bytes[i++] = (byte)((RegionHandle >> 16) % 256); - bytes[i++] = (byte)((RegionHandle >> 24) % 256); - bytes[i++] = (byte)((RegionHandle >> 32) % 256); - bytes[i++] = (byte)((RegionHandle >> 40) % 256); - bytes[i++] = (byte)((RegionHandle >> 48) % 256); - bytes[i++] = (byte)((RegionHandle >> 56) % 256); - if(LookAt == null) { Console.WriteLine("Warning: LookAt is null, in " + this.GetType()); } - Array.Copy(LookAt.GetBytes(), 0, bytes, i, 12); i += 12; - if(Position == null) { Console.WriteLine("Warning: Position is null, in " + this.GetType()); } - Array.Copy(Position.GetBytes(), 0, bytes, i, 12); i += 12; + { + bytes[i++] = (byte)(Timestamp % 256); + bytes[i++] = (byte)((Timestamp >> 8) % 256); + bytes[i++] = (byte)((Timestamp >> 16) % 256); + bytes[i++] = (byte)((Timestamp >> 24) % 256); + bytes[i++] = (byte)(RegionHandle % 256); + bytes[i++] = (byte)((RegionHandle >> 8) % 256); + bytes[i++] = (byte)((RegionHandle >> 16) % 256); + bytes[i++] = (byte)((RegionHandle >> 24) % 256); + bytes[i++] = (byte)((RegionHandle >> 32) % 256); + bytes[i++] = (byte)((RegionHandle >> 40) % 256); + bytes[i++] = (byte)((RegionHandle >> 48) % 256); + bytes[i++] = (byte)((RegionHandle >> 56) % 256); + if(LookAt == null) { Console.WriteLine("Warning: LookAt is null, in " + this.GetType()); } + Array.Copy(LookAt.GetBytes(), 0, bytes, i, 12); i += 12; + if(Position == null) { Console.WriteLine("Warning: Position is null, in " + this.GetType()); } + Array.Copy(Position.GetBytes(), 0, bytes, i, 12); i += 12; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "Timestamp: " + Timestamp.ToString() + "\n"; - output += "RegionHandle: " + RegionHandle.ToString() + "\n"; - output += "LookAt: " + LookAt.ToString() + "\n"; - output += "Position: " + Position.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += "Timestamp: " + Timestamp.ToString() + "\n"; + output += "RegionHandle: " + RegionHandle.ToString() + "\n"; + output += "LookAt: " + LookAt.ToString() + "\n"; + output += "Position: " + Position.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AgentMovementComplete - public override PacketType Type { get { return PacketType.AgentMovementComplete; } } - /// Data block - public DataBlock Data; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AgentMovementComplete + public override PacketType Type { get { return PacketType.AgentMovementComplete; } } + /// Data block + public DataBlock Data; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public AgentMovementCompletePacket() - { - Header = new LowHeader(); - Header.ID = 294; - Header.Reliable = true; - Data = new DataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 294; + Header.Reliable = true; + Data = new DataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AgentMovementCompletePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AgentMovementCompletePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Data.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Data.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Data.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Data.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AgentMovementComplete ---\n"; - output += Data.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- AgentMovementComplete ---\n"; + output += Data.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// LogLogin packet + + /// LogLogin packet public class LogLoginPacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - /// ViewerDigest field - public LLUUID ViewerDigest; - /// SpaceIP field - public uint SpaceIP; - /// LastExecFroze field - public bool LastExecFroze; - - /// Length of this block serialized in bytes + { + /// ViewerDigest field + public LLUUID ViewerDigest; + /// SpaceIP field + public uint SpaceIP; + /// LastExecFroze field + public bool LastExecFroze; + + /// Length of this block serialized in bytes public int Length { get - { - return 21; + { + return 21; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { + { try - { - ViewerDigest = new LLUUID(bytes, i); i += 16; - SpaceIP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - LastExecFroze = (bytes[i++] != 0) ? (bool)true : (bool)false; + { + ViewerDigest = new LLUUID(bytes, i); i += 16; + SpaceIP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + LastExecFroze = (bytes[i++] != 0) ? (bool)true : (bool)false; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ViewerDigest == null) { Console.WriteLine("Warning: ViewerDigest is null, in " + this.GetType()); } - Array.Copy(ViewerDigest.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(SpaceIP % 256); - bytes[i++] = (byte)((SpaceIP >> 8) % 256); - bytes[i++] = (byte)((SpaceIP >> 16) % 256); - bytes[i++] = (byte)((SpaceIP >> 24) % 256); - bytes[i++] = (byte)((LastExecFroze) ? 1 : 0); + { + if(ViewerDigest == null) { Console.WriteLine("Warning: ViewerDigest is null, in " + this.GetType()); } + Array.Copy(ViewerDigest.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(SpaceIP % 256); + bytes[i++] = (byte)((SpaceIP >> 8) % 256); + bytes[i++] = (byte)((SpaceIP >> 16) % 256); + bytes[i++] = (byte)((SpaceIP >> 24) % 256); + bytes[i++] = (byte)((LastExecFroze) ? 1 : 0); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "ViewerDigest: " + ViewerDigest.ToString() + "\n"; - output += "SpaceIP: " + SpaceIP.ToString() + "\n"; - output += "LastExecFroze: " + LastExecFroze.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += "ViewerDigest: " + ViewerDigest.ToString() + "\n"; + output += "SpaceIP: " + SpaceIP.ToString() + "\n"; + output += "LastExecFroze: " + LastExecFroze.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.LogLogin - public override PacketType Type { get { return PacketType.LogLogin; } } - /// Data block - public DataBlock Data; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.LogLogin + public override PacketType Type { get { return PacketType.LogLogin; } } + /// Data block + public DataBlock Data; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public LogLoginPacket() - { - Header = new LowHeader(); - Header.ID = 295; - Header.Reliable = true; - Data = new DataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 295; + Header.Reliable = true; + Data = new DataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public LogLoginPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public LogLoginPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Data.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Data.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Data.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Data.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- LogLogin ---\n"; - output += Data.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- LogLogin ---\n"; + output += Data.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ConnectAgentToUserserver packet + + /// ConnectAgentToUserserver packet public class ConnectAgentToUserserverPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ConnectAgentToUserserver - public override PacketType Type { get { return PacketType.ConnectAgentToUserserver; } } - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ConnectAgentToUserserver + public override PacketType Type { get { return PacketType.ConnectAgentToUserserver; } } + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ConnectAgentToUserserverPacket() - { - Header = new LowHeader(); - Header.ID = 296; - Header.Reliable = true; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 296; + Header.Reliable = true; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ConnectAgentToUserserverPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ConnectAgentToUserserverPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ConnectAgentToUserserver ---\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- ConnectAgentToUserserver ---\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ConnectToUserserver packet + + /// ConnectToUserserver packet public class ConnectToUserserverPacket : Packet - { - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ConnectToUserserver - public override PacketType Type { get { return PacketType.ConnectToUserserver; } } - - /// Default constructor + { + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ConnectToUserserver + public override PacketType Type { get { return PacketType.ConnectToUserserver; } } + + /// Default constructor public ConnectToUserserverPacket() - { - Header = new LowHeader(); - Header.ID = 297; - Header.Reliable = true; + { + Header = new LowHeader(); + Header.ID = 297; + Header.Reliable = true; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ConnectToUserserverPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ConnectToUserserverPacket(Header head, byte[] bytes, ref int i) - { - Header = head; + { + Header = head; } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; -; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; +; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ConnectToUserserver ---\n"; + { + string output = "--- ConnectToUserserver ---\n"; return output; } - + } - - /// DataServerLogout packet + + /// DataServerLogout packet public class DataServerLogoutPacket : Packet - { - /// UserData block + { + /// UserData block public class UserDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - /// ViewerIP field - public uint ViewerIP; - /// Disconnect field - public bool Disconnect; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + /// ViewerIP field + public uint ViewerIP; + /// Disconnect field + public bool Disconnect; + + /// Length of this block serialized in bytes public int Length { get - { - return 37; + { + return 37; } } - - /// Default constructor - public UserDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public UserDataBlock() { } + /// Constructor for building the block from a byte array public UserDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; - ViewerIP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Disconnect = (bytes[i++] != 0) ? (bool)true : (bool)false; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; + ViewerIP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Disconnect = (bytes[i++] != 0) ? (bool)true : (bool)false; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(ViewerIP % 256); - bytes[i++] = (byte)((ViewerIP >> 8) % 256); - bytes[i++] = (byte)((ViewerIP >> 16) % 256); - bytes[i++] = (byte)((ViewerIP >> 24) % 256); - bytes[i++] = (byte)((Disconnect) ? 1 : 0); + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(ViewerIP % 256); + bytes[i++] = (byte)((ViewerIP >> 8) % 256); + bytes[i++] = (byte)((ViewerIP >> 16) % 256); + bytes[i++] = (byte)((ViewerIP >> 24) % 256); + bytes[i++] = (byte)((Disconnect) ? 1 : 0); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- UserData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "ViewerIP: " + ViewerIP.ToString() + "\n"; - output += "Disconnect: " + Disconnect.ToString() + "\n"; + { + string output = "-- UserData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "ViewerIP: " + ViewerIP.ToString() + "\n"; + output += "Disconnect: " + Disconnect.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.DataServerLogout - public override PacketType Type { get { return PacketType.DataServerLogout; } } - /// UserData block - public UserDataBlock UserData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.DataServerLogout + public override PacketType Type { get { return PacketType.DataServerLogout; } } + /// UserData block + public UserDataBlock UserData; + + /// Default constructor public DataServerLogoutPacket() - { - Header = new LowHeader(); - Header.ID = 298; - Header.Reliable = true; - UserData = new UserDataBlock(); + { + Header = new LowHeader(); + Header.ID = 298; + Header.Reliable = true; + UserData = new UserDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public DataServerLogoutPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - UserData = new UserDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + UserData = new UserDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public DataServerLogoutPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - UserData = new UserDataBlock(bytes, ref i); + { + Header = head; + UserData = new UserDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += UserData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - UserData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += UserData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + UserData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- DataServerLogout ---\n"; - output += UserData.ToString() + "\n"; + { + string output = "--- DataServerLogout ---\n"; + output += UserData.ToString() + "\n"; return output; } - + } - - /// LogoutRequest packet + + /// LogoutRequest packet public class LogoutRequestPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.LogoutRequest - public override PacketType Type { get { return PacketType.LogoutRequest; } } - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.LogoutRequest + public override PacketType Type { get { return PacketType.LogoutRequest; } } + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public LogoutRequestPacket() - { - Header = new LowHeader(); - Header.ID = 299; - Header.Reliable = true; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 299; + Header.Reliable = true; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public LogoutRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public LogoutRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- LogoutRequest ---\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- LogoutRequest ---\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// FinalizeLogout packet + + /// FinalizeLogout packet public class FinalizeLogoutPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.FinalizeLogout - public override PacketType Type { get { return PacketType.FinalizeLogout; } } - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.FinalizeLogout + public override PacketType Type { get { return PacketType.FinalizeLogout; } } + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public FinalizeLogoutPacket() - { - Header = new LowHeader(); - Header.ID = 300; - Header.Reliable = true; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 300; + Header.Reliable = true; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public FinalizeLogoutPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public FinalizeLogoutPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- FinalizeLogout ---\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- FinalizeLogout ---\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// LogoutReply packet + + /// LogoutReply packet public class LogoutReplyPacket : Packet - { - /// InventoryData block + { + /// InventoryData block public class InventoryDataBlock - { - /// NewAssetID field - public LLUUID NewAssetID; - /// ItemID field - public LLUUID ItemID; - - /// Length of this block serialized in bytes + { + /// NewAssetID field + public LLUUID NewAssetID; + /// ItemID field + public LLUUID ItemID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public InventoryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public InventoryDataBlock() { } + /// Constructor for building the block from a byte array public InventoryDataBlock(byte[] bytes, ref int i) - { + { try - { - NewAssetID = new LLUUID(bytes, i); i += 16; - ItemID = new LLUUID(bytes, i); i += 16; + { + NewAssetID = new LLUUID(bytes, i); i += 16; + ItemID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(NewAssetID == null) { Console.WriteLine("Warning: NewAssetID is null, in " + this.GetType()); } - Array.Copy(NewAssetID.GetBytes(), 0, bytes, i, 16); i += 16; - if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } - Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(NewAssetID == null) { Console.WriteLine("Warning: NewAssetID is null, in " + this.GetType()); } + Array.Copy(NewAssetID.GetBytes(), 0, bytes, i, 16); i += 16; + if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } + Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- InventoryData --\n"; - output += "NewAssetID: " + NewAssetID.ToString() + "\n"; - output += "ItemID: " + ItemID.ToString() + "\n"; + { + string output = "-- InventoryData --\n"; + output += "NewAssetID: " + NewAssetID.ToString() + "\n"; + output += "ItemID: " + ItemID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.LogoutReply - public override PacketType Type { get { return PacketType.LogoutReply; } } - /// InventoryData block - public InventoryDataBlock[] InventoryData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.LogoutReply + public override PacketType Type { get { return PacketType.LogoutReply; } } + /// InventoryData block + public InventoryDataBlock[] InventoryData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public LogoutReplyPacket() - { - Header = new LowHeader(); - Header.ID = 301; - Header.Reliable = true; - Header.Zerocoded = true; - InventoryData = new InventoryDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 301; + Header.Reliable = true; + Header.Zerocoded = true; + InventoryData = new InventoryDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public LogoutReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - InventoryData = new InventoryDataBlock[count]; - for (int j = 0; j < count; j++) - { InventoryData[j] = new InventoryDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + InventoryData = new InventoryDataBlock[count]; + for (int j = 0; j < count; j++) + { InventoryData[j] = new InventoryDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public LogoutReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - InventoryData = new InventoryDataBlock[count]; - for (int j = 0; j < count; j++) - { InventoryData[j] = new InventoryDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + InventoryData = new InventoryDataBlock[count]; + for (int j = 0; j < count; j++) + { InventoryData[j] = new InventoryDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < InventoryData.Length; j++) { length += InventoryData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)InventoryData.Length; - for (int j = 0; j < InventoryData.Length; j++) { InventoryData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < InventoryData.Length; j++) { length += InventoryData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)InventoryData.Length; + for (int j = 0; j < InventoryData.Length; j++) { InventoryData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- LogoutReply ---\n"; + { + string output = "--- LogoutReply ---\n"; for (int j = 0; j < InventoryData.Length; j++) - { + { output += InventoryData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// LogoutDemand packet + + /// LogoutDemand packet public class LogoutDemandPacket : Packet - { - /// LogoutBlock block + { + /// LogoutBlock block public class LogoutBlockBlock - { - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public LogoutBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public LogoutBlockBlock() { } + /// Constructor for building the block from a byte array public LogoutBlockBlock(byte[] bytes, ref int i) - { + { try - { - SessionID = new LLUUID(bytes, i); i += 16; + { + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- LogoutBlock --\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- LogoutBlock --\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.LogoutDemand - public override PacketType Type { get { return PacketType.LogoutDemand; } } - /// LogoutBlock block - public LogoutBlockBlock LogoutBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.LogoutDemand + public override PacketType Type { get { return PacketType.LogoutDemand; } } + /// LogoutBlock block + public LogoutBlockBlock LogoutBlock; + + /// Default constructor public LogoutDemandPacket() - { - Header = new LowHeader(); - Header.ID = 302; - Header.Reliable = true; - LogoutBlock = new LogoutBlockBlock(); + { + Header = new LowHeader(); + Header.ID = 302; + Header.Reliable = true; + LogoutBlock = new LogoutBlockBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public LogoutDemandPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - LogoutBlock = new LogoutBlockBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + LogoutBlock = new LogoutBlockBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public LogoutDemandPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - LogoutBlock = new LogoutBlockBlock(bytes, ref i); + { + Header = head; + LogoutBlock = new LogoutBlockBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += LogoutBlock.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - LogoutBlock.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += LogoutBlock.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + LogoutBlock.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- LogoutDemand ---\n"; - output += LogoutBlock.ToString() + "\n"; + { + string output = "--- LogoutDemand ---\n"; + output += LogoutBlock.ToString() + "\n"; return output; } - + } - - /// ImprovedInstantMessage packet + + /// ImprovedInstantMessage packet public class ImprovedInstantMessagePacket : Packet - { - /// MessageBlock block + { + /// MessageBlock block public class MessageBlockBlock - { - /// ID field - public LLUUID ID; - /// ToAgentID field - public LLUUID ToAgentID; - /// Offline field - public byte Offline; - /// Timestamp field - public uint Timestamp; - private byte[] _message; - /// Message field + { + /// ID field + public LLUUID ID; + /// ToAgentID field + public LLUUID ToAgentID; + /// Offline field + public byte Offline; + /// Timestamp field + public uint Timestamp; + private byte[] _message; + /// Message field public byte[] Message - { - get { return _message; } + { + get { return _message; } set - { - if (value == null) { _message = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _message = new byte[value.Length]; Array.Copy(value, _message, value.Length); } + { + if (value == null) { _message = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _message = new byte[value.Length]; Array.Copy(value, _message, value.Length); } } - } - /// RegionID field - public LLUUID RegionID; - /// Dialog field - public byte Dialog; - /// FromGroup field - public bool FromGroup; - private byte[] _binarybucket; - /// BinaryBucket field + } + /// RegionID field + public LLUUID RegionID; + /// Dialog field + public byte Dialog; + /// FromGroup field + public bool FromGroup; + private byte[] _binarybucket; + /// BinaryBucket field public byte[] BinaryBucket - { - get { return _binarybucket; } + { + get { return _binarybucket; } set - { - if (value == null) { _binarybucket = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _binarybucket = new byte[value.Length]; Array.Copy(value, _binarybucket, value.Length); } + { + if (value == null) { _binarybucket = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _binarybucket = new byte[value.Length]; Array.Copy(value, _binarybucket, value.Length); } } - } - /// ParentEstateID field - public uint ParentEstateID; - private byte[] _fromagentname; - /// FromAgentName field + } + /// ParentEstateID field + public uint ParentEstateID; + private byte[] _fromagentname; + /// FromAgentName field public byte[] FromAgentName - { - get { return _fromagentname; } + { + get { return _fromagentname; } set - { - if (value == null) { _fromagentname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _fromagentname = new byte[value.Length]; Array.Copy(value, _fromagentname, value.Length); } + { + if (value == null) { _fromagentname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _fromagentname = new byte[value.Length]; Array.Copy(value, _fromagentname, value.Length); } } - } - /// Position field - public LLVector3 Position; - - /// Length of this block serialized in bytes + } + /// Position field + public LLVector3 Position; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 71; - if (Message != null) { length += 2 + Message.Length; } - if (BinaryBucket != null) { length += 2 + BinaryBucket.Length; } - if (FromAgentName != null) { length += 1 + FromAgentName.Length; } - return length; + { + int length = 71; + if (Message != null) { length += 2 + Message.Length; } + if (BinaryBucket != null) { length += 2 + BinaryBucket.Length; } + if (FromAgentName != null) { length += 1 + FromAgentName.Length; } + return length; } } - - /// Default constructor - public MessageBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public MessageBlockBlock() { } + /// Constructor for building the block from a byte array public MessageBlockBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - ID = new LLUUID(bytes, i); i += 16; - ToAgentID = new LLUUID(bytes, i); i += 16; - Offline = (byte)bytes[i++]; - Timestamp = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _message = new byte[length]; - Array.Copy(bytes, i, _message, 0, length); i += length; - RegionID = new LLUUID(bytes, i); i += 16; - Dialog = (byte)bytes[i++]; - FromGroup = (bytes[i++] != 0) ? (bool)true : (bool)false; - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _binarybucket = new byte[length]; - Array.Copy(bytes, i, _binarybucket, 0, length); i += length; - ParentEstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _fromagentname = new byte[length]; - Array.Copy(bytes, i, _fromagentname, 0, length); i += length; - Position = new LLVector3(bytes, i); i += 12; + { + ID = new LLUUID(bytes, i); i += 16; + ToAgentID = new LLUUID(bytes, i); i += 16; + Offline = (byte)bytes[i++]; + Timestamp = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _message = new byte[length]; + Array.Copy(bytes, i, _message, 0, length); i += length; + RegionID = new LLUUID(bytes, i); i += 16; + Dialog = (byte)bytes[i++]; + FromGroup = (bytes[i++] != 0) ? (bool)true : (bool)false; + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _binarybucket = new byte[length]; + Array.Copy(bytes, i, _binarybucket, 0, length); i += length; + ParentEstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _fromagentname = new byte[length]; + Array.Copy(bytes, i, _fromagentname, 0, length); i += length; + Position = new LLVector3(bytes, i); i += 12; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } - Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; - if(ToAgentID == null) { Console.WriteLine("Warning: ToAgentID is null, in " + this.GetType()); } - Array.Copy(ToAgentID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = Offline; - bytes[i++] = (byte)(Timestamp % 256); - bytes[i++] = (byte)((Timestamp >> 8) % 256); - bytes[i++] = (byte)((Timestamp >> 16) % 256); - bytes[i++] = (byte)((Timestamp >> 24) % 256); - if(Message == null) { Console.WriteLine("Warning: Message is null, in " + this.GetType()); } - bytes[i++] = (byte)(Message.Length % 256); - bytes[i++] = (byte)((Message.Length >> 8) % 256); - Array.Copy(Message, 0, bytes, i, Message.Length); i += Message.Length; - if(RegionID == null) { Console.WriteLine("Warning: RegionID is null, in " + this.GetType()); } - Array.Copy(RegionID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = Dialog; - bytes[i++] = (byte)((FromGroup) ? 1 : 0); - if(BinaryBucket == null) { Console.WriteLine("Warning: BinaryBucket is null, in " + this.GetType()); } - bytes[i++] = (byte)(BinaryBucket.Length % 256); - bytes[i++] = (byte)((BinaryBucket.Length >> 8) % 256); - Array.Copy(BinaryBucket, 0, bytes, i, BinaryBucket.Length); i += BinaryBucket.Length; - bytes[i++] = (byte)(ParentEstateID % 256); - bytes[i++] = (byte)((ParentEstateID >> 8) % 256); - bytes[i++] = (byte)((ParentEstateID >> 16) % 256); - bytes[i++] = (byte)((ParentEstateID >> 24) % 256); - if(FromAgentName == null) { Console.WriteLine("Warning: FromAgentName is null, in " + this.GetType()); } - bytes[i++] = (byte)FromAgentName.Length; - Array.Copy(FromAgentName, 0, bytes, i, FromAgentName.Length); i += FromAgentName.Length; - if(Position == null) { Console.WriteLine("Warning: Position is null, in " + this.GetType()); } - Array.Copy(Position.GetBytes(), 0, bytes, i, 12); i += 12; + { + if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } + Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; + if(ToAgentID == null) { Console.WriteLine("Warning: ToAgentID is null, in " + this.GetType()); } + Array.Copy(ToAgentID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = Offline; + bytes[i++] = (byte)(Timestamp % 256); + bytes[i++] = (byte)((Timestamp >> 8) % 256); + bytes[i++] = (byte)((Timestamp >> 16) % 256); + bytes[i++] = (byte)((Timestamp >> 24) % 256); + if(Message == null) { Console.WriteLine("Warning: Message is null, in " + this.GetType()); } + bytes[i++] = (byte)(Message.Length % 256); + bytes[i++] = (byte)((Message.Length >> 8) % 256); + Array.Copy(Message, 0, bytes, i, Message.Length); i += Message.Length; + if(RegionID == null) { Console.WriteLine("Warning: RegionID is null, in " + this.GetType()); } + Array.Copy(RegionID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = Dialog; + bytes[i++] = (byte)((FromGroup) ? 1 : 0); + if(BinaryBucket == null) { Console.WriteLine("Warning: BinaryBucket is null, in " + this.GetType()); } + bytes[i++] = (byte)(BinaryBucket.Length % 256); + bytes[i++] = (byte)((BinaryBucket.Length >> 8) % 256); + Array.Copy(BinaryBucket, 0, bytes, i, BinaryBucket.Length); i += BinaryBucket.Length; + bytes[i++] = (byte)(ParentEstateID % 256); + bytes[i++] = (byte)((ParentEstateID >> 8) % 256); + bytes[i++] = (byte)((ParentEstateID >> 16) % 256); + bytes[i++] = (byte)((ParentEstateID >> 24) % 256); + if(FromAgentName == null) { Console.WriteLine("Warning: FromAgentName is null, in " + this.GetType()); } + bytes[i++] = (byte)FromAgentName.Length; + Array.Copy(FromAgentName, 0, bytes, i, FromAgentName.Length); i += FromAgentName.Length; + if(Position == null) { Console.WriteLine("Warning: Position is null, in " + this.GetType()); } + Array.Copy(Position.GetBytes(), 0, bytes, i, 12); i += 12; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- MessageBlock --\n"; - output += "ID: " + ID.ToString() + "\n"; - output += "ToAgentID: " + ToAgentID.ToString() + "\n"; - output += "Offline: " + Offline.ToString() + "\n"; - output += "Timestamp: " + Timestamp.ToString() + "\n"; - output += Helpers.FieldToString(Message, "Message") + "\n"; - output += "RegionID: " + RegionID.ToString() + "\n"; - output += "Dialog: " + Dialog.ToString() + "\n"; - output += "FromGroup: " + FromGroup.ToString() + "\n"; - output += Helpers.FieldToString(BinaryBucket, "BinaryBucket") + "\n"; - output += "ParentEstateID: " + ParentEstateID.ToString() + "\n"; - output += Helpers.FieldToString(FromAgentName, "FromAgentName") + "\n"; - output += "Position: " + Position.ToString() + "\n"; + { + string output = "-- MessageBlock --\n"; + output += "ID: " + ID.ToString() + "\n"; + output += "ToAgentID: " + ToAgentID.ToString() + "\n"; + output += "Offline: " + Offline.ToString() + "\n"; + output += "Timestamp: " + Timestamp.ToString() + "\n"; + output += Helpers.FieldToString(Message, "Message") + "\n"; + output += "RegionID: " + RegionID.ToString() + "\n"; + output += "Dialog: " + Dialog.ToString() + "\n"; + output += "FromGroup: " + FromGroup.ToString() + "\n"; + output += Helpers.FieldToString(BinaryBucket, "BinaryBucket") + "\n"; + output += "ParentEstateID: " + ParentEstateID.ToString() + "\n"; + output += Helpers.FieldToString(FromAgentName, "FromAgentName") + "\n"; + output += "Position: " + Position.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ImprovedInstantMessage - public override PacketType Type { get { return PacketType.ImprovedInstantMessage; } } - /// MessageBlock block - public MessageBlockBlock MessageBlock; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ImprovedInstantMessage + public override PacketType Type { get { return PacketType.ImprovedInstantMessage; } } + /// MessageBlock block + public MessageBlockBlock MessageBlock; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ImprovedInstantMessagePacket() - { - Header = new LowHeader(); - Header.ID = 303; - Header.Reliable = true; - Header.Zerocoded = true; - MessageBlock = new MessageBlockBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 303; + Header.Reliable = true; + Header.Zerocoded = true; + MessageBlock = new MessageBlockBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ImprovedInstantMessagePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - MessageBlock = new MessageBlockBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + MessageBlock = new MessageBlockBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ImprovedInstantMessagePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - MessageBlock = new MessageBlockBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + MessageBlock = new MessageBlockBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += MessageBlock.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - MessageBlock.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += MessageBlock.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + MessageBlock.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ImprovedInstantMessage ---\n"; - output += MessageBlock.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- ImprovedInstantMessage ---\n"; + output += MessageBlock.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// RetrieveInstantMessages packet + + /// RetrieveInstantMessages packet public class RetrieveInstantMessagesPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.RetrieveInstantMessages - public override PacketType Type { get { return PacketType.RetrieveInstantMessages; } } - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.RetrieveInstantMessages + public override PacketType Type { get { return PacketType.RetrieveInstantMessages; } } + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public RetrieveInstantMessagesPacket() - { - Header = new LowHeader(); - Header.ID = 304; - Header.Reliable = true; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 304; + Header.Reliable = true; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public RetrieveInstantMessagesPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public RetrieveInstantMessagesPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- RetrieveInstantMessages ---\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- RetrieveInstantMessages ---\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// DequeueInstantMessages packet + + /// DequeueInstantMessages packet public class DequeueInstantMessagesPacket : Packet - { - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.DequeueInstantMessages - public override PacketType Type { get { return PacketType.DequeueInstantMessages; } } - - /// Default constructor + { + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.DequeueInstantMessages + public override PacketType Type { get { return PacketType.DequeueInstantMessages; } } + + /// Default constructor public DequeueInstantMessagesPacket() - { - Header = new LowHeader(); - Header.ID = 305; - Header.Reliable = true; + { + Header = new LowHeader(); + Header.ID = 305; + Header.Reliable = true; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public DequeueInstantMessagesPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public DequeueInstantMessagesPacket(Header head, byte[] bytes, ref int i) - { - Header = head; + { + Header = head; } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; -; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; +; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- DequeueInstantMessages ---\n"; + { + string output = "--- DequeueInstantMessages ---\n"; return output; } - + } - - /// FindAgent packet + + /// FindAgent packet public class FindAgentPacket : Packet - { - /// LocationBlock block + { + /// LocationBlock block public class LocationBlockBlock - { - /// GlobalX field - public double GlobalX; - /// GlobalY field - public double GlobalY; - - /// Length of this block serialized in bytes + { + /// GlobalX field + public double GlobalX; + /// GlobalY field + public double GlobalY; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public LocationBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public LocationBlockBlock() { } + /// Constructor for building the block from a byte array public LocationBlockBlock(byte[] bytes, ref int i) - { + { try - { - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 8); - GlobalX = BitConverter.ToDouble(bytes, i); i += 8; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 8); - GlobalY = BitConverter.ToDouble(bytes, i); i += 8; + { + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 8); + GlobalX = BitConverter.ToDouble(bytes, i); i += 8; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 8); + GlobalY = BitConverter.ToDouble(bytes, i); i += 8; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; + { + byte[] ba; ba = BitConverter.GetBytes(GlobalX); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 8); } - Array.Copy(ba, 0, bytes, i, 8); i += 8; + Array.Copy(ba, 0, bytes, i, 8); i += 8; ba = BitConverter.GetBytes(GlobalY); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 8); } - Array.Copy(ba, 0, bytes, i, 8); i += 8; + Array.Copy(ba, 0, bytes, i, 8); i += 8; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- LocationBlock --\n"; - output += "GlobalX: " + GlobalX.ToString() + "\n"; - output += "GlobalY: " + GlobalY.ToString() + "\n"; + { + string output = "-- LocationBlock --\n"; + output += "GlobalX: " + GlobalX.ToString() + "\n"; + output += "GlobalY: " + GlobalY.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentBlock block + + /// AgentBlock block public class AgentBlockBlock - { - /// SpaceIP field - public uint SpaceIP; - /// Prey field - public LLUUID Prey; - /// Hunter field - public LLUUID Hunter; - - /// Length of this block serialized in bytes + { + /// SpaceIP field + public uint SpaceIP; + /// Prey field + public LLUUID Prey; + /// Hunter field + public LLUUID Hunter; + + /// Length of this block serialized in bytes public int Length { get - { - return 36; + { + return 36; } } - - /// Default constructor - public AgentBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentBlockBlock() { } + /// Constructor for building the block from a byte array public AgentBlockBlock(byte[] bytes, ref int i) - { + { try - { - SpaceIP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Prey = new LLUUID(bytes, i); i += 16; - Hunter = new LLUUID(bytes, i); i += 16; + { + SpaceIP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Prey = new LLUUID(bytes, i); i += 16; + Hunter = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(SpaceIP % 256); - bytes[i++] = (byte)((SpaceIP >> 8) % 256); - bytes[i++] = (byte)((SpaceIP >> 16) % 256); - bytes[i++] = (byte)((SpaceIP >> 24) % 256); - if(Prey == null) { Console.WriteLine("Warning: Prey is null, in " + this.GetType()); } - Array.Copy(Prey.GetBytes(), 0, bytes, i, 16); i += 16; - if(Hunter == null) { Console.WriteLine("Warning: Hunter is null, in " + this.GetType()); } - Array.Copy(Hunter.GetBytes(), 0, bytes, i, 16); i += 16; + { + bytes[i++] = (byte)(SpaceIP % 256); + bytes[i++] = (byte)((SpaceIP >> 8) % 256); + bytes[i++] = (byte)((SpaceIP >> 16) % 256); + bytes[i++] = (byte)((SpaceIP >> 24) % 256); + if(Prey == null) { Console.WriteLine("Warning: Prey is null, in " + this.GetType()); } + Array.Copy(Prey.GetBytes(), 0, bytes, i, 16); i += 16; + if(Hunter == null) { Console.WriteLine("Warning: Hunter is null, in " + this.GetType()); } + Array.Copy(Hunter.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentBlock --\n"; - output += "SpaceIP: " + SpaceIP.ToString() + "\n"; - output += "Prey: " + Prey.ToString() + "\n"; - output += "Hunter: " + Hunter.ToString() + "\n"; + { + string output = "-- AgentBlock --\n"; + output += "SpaceIP: " + SpaceIP.ToString() + "\n"; + output += "Prey: " + Prey.ToString() + "\n"; + output += "Hunter: " + Hunter.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.FindAgent - public override PacketType Type { get { return PacketType.FindAgent; } } - /// LocationBlock block - public LocationBlockBlock[] LocationBlock; - /// AgentBlock block - public AgentBlockBlock AgentBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.FindAgent + public override PacketType Type { get { return PacketType.FindAgent; } } + /// LocationBlock block + public LocationBlockBlock[] LocationBlock; + /// AgentBlock block + public AgentBlockBlock AgentBlock; + + /// Default constructor public FindAgentPacket() - { - Header = new LowHeader(); - Header.ID = 306; - Header.Reliable = true; - LocationBlock = new LocationBlockBlock[0]; - AgentBlock = new AgentBlockBlock(); + { + Header = new LowHeader(); + Header.ID = 306; + Header.Reliable = true; + LocationBlock = new LocationBlockBlock[0]; + AgentBlock = new AgentBlockBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public FindAgentPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - LocationBlock = new LocationBlockBlock[count]; - for (int j = 0; j < count; j++) - { LocationBlock[j] = new LocationBlockBlock(bytes, ref i); } - AgentBlock = new AgentBlockBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + LocationBlock = new LocationBlockBlock[count]; + for (int j = 0; j < count; j++) + { LocationBlock[j] = new LocationBlockBlock(bytes, ref i); } + AgentBlock = new AgentBlockBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public FindAgentPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - LocationBlock = new LocationBlockBlock[count]; - for (int j = 0; j < count; j++) - { LocationBlock[j] = new LocationBlockBlock(bytes, ref i); } - AgentBlock = new AgentBlockBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + LocationBlock = new LocationBlockBlock[count]; + for (int j = 0; j < count; j++) + { LocationBlock[j] = new LocationBlockBlock(bytes, ref i); } + AgentBlock = new AgentBlockBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentBlock.Length;; - length++; - for (int j = 0; j < LocationBlock.Length; j++) { length += LocationBlock[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)LocationBlock.Length; - for (int j = 0; j < LocationBlock.Length; j++) { LocationBlock[j].ToBytes(bytes, ref i); } - AgentBlock.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentBlock.Length;; + length++; + for (int j = 0; j < LocationBlock.Length; j++) { length += LocationBlock[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)LocationBlock.Length; + for (int j = 0; j < LocationBlock.Length; j++) { LocationBlock[j].ToBytes(bytes, ref i); } + AgentBlock.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- FindAgent ---\n"; + { + string output = "--- FindAgent ---\n"; for (int j = 0; j < LocationBlock.Length; j++) - { + { output += LocationBlock[j].ToString() + "\n"; - } - output += AgentBlock.ToString() + "\n"; + } + output += AgentBlock.ToString() + "\n"; return output; } - + } - - /// RequestGodlikePowers packet + + /// RequestGodlikePowers packet public class RequestGodlikePowersPacket : Packet - { - /// RequestBlock block + { + /// RequestBlock block public class RequestBlockBlock - { - /// Godlike field - public bool Godlike; - /// Token field - public LLUUID Token; - - /// Length of this block serialized in bytes + { + /// Godlike field + public bool Godlike; + /// Token field + public LLUUID Token; + + /// Length of this block serialized in bytes public int Length { get - { - return 17; + { + return 17; } } - - /// Default constructor - public RequestBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public RequestBlockBlock() { } + /// Constructor for building the block from a byte array public RequestBlockBlock(byte[] bytes, ref int i) - { + { try - { - Godlike = (bytes[i++] != 0) ? (bool)true : (bool)false; - Token = new LLUUID(bytes, i); i += 16; + { + Godlike = (bytes[i++] != 0) ? (bool)true : (bool)false; + Token = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)((Godlike) ? 1 : 0); - if(Token == null) { Console.WriteLine("Warning: Token is null, in " + this.GetType()); } - Array.Copy(Token.GetBytes(), 0, bytes, i, 16); i += 16; + { + bytes[i++] = (byte)((Godlike) ? 1 : 0); + if(Token == null) { Console.WriteLine("Warning: Token is null, in " + this.GetType()); } + Array.Copy(Token.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- RequestBlock --\n"; - output += "Godlike: " + Godlike.ToString() + "\n"; - output += "Token: " + Token.ToString() + "\n"; + { + string output = "-- RequestBlock --\n"; + output += "Godlike: " + Godlike.ToString() + "\n"; + output += "Token: " + Token.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.RequestGodlikePowers - public override PacketType Type { get { return PacketType.RequestGodlikePowers; } } - /// RequestBlock block - public RequestBlockBlock RequestBlock; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.RequestGodlikePowers + public override PacketType Type { get { return PacketType.RequestGodlikePowers; } } + /// RequestBlock block + public RequestBlockBlock RequestBlock; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public RequestGodlikePowersPacket() - { - Header = new LowHeader(); - Header.ID = 307; - Header.Reliable = true; - RequestBlock = new RequestBlockBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 307; + Header.Reliable = true; + RequestBlock = new RequestBlockBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public RequestGodlikePowersPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - RequestBlock = new RequestBlockBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + RequestBlock = new RequestBlockBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public RequestGodlikePowersPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - RequestBlock = new RequestBlockBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + RequestBlock = new RequestBlockBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += RequestBlock.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - RequestBlock.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += RequestBlock.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + RequestBlock.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- RequestGodlikePowers ---\n"; - output += RequestBlock.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- RequestGodlikePowers ---\n"; + output += RequestBlock.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// GrantGodlikePowers packet + + /// GrantGodlikePowers packet public class GrantGodlikePowersPacket : Packet - { - /// GrantData block + { + /// GrantData block public class GrantDataBlock - { - /// GodLevel field - public byte GodLevel; - /// Token field - public LLUUID Token; - - /// Length of this block serialized in bytes + { + /// GodLevel field + public byte GodLevel; + /// Token field + public LLUUID Token; + + /// Length of this block serialized in bytes public int Length { get - { - return 17; + { + return 17; } } - - /// Default constructor - public GrantDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public GrantDataBlock() { } + /// Constructor for building the block from a byte array public GrantDataBlock(byte[] bytes, ref int i) - { + { try - { - GodLevel = (byte)bytes[i++]; - Token = new LLUUID(bytes, i); i += 16; + { + GodLevel = (byte)bytes[i++]; + Token = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = GodLevel; - if(Token == null) { Console.WriteLine("Warning: Token is null, in " + this.GetType()); } - Array.Copy(Token.GetBytes(), 0, bytes, i, 16); i += 16; + { + bytes[i++] = GodLevel; + if(Token == null) { Console.WriteLine("Warning: Token is null, in " + this.GetType()); } + Array.Copy(Token.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- GrantData --\n"; - output += "GodLevel: " + GodLevel.ToString() + "\n"; - output += "Token: " + Token.ToString() + "\n"; + { + string output = "-- GrantData --\n"; + output += "GodLevel: " + GodLevel.ToString() + "\n"; + output += "Token: " + Token.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.GrantGodlikePowers - public override PacketType Type { get { return PacketType.GrantGodlikePowers; } } - /// GrantData block - public GrantDataBlock GrantData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.GrantGodlikePowers + public override PacketType Type { get { return PacketType.GrantGodlikePowers; } } + /// GrantData block + public GrantDataBlock GrantData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public GrantGodlikePowersPacket() - { - Header = new LowHeader(); - Header.ID = 308; - Header.Reliable = true; - GrantData = new GrantDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 308; + Header.Reliable = true; + GrantData = new GrantDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public GrantGodlikePowersPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - GrantData = new GrantDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + GrantData = new GrantDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public GrantGodlikePowersPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - GrantData = new GrantDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + GrantData = new GrantDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += GrantData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - GrantData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += GrantData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + GrantData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- GrantGodlikePowers ---\n"; - output += GrantData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- GrantGodlikePowers ---\n"; + output += GrantData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// GodlikeMessage packet + + /// GodlikeMessage packet public class GodlikeMessagePacket : Packet - { - /// MethodData block + { + /// MethodData block public class MethodDataBlock - { - /// Invoice field - public LLUUID Invoice; - private byte[] _method; - /// Method field + { + /// Invoice field + public LLUUID Invoice; + private byte[] _method; + /// Method field public byte[] Method - { - get { return _method; } + { + get { return _method; } set - { - if (value == null) { _method = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _method = new byte[value.Length]; Array.Copy(value, _method, value.Length); } + { + if (value == null) { _method = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _method = new byte[value.Length]; Array.Copy(value, _method, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 16; - if (Method != null) { length += 1 + Method.Length; } - return length; + { + int length = 16; + if (Method != null) { length += 1 + Method.Length; } + return length; } } - - /// Default constructor - public MethodDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public MethodDataBlock() { } + /// Constructor for building the block from a byte array public MethodDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - Invoice = new LLUUID(bytes, i); i += 16; - length = (ushort)bytes[i++]; - _method = new byte[length]; - Array.Copy(bytes, i, _method, 0, length); i += length; + { + Invoice = new LLUUID(bytes, i); i += 16; + length = (ushort)bytes[i++]; + _method = new byte[length]; + Array.Copy(bytes, i, _method, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(Invoice == null) { Console.WriteLine("Warning: Invoice is null, in " + this.GetType()); } - Array.Copy(Invoice.GetBytes(), 0, bytes, i, 16); i += 16; - if(Method == null) { Console.WriteLine("Warning: Method is null, in " + this.GetType()); } - bytes[i++] = (byte)Method.Length; - Array.Copy(Method, 0, bytes, i, Method.Length); i += Method.Length; + { + if(Invoice == null) { Console.WriteLine("Warning: Invoice is null, in " + this.GetType()); } + Array.Copy(Invoice.GetBytes(), 0, bytes, i, 16); i += 16; + if(Method == null) { Console.WriteLine("Warning: Method is null, in " + this.GetType()); } + bytes[i++] = (byte)Method.Length; + Array.Copy(Method, 0, bytes, i, Method.Length); i += Method.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- MethodData --\n"; - output += "Invoice: " + Invoice.ToString() + "\n"; - output += Helpers.FieldToString(Method, "Method") + "\n"; + { + string output = "-- MethodData --\n"; + output += "Invoice: " + Invoice.ToString() + "\n"; + output += Helpers.FieldToString(Method, "Method") + "\n"; output = output.Trim(); return output; - } + } } - - /// ParamList block + + /// ParamList block public class ParamListBlock - { - private byte[] _parameter; - /// Parameter field + { + private byte[] _parameter; + /// Parameter field public byte[] Parameter - { - get { return _parameter; } + { + get { return _parameter; } set - { - if (value == null) { _parameter = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _parameter = new byte[value.Length]; Array.Copy(value, _parameter, value.Length); } + { + if (value == null) { _parameter = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _parameter = new byte[value.Length]; Array.Copy(value, _parameter, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 0; - if (Parameter != null) { length += 1 + Parameter.Length; } - return length; + { + int length = 0; + if (Parameter != null) { length += 1 + Parameter.Length; } + return length; } } - - /// Default constructor - public ParamListBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ParamListBlock() { } + /// Constructor for building the block from a byte array public ParamListBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _parameter = new byte[length]; - Array.Copy(bytes, i, _parameter, 0, length); i += length; + { + length = (ushort)bytes[i++]; + _parameter = new byte[length]; + Array.Copy(bytes, i, _parameter, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(Parameter == null) { Console.WriteLine("Warning: Parameter is null, in " + this.GetType()); } - bytes[i++] = (byte)Parameter.Length; - Array.Copy(Parameter, 0, bytes, i, Parameter.Length); i += Parameter.Length; + { + if(Parameter == null) { Console.WriteLine("Warning: Parameter is null, in " + this.GetType()); } + bytes[i++] = (byte)Parameter.Length; + Array.Copy(Parameter, 0, bytes, i, Parameter.Length); i += Parameter.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ParamList --\n"; - output += Helpers.FieldToString(Parameter, "Parameter") + "\n"; + { + string output = "-- ParamList --\n"; + output += Helpers.FieldToString(Parameter, "Parameter") + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.GodlikeMessage - public override PacketType Type { get { return PacketType.GodlikeMessage; } } - /// MethodData block - public MethodDataBlock MethodData; - /// ParamList block - public ParamListBlock[] ParamList; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.GodlikeMessage + public override PacketType Type { get { return PacketType.GodlikeMessage; } } + /// MethodData block + public MethodDataBlock MethodData; + /// ParamList block + public ParamListBlock[] ParamList; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public GodlikeMessagePacket() - { - Header = new LowHeader(); - Header.ID = 309; - Header.Reliable = true; - Header.Zerocoded = true; - MethodData = new MethodDataBlock(); - ParamList = new ParamListBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 309; + Header.Reliable = true; + Header.Zerocoded = true; + MethodData = new MethodDataBlock(); + ParamList = new ParamListBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public GodlikeMessagePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - MethodData = new MethodDataBlock(bytes, ref i); - int count = (int)bytes[i++]; - ParamList = new ParamListBlock[count]; - for (int j = 0; j < count; j++) - { ParamList[j] = new ParamListBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + MethodData = new MethodDataBlock(bytes, ref i); + int count = (int)bytes[i++]; + ParamList = new ParamListBlock[count]; + for (int j = 0; j < count; j++) + { ParamList[j] = new ParamListBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public GodlikeMessagePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - MethodData = new MethodDataBlock(bytes, ref i); - int count = (int)bytes[i++]; - ParamList = new ParamListBlock[count]; - for (int j = 0; j < count; j++) - { ParamList[j] = new ParamListBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + MethodData = new MethodDataBlock(bytes, ref i); + int count = (int)bytes[i++]; + ParamList = new ParamListBlock[count]; + for (int j = 0; j < count; j++) + { ParamList[j] = new ParamListBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += MethodData.Length; length += AgentData.Length;; - length++; - for (int j = 0; j < ParamList.Length; j++) { length += ParamList[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - MethodData.ToBytes(bytes, ref i); - bytes[i++] = (byte)ParamList.Length; - for (int j = 0; j < ParamList.Length; j++) { ParamList[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += MethodData.Length; length += AgentData.Length;; + length++; + for (int j = 0; j < ParamList.Length; j++) { length += ParamList[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + MethodData.ToBytes(bytes, ref i); + bytes[i++] = (byte)ParamList.Length; + for (int j = 0; j < ParamList.Length; j++) { ParamList[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- GodlikeMessage ---\n"; - output += MethodData.ToString() + "\n"; + { + string output = "--- GodlikeMessage ---\n"; + output += MethodData.ToString() + "\n"; for (int j = 0; j < ParamList.Length; j++) - { + { output += ParamList[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// EstateOwnerMessage packet + + /// EstateOwnerMessage packet public class EstateOwnerMessagePacket : Packet - { - /// MethodData block + { + /// MethodData block public class MethodDataBlock - { - /// Invoice field - public LLUUID Invoice; - private byte[] _method; - /// Method field + { + /// Invoice field + public LLUUID Invoice; + private byte[] _method; + /// Method field public byte[] Method - { - get { return _method; } + { + get { return _method; } set - { - if (value == null) { _method = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _method = new byte[value.Length]; Array.Copy(value, _method, value.Length); } + { + if (value == null) { _method = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _method = new byte[value.Length]; Array.Copy(value, _method, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 16; - if (Method != null) { length += 1 + Method.Length; } - return length; + { + int length = 16; + if (Method != null) { length += 1 + Method.Length; } + return length; } } - - /// Default constructor - public MethodDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public MethodDataBlock() { } + /// Constructor for building the block from a byte array public MethodDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - Invoice = new LLUUID(bytes, i); i += 16; - length = (ushort)bytes[i++]; - _method = new byte[length]; - Array.Copy(bytes, i, _method, 0, length); i += length; + { + Invoice = new LLUUID(bytes, i); i += 16; + length = (ushort)bytes[i++]; + _method = new byte[length]; + Array.Copy(bytes, i, _method, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(Invoice == null) { Console.WriteLine("Warning: Invoice is null, in " + this.GetType()); } - Array.Copy(Invoice.GetBytes(), 0, bytes, i, 16); i += 16; - if(Method == null) { Console.WriteLine("Warning: Method is null, in " + this.GetType()); } - bytes[i++] = (byte)Method.Length; - Array.Copy(Method, 0, bytes, i, Method.Length); i += Method.Length; + { + if(Invoice == null) { Console.WriteLine("Warning: Invoice is null, in " + this.GetType()); } + Array.Copy(Invoice.GetBytes(), 0, bytes, i, 16); i += 16; + if(Method == null) { Console.WriteLine("Warning: Method is null, in " + this.GetType()); } + bytes[i++] = (byte)Method.Length; + Array.Copy(Method, 0, bytes, i, Method.Length); i += Method.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- MethodData --\n"; - output += "Invoice: " + Invoice.ToString() + "\n"; - output += Helpers.FieldToString(Method, "Method") + "\n"; + { + string output = "-- MethodData --\n"; + output += "Invoice: " + Invoice.ToString() + "\n"; + output += Helpers.FieldToString(Method, "Method") + "\n"; output = output.Trim(); return output; - } + } } - - /// ParamList block + + /// ParamList block public class ParamListBlock - { - private byte[] _parameter; - /// Parameter field + { + private byte[] _parameter; + /// Parameter field public byte[] Parameter - { - get { return _parameter; } + { + get { return _parameter; } set - { - if (value == null) { _parameter = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _parameter = new byte[value.Length]; Array.Copy(value, _parameter, value.Length); } + { + if (value == null) { _parameter = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _parameter = new byte[value.Length]; Array.Copy(value, _parameter, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 0; - if (Parameter != null) { length += 1 + Parameter.Length; } - return length; + { + int length = 0; + if (Parameter != null) { length += 1 + Parameter.Length; } + return length; } } - - /// Default constructor - public ParamListBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ParamListBlock() { } + /// Constructor for building the block from a byte array public ParamListBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _parameter = new byte[length]; - Array.Copy(bytes, i, _parameter, 0, length); i += length; + { + length = (ushort)bytes[i++]; + _parameter = new byte[length]; + Array.Copy(bytes, i, _parameter, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(Parameter == null) { Console.WriteLine("Warning: Parameter is null, in " + this.GetType()); } - bytes[i++] = (byte)Parameter.Length; - Array.Copy(Parameter, 0, bytes, i, Parameter.Length); i += Parameter.Length; + { + if(Parameter == null) { Console.WriteLine("Warning: Parameter is null, in " + this.GetType()); } + bytes[i++] = (byte)Parameter.Length; + Array.Copy(Parameter, 0, bytes, i, Parameter.Length); i += Parameter.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ParamList --\n"; - output += Helpers.FieldToString(Parameter, "Parameter") + "\n"; + { + string output = "-- ParamList --\n"; + output += Helpers.FieldToString(Parameter, "Parameter") + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.EstateOwnerMessage - public override PacketType Type { get { return PacketType.EstateOwnerMessage; } } - /// MethodData block - public MethodDataBlock MethodData; - /// ParamList block - public ParamListBlock[] ParamList; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.EstateOwnerMessage + public override PacketType Type { get { return PacketType.EstateOwnerMessage; } } + /// MethodData block + public MethodDataBlock MethodData; + /// ParamList block + public ParamListBlock[] ParamList; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public EstateOwnerMessagePacket() - { - Header = new LowHeader(); - Header.ID = 310; - Header.Reliable = true; - Header.Zerocoded = true; - MethodData = new MethodDataBlock(); - ParamList = new ParamListBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 310; + Header.Reliable = true; + Header.Zerocoded = true; + MethodData = new MethodDataBlock(); + ParamList = new ParamListBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public EstateOwnerMessagePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - MethodData = new MethodDataBlock(bytes, ref i); - int count = (int)bytes[i++]; - ParamList = new ParamListBlock[count]; - for (int j = 0; j < count; j++) - { ParamList[j] = new ParamListBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + MethodData = new MethodDataBlock(bytes, ref i); + int count = (int)bytes[i++]; + ParamList = new ParamListBlock[count]; + for (int j = 0; j < count; j++) + { ParamList[j] = new ParamListBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public EstateOwnerMessagePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - MethodData = new MethodDataBlock(bytes, ref i); - int count = (int)bytes[i++]; - ParamList = new ParamListBlock[count]; - for (int j = 0; j < count; j++) - { ParamList[j] = new ParamListBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + MethodData = new MethodDataBlock(bytes, ref i); + int count = (int)bytes[i++]; + ParamList = new ParamListBlock[count]; + for (int j = 0; j < count; j++) + { ParamList[j] = new ParamListBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += MethodData.Length; length += AgentData.Length;; - length++; - for (int j = 0; j < ParamList.Length; j++) { length += ParamList[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - MethodData.ToBytes(bytes, ref i); - bytes[i++] = (byte)ParamList.Length; - for (int j = 0; j < ParamList.Length; j++) { ParamList[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += MethodData.Length; length += AgentData.Length;; + length++; + for (int j = 0; j < ParamList.Length; j++) { length += ParamList[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + MethodData.ToBytes(bytes, ref i); + bytes[i++] = (byte)ParamList.Length; + for (int j = 0; j < ParamList.Length; j++) { ParamList[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- EstateOwnerMessage ---\n"; - output += MethodData.ToString() + "\n"; + { + string output = "--- EstateOwnerMessage ---\n"; + output += MethodData.ToString() + "\n"; for (int j = 0; j < ParamList.Length; j++) - { + { output += ParamList[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// GenericMessage packet + + /// GenericMessage packet public class GenericMessagePacket : Packet - { - /// MethodData block + { + /// MethodData block public class MethodDataBlock - { - /// Invoice field - public LLUUID Invoice; - private byte[] _method; - /// Method field + { + /// Invoice field + public LLUUID Invoice; + private byte[] _method; + /// Method field public byte[] Method - { - get { return _method; } + { + get { return _method; } set - { - if (value == null) { _method = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _method = new byte[value.Length]; Array.Copy(value, _method, value.Length); } + { + if (value == null) { _method = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _method = new byte[value.Length]; Array.Copy(value, _method, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 16; - if (Method != null) { length += 1 + Method.Length; } - return length; + { + int length = 16; + if (Method != null) { length += 1 + Method.Length; } + return length; } } - - /// Default constructor - public MethodDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public MethodDataBlock() { } + /// Constructor for building the block from a byte array public MethodDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - Invoice = new LLUUID(bytes, i); i += 16; - length = (ushort)bytes[i++]; - _method = new byte[length]; - Array.Copy(bytes, i, _method, 0, length); i += length; + { + Invoice = new LLUUID(bytes, i); i += 16; + length = (ushort)bytes[i++]; + _method = new byte[length]; + Array.Copy(bytes, i, _method, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(Invoice == null) { Console.WriteLine("Warning: Invoice is null, in " + this.GetType()); } - Array.Copy(Invoice.GetBytes(), 0, bytes, i, 16); i += 16; - if(Method == null) { Console.WriteLine("Warning: Method is null, in " + this.GetType()); } - bytes[i++] = (byte)Method.Length; - Array.Copy(Method, 0, bytes, i, Method.Length); i += Method.Length; + { + if(Invoice == null) { Console.WriteLine("Warning: Invoice is null, in " + this.GetType()); } + Array.Copy(Invoice.GetBytes(), 0, bytes, i, 16); i += 16; + if(Method == null) { Console.WriteLine("Warning: Method is null, in " + this.GetType()); } + bytes[i++] = (byte)Method.Length; + Array.Copy(Method, 0, bytes, i, Method.Length); i += Method.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- MethodData --\n"; - output += "Invoice: " + Invoice.ToString() + "\n"; - output += Helpers.FieldToString(Method, "Method") + "\n"; + { + string output = "-- MethodData --\n"; + output += "Invoice: " + Invoice.ToString() + "\n"; + output += Helpers.FieldToString(Method, "Method") + "\n"; output = output.Trim(); return output; - } + } } - - /// ParamList block + + /// ParamList block public class ParamListBlock - { - private byte[] _parameter; - /// Parameter field + { + private byte[] _parameter; + /// Parameter field public byte[] Parameter - { - get { return _parameter; } + { + get { return _parameter; } set - { - if (value == null) { _parameter = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _parameter = new byte[value.Length]; Array.Copy(value, _parameter, value.Length); } + { + if (value == null) { _parameter = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _parameter = new byte[value.Length]; Array.Copy(value, _parameter, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 0; - if (Parameter != null) { length += 1 + Parameter.Length; } - return length; + { + int length = 0; + if (Parameter != null) { length += 1 + Parameter.Length; } + return length; } } - - /// Default constructor - public ParamListBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ParamListBlock() { } + /// Constructor for building the block from a byte array public ParamListBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _parameter = new byte[length]; - Array.Copy(bytes, i, _parameter, 0, length); i += length; + { + length = (ushort)bytes[i++]; + _parameter = new byte[length]; + Array.Copy(bytes, i, _parameter, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(Parameter == null) { Console.WriteLine("Warning: Parameter is null, in " + this.GetType()); } - bytes[i++] = (byte)Parameter.Length; - Array.Copy(Parameter, 0, bytes, i, Parameter.Length); i += Parameter.Length; + { + if(Parameter == null) { Console.WriteLine("Warning: Parameter is null, in " + this.GetType()); } + bytes[i++] = (byte)Parameter.Length; + Array.Copy(Parameter, 0, bytes, i, Parameter.Length); i += Parameter.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ParamList --\n"; - output += Helpers.FieldToString(Parameter, "Parameter") + "\n"; + { + string output = "-- ParamList --\n"; + output += Helpers.FieldToString(Parameter, "Parameter") + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.GenericMessage - public override PacketType Type { get { return PacketType.GenericMessage; } } - /// MethodData block - public MethodDataBlock MethodData; - /// ParamList block - public ParamListBlock[] ParamList; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.GenericMessage + public override PacketType Type { get { return PacketType.GenericMessage; } } + /// MethodData block + public MethodDataBlock MethodData; + /// ParamList block + public ParamListBlock[] ParamList; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public GenericMessagePacket() - { - Header = new LowHeader(); - Header.ID = 311; - Header.Reliable = true; - Header.Zerocoded = true; - MethodData = new MethodDataBlock(); - ParamList = new ParamListBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 311; + Header.Reliable = true; + Header.Zerocoded = true; + MethodData = new MethodDataBlock(); + ParamList = new ParamListBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public GenericMessagePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - MethodData = new MethodDataBlock(bytes, ref i); - int count = (int)bytes[i++]; - ParamList = new ParamListBlock[count]; - for (int j = 0; j < count; j++) - { ParamList[j] = new ParamListBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + MethodData = new MethodDataBlock(bytes, ref i); + int count = (int)bytes[i++]; + ParamList = new ParamListBlock[count]; + for (int j = 0; j < count; j++) + { ParamList[j] = new ParamListBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public GenericMessagePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - MethodData = new MethodDataBlock(bytes, ref i); - int count = (int)bytes[i++]; - ParamList = new ParamListBlock[count]; - for (int j = 0; j < count; j++) - { ParamList[j] = new ParamListBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + MethodData = new MethodDataBlock(bytes, ref i); + int count = (int)bytes[i++]; + ParamList = new ParamListBlock[count]; + for (int j = 0; j < count; j++) + { ParamList[j] = new ParamListBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += MethodData.Length; length += AgentData.Length;; - length++; - for (int j = 0; j < ParamList.Length; j++) { length += ParamList[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - MethodData.ToBytes(bytes, ref i); - bytes[i++] = (byte)ParamList.Length; - for (int j = 0; j < ParamList.Length; j++) { ParamList[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += MethodData.Length; length += AgentData.Length;; + length++; + for (int j = 0; j < ParamList.Length; j++) { length += ParamList[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + MethodData.ToBytes(bytes, ref i); + bytes[i++] = (byte)ParamList.Length; + for (int j = 0; j < ParamList.Length; j++) { ParamList[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- GenericMessage ---\n"; - output += MethodData.ToString() + "\n"; + { + string output = "--- GenericMessage ---\n"; + output += MethodData.ToString() + "\n"; for (int j = 0; j < ParamList.Length; j++) - { + { output += ParamList[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// MuteListRequest packet + + /// MuteListRequest packet public class MuteListRequestPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// MuteData block + + /// MuteData block public class MuteDataBlock - { - /// MuteCRC field - public uint MuteCRC; - - /// Length of this block serialized in bytes + { + /// MuteCRC field + public uint MuteCRC; + + /// Length of this block serialized in bytes public int Length { get - { - return 4; + { + return 4; } } - - /// Default constructor - public MuteDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public MuteDataBlock() { } + /// Constructor for building the block from a byte array public MuteDataBlock(byte[] bytes, ref int i) - { + { try - { - MuteCRC = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + MuteCRC = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(MuteCRC % 256); - bytes[i++] = (byte)((MuteCRC >> 8) % 256); - bytes[i++] = (byte)((MuteCRC >> 16) % 256); - bytes[i++] = (byte)((MuteCRC >> 24) % 256); + { + bytes[i++] = (byte)(MuteCRC % 256); + bytes[i++] = (byte)((MuteCRC >> 8) % 256); + bytes[i++] = (byte)((MuteCRC >> 16) % 256); + bytes[i++] = (byte)((MuteCRC >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- MuteData --\n"; - output += "MuteCRC: " + MuteCRC.ToString() + "\n"; + { + string output = "-- MuteData --\n"; + output += "MuteCRC: " + MuteCRC.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.MuteListRequest - public override PacketType Type { get { return PacketType.MuteListRequest; } } - /// AgentData block - public AgentDataBlock AgentData; - /// MuteData block - public MuteDataBlock MuteData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.MuteListRequest + public override PacketType Type { get { return PacketType.MuteListRequest; } } + /// AgentData block + public AgentDataBlock AgentData; + /// MuteData block + public MuteDataBlock MuteData; + + /// Default constructor public MuteListRequestPacket() - { - Header = new LowHeader(); - Header.ID = 312; - Header.Reliable = true; - AgentData = new AgentDataBlock(); - MuteData = new MuteDataBlock(); + { + Header = new LowHeader(); + Header.ID = 312; + Header.Reliable = true; + AgentData = new AgentDataBlock(); + MuteData = new MuteDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public MuteListRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); - MuteData = new MuteDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); + MuteData = new MuteDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public MuteListRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); - MuteData = new MuteDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); + MuteData = new MuteDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length; length += MuteData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - MuteData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length; length += MuteData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + MuteData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- MuteListRequest ---\n"; - output += AgentData.ToString() + "\n"; - output += MuteData.ToString() + "\n"; + { + string output = "--- MuteListRequest ---\n"; + output += AgentData.ToString() + "\n"; + output += MuteData.ToString() + "\n"; return output; } - + } - - /// UpdateMuteListEntry packet + + /// UpdateMuteListEntry packet public class UpdateMuteListEntryPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// MuteData block + + /// MuteData block public class MuteDataBlock - { - /// MuteID field - public LLUUID MuteID; - /// MuteFlags field - public uint MuteFlags; - private byte[] _mutename; - /// MuteName field + { + /// MuteID field + public LLUUID MuteID; + /// MuteFlags field + public uint MuteFlags; + private byte[] _mutename; + /// MuteName field public byte[] MuteName - { - get { return _mutename; } + { + get { return _mutename; } set - { - if (value == null) { _mutename = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _mutename = new byte[value.Length]; Array.Copy(value, _mutename, value.Length); } + { + if (value == null) { _mutename = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _mutename = new byte[value.Length]; Array.Copy(value, _mutename, value.Length); } } - } - /// MuteType field - public int MuteType; - - /// Length of this block serialized in bytes + } + /// MuteType field + public int MuteType; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 24; - if (MuteName != null) { length += 1 + MuteName.Length; } - return length; + { + int length = 24; + if (MuteName != null) { length += 1 + MuteName.Length; } + return length; } } - - /// Default constructor - public MuteDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public MuteDataBlock() { } + /// Constructor for building the block from a byte array public MuteDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - MuteID = new LLUUID(bytes, i); i += 16; - MuteFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _mutename = new byte[length]; - Array.Copy(bytes, i, _mutename, 0, length); i += length; - MuteType = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + MuteID = new LLUUID(bytes, i); i += 16; + MuteFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _mutename = new byte[length]; + Array.Copy(bytes, i, _mutename, 0, length); i += length; + MuteType = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(MuteID == null) { Console.WriteLine("Warning: MuteID is null, in " + this.GetType()); } - Array.Copy(MuteID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(MuteFlags % 256); - bytes[i++] = (byte)((MuteFlags >> 8) % 256); - bytes[i++] = (byte)((MuteFlags >> 16) % 256); - bytes[i++] = (byte)((MuteFlags >> 24) % 256); - if(MuteName == null) { Console.WriteLine("Warning: MuteName is null, in " + this.GetType()); } - bytes[i++] = (byte)MuteName.Length; - Array.Copy(MuteName, 0, bytes, i, MuteName.Length); i += MuteName.Length; - bytes[i++] = (byte)(MuteType % 256); - bytes[i++] = (byte)((MuteType >> 8) % 256); - bytes[i++] = (byte)((MuteType >> 16) % 256); - bytes[i++] = (byte)((MuteType >> 24) % 256); + { + if(MuteID == null) { Console.WriteLine("Warning: MuteID is null, in " + this.GetType()); } + Array.Copy(MuteID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(MuteFlags % 256); + bytes[i++] = (byte)((MuteFlags >> 8) % 256); + bytes[i++] = (byte)((MuteFlags >> 16) % 256); + bytes[i++] = (byte)((MuteFlags >> 24) % 256); + if(MuteName == null) { Console.WriteLine("Warning: MuteName is null, in " + this.GetType()); } + bytes[i++] = (byte)MuteName.Length; + Array.Copy(MuteName, 0, bytes, i, MuteName.Length); i += MuteName.Length; + bytes[i++] = (byte)(MuteType % 256); + bytes[i++] = (byte)((MuteType >> 8) % 256); + bytes[i++] = (byte)((MuteType >> 16) % 256); + bytes[i++] = (byte)((MuteType >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- MuteData --\n"; - output += "MuteID: " + MuteID.ToString() + "\n"; - output += "MuteFlags: " + MuteFlags.ToString() + "\n"; - output += Helpers.FieldToString(MuteName, "MuteName") + "\n"; - output += "MuteType: " + MuteType.ToString() + "\n"; + { + string output = "-- MuteData --\n"; + output += "MuteID: " + MuteID.ToString() + "\n"; + output += "MuteFlags: " + MuteFlags.ToString() + "\n"; + output += Helpers.FieldToString(MuteName, "MuteName") + "\n"; + output += "MuteType: " + MuteType.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.UpdateMuteListEntry - public override PacketType Type { get { return PacketType.UpdateMuteListEntry; } } - /// AgentData block - public AgentDataBlock AgentData; - /// MuteData block - public MuteDataBlock MuteData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.UpdateMuteListEntry + public override PacketType Type { get { return PacketType.UpdateMuteListEntry; } } + /// AgentData block + public AgentDataBlock AgentData; + /// MuteData block + public MuteDataBlock MuteData; + + /// Default constructor public UpdateMuteListEntryPacket() - { - Header = new LowHeader(); - Header.ID = 313; - Header.Reliable = true; - AgentData = new AgentDataBlock(); - MuteData = new MuteDataBlock(); + { + Header = new LowHeader(); + Header.ID = 313; + Header.Reliable = true; + AgentData = new AgentDataBlock(); + MuteData = new MuteDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public UpdateMuteListEntryPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); - MuteData = new MuteDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); + MuteData = new MuteDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public UpdateMuteListEntryPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); - MuteData = new MuteDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); + MuteData = new MuteDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length; length += MuteData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - MuteData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length; length += MuteData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + MuteData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- UpdateMuteListEntry ---\n"; - output += AgentData.ToString() + "\n"; - output += MuteData.ToString() + "\n"; + { + string output = "--- UpdateMuteListEntry ---\n"; + output += AgentData.ToString() + "\n"; + output += MuteData.ToString() + "\n"; return output; } - + } - - /// RemoveMuteListEntry packet + + /// RemoveMuteListEntry packet public class RemoveMuteListEntryPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// MuteData block + + /// MuteData block public class MuteDataBlock - { - /// MuteID field - public LLUUID MuteID; - private byte[] _mutename; - /// MuteName field + { + /// MuteID field + public LLUUID MuteID; + private byte[] _mutename; + /// MuteName field public byte[] MuteName - { - get { return _mutename; } + { + get { return _mutename; } set - { - if (value == null) { _mutename = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _mutename = new byte[value.Length]; Array.Copy(value, _mutename, value.Length); } + { + if (value == null) { _mutename = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _mutename = new byte[value.Length]; Array.Copy(value, _mutename, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 16; - if (MuteName != null) { length += 1 + MuteName.Length; } - return length; + { + int length = 16; + if (MuteName != null) { length += 1 + MuteName.Length; } + return length; } } - - /// Default constructor - public MuteDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public MuteDataBlock() { } + /// Constructor for building the block from a byte array public MuteDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - MuteID = new LLUUID(bytes, i); i += 16; - length = (ushort)bytes[i++]; - _mutename = new byte[length]; - Array.Copy(bytes, i, _mutename, 0, length); i += length; + { + MuteID = new LLUUID(bytes, i); i += 16; + length = (ushort)bytes[i++]; + _mutename = new byte[length]; + Array.Copy(bytes, i, _mutename, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(MuteID == null) { Console.WriteLine("Warning: MuteID is null, in " + this.GetType()); } - Array.Copy(MuteID.GetBytes(), 0, bytes, i, 16); i += 16; - if(MuteName == null) { Console.WriteLine("Warning: MuteName is null, in " + this.GetType()); } - bytes[i++] = (byte)MuteName.Length; - Array.Copy(MuteName, 0, bytes, i, MuteName.Length); i += MuteName.Length; + { + if(MuteID == null) { Console.WriteLine("Warning: MuteID is null, in " + this.GetType()); } + Array.Copy(MuteID.GetBytes(), 0, bytes, i, 16); i += 16; + if(MuteName == null) { Console.WriteLine("Warning: MuteName is null, in " + this.GetType()); } + bytes[i++] = (byte)MuteName.Length; + Array.Copy(MuteName, 0, bytes, i, MuteName.Length); i += MuteName.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- MuteData --\n"; - output += "MuteID: " + MuteID.ToString() + "\n"; - output += Helpers.FieldToString(MuteName, "MuteName") + "\n"; + { + string output = "-- MuteData --\n"; + output += "MuteID: " + MuteID.ToString() + "\n"; + output += Helpers.FieldToString(MuteName, "MuteName") + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.RemoveMuteListEntry - public override PacketType Type { get { return PacketType.RemoveMuteListEntry; } } - /// AgentData block - public AgentDataBlock AgentData; - /// MuteData block - public MuteDataBlock MuteData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.RemoveMuteListEntry + public override PacketType Type { get { return PacketType.RemoveMuteListEntry; } } + /// AgentData block + public AgentDataBlock AgentData; + /// MuteData block + public MuteDataBlock MuteData; + + /// Default constructor public RemoveMuteListEntryPacket() - { - Header = new LowHeader(); - Header.ID = 314; - Header.Reliable = true; - AgentData = new AgentDataBlock(); - MuteData = new MuteDataBlock(); + { + Header = new LowHeader(); + Header.ID = 314; + Header.Reliable = true; + AgentData = new AgentDataBlock(); + MuteData = new MuteDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public RemoveMuteListEntryPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); - MuteData = new MuteDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); + MuteData = new MuteDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public RemoveMuteListEntryPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); - MuteData = new MuteDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); + MuteData = new MuteDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length; length += MuteData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - MuteData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length; length += MuteData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + MuteData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- RemoveMuteListEntry ---\n"; - output += AgentData.ToString() + "\n"; - output += MuteData.ToString() + "\n"; + { + string output = "--- RemoveMuteListEntry ---\n"; + output += AgentData.ToString() + "\n"; + output += MuteData.ToString() + "\n"; return output; } - + } - - /// CopyInventoryFromNotecard packet + + /// CopyInventoryFromNotecard packet public class CopyInventoryFromNotecardPacket : Packet - { - /// InventoryData block + { + /// InventoryData block public class InventoryDataBlock - { - /// ItemID field - public LLUUID ItemID; - /// FolderID field - public LLUUID FolderID; - - /// Length of this block serialized in bytes + { + /// ItemID field + public LLUUID ItemID; + /// FolderID field + public LLUUID FolderID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public InventoryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public InventoryDataBlock() { } + /// Constructor for building the block from a byte array public InventoryDataBlock(byte[] bytes, ref int i) - { + { try - { - ItemID = new LLUUID(bytes, i); i += 16; - FolderID = new LLUUID(bytes, i); i += 16; + { + ItemID = new LLUUID(bytes, i); i += 16; + FolderID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } - Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; - if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } - Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } + Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; + if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } + Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- InventoryData --\n"; - output += "ItemID: " + ItemID.ToString() + "\n"; - output += "FolderID: " + FolderID.ToString() + "\n"; + { + string output = "-- InventoryData --\n"; + output += "ItemID: " + ItemID.ToString() + "\n"; + output += "FolderID: " + FolderID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// NotecardData block + + /// NotecardData block public class NotecardDataBlock - { - /// ObjectID field - public LLUUID ObjectID; - /// NotecardItemID field - public LLUUID NotecardItemID; - - /// Length of this block serialized in bytes + { + /// ObjectID field + public LLUUID ObjectID; + /// NotecardItemID field + public LLUUID NotecardItemID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public NotecardDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public NotecardDataBlock() { } + /// Constructor for building the block from a byte array public NotecardDataBlock(byte[] bytes, ref int i) - { + { try - { - ObjectID = new LLUUID(bytes, i); i += 16; - NotecardItemID = new LLUUID(bytes, i); i += 16; + { + ObjectID = new LLUUID(bytes, i); i += 16; + NotecardItemID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } - Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; - if(NotecardItemID == null) { Console.WriteLine("Warning: NotecardItemID is null, in " + this.GetType()); } - Array.Copy(NotecardItemID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } + Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; + if(NotecardItemID == null) { Console.WriteLine("Warning: NotecardItemID is null, in " + this.GetType()); } + Array.Copy(NotecardItemID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- NotecardData --\n"; - output += "ObjectID: " + ObjectID.ToString() + "\n"; - output += "NotecardItemID: " + NotecardItemID.ToString() + "\n"; + { + string output = "-- NotecardData --\n"; + output += "ObjectID: " + ObjectID.ToString() + "\n"; + output += "NotecardItemID: " + NotecardItemID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.CopyInventoryFromNotecard - public override PacketType Type { get { return PacketType.CopyInventoryFromNotecard; } } - /// InventoryData block - public InventoryDataBlock[] InventoryData; - /// NotecardData block - public NotecardDataBlock NotecardData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.CopyInventoryFromNotecard + public override PacketType Type { get { return PacketType.CopyInventoryFromNotecard; } } + /// InventoryData block + public InventoryDataBlock[] InventoryData; + /// NotecardData block + public NotecardDataBlock NotecardData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public CopyInventoryFromNotecardPacket() - { - Header = new LowHeader(); - Header.ID = 315; - Header.Reliable = true; - Header.Zerocoded = true; - InventoryData = new InventoryDataBlock[0]; - NotecardData = new NotecardDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 315; + Header.Reliable = true; + Header.Zerocoded = true; + InventoryData = new InventoryDataBlock[0]; + NotecardData = new NotecardDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public CopyInventoryFromNotecardPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - InventoryData = new InventoryDataBlock[count]; - for (int j = 0; j < count; j++) - { InventoryData[j] = new InventoryDataBlock(bytes, ref i); } - NotecardData = new NotecardDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + InventoryData = new InventoryDataBlock[count]; + for (int j = 0; j < count; j++) + { InventoryData[j] = new InventoryDataBlock(bytes, ref i); } + NotecardData = new NotecardDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public CopyInventoryFromNotecardPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - InventoryData = new InventoryDataBlock[count]; - for (int j = 0; j < count; j++) - { InventoryData[j] = new InventoryDataBlock(bytes, ref i); } - NotecardData = new NotecardDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + InventoryData = new InventoryDataBlock[count]; + for (int j = 0; j < count; j++) + { InventoryData[j] = new InventoryDataBlock(bytes, ref i); } + NotecardData = new NotecardDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += NotecardData.Length; length += AgentData.Length;; - length++; - for (int j = 0; j < InventoryData.Length; j++) { length += InventoryData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)InventoryData.Length; - for (int j = 0; j < InventoryData.Length; j++) { InventoryData[j].ToBytes(bytes, ref i); } - NotecardData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += NotecardData.Length; length += AgentData.Length;; + length++; + for (int j = 0; j < InventoryData.Length; j++) { length += InventoryData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)InventoryData.Length; + for (int j = 0; j < InventoryData.Length; j++) { InventoryData[j].ToBytes(bytes, ref i); } + NotecardData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- CopyInventoryFromNotecard ---\n"; + { + string output = "--- CopyInventoryFromNotecard ---\n"; for (int j = 0; j < InventoryData.Length; j++) - { + { output += InventoryData[j].ToString() + "\n"; - } - output += NotecardData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + } + output += NotecardData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// UpdateInventoryItem packet + + /// UpdateInventoryItem packet public class UpdateInventoryItemPacket : Packet - { - /// InventoryData block + { + /// InventoryData block public class InventoryDataBlock - { - /// GroupOwned field - public bool GroupOwned; - /// CRC field - public uint CRC; - /// CreationDate field - public int CreationDate; - /// SaleType field - public byte SaleType; - /// CallbackID field - public uint CallbackID; - /// BaseMask field - public uint BaseMask; - private byte[] _name; - /// Name field + { + /// GroupOwned field + public bool GroupOwned; + /// CRC field + public uint CRC; + /// CreationDate field + public int CreationDate; + /// SaleType field + public byte SaleType; + /// CallbackID field + public uint CallbackID; + /// BaseMask field + public uint BaseMask; + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - /// InvType field - public sbyte InvType; - /// Type field - public sbyte Type; - /// GroupID field - public LLUUID GroupID; - /// SalePrice field - public int SalePrice; - /// OwnerID field - public LLUUID OwnerID; - /// CreatorID field - public LLUUID CreatorID; - /// ItemID field - public LLUUID ItemID; - /// FolderID field - public LLUUID FolderID; - /// EveryoneMask field - public uint EveryoneMask; - private byte[] _description; - /// Description field + } + /// InvType field + public sbyte InvType; + /// Type field + public sbyte Type; + /// GroupID field + public LLUUID GroupID; + /// SalePrice field + public int SalePrice; + /// OwnerID field + public LLUUID OwnerID; + /// CreatorID field + public LLUUID CreatorID; + /// ItemID field + public LLUUID ItemID; + /// FolderID field + public LLUUID FolderID; + /// EveryoneMask field + public uint EveryoneMask; + private byte[] _description; + /// Description field public byte[] Description - { - get { return _description; } + { + get { return _description; } set - { - if (value == null) { _description = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } + { + if (value == null) { _description = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } } - } - /// Flags field - public uint Flags; - /// NextOwnerMask field - public uint NextOwnerMask; - /// TransactionID field - public LLUUID TransactionID; - /// GroupMask field - public uint GroupMask; - /// OwnerMask field - public uint OwnerMask; - - /// Length of this block serialized in bytes + } + /// Flags field + public uint Flags; + /// NextOwnerMask field + public uint NextOwnerMask; + /// TransactionID field + public LLUUID TransactionID; + /// GroupMask field + public uint GroupMask; + /// OwnerMask field + public uint OwnerMask; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 140; - if (Name != null) { length += 1 + Name.Length; } - if (Description != null) { length += 1 + Description.Length; } - return length; + { + int length = 140; + if (Name != null) { length += 1 + Name.Length; } + if (Description != null) { length += 1 + Description.Length; } + return length; } } - - /// Default constructor - public InventoryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public InventoryDataBlock() { } + /// Constructor for building the block from a byte array public InventoryDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - GroupOwned = (bytes[i++] != 0) ? (bool)true : (bool)false; - CRC = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - CreationDate = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - SaleType = (byte)bytes[i++]; - CallbackID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - BaseMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; - InvType = (sbyte)bytes[i++]; - Type = (sbyte)bytes[i++]; - GroupID = new LLUUID(bytes, i); i += 16; - SalePrice = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - OwnerID = new LLUUID(bytes, i); i += 16; - CreatorID = new LLUUID(bytes, i); i += 16; - ItemID = new LLUUID(bytes, i); i += 16; - FolderID = new LLUUID(bytes, i); i += 16; - EveryoneMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _description = new byte[length]; - Array.Copy(bytes, i, _description, 0, length); i += length; - Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - NextOwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - TransactionID = new LLUUID(bytes, i); i += 16; - GroupMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - OwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + GroupOwned = (bytes[i++] != 0) ? (bool)true : (bool)false; + CRC = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + CreationDate = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + SaleType = (byte)bytes[i++]; + CallbackID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + BaseMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; + InvType = (sbyte)bytes[i++]; + Type = (sbyte)bytes[i++]; + GroupID = new LLUUID(bytes, i); i += 16; + SalePrice = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + OwnerID = new LLUUID(bytes, i); i += 16; + CreatorID = new LLUUID(bytes, i); i += 16; + ItemID = new LLUUID(bytes, i); i += 16; + FolderID = new LLUUID(bytes, i); i += 16; + EveryoneMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _description = new byte[length]; + Array.Copy(bytes, i, _description, 0, length); i += length; + Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + NextOwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + TransactionID = new LLUUID(bytes, i); i += 16; + GroupMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + OwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)((GroupOwned) ? 1 : 0); - bytes[i++] = (byte)(CRC % 256); - bytes[i++] = (byte)((CRC >> 8) % 256); - bytes[i++] = (byte)((CRC >> 16) % 256); - bytes[i++] = (byte)((CRC >> 24) % 256); - bytes[i++] = (byte)(CreationDate % 256); - bytes[i++] = (byte)((CreationDate >> 8) % 256); - bytes[i++] = (byte)((CreationDate >> 16) % 256); - bytes[i++] = (byte)((CreationDate >> 24) % 256); - bytes[i++] = SaleType; - bytes[i++] = (byte)(CallbackID % 256); - bytes[i++] = (byte)((CallbackID >> 8) % 256); - bytes[i++] = (byte)((CallbackID >> 16) % 256); - bytes[i++] = (byte)((CallbackID >> 24) % 256); - bytes[i++] = (byte)(BaseMask % 256); - bytes[i++] = (byte)((BaseMask >> 8) % 256); - bytes[i++] = (byte)((BaseMask >> 16) % 256); - bytes[i++] = (byte)((BaseMask >> 24) % 256); - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; - bytes[i++] = (byte)InvType; - bytes[i++] = (byte)Type; - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(SalePrice % 256); - bytes[i++] = (byte)((SalePrice >> 8) % 256); - bytes[i++] = (byte)((SalePrice >> 16) % 256); - bytes[i++] = (byte)((SalePrice >> 24) % 256); - if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } - Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; - if(CreatorID == null) { Console.WriteLine("Warning: CreatorID is null, in " + this.GetType()); } - Array.Copy(CreatorID.GetBytes(), 0, bytes, i, 16); i += 16; - if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } - Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; - if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } - Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(EveryoneMask % 256); - bytes[i++] = (byte)((EveryoneMask >> 8) % 256); - bytes[i++] = (byte)((EveryoneMask >> 16) % 256); - bytes[i++] = (byte)((EveryoneMask >> 24) % 256); - if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } - bytes[i++] = (byte)Description.Length; - Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; - bytes[i++] = (byte)(Flags % 256); - bytes[i++] = (byte)((Flags >> 8) % 256); - bytes[i++] = (byte)((Flags >> 16) % 256); - bytes[i++] = (byte)((Flags >> 24) % 256); - bytes[i++] = (byte)(NextOwnerMask % 256); - bytes[i++] = (byte)((NextOwnerMask >> 8) % 256); - bytes[i++] = (byte)((NextOwnerMask >> 16) % 256); - bytes[i++] = (byte)((NextOwnerMask >> 24) % 256); - if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } - Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(GroupMask % 256); - bytes[i++] = (byte)((GroupMask >> 8) % 256); - bytes[i++] = (byte)((GroupMask >> 16) % 256); - bytes[i++] = (byte)((GroupMask >> 24) % 256); - bytes[i++] = (byte)(OwnerMask % 256); - bytes[i++] = (byte)((OwnerMask >> 8) % 256); - bytes[i++] = (byte)((OwnerMask >> 16) % 256); - bytes[i++] = (byte)((OwnerMask >> 24) % 256); + { + bytes[i++] = (byte)((GroupOwned) ? 1 : 0); + bytes[i++] = (byte)(CRC % 256); + bytes[i++] = (byte)((CRC >> 8) % 256); + bytes[i++] = (byte)((CRC >> 16) % 256); + bytes[i++] = (byte)((CRC >> 24) % 256); + bytes[i++] = (byte)(CreationDate % 256); + bytes[i++] = (byte)((CreationDate >> 8) % 256); + bytes[i++] = (byte)((CreationDate >> 16) % 256); + bytes[i++] = (byte)((CreationDate >> 24) % 256); + bytes[i++] = SaleType; + bytes[i++] = (byte)(CallbackID % 256); + bytes[i++] = (byte)((CallbackID >> 8) % 256); + bytes[i++] = (byte)((CallbackID >> 16) % 256); + bytes[i++] = (byte)((CallbackID >> 24) % 256); + bytes[i++] = (byte)(BaseMask % 256); + bytes[i++] = (byte)((BaseMask >> 8) % 256); + bytes[i++] = (byte)((BaseMask >> 16) % 256); + bytes[i++] = (byte)((BaseMask >> 24) % 256); + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + bytes[i++] = (byte)InvType; + bytes[i++] = (byte)Type; + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(SalePrice % 256); + bytes[i++] = (byte)((SalePrice >> 8) % 256); + bytes[i++] = (byte)((SalePrice >> 16) % 256); + bytes[i++] = (byte)((SalePrice >> 24) % 256); + if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } + Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; + if(CreatorID == null) { Console.WriteLine("Warning: CreatorID is null, in " + this.GetType()); } + Array.Copy(CreatorID.GetBytes(), 0, bytes, i, 16); i += 16; + if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } + Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; + if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } + Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(EveryoneMask % 256); + bytes[i++] = (byte)((EveryoneMask >> 8) % 256); + bytes[i++] = (byte)((EveryoneMask >> 16) % 256); + bytes[i++] = (byte)((EveryoneMask >> 24) % 256); + if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } + bytes[i++] = (byte)Description.Length; + Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; + bytes[i++] = (byte)(Flags % 256); + bytes[i++] = (byte)((Flags >> 8) % 256); + bytes[i++] = (byte)((Flags >> 16) % 256); + bytes[i++] = (byte)((Flags >> 24) % 256); + bytes[i++] = (byte)(NextOwnerMask % 256); + bytes[i++] = (byte)((NextOwnerMask >> 8) % 256); + bytes[i++] = (byte)((NextOwnerMask >> 16) % 256); + bytes[i++] = (byte)((NextOwnerMask >> 24) % 256); + if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } + Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(GroupMask % 256); + bytes[i++] = (byte)((GroupMask >> 8) % 256); + bytes[i++] = (byte)((GroupMask >> 16) % 256); + bytes[i++] = (byte)((GroupMask >> 24) % 256); + bytes[i++] = (byte)(OwnerMask % 256); + bytes[i++] = (byte)((OwnerMask >> 8) % 256); + bytes[i++] = (byte)((OwnerMask >> 16) % 256); + bytes[i++] = (byte)((OwnerMask >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- InventoryData --\n"; - output += "GroupOwned: " + GroupOwned.ToString() + "\n"; - output += "CRC: " + CRC.ToString() + "\n"; - output += "CreationDate: " + CreationDate.ToString() + "\n"; - output += "SaleType: " + SaleType.ToString() + "\n"; - output += "CallbackID: " + CallbackID.ToString() + "\n"; - output += "BaseMask: " + BaseMask.ToString() + "\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; - output += "InvType: " + InvType.ToString() + "\n"; - output += "Type: " + Type.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; - output += "SalePrice: " + SalePrice.ToString() + "\n"; - output += "OwnerID: " + OwnerID.ToString() + "\n"; - output += "CreatorID: " + CreatorID.ToString() + "\n"; - output += "ItemID: " + ItemID.ToString() + "\n"; - output += "FolderID: " + FolderID.ToString() + "\n"; - output += "EveryoneMask: " + EveryoneMask.ToString() + "\n"; - output += Helpers.FieldToString(Description, "Description") + "\n"; - output += "Flags: " + Flags.ToString() + "\n"; - output += "NextOwnerMask: " + NextOwnerMask.ToString() + "\n"; - output += "TransactionID: " + TransactionID.ToString() + "\n"; - output += "GroupMask: " + GroupMask.ToString() + "\n"; - output += "OwnerMask: " + OwnerMask.ToString() + "\n"; + { + string output = "-- InventoryData --\n"; + output += "GroupOwned: " + GroupOwned.ToString() + "\n"; + output += "CRC: " + CRC.ToString() + "\n"; + output += "CreationDate: " + CreationDate.ToString() + "\n"; + output += "SaleType: " + SaleType.ToString() + "\n"; + output += "CallbackID: " + CallbackID.ToString() + "\n"; + output += "BaseMask: " + BaseMask.ToString() + "\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; + output += "InvType: " + InvType.ToString() + "\n"; + output += "Type: " + Type.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; + output += "SalePrice: " + SalePrice.ToString() + "\n"; + output += "OwnerID: " + OwnerID.ToString() + "\n"; + output += "CreatorID: " + CreatorID.ToString() + "\n"; + output += "ItemID: " + ItemID.ToString() + "\n"; + output += "FolderID: " + FolderID.ToString() + "\n"; + output += "EveryoneMask: " + EveryoneMask.ToString() + "\n"; + output += Helpers.FieldToString(Description, "Description") + "\n"; + output += "Flags: " + Flags.ToString() + "\n"; + output += "NextOwnerMask: " + NextOwnerMask.ToString() + "\n"; + output += "TransactionID: " + TransactionID.ToString() + "\n"; + output += "GroupMask: " + GroupMask.ToString() + "\n"; + output += "OwnerMask: " + OwnerMask.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.UpdateInventoryItem - public override PacketType Type { get { return PacketType.UpdateInventoryItem; } } - /// InventoryData block - public InventoryDataBlock[] InventoryData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.UpdateInventoryItem + public override PacketType Type { get { return PacketType.UpdateInventoryItem; } } + /// InventoryData block + public InventoryDataBlock[] InventoryData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public UpdateInventoryItemPacket() - { - Header = new LowHeader(); - Header.ID = 316; - Header.Reliable = true; - Header.Zerocoded = true; - InventoryData = new InventoryDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 316; + Header.Reliable = true; + Header.Zerocoded = true; + InventoryData = new InventoryDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public UpdateInventoryItemPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - InventoryData = new InventoryDataBlock[count]; - for (int j = 0; j < count; j++) - { InventoryData[j] = new InventoryDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + InventoryData = new InventoryDataBlock[count]; + for (int j = 0; j < count; j++) + { InventoryData[j] = new InventoryDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public UpdateInventoryItemPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - InventoryData = new InventoryDataBlock[count]; - for (int j = 0; j < count; j++) - { InventoryData[j] = new InventoryDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + InventoryData = new InventoryDataBlock[count]; + for (int j = 0; j < count; j++) + { InventoryData[j] = new InventoryDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < InventoryData.Length; j++) { length += InventoryData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)InventoryData.Length; - for (int j = 0; j < InventoryData.Length; j++) { InventoryData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < InventoryData.Length; j++) { length += InventoryData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)InventoryData.Length; + for (int j = 0; j < InventoryData.Length; j++) { InventoryData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- UpdateInventoryItem ---\n"; + { + string output = "--- UpdateInventoryItem ---\n"; for (int j = 0; j < InventoryData.Length; j++) - { + { output += InventoryData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// UpdateCreateInventoryItem packet + + /// UpdateCreateInventoryItem packet public class UpdateCreateInventoryItemPacket : Packet - { - /// InventoryData block + { + /// InventoryData block public class InventoryDataBlock - { - /// GroupOwned field - public bool GroupOwned; - /// CRC field - public uint CRC; - /// CreationDate field - public int CreationDate; - /// SaleType field - public byte SaleType; - /// CallbackID field - public uint CallbackID; - /// BaseMask field - public uint BaseMask; - private byte[] _name; - /// Name field + { + /// GroupOwned field + public bool GroupOwned; + /// CRC field + public uint CRC; + /// CreationDate field + public int CreationDate; + /// SaleType field + public byte SaleType; + /// CallbackID field + public uint CallbackID; + /// BaseMask field + public uint BaseMask; + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - /// InvType field - public sbyte InvType; - /// Type field - public sbyte Type; - /// AssetID field - public LLUUID AssetID; - /// GroupID field - public LLUUID GroupID; - /// SalePrice field - public int SalePrice; - /// OwnerID field - public LLUUID OwnerID; - /// CreatorID field - public LLUUID CreatorID; - /// ItemID field - public LLUUID ItemID; - /// FolderID field - public LLUUID FolderID; - /// EveryoneMask field - public uint EveryoneMask; - private byte[] _description; - /// Description field + } + /// InvType field + public sbyte InvType; + /// Type field + public sbyte Type; + /// AssetID field + public LLUUID AssetID; + /// GroupID field + public LLUUID GroupID; + /// SalePrice field + public int SalePrice; + /// OwnerID field + public LLUUID OwnerID; + /// CreatorID field + public LLUUID CreatorID; + /// ItemID field + public LLUUID ItemID; + /// FolderID field + public LLUUID FolderID; + /// EveryoneMask field + public uint EveryoneMask; + private byte[] _description; + /// Description field public byte[] Description - { - get { return _description; } + { + get { return _description; } set - { - if (value == null) { _description = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } + { + if (value == null) { _description = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } } - } - /// Flags field - public uint Flags; - /// NextOwnerMask field - public uint NextOwnerMask; - /// GroupMask field - public uint GroupMask; - /// OwnerMask field - public uint OwnerMask; - - /// Length of this block serialized in bytes + } + /// Flags field + public uint Flags; + /// NextOwnerMask field + public uint NextOwnerMask; + /// GroupMask field + public uint GroupMask; + /// OwnerMask field + public uint OwnerMask; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 140; - if (Name != null) { length += 1 + Name.Length; } - if (Description != null) { length += 1 + Description.Length; } - return length; + { + int length = 140; + if (Name != null) { length += 1 + Name.Length; } + if (Description != null) { length += 1 + Description.Length; } + return length; } } - - /// Default constructor - public InventoryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public InventoryDataBlock() { } + /// Constructor for building the block from a byte array public InventoryDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - GroupOwned = (bytes[i++] != 0) ? (bool)true : (bool)false; - CRC = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - CreationDate = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - SaleType = (byte)bytes[i++]; - CallbackID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - BaseMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; - InvType = (sbyte)bytes[i++]; - Type = (sbyte)bytes[i++]; - AssetID = new LLUUID(bytes, i); i += 16; - GroupID = new LLUUID(bytes, i); i += 16; - SalePrice = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - OwnerID = new LLUUID(bytes, i); i += 16; - CreatorID = new LLUUID(bytes, i); i += 16; - ItemID = new LLUUID(bytes, i); i += 16; - FolderID = new LLUUID(bytes, i); i += 16; - EveryoneMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _description = new byte[length]; - Array.Copy(bytes, i, _description, 0, length); i += length; - Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - NextOwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - GroupMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - OwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + GroupOwned = (bytes[i++] != 0) ? (bool)true : (bool)false; + CRC = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + CreationDate = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + SaleType = (byte)bytes[i++]; + CallbackID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + BaseMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; + InvType = (sbyte)bytes[i++]; + Type = (sbyte)bytes[i++]; + AssetID = new LLUUID(bytes, i); i += 16; + GroupID = new LLUUID(bytes, i); i += 16; + SalePrice = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + OwnerID = new LLUUID(bytes, i); i += 16; + CreatorID = new LLUUID(bytes, i); i += 16; + ItemID = new LLUUID(bytes, i); i += 16; + FolderID = new LLUUID(bytes, i); i += 16; + EveryoneMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _description = new byte[length]; + Array.Copy(bytes, i, _description, 0, length); i += length; + Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + NextOwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + GroupMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + OwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)((GroupOwned) ? 1 : 0); - bytes[i++] = (byte)(CRC % 256); - bytes[i++] = (byte)((CRC >> 8) % 256); - bytes[i++] = (byte)((CRC >> 16) % 256); - bytes[i++] = (byte)((CRC >> 24) % 256); - bytes[i++] = (byte)(CreationDate % 256); - bytes[i++] = (byte)((CreationDate >> 8) % 256); - bytes[i++] = (byte)((CreationDate >> 16) % 256); - bytes[i++] = (byte)((CreationDate >> 24) % 256); - bytes[i++] = SaleType; - bytes[i++] = (byte)(CallbackID % 256); - bytes[i++] = (byte)((CallbackID >> 8) % 256); - bytes[i++] = (byte)((CallbackID >> 16) % 256); - bytes[i++] = (byte)((CallbackID >> 24) % 256); - bytes[i++] = (byte)(BaseMask % 256); - bytes[i++] = (byte)((BaseMask >> 8) % 256); - bytes[i++] = (byte)((BaseMask >> 16) % 256); - bytes[i++] = (byte)((BaseMask >> 24) % 256); - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; - bytes[i++] = (byte)InvType; - bytes[i++] = (byte)Type; - if(AssetID == null) { Console.WriteLine("Warning: AssetID is null, in " + this.GetType()); } - Array.Copy(AssetID.GetBytes(), 0, bytes, i, 16); i += 16; - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(SalePrice % 256); - bytes[i++] = (byte)((SalePrice >> 8) % 256); - bytes[i++] = (byte)((SalePrice >> 16) % 256); - bytes[i++] = (byte)((SalePrice >> 24) % 256); - if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } - Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; - if(CreatorID == null) { Console.WriteLine("Warning: CreatorID is null, in " + this.GetType()); } - Array.Copy(CreatorID.GetBytes(), 0, bytes, i, 16); i += 16; - if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } - Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; - if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } - Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(EveryoneMask % 256); - bytes[i++] = (byte)((EveryoneMask >> 8) % 256); - bytes[i++] = (byte)((EveryoneMask >> 16) % 256); - bytes[i++] = (byte)((EveryoneMask >> 24) % 256); - if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } - bytes[i++] = (byte)Description.Length; - Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; - bytes[i++] = (byte)(Flags % 256); - bytes[i++] = (byte)((Flags >> 8) % 256); - bytes[i++] = (byte)((Flags >> 16) % 256); - bytes[i++] = (byte)((Flags >> 24) % 256); - bytes[i++] = (byte)(NextOwnerMask % 256); - bytes[i++] = (byte)((NextOwnerMask >> 8) % 256); - bytes[i++] = (byte)((NextOwnerMask >> 16) % 256); - bytes[i++] = (byte)((NextOwnerMask >> 24) % 256); - bytes[i++] = (byte)(GroupMask % 256); - bytes[i++] = (byte)((GroupMask >> 8) % 256); - bytes[i++] = (byte)((GroupMask >> 16) % 256); - bytes[i++] = (byte)((GroupMask >> 24) % 256); - bytes[i++] = (byte)(OwnerMask % 256); - bytes[i++] = (byte)((OwnerMask >> 8) % 256); - bytes[i++] = (byte)((OwnerMask >> 16) % 256); - bytes[i++] = (byte)((OwnerMask >> 24) % 256); + { + bytes[i++] = (byte)((GroupOwned) ? 1 : 0); + bytes[i++] = (byte)(CRC % 256); + bytes[i++] = (byte)((CRC >> 8) % 256); + bytes[i++] = (byte)((CRC >> 16) % 256); + bytes[i++] = (byte)((CRC >> 24) % 256); + bytes[i++] = (byte)(CreationDate % 256); + bytes[i++] = (byte)((CreationDate >> 8) % 256); + bytes[i++] = (byte)((CreationDate >> 16) % 256); + bytes[i++] = (byte)((CreationDate >> 24) % 256); + bytes[i++] = SaleType; + bytes[i++] = (byte)(CallbackID % 256); + bytes[i++] = (byte)((CallbackID >> 8) % 256); + bytes[i++] = (byte)((CallbackID >> 16) % 256); + bytes[i++] = (byte)((CallbackID >> 24) % 256); + bytes[i++] = (byte)(BaseMask % 256); + bytes[i++] = (byte)((BaseMask >> 8) % 256); + bytes[i++] = (byte)((BaseMask >> 16) % 256); + bytes[i++] = (byte)((BaseMask >> 24) % 256); + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + bytes[i++] = (byte)InvType; + bytes[i++] = (byte)Type; + if(AssetID == null) { Console.WriteLine("Warning: AssetID is null, in " + this.GetType()); } + Array.Copy(AssetID.GetBytes(), 0, bytes, i, 16); i += 16; + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(SalePrice % 256); + bytes[i++] = (byte)((SalePrice >> 8) % 256); + bytes[i++] = (byte)((SalePrice >> 16) % 256); + bytes[i++] = (byte)((SalePrice >> 24) % 256); + if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } + Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; + if(CreatorID == null) { Console.WriteLine("Warning: CreatorID is null, in " + this.GetType()); } + Array.Copy(CreatorID.GetBytes(), 0, bytes, i, 16); i += 16; + if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } + Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; + if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } + Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(EveryoneMask % 256); + bytes[i++] = (byte)((EveryoneMask >> 8) % 256); + bytes[i++] = (byte)((EveryoneMask >> 16) % 256); + bytes[i++] = (byte)((EveryoneMask >> 24) % 256); + if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } + bytes[i++] = (byte)Description.Length; + Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; + bytes[i++] = (byte)(Flags % 256); + bytes[i++] = (byte)((Flags >> 8) % 256); + bytes[i++] = (byte)((Flags >> 16) % 256); + bytes[i++] = (byte)((Flags >> 24) % 256); + bytes[i++] = (byte)(NextOwnerMask % 256); + bytes[i++] = (byte)((NextOwnerMask >> 8) % 256); + bytes[i++] = (byte)((NextOwnerMask >> 16) % 256); + bytes[i++] = (byte)((NextOwnerMask >> 24) % 256); + bytes[i++] = (byte)(GroupMask % 256); + bytes[i++] = (byte)((GroupMask >> 8) % 256); + bytes[i++] = (byte)((GroupMask >> 16) % 256); + bytes[i++] = (byte)((GroupMask >> 24) % 256); + bytes[i++] = (byte)(OwnerMask % 256); + bytes[i++] = (byte)((OwnerMask >> 8) % 256); + bytes[i++] = (byte)((OwnerMask >> 16) % 256); + bytes[i++] = (byte)((OwnerMask >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- InventoryData --\n"; - output += "GroupOwned: " + GroupOwned.ToString() + "\n"; - output += "CRC: " + CRC.ToString() + "\n"; - output += "CreationDate: " + CreationDate.ToString() + "\n"; - output += "SaleType: " + SaleType.ToString() + "\n"; - output += "CallbackID: " + CallbackID.ToString() + "\n"; - output += "BaseMask: " + BaseMask.ToString() + "\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; - output += "InvType: " + InvType.ToString() + "\n"; - output += "Type: " + Type.ToString() + "\n"; - output += "AssetID: " + AssetID.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; - output += "SalePrice: " + SalePrice.ToString() + "\n"; - output += "OwnerID: " + OwnerID.ToString() + "\n"; - output += "CreatorID: " + CreatorID.ToString() + "\n"; - output += "ItemID: " + ItemID.ToString() + "\n"; - output += "FolderID: " + FolderID.ToString() + "\n"; - output += "EveryoneMask: " + EveryoneMask.ToString() + "\n"; - output += Helpers.FieldToString(Description, "Description") + "\n"; - output += "Flags: " + Flags.ToString() + "\n"; - output += "NextOwnerMask: " + NextOwnerMask.ToString() + "\n"; - output += "GroupMask: " + GroupMask.ToString() + "\n"; - output += "OwnerMask: " + OwnerMask.ToString() + "\n"; + { + string output = "-- InventoryData --\n"; + output += "GroupOwned: " + GroupOwned.ToString() + "\n"; + output += "CRC: " + CRC.ToString() + "\n"; + output += "CreationDate: " + CreationDate.ToString() + "\n"; + output += "SaleType: " + SaleType.ToString() + "\n"; + output += "CallbackID: " + CallbackID.ToString() + "\n"; + output += "BaseMask: " + BaseMask.ToString() + "\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; + output += "InvType: " + InvType.ToString() + "\n"; + output += "Type: " + Type.ToString() + "\n"; + output += "AssetID: " + AssetID.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; + output += "SalePrice: " + SalePrice.ToString() + "\n"; + output += "OwnerID: " + OwnerID.ToString() + "\n"; + output += "CreatorID: " + CreatorID.ToString() + "\n"; + output += "ItemID: " + ItemID.ToString() + "\n"; + output += "FolderID: " + FolderID.ToString() + "\n"; + output += "EveryoneMask: " + EveryoneMask.ToString() + "\n"; + output += Helpers.FieldToString(Description, "Description") + "\n"; + output += "Flags: " + Flags.ToString() + "\n"; + output += "NextOwnerMask: " + NextOwnerMask.ToString() + "\n"; + output += "GroupMask: " + GroupMask.ToString() + "\n"; + output += "OwnerMask: " + OwnerMask.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SimApproved field - public bool SimApproved; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SimApproved field + public bool SimApproved; + + /// Length of this block serialized in bytes public int Length { get - { - return 17; + { + return 17; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SimApproved = (bytes[i++] != 0) ? (bool)true : (bool)false; + { + AgentID = new LLUUID(bytes, i); i += 16; + SimApproved = (bytes[i++] != 0) ? (bool)true : (bool)false; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((SimApproved) ? 1 : 0); + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((SimApproved) ? 1 : 0); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SimApproved: " + SimApproved.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SimApproved: " + SimApproved.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.UpdateCreateInventoryItem - public override PacketType Type { get { return PacketType.UpdateCreateInventoryItem; } } - /// InventoryData block - public InventoryDataBlock[] InventoryData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.UpdateCreateInventoryItem + public override PacketType Type { get { return PacketType.UpdateCreateInventoryItem; } } + /// InventoryData block + public InventoryDataBlock[] InventoryData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public UpdateCreateInventoryItemPacket() - { - Header = new LowHeader(); - Header.ID = 317; - Header.Reliable = true; - Header.Zerocoded = true; - InventoryData = new InventoryDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 317; + Header.Reliable = true; + Header.Zerocoded = true; + InventoryData = new InventoryDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public UpdateCreateInventoryItemPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - InventoryData = new InventoryDataBlock[count]; - for (int j = 0; j < count; j++) - { InventoryData[j] = new InventoryDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + InventoryData = new InventoryDataBlock[count]; + for (int j = 0; j < count; j++) + { InventoryData[j] = new InventoryDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public UpdateCreateInventoryItemPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - InventoryData = new InventoryDataBlock[count]; - for (int j = 0; j < count; j++) - { InventoryData[j] = new InventoryDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + InventoryData = new InventoryDataBlock[count]; + for (int j = 0; j < count; j++) + { InventoryData[j] = new InventoryDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < InventoryData.Length; j++) { length += InventoryData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)InventoryData.Length; - for (int j = 0; j < InventoryData.Length; j++) { InventoryData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < InventoryData.Length; j++) { length += InventoryData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)InventoryData.Length; + for (int j = 0; j < InventoryData.Length; j++) { InventoryData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- UpdateCreateInventoryItem ---\n"; + { + string output = "--- UpdateCreateInventoryItem ---\n"; for (int j = 0; j < InventoryData.Length; j++) - { + { output += InventoryData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// MoveInventoryItem packet + + /// MoveInventoryItem packet public class MoveInventoryItemPacket : Packet - { - /// InventoryData block + { + /// InventoryData block public class InventoryDataBlock - { - /// ItemID field - public LLUUID ItemID; - /// FolderID field - public LLUUID FolderID; - - /// Length of this block serialized in bytes + { + /// ItemID field + public LLUUID ItemID; + /// FolderID field + public LLUUID FolderID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public InventoryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public InventoryDataBlock() { } + /// Constructor for building the block from a byte array public InventoryDataBlock(byte[] bytes, ref int i) - { + { try - { - ItemID = new LLUUID(bytes, i); i += 16; - FolderID = new LLUUID(bytes, i); i += 16; + { + ItemID = new LLUUID(bytes, i); i += 16; + FolderID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } - Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; - if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } - Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } + Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; + if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } + Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- InventoryData --\n"; - output += "ItemID: " + ItemID.ToString() + "\n"; - output += "FolderID: " + FolderID.ToString() + "\n"; + { + string output = "-- InventoryData --\n"; + output += "ItemID: " + ItemID.ToString() + "\n"; + output += "FolderID: " + FolderID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - /// Stamp field - public bool Stamp; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + /// Stamp field + public bool Stamp; + + /// Length of this block serialized in bytes public int Length { get - { - return 33; + { + return 33; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; - Stamp = (bytes[i++] != 0) ? (bool)true : (bool)false; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; + Stamp = (bytes[i++] != 0) ? (bool)true : (bool)false; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((Stamp) ? 1 : 0); + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((Stamp) ? 1 : 0); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "Stamp: " + Stamp.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "Stamp: " + Stamp.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.MoveInventoryItem - public override PacketType Type { get { return PacketType.MoveInventoryItem; } } - /// InventoryData block - public InventoryDataBlock[] InventoryData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.MoveInventoryItem + public override PacketType Type { get { return PacketType.MoveInventoryItem; } } + /// InventoryData block + public InventoryDataBlock[] InventoryData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public MoveInventoryItemPacket() - { - Header = new LowHeader(); - Header.ID = 318; - Header.Reliable = true; - Header.Zerocoded = true; - InventoryData = new InventoryDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 318; + Header.Reliable = true; + Header.Zerocoded = true; + InventoryData = new InventoryDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public MoveInventoryItemPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - InventoryData = new InventoryDataBlock[count]; - for (int j = 0; j < count; j++) - { InventoryData[j] = new InventoryDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + InventoryData = new InventoryDataBlock[count]; + for (int j = 0; j < count; j++) + { InventoryData[j] = new InventoryDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public MoveInventoryItemPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - InventoryData = new InventoryDataBlock[count]; - for (int j = 0; j < count; j++) - { InventoryData[j] = new InventoryDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + InventoryData = new InventoryDataBlock[count]; + for (int j = 0; j < count; j++) + { InventoryData[j] = new InventoryDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < InventoryData.Length; j++) { length += InventoryData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)InventoryData.Length; - for (int j = 0; j < InventoryData.Length; j++) { InventoryData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < InventoryData.Length; j++) { length += InventoryData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)InventoryData.Length; + for (int j = 0; j < InventoryData.Length; j++) { InventoryData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- MoveInventoryItem ---\n"; + { + string output = "--- MoveInventoryItem ---\n"; for (int j = 0; j < InventoryData.Length; j++) - { + { output += InventoryData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// CopyInventoryItem packet + + /// CopyInventoryItem packet public class CopyInventoryItemPacket : Packet - { - /// InventoryData block + { + /// InventoryData block public class InventoryDataBlock - { - /// NewFolderID field - public LLUUID NewFolderID; - /// CallbackID field - public uint CallbackID; - /// OldItemID field - public LLUUID OldItemID; - /// OldAgentID field - public LLUUID OldAgentID; - - /// Length of this block serialized in bytes + { + /// NewFolderID field + public LLUUID NewFolderID; + /// CallbackID field + public uint CallbackID; + /// OldItemID field + public LLUUID OldItemID; + /// OldAgentID field + public LLUUID OldAgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 52; + { + return 52; } } - - /// Default constructor - public InventoryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public InventoryDataBlock() { } + /// Constructor for building the block from a byte array public InventoryDataBlock(byte[] bytes, ref int i) - { + { try - { - NewFolderID = new LLUUID(bytes, i); i += 16; - CallbackID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - OldItemID = new LLUUID(bytes, i); i += 16; - OldAgentID = new LLUUID(bytes, i); i += 16; + { + NewFolderID = new LLUUID(bytes, i); i += 16; + CallbackID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + OldItemID = new LLUUID(bytes, i); i += 16; + OldAgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(NewFolderID == null) { Console.WriteLine("Warning: NewFolderID is null, in " + this.GetType()); } - Array.Copy(NewFolderID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(CallbackID % 256); - bytes[i++] = (byte)((CallbackID >> 8) % 256); - bytes[i++] = (byte)((CallbackID >> 16) % 256); - bytes[i++] = (byte)((CallbackID >> 24) % 256); - if(OldItemID == null) { Console.WriteLine("Warning: OldItemID is null, in " + this.GetType()); } - Array.Copy(OldItemID.GetBytes(), 0, bytes, i, 16); i += 16; - if(OldAgentID == null) { Console.WriteLine("Warning: OldAgentID is null, in " + this.GetType()); } - Array.Copy(OldAgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(NewFolderID == null) { Console.WriteLine("Warning: NewFolderID is null, in " + this.GetType()); } + Array.Copy(NewFolderID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(CallbackID % 256); + bytes[i++] = (byte)((CallbackID >> 8) % 256); + bytes[i++] = (byte)((CallbackID >> 16) % 256); + bytes[i++] = (byte)((CallbackID >> 24) % 256); + if(OldItemID == null) { Console.WriteLine("Warning: OldItemID is null, in " + this.GetType()); } + Array.Copy(OldItemID.GetBytes(), 0, bytes, i, 16); i += 16; + if(OldAgentID == null) { Console.WriteLine("Warning: OldAgentID is null, in " + this.GetType()); } + Array.Copy(OldAgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- InventoryData --\n"; - output += "NewFolderID: " + NewFolderID.ToString() + "\n"; - output += "CallbackID: " + CallbackID.ToString() + "\n"; - output += "OldItemID: " + OldItemID.ToString() + "\n"; - output += "OldAgentID: " + OldAgentID.ToString() + "\n"; + { + string output = "-- InventoryData --\n"; + output += "NewFolderID: " + NewFolderID.ToString() + "\n"; + output += "CallbackID: " + CallbackID.ToString() + "\n"; + output += "OldItemID: " + OldItemID.ToString() + "\n"; + output += "OldAgentID: " + OldAgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.CopyInventoryItem - public override PacketType Type { get { return PacketType.CopyInventoryItem; } } - /// InventoryData block - public InventoryDataBlock[] InventoryData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.CopyInventoryItem + public override PacketType Type { get { return PacketType.CopyInventoryItem; } } + /// InventoryData block + public InventoryDataBlock[] InventoryData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public CopyInventoryItemPacket() - { - Header = new LowHeader(); - Header.ID = 319; - Header.Reliable = true; - Header.Zerocoded = true; - InventoryData = new InventoryDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 319; + Header.Reliable = true; + Header.Zerocoded = true; + InventoryData = new InventoryDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public CopyInventoryItemPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - InventoryData = new InventoryDataBlock[count]; - for (int j = 0; j < count; j++) - { InventoryData[j] = new InventoryDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + InventoryData = new InventoryDataBlock[count]; + for (int j = 0; j < count; j++) + { InventoryData[j] = new InventoryDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public CopyInventoryItemPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - InventoryData = new InventoryDataBlock[count]; - for (int j = 0; j < count; j++) - { InventoryData[j] = new InventoryDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + InventoryData = new InventoryDataBlock[count]; + for (int j = 0; j < count; j++) + { InventoryData[j] = new InventoryDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < InventoryData.Length; j++) { length += InventoryData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)InventoryData.Length; - for (int j = 0; j < InventoryData.Length; j++) { InventoryData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < InventoryData.Length; j++) { length += InventoryData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)InventoryData.Length; + for (int j = 0; j < InventoryData.Length; j++) { InventoryData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- CopyInventoryItem ---\n"; + { + string output = "--- CopyInventoryItem ---\n"; for (int j = 0; j < InventoryData.Length; j++) - { + { output += InventoryData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// RemoveInventoryItem packet + + /// RemoveInventoryItem packet public class RemoveInventoryItemPacket : Packet - { - /// InventoryData block + { + /// InventoryData block public class InventoryDataBlock - { - /// ItemID field - public LLUUID ItemID; - - /// Length of this block serialized in bytes + { + /// ItemID field + public LLUUID ItemID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public InventoryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public InventoryDataBlock() { } + /// Constructor for building the block from a byte array public InventoryDataBlock(byte[] bytes, ref int i) - { + { try - { - ItemID = new LLUUID(bytes, i); i += 16; + { + ItemID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } - Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } + Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- InventoryData --\n"; - output += "ItemID: " + ItemID.ToString() + "\n"; + { + string output = "-- InventoryData --\n"; + output += "ItemID: " + ItemID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.RemoveInventoryItem - public override PacketType Type { get { return PacketType.RemoveInventoryItem; } } - /// InventoryData block - public InventoryDataBlock[] InventoryData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.RemoveInventoryItem + public override PacketType Type { get { return PacketType.RemoveInventoryItem; } } + /// InventoryData block + public InventoryDataBlock[] InventoryData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public RemoveInventoryItemPacket() - { - Header = new LowHeader(); - Header.ID = 320; - Header.Reliable = true; - InventoryData = new InventoryDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 320; + Header.Reliable = true; + InventoryData = new InventoryDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public RemoveInventoryItemPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - InventoryData = new InventoryDataBlock[count]; - for (int j = 0; j < count; j++) - { InventoryData[j] = new InventoryDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + InventoryData = new InventoryDataBlock[count]; + for (int j = 0; j < count; j++) + { InventoryData[j] = new InventoryDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public RemoveInventoryItemPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - InventoryData = new InventoryDataBlock[count]; - for (int j = 0; j < count; j++) - { InventoryData[j] = new InventoryDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + InventoryData = new InventoryDataBlock[count]; + for (int j = 0; j < count; j++) + { InventoryData[j] = new InventoryDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < InventoryData.Length; j++) { length += InventoryData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)InventoryData.Length; - for (int j = 0; j < InventoryData.Length; j++) { InventoryData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < InventoryData.Length; j++) { length += InventoryData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)InventoryData.Length; + for (int j = 0; j < InventoryData.Length; j++) { InventoryData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- RemoveInventoryItem ---\n"; + { + string output = "--- RemoveInventoryItem ---\n"; for (int j = 0; j < InventoryData.Length; j++) - { + { output += InventoryData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ChangeInventoryItemFlags packet + + /// ChangeInventoryItemFlags packet public class ChangeInventoryItemFlagsPacket : Packet - { - /// InventoryData block + { + /// InventoryData block public class InventoryDataBlock - { - /// ItemID field - public LLUUID ItemID; - /// Flags field - public uint Flags; - - /// Length of this block serialized in bytes + { + /// ItemID field + public LLUUID ItemID; + /// Flags field + public uint Flags; + + /// Length of this block serialized in bytes public int Length { get - { - return 20; + { + return 20; } } - - /// Default constructor - public InventoryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public InventoryDataBlock() { } + /// Constructor for building the block from a byte array public InventoryDataBlock(byte[] bytes, ref int i) - { + { try - { - ItemID = new LLUUID(bytes, i); i += 16; - Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + ItemID = new LLUUID(bytes, i); i += 16; + Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } - Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(Flags % 256); - bytes[i++] = (byte)((Flags >> 8) % 256); - bytes[i++] = (byte)((Flags >> 16) % 256); - bytes[i++] = (byte)((Flags >> 24) % 256); + { + if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } + Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(Flags % 256); + bytes[i++] = (byte)((Flags >> 8) % 256); + bytes[i++] = (byte)((Flags >> 16) % 256); + bytes[i++] = (byte)((Flags >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- InventoryData --\n"; - output += "ItemID: " + ItemID.ToString() + "\n"; - output += "Flags: " + Flags.ToString() + "\n"; + { + string output = "-- InventoryData --\n"; + output += "ItemID: " + ItemID.ToString() + "\n"; + output += "Flags: " + Flags.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ChangeInventoryItemFlags - public override PacketType Type { get { return PacketType.ChangeInventoryItemFlags; } } - /// InventoryData block - public InventoryDataBlock[] InventoryData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ChangeInventoryItemFlags + public override PacketType Type { get { return PacketType.ChangeInventoryItemFlags; } } + /// InventoryData block + public InventoryDataBlock[] InventoryData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ChangeInventoryItemFlagsPacket() - { - Header = new LowHeader(); - Header.ID = 321; - Header.Reliable = true; - InventoryData = new InventoryDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 321; + Header.Reliable = true; + InventoryData = new InventoryDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ChangeInventoryItemFlagsPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - InventoryData = new InventoryDataBlock[count]; - for (int j = 0; j < count; j++) - { InventoryData[j] = new InventoryDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + InventoryData = new InventoryDataBlock[count]; + for (int j = 0; j < count; j++) + { InventoryData[j] = new InventoryDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ChangeInventoryItemFlagsPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - InventoryData = new InventoryDataBlock[count]; - for (int j = 0; j < count; j++) - { InventoryData[j] = new InventoryDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + InventoryData = new InventoryDataBlock[count]; + for (int j = 0; j < count; j++) + { InventoryData[j] = new InventoryDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < InventoryData.Length; j++) { length += InventoryData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)InventoryData.Length; - for (int j = 0; j < InventoryData.Length; j++) { InventoryData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < InventoryData.Length; j++) { length += InventoryData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)InventoryData.Length; + for (int j = 0; j < InventoryData.Length; j++) { InventoryData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ChangeInventoryItemFlags ---\n"; + { + string output = "--- ChangeInventoryItemFlags ---\n"; for (int j = 0; j < InventoryData.Length; j++) - { + { output += InventoryData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// SaveAssetIntoInventory packet + + /// SaveAssetIntoInventory packet public class SaveAssetIntoInventoryPacket : Packet - { - /// InventoryData block + { + /// InventoryData block public class InventoryDataBlock - { - /// NewAssetID field - public LLUUID NewAssetID; - /// ItemID field - public LLUUID ItemID; - - /// Length of this block serialized in bytes + { + /// NewAssetID field + public LLUUID NewAssetID; + /// ItemID field + public LLUUID ItemID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public InventoryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public InventoryDataBlock() { } + /// Constructor for building the block from a byte array public InventoryDataBlock(byte[] bytes, ref int i) - { + { try - { - NewAssetID = new LLUUID(bytes, i); i += 16; - ItemID = new LLUUID(bytes, i); i += 16; + { + NewAssetID = new LLUUID(bytes, i); i += 16; + ItemID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(NewAssetID == null) { Console.WriteLine("Warning: NewAssetID is null, in " + this.GetType()); } - Array.Copy(NewAssetID.GetBytes(), 0, bytes, i, 16); i += 16; - if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } - Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(NewAssetID == null) { Console.WriteLine("Warning: NewAssetID is null, in " + this.GetType()); } + Array.Copy(NewAssetID.GetBytes(), 0, bytes, i, 16); i += 16; + if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } + Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- InventoryData --\n"; - output += "NewAssetID: " + NewAssetID.ToString() + "\n"; - output += "ItemID: " + ItemID.ToString() + "\n"; + { + string output = "-- InventoryData --\n"; + output += "NewAssetID: " + NewAssetID.ToString() + "\n"; + output += "ItemID: " + ItemID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.SaveAssetIntoInventory - public override PacketType Type { get { return PacketType.SaveAssetIntoInventory; } } - /// InventoryData block - public InventoryDataBlock InventoryData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.SaveAssetIntoInventory + public override PacketType Type { get { return PacketType.SaveAssetIntoInventory; } } + /// InventoryData block + public InventoryDataBlock InventoryData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public SaveAssetIntoInventoryPacket() - { - Header = new LowHeader(); - Header.ID = 322; - Header.Reliable = true; - InventoryData = new InventoryDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 322; + Header.Reliable = true; + InventoryData = new InventoryDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public SaveAssetIntoInventoryPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - InventoryData = new InventoryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + InventoryData = new InventoryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public SaveAssetIntoInventoryPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - InventoryData = new InventoryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + InventoryData = new InventoryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += InventoryData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - InventoryData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += InventoryData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + InventoryData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- SaveAssetIntoInventory ---\n"; - output += InventoryData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- SaveAssetIntoInventory ---\n"; + output += InventoryData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// CreateInventoryFolder packet + + /// CreateInventoryFolder packet public class CreateInventoryFolderPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// FolderData block + + /// FolderData block public class FolderDataBlock - { - private byte[] _name; - /// Name field + { + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - /// ParentID field - public LLUUID ParentID; - /// Type field - public sbyte Type; - /// FolderID field - public LLUUID FolderID; - - /// Length of this block serialized in bytes + } + /// ParentID field + public LLUUID ParentID; + /// Type field + public sbyte Type; + /// FolderID field + public LLUUID FolderID; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 33; - if (Name != null) { length += 1 + Name.Length; } - return length; + { + int length = 33; + if (Name != null) { length += 1 + Name.Length; } + return length; } } - - /// Default constructor - public FolderDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public FolderDataBlock() { } + /// Constructor for building the block from a byte array public FolderDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; - ParentID = new LLUUID(bytes, i); i += 16; - Type = (sbyte)bytes[i++]; - FolderID = new LLUUID(bytes, i); i += 16; + { + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; + ParentID = new LLUUID(bytes, i); i += 16; + Type = (sbyte)bytes[i++]; + FolderID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; - if(ParentID == null) { Console.WriteLine("Warning: ParentID is null, in " + this.GetType()); } - Array.Copy(ParentID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)Type; - if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } - Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + if(ParentID == null) { Console.WriteLine("Warning: ParentID is null, in " + this.GetType()); } + Array.Copy(ParentID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)Type; + if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } + Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- FolderData --\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; - output += "ParentID: " + ParentID.ToString() + "\n"; - output += "Type: " + Type.ToString() + "\n"; - output += "FolderID: " + FolderID.ToString() + "\n"; + { + string output = "-- FolderData --\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; + output += "ParentID: " + ParentID.ToString() + "\n"; + output += "Type: " + Type.ToString() + "\n"; + output += "FolderID: " + FolderID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.CreateInventoryFolder - public override PacketType Type { get { return PacketType.CreateInventoryFolder; } } - /// AgentData block - public AgentDataBlock AgentData; - /// FolderData block - public FolderDataBlock FolderData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.CreateInventoryFolder + public override PacketType Type { get { return PacketType.CreateInventoryFolder; } } + /// AgentData block + public AgentDataBlock AgentData; + /// FolderData block + public FolderDataBlock FolderData; + + /// Default constructor public CreateInventoryFolderPacket() - { - Header = new LowHeader(); - Header.ID = 323; - Header.Reliable = true; - AgentData = new AgentDataBlock(); - FolderData = new FolderDataBlock(); + { + Header = new LowHeader(); + Header.ID = 323; + Header.Reliable = true; + AgentData = new AgentDataBlock(); + FolderData = new FolderDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public CreateInventoryFolderPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); - FolderData = new FolderDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); + FolderData = new FolderDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public CreateInventoryFolderPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); - FolderData = new FolderDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); + FolderData = new FolderDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length; length += FolderData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - FolderData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length; length += FolderData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + FolderData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- CreateInventoryFolder ---\n"; - output += AgentData.ToString() + "\n"; - output += FolderData.ToString() + "\n"; + { + string output = "--- CreateInventoryFolder ---\n"; + output += AgentData.ToString() + "\n"; + output += FolderData.ToString() + "\n"; return output; } - + } - - /// UpdateInventoryFolder packet + + /// UpdateInventoryFolder packet public class UpdateInventoryFolderPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// FolderData block + + /// FolderData block public class FolderDataBlock - { - private byte[] _name; - /// Name field + { + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - /// ParentID field - public LLUUID ParentID; - /// Type field - public sbyte Type; - /// FolderID field - public LLUUID FolderID; - - /// Length of this block serialized in bytes + } + /// ParentID field + public LLUUID ParentID; + /// Type field + public sbyte Type; + /// FolderID field + public LLUUID FolderID; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 33; - if (Name != null) { length += 1 + Name.Length; } - return length; + { + int length = 33; + if (Name != null) { length += 1 + Name.Length; } + return length; } } - - /// Default constructor - public FolderDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public FolderDataBlock() { } + /// Constructor for building the block from a byte array public FolderDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; - ParentID = new LLUUID(bytes, i); i += 16; - Type = (sbyte)bytes[i++]; - FolderID = new LLUUID(bytes, i); i += 16; + { + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; + ParentID = new LLUUID(bytes, i); i += 16; + Type = (sbyte)bytes[i++]; + FolderID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; - if(ParentID == null) { Console.WriteLine("Warning: ParentID is null, in " + this.GetType()); } - Array.Copy(ParentID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)Type; - if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } - Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + if(ParentID == null) { Console.WriteLine("Warning: ParentID is null, in " + this.GetType()); } + Array.Copy(ParentID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)Type; + if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } + Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- FolderData --\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; - output += "ParentID: " + ParentID.ToString() + "\n"; - output += "Type: " + Type.ToString() + "\n"; - output += "FolderID: " + FolderID.ToString() + "\n"; + { + string output = "-- FolderData --\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; + output += "ParentID: " + ParentID.ToString() + "\n"; + output += "Type: " + Type.ToString() + "\n"; + output += "FolderID: " + FolderID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.UpdateInventoryFolder - public override PacketType Type { get { return PacketType.UpdateInventoryFolder; } } - /// AgentData block - public AgentDataBlock AgentData; - /// FolderData block - public FolderDataBlock[] FolderData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.UpdateInventoryFolder + public override PacketType Type { get { return PacketType.UpdateInventoryFolder; } } + /// AgentData block + public AgentDataBlock AgentData; + /// FolderData block + public FolderDataBlock[] FolderData; + + /// Default constructor public UpdateInventoryFolderPacket() - { - Header = new LowHeader(); - Header.ID = 324; - Header.Reliable = true; - AgentData = new AgentDataBlock(); - FolderData = new FolderDataBlock[0]; + { + Header = new LowHeader(); + Header.ID = 324; + Header.Reliable = true; + AgentData = new AgentDataBlock(); + FolderData = new FolderDataBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public UpdateInventoryFolderPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); - int count = (int)bytes[i++]; - FolderData = new FolderDataBlock[count]; - for (int j = 0; j < count; j++) - { FolderData[j] = new FolderDataBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); + int count = (int)bytes[i++]; + FolderData = new FolderDataBlock[count]; + for (int j = 0; j < count; j++) + { FolderData[j] = new FolderDataBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public UpdateInventoryFolderPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); - int count = (int)bytes[i++]; - FolderData = new FolderDataBlock[count]; - for (int j = 0; j < count; j++) - { FolderData[j] = new FolderDataBlock(bytes, ref i); } + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); + int count = (int)bytes[i++]; + FolderData = new FolderDataBlock[count]; + for (int j = 0; j < count; j++) + { FolderData[j] = new FolderDataBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < FolderData.Length; j++) { length += FolderData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - bytes[i++] = (byte)FolderData.Length; - for (int j = 0; j < FolderData.Length; j++) { FolderData[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < FolderData.Length; j++) { length += FolderData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + bytes[i++] = (byte)FolderData.Length; + for (int j = 0; j < FolderData.Length; j++) { FolderData[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- UpdateInventoryFolder ---\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- UpdateInventoryFolder ---\n"; + output += AgentData.ToString() + "\n"; for (int j = 0; j < FolderData.Length; j++) - { + { output += FolderData[j].ToString() + "\n"; - } + } return output; } - + } - - /// MoveInventoryFolder packet + + /// MoveInventoryFolder packet public class MoveInventoryFolderPacket : Packet - { - /// InventoryData block + { + /// InventoryData block public class InventoryDataBlock - { - /// ParentID field - public LLUUID ParentID; - /// FolderID field - public LLUUID FolderID; - - /// Length of this block serialized in bytes + { + /// ParentID field + public LLUUID ParentID; + /// FolderID field + public LLUUID FolderID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public InventoryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public InventoryDataBlock() { } + /// Constructor for building the block from a byte array public InventoryDataBlock(byte[] bytes, ref int i) - { + { try - { - ParentID = new LLUUID(bytes, i); i += 16; - FolderID = new LLUUID(bytes, i); i += 16; + { + ParentID = new LLUUID(bytes, i); i += 16; + FolderID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ParentID == null) { Console.WriteLine("Warning: ParentID is null, in " + this.GetType()); } - Array.Copy(ParentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } - Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(ParentID == null) { Console.WriteLine("Warning: ParentID is null, in " + this.GetType()); } + Array.Copy(ParentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } + Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- InventoryData --\n"; - output += "ParentID: " + ParentID.ToString() + "\n"; - output += "FolderID: " + FolderID.ToString() + "\n"; + { + string output = "-- InventoryData --\n"; + output += "ParentID: " + ParentID.ToString() + "\n"; + output += "FolderID: " + FolderID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - /// Stamp field - public bool Stamp; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + /// Stamp field + public bool Stamp; + + /// Length of this block serialized in bytes public int Length { get - { - return 33; + { + return 33; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; - Stamp = (bytes[i++] != 0) ? (bool)true : (bool)false; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; + Stamp = (bytes[i++] != 0) ? (bool)true : (bool)false; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((Stamp) ? 1 : 0); + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((Stamp) ? 1 : 0); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "Stamp: " + Stamp.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "Stamp: " + Stamp.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.MoveInventoryFolder - public override PacketType Type { get { return PacketType.MoveInventoryFolder; } } - /// InventoryData block - public InventoryDataBlock[] InventoryData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.MoveInventoryFolder + public override PacketType Type { get { return PacketType.MoveInventoryFolder; } } + /// InventoryData block + public InventoryDataBlock[] InventoryData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public MoveInventoryFolderPacket() - { - Header = new LowHeader(); - Header.ID = 325; - Header.Reliable = true; - Header.Zerocoded = true; - InventoryData = new InventoryDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 325; + Header.Reliable = true; + Header.Zerocoded = true; + InventoryData = new InventoryDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public MoveInventoryFolderPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - InventoryData = new InventoryDataBlock[count]; - for (int j = 0; j < count; j++) - { InventoryData[j] = new InventoryDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + InventoryData = new InventoryDataBlock[count]; + for (int j = 0; j < count; j++) + { InventoryData[j] = new InventoryDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public MoveInventoryFolderPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - InventoryData = new InventoryDataBlock[count]; - for (int j = 0; j < count; j++) - { InventoryData[j] = new InventoryDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + InventoryData = new InventoryDataBlock[count]; + for (int j = 0; j < count; j++) + { InventoryData[j] = new InventoryDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < InventoryData.Length; j++) { length += InventoryData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)InventoryData.Length; - for (int j = 0; j < InventoryData.Length; j++) { InventoryData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < InventoryData.Length; j++) { length += InventoryData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)InventoryData.Length; + for (int j = 0; j < InventoryData.Length; j++) { InventoryData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- MoveInventoryFolder ---\n"; + { + string output = "--- MoveInventoryFolder ---\n"; for (int j = 0; j < InventoryData.Length; j++) - { + { output += InventoryData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// RemoveInventoryFolder packet + + /// RemoveInventoryFolder packet public class RemoveInventoryFolderPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// FolderData block + + /// FolderData block public class FolderDataBlock - { - /// FolderID field - public LLUUID FolderID; - - /// Length of this block serialized in bytes + { + /// FolderID field + public LLUUID FolderID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public FolderDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public FolderDataBlock() { } + /// Constructor for building the block from a byte array public FolderDataBlock(byte[] bytes, ref int i) - { + { try - { - FolderID = new LLUUID(bytes, i); i += 16; + { + FolderID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } - Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } + Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- FolderData --\n"; - output += "FolderID: " + FolderID.ToString() + "\n"; + { + string output = "-- FolderData --\n"; + output += "FolderID: " + FolderID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.RemoveInventoryFolder - public override PacketType Type { get { return PacketType.RemoveInventoryFolder; } } - /// AgentData block - public AgentDataBlock AgentData; - /// FolderData block - public FolderDataBlock[] FolderData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.RemoveInventoryFolder + public override PacketType Type { get { return PacketType.RemoveInventoryFolder; } } + /// AgentData block + public AgentDataBlock AgentData; + /// FolderData block + public FolderDataBlock[] FolderData; + + /// Default constructor public RemoveInventoryFolderPacket() - { - Header = new LowHeader(); - Header.ID = 326; - Header.Reliable = true; - AgentData = new AgentDataBlock(); - FolderData = new FolderDataBlock[0]; + { + Header = new LowHeader(); + Header.ID = 326; + Header.Reliable = true; + AgentData = new AgentDataBlock(); + FolderData = new FolderDataBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public RemoveInventoryFolderPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); - int count = (int)bytes[i++]; - FolderData = new FolderDataBlock[count]; - for (int j = 0; j < count; j++) - { FolderData[j] = new FolderDataBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); + int count = (int)bytes[i++]; + FolderData = new FolderDataBlock[count]; + for (int j = 0; j < count; j++) + { FolderData[j] = new FolderDataBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public RemoveInventoryFolderPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); - int count = (int)bytes[i++]; - FolderData = new FolderDataBlock[count]; - for (int j = 0; j < count; j++) - { FolderData[j] = new FolderDataBlock(bytes, ref i); } + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); + int count = (int)bytes[i++]; + FolderData = new FolderDataBlock[count]; + for (int j = 0; j < count; j++) + { FolderData[j] = new FolderDataBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < FolderData.Length; j++) { length += FolderData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - bytes[i++] = (byte)FolderData.Length; - for (int j = 0; j < FolderData.Length; j++) { FolderData[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < FolderData.Length; j++) { length += FolderData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + bytes[i++] = (byte)FolderData.Length; + for (int j = 0; j < FolderData.Length; j++) { FolderData[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- RemoveInventoryFolder ---\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- RemoveInventoryFolder ---\n"; + output += AgentData.ToString() + "\n"; for (int j = 0; j < FolderData.Length; j++) - { + { output += FolderData[j].ToString() + "\n"; - } + } return output; } - + } - - /// FetchInventoryDescendents packet + + /// FetchInventoryDescendents packet public class FetchInventoryDescendentsPacket : Packet - { - /// InventoryData block + { + /// InventoryData block public class InventoryDataBlock - { - /// OwnerID field - public LLUUID OwnerID; - /// FolderID field - public LLUUID FolderID; - /// SortOrder field - public int SortOrder; - /// FetchFolders field - public bool FetchFolders; - /// FetchItems field - public bool FetchItems; - - /// Length of this block serialized in bytes + { + /// OwnerID field + public LLUUID OwnerID; + /// FolderID field + public LLUUID FolderID; + /// SortOrder field + public int SortOrder; + /// FetchFolders field + public bool FetchFolders; + /// FetchItems field + public bool FetchItems; + + /// Length of this block serialized in bytes public int Length { get - { - return 38; + { + return 38; } } - - /// Default constructor - public InventoryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public InventoryDataBlock() { } + /// Constructor for building the block from a byte array public InventoryDataBlock(byte[] bytes, ref int i) - { + { try - { - OwnerID = new LLUUID(bytes, i); i += 16; - FolderID = new LLUUID(bytes, i); i += 16; - SortOrder = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - FetchFolders = (bytes[i++] != 0) ? (bool)true : (bool)false; - FetchItems = (bytes[i++] != 0) ? (bool)true : (bool)false; + { + OwnerID = new LLUUID(bytes, i); i += 16; + FolderID = new LLUUID(bytes, i); i += 16; + SortOrder = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + FetchFolders = (bytes[i++] != 0) ? (bool)true : (bool)false; + FetchItems = (bytes[i++] != 0) ? (bool)true : (bool)false; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } - Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; - if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } - Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(SortOrder % 256); - bytes[i++] = (byte)((SortOrder >> 8) % 256); - bytes[i++] = (byte)((SortOrder >> 16) % 256); - bytes[i++] = (byte)((SortOrder >> 24) % 256); - bytes[i++] = (byte)((FetchFolders) ? 1 : 0); - bytes[i++] = (byte)((FetchItems) ? 1 : 0); + { + if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } + Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; + if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } + Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(SortOrder % 256); + bytes[i++] = (byte)((SortOrder >> 8) % 256); + bytes[i++] = (byte)((SortOrder >> 16) % 256); + bytes[i++] = (byte)((SortOrder >> 24) % 256); + bytes[i++] = (byte)((FetchFolders) ? 1 : 0); + bytes[i++] = (byte)((FetchItems) ? 1 : 0); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- InventoryData --\n"; - output += "OwnerID: " + OwnerID.ToString() + "\n"; - output += "FolderID: " + FolderID.ToString() + "\n"; - output += "SortOrder: " + SortOrder.ToString() + "\n"; - output += "FetchFolders: " + FetchFolders.ToString() + "\n"; - output += "FetchItems: " + FetchItems.ToString() + "\n"; + { + string output = "-- InventoryData --\n"; + output += "OwnerID: " + OwnerID.ToString() + "\n"; + output += "FolderID: " + FolderID.ToString() + "\n"; + output += "SortOrder: " + SortOrder.ToString() + "\n"; + output += "FetchFolders: " + FetchFolders.ToString() + "\n"; + output += "FetchItems: " + FetchItems.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.FetchInventoryDescendents - public override PacketType Type { get { return PacketType.FetchInventoryDescendents; } } - /// InventoryData block - public InventoryDataBlock InventoryData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.FetchInventoryDescendents + public override PacketType Type { get { return PacketType.FetchInventoryDescendents; } } + /// InventoryData block + public InventoryDataBlock InventoryData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public FetchInventoryDescendentsPacket() - { - Header = new LowHeader(); - Header.ID = 327; - Header.Reliable = true; - Header.Zerocoded = true; - InventoryData = new InventoryDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 327; + Header.Reliable = true; + Header.Zerocoded = true; + InventoryData = new InventoryDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public FetchInventoryDescendentsPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - InventoryData = new InventoryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + InventoryData = new InventoryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public FetchInventoryDescendentsPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - InventoryData = new InventoryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + InventoryData = new InventoryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += InventoryData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - InventoryData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += InventoryData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + InventoryData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- FetchInventoryDescendents ---\n"; - output += InventoryData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- FetchInventoryDescendents ---\n"; + output += InventoryData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// InventoryDescendents packet + + /// InventoryDescendents packet public class InventoryDescendentsPacket : Packet - { - /// ItemData block + { + /// ItemData block public class ItemDataBlock - { - /// GroupOwned field - public bool GroupOwned; - /// CRC field - public uint CRC; - /// CreationDate field - public int CreationDate; - /// SaleType field - public byte SaleType; - /// BaseMask field - public uint BaseMask; - private byte[] _name; - /// Name field + { + /// GroupOwned field + public bool GroupOwned; + /// CRC field + public uint CRC; + /// CreationDate field + public int CreationDate; + /// SaleType field + public byte SaleType; + /// BaseMask field + public uint BaseMask; + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - /// InvType field - public sbyte InvType; - /// Type field - public sbyte Type; - /// AssetID field - public LLUUID AssetID; - /// GroupID field - public LLUUID GroupID; - /// SalePrice field - public int SalePrice; - /// OwnerID field - public LLUUID OwnerID; - /// CreatorID field - public LLUUID CreatorID; - /// ItemID field - public LLUUID ItemID; - /// FolderID field - public LLUUID FolderID; - /// EveryoneMask field - public uint EveryoneMask; - private byte[] _description; - /// Description field + } + /// InvType field + public sbyte InvType; + /// Type field + public sbyte Type; + /// AssetID field + public LLUUID AssetID; + /// GroupID field + public LLUUID GroupID; + /// SalePrice field + public int SalePrice; + /// OwnerID field + public LLUUID OwnerID; + /// CreatorID field + public LLUUID CreatorID; + /// ItemID field + public LLUUID ItemID; + /// FolderID field + public LLUUID FolderID; + /// EveryoneMask field + public uint EveryoneMask; + private byte[] _description; + /// Description field public byte[] Description - { - get { return _description; } + { + get { return _description; } set - { - if (value == null) { _description = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } + { + if (value == null) { _description = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } } - } - /// Flags field - public uint Flags; - /// NextOwnerMask field - public uint NextOwnerMask; - /// GroupMask field - public uint GroupMask; - /// OwnerMask field - public uint OwnerMask; - - /// Length of this block serialized in bytes + } + /// Flags field + public uint Flags; + /// NextOwnerMask field + public uint NextOwnerMask; + /// GroupMask field + public uint GroupMask; + /// OwnerMask field + public uint OwnerMask; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 136; - if (Name != null) { length += 1 + Name.Length; } - if (Description != null) { length += 1 + Description.Length; } - return length; + { + int length = 136; + if (Name != null) { length += 1 + Name.Length; } + if (Description != null) { length += 1 + Description.Length; } + return length; } } - - /// Default constructor - public ItemDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ItemDataBlock() { } + /// Constructor for building the block from a byte array public ItemDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - GroupOwned = (bytes[i++] != 0) ? (bool)true : (bool)false; - CRC = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - CreationDate = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - SaleType = (byte)bytes[i++]; - BaseMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; - InvType = (sbyte)bytes[i++]; - Type = (sbyte)bytes[i++]; - AssetID = new LLUUID(bytes, i); i += 16; - GroupID = new LLUUID(bytes, i); i += 16; - SalePrice = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - OwnerID = new LLUUID(bytes, i); i += 16; - CreatorID = new LLUUID(bytes, i); i += 16; - ItemID = new LLUUID(bytes, i); i += 16; - FolderID = new LLUUID(bytes, i); i += 16; - EveryoneMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _description = new byte[length]; - Array.Copy(bytes, i, _description, 0, length); i += length; - Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - NextOwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - GroupMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - OwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + GroupOwned = (bytes[i++] != 0) ? (bool)true : (bool)false; + CRC = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + CreationDate = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + SaleType = (byte)bytes[i++]; + BaseMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; + InvType = (sbyte)bytes[i++]; + Type = (sbyte)bytes[i++]; + AssetID = new LLUUID(bytes, i); i += 16; + GroupID = new LLUUID(bytes, i); i += 16; + SalePrice = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + OwnerID = new LLUUID(bytes, i); i += 16; + CreatorID = new LLUUID(bytes, i); i += 16; + ItemID = new LLUUID(bytes, i); i += 16; + FolderID = new LLUUID(bytes, i); i += 16; + EveryoneMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _description = new byte[length]; + Array.Copy(bytes, i, _description, 0, length); i += length; + Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + NextOwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + GroupMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + OwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)((GroupOwned) ? 1 : 0); - bytes[i++] = (byte)(CRC % 256); - bytes[i++] = (byte)((CRC >> 8) % 256); - bytes[i++] = (byte)((CRC >> 16) % 256); - bytes[i++] = (byte)((CRC >> 24) % 256); - bytes[i++] = (byte)(CreationDate % 256); - bytes[i++] = (byte)((CreationDate >> 8) % 256); - bytes[i++] = (byte)((CreationDate >> 16) % 256); - bytes[i++] = (byte)((CreationDate >> 24) % 256); - bytes[i++] = SaleType; - bytes[i++] = (byte)(BaseMask % 256); - bytes[i++] = (byte)((BaseMask >> 8) % 256); - bytes[i++] = (byte)((BaseMask >> 16) % 256); - bytes[i++] = (byte)((BaseMask >> 24) % 256); - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; - bytes[i++] = (byte)InvType; - bytes[i++] = (byte)Type; - if(AssetID == null) { Console.WriteLine("Warning: AssetID is null, in " + this.GetType()); } - Array.Copy(AssetID.GetBytes(), 0, bytes, i, 16); i += 16; - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(SalePrice % 256); - bytes[i++] = (byte)((SalePrice >> 8) % 256); - bytes[i++] = (byte)((SalePrice >> 16) % 256); - bytes[i++] = (byte)((SalePrice >> 24) % 256); - if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } - Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; - if(CreatorID == null) { Console.WriteLine("Warning: CreatorID is null, in " + this.GetType()); } - Array.Copy(CreatorID.GetBytes(), 0, bytes, i, 16); i += 16; - if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } - Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; - if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } - Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(EveryoneMask % 256); - bytes[i++] = (byte)((EveryoneMask >> 8) % 256); - bytes[i++] = (byte)((EveryoneMask >> 16) % 256); - bytes[i++] = (byte)((EveryoneMask >> 24) % 256); - if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } - bytes[i++] = (byte)Description.Length; - Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; - bytes[i++] = (byte)(Flags % 256); - bytes[i++] = (byte)((Flags >> 8) % 256); - bytes[i++] = (byte)((Flags >> 16) % 256); - bytes[i++] = (byte)((Flags >> 24) % 256); - bytes[i++] = (byte)(NextOwnerMask % 256); - bytes[i++] = (byte)((NextOwnerMask >> 8) % 256); - bytes[i++] = (byte)((NextOwnerMask >> 16) % 256); - bytes[i++] = (byte)((NextOwnerMask >> 24) % 256); - bytes[i++] = (byte)(GroupMask % 256); - bytes[i++] = (byte)((GroupMask >> 8) % 256); - bytes[i++] = (byte)((GroupMask >> 16) % 256); - bytes[i++] = (byte)((GroupMask >> 24) % 256); - bytes[i++] = (byte)(OwnerMask % 256); - bytes[i++] = (byte)((OwnerMask >> 8) % 256); - bytes[i++] = (byte)((OwnerMask >> 16) % 256); - bytes[i++] = (byte)((OwnerMask >> 24) % 256); + { + bytes[i++] = (byte)((GroupOwned) ? 1 : 0); + bytes[i++] = (byte)(CRC % 256); + bytes[i++] = (byte)((CRC >> 8) % 256); + bytes[i++] = (byte)((CRC >> 16) % 256); + bytes[i++] = (byte)((CRC >> 24) % 256); + bytes[i++] = (byte)(CreationDate % 256); + bytes[i++] = (byte)((CreationDate >> 8) % 256); + bytes[i++] = (byte)((CreationDate >> 16) % 256); + bytes[i++] = (byte)((CreationDate >> 24) % 256); + bytes[i++] = SaleType; + bytes[i++] = (byte)(BaseMask % 256); + bytes[i++] = (byte)((BaseMask >> 8) % 256); + bytes[i++] = (byte)((BaseMask >> 16) % 256); + bytes[i++] = (byte)((BaseMask >> 24) % 256); + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + bytes[i++] = (byte)InvType; + bytes[i++] = (byte)Type; + if(AssetID == null) { Console.WriteLine("Warning: AssetID is null, in " + this.GetType()); } + Array.Copy(AssetID.GetBytes(), 0, bytes, i, 16); i += 16; + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(SalePrice % 256); + bytes[i++] = (byte)((SalePrice >> 8) % 256); + bytes[i++] = (byte)((SalePrice >> 16) % 256); + bytes[i++] = (byte)((SalePrice >> 24) % 256); + if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } + Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; + if(CreatorID == null) { Console.WriteLine("Warning: CreatorID is null, in " + this.GetType()); } + Array.Copy(CreatorID.GetBytes(), 0, bytes, i, 16); i += 16; + if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } + Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; + if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } + Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(EveryoneMask % 256); + bytes[i++] = (byte)((EveryoneMask >> 8) % 256); + bytes[i++] = (byte)((EveryoneMask >> 16) % 256); + bytes[i++] = (byte)((EveryoneMask >> 24) % 256); + if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } + bytes[i++] = (byte)Description.Length; + Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; + bytes[i++] = (byte)(Flags % 256); + bytes[i++] = (byte)((Flags >> 8) % 256); + bytes[i++] = (byte)((Flags >> 16) % 256); + bytes[i++] = (byte)((Flags >> 24) % 256); + bytes[i++] = (byte)(NextOwnerMask % 256); + bytes[i++] = (byte)((NextOwnerMask >> 8) % 256); + bytes[i++] = (byte)((NextOwnerMask >> 16) % 256); + bytes[i++] = (byte)((NextOwnerMask >> 24) % 256); + bytes[i++] = (byte)(GroupMask % 256); + bytes[i++] = (byte)((GroupMask >> 8) % 256); + bytes[i++] = (byte)((GroupMask >> 16) % 256); + bytes[i++] = (byte)((GroupMask >> 24) % 256); + bytes[i++] = (byte)(OwnerMask % 256); + bytes[i++] = (byte)((OwnerMask >> 8) % 256); + bytes[i++] = (byte)((OwnerMask >> 16) % 256); + bytes[i++] = (byte)((OwnerMask >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ItemData --\n"; - output += "GroupOwned: " + GroupOwned.ToString() + "\n"; - output += "CRC: " + CRC.ToString() + "\n"; - output += "CreationDate: " + CreationDate.ToString() + "\n"; - output += "SaleType: " + SaleType.ToString() + "\n"; - output += "BaseMask: " + BaseMask.ToString() + "\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; - output += "InvType: " + InvType.ToString() + "\n"; - output += "Type: " + Type.ToString() + "\n"; - output += "AssetID: " + AssetID.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; - output += "SalePrice: " + SalePrice.ToString() + "\n"; - output += "OwnerID: " + OwnerID.ToString() + "\n"; - output += "CreatorID: " + CreatorID.ToString() + "\n"; - output += "ItemID: " + ItemID.ToString() + "\n"; - output += "FolderID: " + FolderID.ToString() + "\n"; - output += "EveryoneMask: " + EveryoneMask.ToString() + "\n"; - output += Helpers.FieldToString(Description, "Description") + "\n"; - output += "Flags: " + Flags.ToString() + "\n"; - output += "NextOwnerMask: " + NextOwnerMask.ToString() + "\n"; - output += "GroupMask: " + GroupMask.ToString() + "\n"; - output += "OwnerMask: " + OwnerMask.ToString() + "\n"; + { + string output = "-- ItemData --\n"; + output += "GroupOwned: " + GroupOwned.ToString() + "\n"; + output += "CRC: " + CRC.ToString() + "\n"; + output += "CreationDate: " + CreationDate.ToString() + "\n"; + output += "SaleType: " + SaleType.ToString() + "\n"; + output += "BaseMask: " + BaseMask.ToString() + "\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; + output += "InvType: " + InvType.ToString() + "\n"; + output += "Type: " + Type.ToString() + "\n"; + output += "AssetID: " + AssetID.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; + output += "SalePrice: " + SalePrice.ToString() + "\n"; + output += "OwnerID: " + OwnerID.ToString() + "\n"; + output += "CreatorID: " + CreatorID.ToString() + "\n"; + output += "ItemID: " + ItemID.ToString() + "\n"; + output += "FolderID: " + FolderID.ToString() + "\n"; + output += "EveryoneMask: " + EveryoneMask.ToString() + "\n"; + output += Helpers.FieldToString(Description, "Description") + "\n"; + output += "Flags: " + Flags.ToString() + "\n"; + output += "NextOwnerMask: " + NextOwnerMask.ToString() + "\n"; + output += "GroupMask: " + GroupMask.ToString() + "\n"; + output += "OwnerMask: " + OwnerMask.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// Descendents field - public int Descendents; - /// Version field - public int Version; - /// OwnerID field - public LLUUID OwnerID; - /// FolderID field - public LLUUID FolderID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// Descendents field + public int Descendents; + /// Version field + public int Version; + /// OwnerID field + public LLUUID OwnerID; + /// FolderID field + public LLUUID FolderID; + + /// Length of this block serialized in bytes public int Length { get - { - return 56; + { + return 56; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - Descendents = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Version = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - OwnerID = new LLUUID(bytes, i); i += 16; - FolderID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + Descendents = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Version = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + OwnerID = new LLUUID(bytes, i); i += 16; + FolderID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(Descendents % 256); - bytes[i++] = (byte)((Descendents >> 8) % 256); - bytes[i++] = (byte)((Descendents >> 16) % 256); - bytes[i++] = (byte)((Descendents >> 24) % 256); - bytes[i++] = (byte)(Version % 256); - bytes[i++] = (byte)((Version >> 8) % 256); - bytes[i++] = (byte)((Version >> 16) % 256); - bytes[i++] = (byte)((Version >> 24) % 256); - if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } - Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; - if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } - Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(Descendents % 256); + bytes[i++] = (byte)((Descendents >> 8) % 256); + bytes[i++] = (byte)((Descendents >> 16) % 256); + bytes[i++] = (byte)((Descendents >> 24) % 256); + bytes[i++] = (byte)(Version % 256); + bytes[i++] = (byte)((Version >> 8) % 256); + bytes[i++] = (byte)((Version >> 16) % 256); + bytes[i++] = (byte)((Version >> 24) % 256); + if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } + Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; + if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } + Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "Descendents: " + Descendents.ToString() + "\n"; - output += "Version: " + Version.ToString() + "\n"; - output += "OwnerID: " + OwnerID.ToString() + "\n"; - output += "FolderID: " + FolderID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "Descendents: " + Descendents.ToString() + "\n"; + output += "Version: " + Version.ToString() + "\n"; + output += "OwnerID: " + OwnerID.ToString() + "\n"; + output += "FolderID: " + FolderID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// FolderData block + + /// FolderData block public class FolderDataBlock - { - private byte[] _name; - /// Name field + { + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - /// ParentID field - public LLUUID ParentID; - /// Type field - public sbyte Type; - /// FolderID field - public LLUUID FolderID; - - /// Length of this block serialized in bytes + } + /// ParentID field + public LLUUID ParentID; + /// Type field + public sbyte Type; + /// FolderID field + public LLUUID FolderID; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 33; - if (Name != null) { length += 1 + Name.Length; } - return length; + { + int length = 33; + if (Name != null) { length += 1 + Name.Length; } + return length; } } - - /// Default constructor - public FolderDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public FolderDataBlock() { } + /// Constructor for building the block from a byte array public FolderDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; - ParentID = new LLUUID(bytes, i); i += 16; - Type = (sbyte)bytes[i++]; - FolderID = new LLUUID(bytes, i); i += 16; + { + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; + ParentID = new LLUUID(bytes, i); i += 16; + Type = (sbyte)bytes[i++]; + FolderID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; - if(ParentID == null) { Console.WriteLine("Warning: ParentID is null, in " + this.GetType()); } - Array.Copy(ParentID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)Type; - if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } - Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + if(ParentID == null) { Console.WriteLine("Warning: ParentID is null, in " + this.GetType()); } + Array.Copy(ParentID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)Type; + if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } + Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- FolderData --\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; - output += "ParentID: " + ParentID.ToString() + "\n"; - output += "Type: " + Type.ToString() + "\n"; - output += "FolderID: " + FolderID.ToString() + "\n"; + { + string output = "-- FolderData --\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; + output += "ParentID: " + ParentID.ToString() + "\n"; + output += "Type: " + Type.ToString() + "\n"; + output += "FolderID: " + FolderID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.InventoryDescendents - public override PacketType Type { get { return PacketType.InventoryDescendents; } } - /// ItemData block - public ItemDataBlock[] ItemData; - /// AgentData block - public AgentDataBlock AgentData; - /// FolderData block - public FolderDataBlock[] FolderData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.InventoryDescendents + public override PacketType Type { get { return PacketType.InventoryDescendents; } } + /// ItemData block + public ItemDataBlock[] ItemData; + /// AgentData block + public AgentDataBlock AgentData; + /// FolderData block + public FolderDataBlock[] FolderData; + + /// Default constructor public InventoryDescendentsPacket() - { - Header = new LowHeader(); - Header.ID = 328; - Header.Reliable = true; - Header.Zerocoded = true; - ItemData = new ItemDataBlock[0]; - AgentData = new AgentDataBlock(); - FolderData = new FolderDataBlock[0]; + { + Header = new LowHeader(); + Header.ID = 328; + Header.Reliable = true; + Header.Zerocoded = true; + ItemData = new ItemDataBlock[0]; + AgentData = new AgentDataBlock(); + FolderData = new FolderDataBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public InventoryDescendentsPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ItemData = new ItemDataBlock[count]; - for (int j = 0; j < count; j++) - { ItemData[j] = new ItemDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); - count = (int)bytes[i++]; - FolderData = new FolderDataBlock[count]; - for (int j = 0; j < count; j++) - { FolderData[j] = new FolderDataBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ItemData = new ItemDataBlock[count]; + for (int j = 0; j < count; j++) + { ItemData[j] = new ItemDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); + count = (int)bytes[i++]; + FolderData = new FolderDataBlock[count]; + for (int j = 0; j < count; j++) + { FolderData[j] = new FolderDataBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public InventoryDescendentsPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ItemData = new ItemDataBlock[count]; - for (int j = 0; j < count; j++) - { ItemData[j] = new ItemDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); - count = (int)bytes[i++]; - FolderData = new FolderDataBlock[count]; - for (int j = 0; j < count; j++) - { FolderData[j] = new FolderDataBlock(bytes, ref i); } + { + Header = head; + int count = (int)bytes[i++]; + ItemData = new ItemDataBlock[count]; + for (int j = 0; j < count; j++) + { ItemData[j] = new ItemDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); + count = (int)bytes[i++]; + FolderData = new FolderDataBlock[count]; + for (int j = 0; j < count; j++) + { FolderData[j] = new FolderDataBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < ItemData.Length; j++) { length += ItemData[j].Length; } - length++; - for (int j = 0; j < FolderData.Length; j++) { length += FolderData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ItemData.Length; - for (int j = 0; j < ItemData.Length; j++) { ItemData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - bytes[i++] = (byte)FolderData.Length; - for (int j = 0; j < FolderData.Length; j++) { FolderData[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < ItemData.Length; j++) { length += ItemData[j].Length; } + length++; + for (int j = 0; j < FolderData.Length; j++) { length += FolderData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ItemData.Length; + for (int j = 0; j < ItemData.Length; j++) { ItemData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + bytes[i++] = (byte)FolderData.Length; + for (int j = 0; j < FolderData.Length; j++) { FolderData[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- InventoryDescendents ---\n"; + { + string output = "--- InventoryDescendents ---\n"; for (int j = 0; j < ItemData.Length; j++) - { + { output += ItemData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; for (int j = 0; j < FolderData.Length; j++) - { + { output += FolderData[j].ToString() + "\n"; - } + } return output; } - + } - - /// FetchInventory packet + + /// FetchInventory packet public class FetchInventoryPacket : Packet - { - /// InventoryData block + { + /// InventoryData block public class InventoryDataBlock - { - /// OwnerID field - public LLUUID OwnerID; - /// ItemID field - public LLUUID ItemID; - - /// Length of this block serialized in bytes + { + /// OwnerID field + public LLUUID OwnerID; + /// ItemID field + public LLUUID ItemID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public InventoryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public InventoryDataBlock() { } + /// Constructor for building the block from a byte array public InventoryDataBlock(byte[] bytes, ref int i) - { + { try - { - OwnerID = new LLUUID(bytes, i); i += 16; - ItemID = new LLUUID(bytes, i); i += 16; + { + OwnerID = new LLUUID(bytes, i); i += 16; + ItemID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } - Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; - if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } - Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } + Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; + if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } + Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- InventoryData --\n"; - output += "OwnerID: " + OwnerID.ToString() + "\n"; - output += "ItemID: " + ItemID.ToString() + "\n"; + { + string output = "-- InventoryData --\n"; + output += "OwnerID: " + OwnerID.ToString() + "\n"; + output += "ItemID: " + ItemID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.FetchInventory - public override PacketType Type { get { return PacketType.FetchInventory; } } - /// InventoryData block - public InventoryDataBlock[] InventoryData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.FetchInventory + public override PacketType Type { get { return PacketType.FetchInventory; } } + /// InventoryData block + public InventoryDataBlock[] InventoryData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public FetchInventoryPacket() - { - Header = new LowHeader(); - Header.ID = 329; - Header.Reliable = true; - Header.Zerocoded = true; - InventoryData = new InventoryDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 329; + Header.Reliable = true; + Header.Zerocoded = true; + InventoryData = new InventoryDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public FetchInventoryPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - InventoryData = new InventoryDataBlock[count]; - for (int j = 0; j < count; j++) - { InventoryData[j] = new InventoryDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + InventoryData = new InventoryDataBlock[count]; + for (int j = 0; j < count; j++) + { InventoryData[j] = new InventoryDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public FetchInventoryPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - InventoryData = new InventoryDataBlock[count]; - for (int j = 0; j < count; j++) - { InventoryData[j] = new InventoryDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + InventoryData = new InventoryDataBlock[count]; + for (int j = 0; j < count; j++) + { InventoryData[j] = new InventoryDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < InventoryData.Length; j++) { length += InventoryData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)InventoryData.Length; - for (int j = 0; j < InventoryData.Length; j++) { InventoryData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < InventoryData.Length; j++) { length += InventoryData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)InventoryData.Length; + for (int j = 0; j < InventoryData.Length; j++) { InventoryData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- FetchInventory ---\n"; + { + string output = "--- FetchInventory ---\n"; for (int j = 0; j < InventoryData.Length; j++) - { + { output += InventoryData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// FetchInventoryReply packet + + /// FetchInventoryReply packet public class FetchInventoryReplyPacket : Packet - { - /// InventoryData block + { + /// InventoryData block public class InventoryDataBlock - { - /// GroupOwned field - public bool GroupOwned; - /// CRC field - public uint CRC; - /// CreationDate field - public int CreationDate; - /// SaleType field - public byte SaleType; - /// BaseMask field - public uint BaseMask; - private byte[] _name; - /// Name field + { + /// GroupOwned field + public bool GroupOwned; + /// CRC field + public uint CRC; + /// CreationDate field + public int CreationDate; + /// SaleType field + public byte SaleType; + /// BaseMask field + public uint BaseMask; + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - /// InvType field - public sbyte InvType; - /// Type field - public sbyte Type; - /// AssetID field - public LLUUID AssetID; - /// GroupID field - public LLUUID GroupID; - /// SalePrice field - public int SalePrice; - /// OwnerID field - public LLUUID OwnerID; - /// CreatorID field - public LLUUID CreatorID; - /// ItemID field - public LLUUID ItemID; - /// FolderID field - public LLUUID FolderID; - /// EveryoneMask field - public uint EveryoneMask; - private byte[] _description; - /// Description field + } + /// InvType field + public sbyte InvType; + /// Type field + public sbyte Type; + /// AssetID field + public LLUUID AssetID; + /// GroupID field + public LLUUID GroupID; + /// SalePrice field + public int SalePrice; + /// OwnerID field + public LLUUID OwnerID; + /// CreatorID field + public LLUUID CreatorID; + /// ItemID field + public LLUUID ItemID; + /// FolderID field + public LLUUID FolderID; + /// EveryoneMask field + public uint EveryoneMask; + private byte[] _description; + /// Description field public byte[] Description - { - get { return _description; } + { + get { return _description; } set - { - if (value == null) { _description = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } + { + if (value == null) { _description = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } } - } - /// Flags field - public uint Flags; - /// NextOwnerMask field - public uint NextOwnerMask; - /// GroupMask field - public uint GroupMask; - /// OwnerMask field - public uint OwnerMask; - - /// Length of this block serialized in bytes + } + /// Flags field + public uint Flags; + /// NextOwnerMask field + public uint NextOwnerMask; + /// GroupMask field + public uint GroupMask; + /// OwnerMask field + public uint OwnerMask; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 136; - if (Name != null) { length += 1 + Name.Length; } - if (Description != null) { length += 1 + Description.Length; } - return length; + { + int length = 136; + if (Name != null) { length += 1 + Name.Length; } + if (Description != null) { length += 1 + Description.Length; } + return length; } } - - /// Default constructor - public InventoryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public InventoryDataBlock() { } + /// Constructor for building the block from a byte array public InventoryDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - GroupOwned = (bytes[i++] != 0) ? (bool)true : (bool)false; - CRC = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - CreationDate = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - SaleType = (byte)bytes[i++]; - BaseMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; - InvType = (sbyte)bytes[i++]; - Type = (sbyte)bytes[i++]; - AssetID = new LLUUID(bytes, i); i += 16; - GroupID = new LLUUID(bytes, i); i += 16; - SalePrice = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - OwnerID = new LLUUID(bytes, i); i += 16; - CreatorID = new LLUUID(bytes, i); i += 16; - ItemID = new LLUUID(bytes, i); i += 16; - FolderID = new LLUUID(bytes, i); i += 16; - EveryoneMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _description = new byte[length]; - Array.Copy(bytes, i, _description, 0, length); i += length; - Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - NextOwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - GroupMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - OwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + GroupOwned = (bytes[i++] != 0) ? (bool)true : (bool)false; + CRC = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + CreationDate = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + SaleType = (byte)bytes[i++]; + BaseMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; + InvType = (sbyte)bytes[i++]; + Type = (sbyte)bytes[i++]; + AssetID = new LLUUID(bytes, i); i += 16; + GroupID = new LLUUID(bytes, i); i += 16; + SalePrice = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + OwnerID = new LLUUID(bytes, i); i += 16; + CreatorID = new LLUUID(bytes, i); i += 16; + ItemID = new LLUUID(bytes, i); i += 16; + FolderID = new LLUUID(bytes, i); i += 16; + EveryoneMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _description = new byte[length]; + Array.Copy(bytes, i, _description, 0, length); i += length; + Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + NextOwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + GroupMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + OwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)((GroupOwned) ? 1 : 0); - bytes[i++] = (byte)(CRC % 256); - bytes[i++] = (byte)((CRC >> 8) % 256); - bytes[i++] = (byte)((CRC >> 16) % 256); - bytes[i++] = (byte)((CRC >> 24) % 256); - bytes[i++] = (byte)(CreationDate % 256); - bytes[i++] = (byte)((CreationDate >> 8) % 256); - bytes[i++] = (byte)((CreationDate >> 16) % 256); - bytes[i++] = (byte)((CreationDate >> 24) % 256); - bytes[i++] = SaleType; - bytes[i++] = (byte)(BaseMask % 256); - bytes[i++] = (byte)((BaseMask >> 8) % 256); - bytes[i++] = (byte)((BaseMask >> 16) % 256); - bytes[i++] = (byte)((BaseMask >> 24) % 256); - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; - bytes[i++] = (byte)InvType; - bytes[i++] = (byte)Type; - if(AssetID == null) { Console.WriteLine("Warning: AssetID is null, in " + this.GetType()); } - Array.Copy(AssetID.GetBytes(), 0, bytes, i, 16); i += 16; - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(SalePrice % 256); - bytes[i++] = (byte)((SalePrice >> 8) % 256); - bytes[i++] = (byte)((SalePrice >> 16) % 256); - bytes[i++] = (byte)((SalePrice >> 24) % 256); - if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } - Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; - if(CreatorID == null) { Console.WriteLine("Warning: CreatorID is null, in " + this.GetType()); } - Array.Copy(CreatorID.GetBytes(), 0, bytes, i, 16); i += 16; - if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } - Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; - if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } - Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(EveryoneMask % 256); - bytes[i++] = (byte)((EveryoneMask >> 8) % 256); - bytes[i++] = (byte)((EveryoneMask >> 16) % 256); - bytes[i++] = (byte)((EveryoneMask >> 24) % 256); - if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } - bytes[i++] = (byte)Description.Length; - Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; - bytes[i++] = (byte)(Flags % 256); - bytes[i++] = (byte)((Flags >> 8) % 256); - bytes[i++] = (byte)((Flags >> 16) % 256); - bytes[i++] = (byte)((Flags >> 24) % 256); - bytes[i++] = (byte)(NextOwnerMask % 256); - bytes[i++] = (byte)((NextOwnerMask >> 8) % 256); - bytes[i++] = (byte)((NextOwnerMask >> 16) % 256); - bytes[i++] = (byte)((NextOwnerMask >> 24) % 256); - bytes[i++] = (byte)(GroupMask % 256); - bytes[i++] = (byte)((GroupMask >> 8) % 256); - bytes[i++] = (byte)((GroupMask >> 16) % 256); - bytes[i++] = (byte)((GroupMask >> 24) % 256); - bytes[i++] = (byte)(OwnerMask % 256); - bytes[i++] = (byte)((OwnerMask >> 8) % 256); - bytes[i++] = (byte)((OwnerMask >> 16) % 256); - bytes[i++] = (byte)((OwnerMask >> 24) % 256); + { + bytes[i++] = (byte)((GroupOwned) ? 1 : 0); + bytes[i++] = (byte)(CRC % 256); + bytes[i++] = (byte)((CRC >> 8) % 256); + bytes[i++] = (byte)((CRC >> 16) % 256); + bytes[i++] = (byte)((CRC >> 24) % 256); + bytes[i++] = (byte)(CreationDate % 256); + bytes[i++] = (byte)((CreationDate >> 8) % 256); + bytes[i++] = (byte)((CreationDate >> 16) % 256); + bytes[i++] = (byte)((CreationDate >> 24) % 256); + bytes[i++] = SaleType; + bytes[i++] = (byte)(BaseMask % 256); + bytes[i++] = (byte)((BaseMask >> 8) % 256); + bytes[i++] = (byte)((BaseMask >> 16) % 256); + bytes[i++] = (byte)((BaseMask >> 24) % 256); + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + bytes[i++] = (byte)InvType; + bytes[i++] = (byte)Type; + if(AssetID == null) { Console.WriteLine("Warning: AssetID is null, in " + this.GetType()); } + Array.Copy(AssetID.GetBytes(), 0, bytes, i, 16); i += 16; + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(SalePrice % 256); + bytes[i++] = (byte)((SalePrice >> 8) % 256); + bytes[i++] = (byte)((SalePrice >> 16) % 256); + bytes[i++] = (byte)((SalePrice >> 24) % 256); + if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } + Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; + if(CreatorID == null) { Console.WriteLine("Warning: CreatorID is null, in " + this.GetType()); } + Array.Copy(CreatorID.GetBytes(), 0, bytes, i, 16); i += 16; + if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } + Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; + if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } + Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(EveryoneMask % 256); + bytes[i++] = (byte)((EveryoneMask >> 8) % 256); + bytes[i++] = (byte)((EveryoneMask >> 16) % 256); + bytes[i++] = (byte)((EveryoneMask >> 24) % 256); + if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } + bytes[i++] = (byte)Description.Length; + Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; + bytes[i++] = (byte)(Flags % 256); + bytes[i++] = (byte)((Flags >> 8) % 256); + bytes[i++] = (byte)((Flags >> 16) % 256); + bytes[i++] = (byte)((Flags >> 24) % 256); + bytes[i++] = (byte)(NextOwnerMask % 256); + bytes[i++] = (byte)((NextOwnerMask >> 8) % 256); + bytes[i++] = (byte)((NextOwnerMask >> 16) % 256); + bytes[i++] = (byte)((NextOwnerMask >> 24) % 256); + bytes[i++] = (byte)(GroupMask % 256); + bytes[i++] = (byte)((GroupMask >> 8) % 256); + bytes[i++] = (byte)((GroupMask >> 16) % 256); + bytes[i++] = (byte)((GroupMask >> 24) % 256); + bytes[i++] = (byte)(OwnerMask % 256); + bytes[i++] = (byte)((OwnerMask >> 8) % 256); + bytes[i++] = (byte)((OwnerMask >> 16) % 256); + bytes[i++] = (byte)((OwnerMask >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- InventoryData --\n"; - output += "GroupOwned: " + GroupOwned.ToString() + "\n"; - output += "CRC: " + CRC.ToString() + "\n"; - output += "CreationDate: " + CreationDate.ToString() + "\n"; - output += "SaleType: " + SaleType.ToString() + "\n"; - output += "BaseMask: " + BaseMask.ToString() + "\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; - output += "InvType: " + InvType.ToString() + "\n"; - output += "Type: " + Type.ToString() + "\n"; - output += "AssetID: " + AssetID.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; - output += "SalePrice: " + SalePrice.ToString() + "\n"; - output += "OwnerID: " + OwnerID.ToString() + "\n"; - output += "CreatorID: " + CreatorID.ToString() + "\n"; - output += "ItemID: " + ItemID.ToString() + "\n"; - output += "FolderID: " + FolderID.ToString() + "\n"; - output += "EveryoneMask: " + EveryoneMask.ToString() + "\n"; - output += Helpers.FieldToString(Description, "Description") + "\n"; - output += "Flags: " + Flags.ToString() + "\n"; - output += "NextOwnerMask: " + NextOwnerMask.ToString() + "\n"; - output += "GroupMask: " + GroupMask.ToString() + "\n"; - output += "OwnerMask: " + OwnerMask.ToString() + "\n"; + { + string output = "-- InventoryData --\n"; + output += "GroupOwned: " + GroupOwned.ToString() + "\n"; + output += "CRC: " + CRC.ToString() + "\n"; + output += "CreationDate: " + CreationDate.ToString() + "\n"; + output += "SaleType: " + SaleType.ToString() + "\n"; + output += "BaseMask: " + BaseMask.ToString() + "\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; + output += "InvType: " + InvType.ToString() + "\n"; + output += "Type: " + Type.ToString() + "\n"; + output += "AssetID: " + AssetID.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; + output += "SalePrice: " + SalePrice.ToString() + "\n"; + output += "OwnerID: " + OwnerID.ToString() + "\n"; + output += "CreatorID: " + CreatorID.ToString() + "\n"; + output += "ItemID: " + ItemID.ToString() + "\n"; + output += "FolderID: " + FolderID.ToString() + "\n"; + output += "EveryoneMask: " + EveryoneMask.ToString() + "\n"; + output += Helpers.FieldToString(Description, "Description") + "\n"; + output += "Flags: " + Flags.ToString() + "\n"; + output += "NextOwnerMask: " + NextOwnerMask.ToString() + "\n"; + output += "GroupMask: " + GroupMask.ToString() + "\n"; + output += "OwnerMask: " + OwnerMask.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.FetchInventoryReply - public override PacketType Type { get { return PacketType.FetchInventoryReply; } } - /// InventoryData block - public InventoryDataBlock[] InventoryData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.FetchInventoryReply + public override PacketType Type { get { return PacketType.FetchInventoryReply; } } + /// InventoryData block + public InventoryDataBlock[] InventoryData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public FetchInventoryReplyPacket() - { - Header = new LowHeader(); - Header.ID = 330; - Header.Reliable = true; - Header.Zerocoded = true; - InventoryData = new InventoryDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 330; + Header.Reliable = true; + Header.Zerocoded = true; + InventoryData = new InventoryDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public FetchInventoryReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - InventoryData = new InventoryDataBlock[count]; - for (int j = 0; j < count; j++) - { InventoryData[j] = new InventoryDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + InventoryData = new InventoryDataBlock[count]; + for (int j = 0; j < count; j++) + { InventoryData[j] = new InventoryDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public FetchInventoryReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - InventoryData = new InventoryDataBlock[count]; - for (int j = 0; j < count; j++) - { InventoryData[j] = new InventoryDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + InventoryData = new InventoryDataBlock[count]; + for (int j = 0; j < count; j++) + { InventoryData[j] = new InventoryDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < InventoryData.Length; j++) { length += InventoryData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)InventoryData.Length; - for (int j = 0; j < InventoryData.Length; j++) { InventoryData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < InventoryData.Length; j++) { length += InventoryData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)InventoryData.Length; + for (int j = 0; j < InventoryData.Length; j++) { InventoryData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- FetchInventoryReply ---\n"; + { + string output = "--- FetchInventoryReply ---\n"; for (int j = 0; j < InventoryData.Length; j++) - { + { output += InventoryData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// BulkUpdateInventory packet + + /// BulkUpdateInventory packet public class BulkUpdateInventoryPacket : Packet - { - /// ItemData block + { + /// ItemData block public class ItemDataBlock - { - /// GroupOwned field - public bool GroupOwned; - /// CRC field - public uint CRC; - /// CreationDate field - public int CreationDate; - /// SaleType field - public byte SaleType; - /// CallbackID field - public uint CallbackID; - /// BaseMask field - public uint BaseMask; - private byte[] _name; - /// Name field + { + /// GroupOwned field + public bool GroupOwned; + /// CRC field + public uint CRC; + /// CreationDate field + public int CreationDate; + /// SaleType field + public byte SaleType; + /// CallbackID field + public uint CallbackID; + /// BaseMask field + public uint BaseMask; + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - /// InvType field - public sbyte InvType; - /// Type field - public sbyte Type; - /// AssetID field - public LLUUID AssetID; - /// GroupID field - public LLUUID GroupID; - /// SalePrice field - public int SalePrice; - /// OwnerID field - public LLUUID OwnerID; - /// CreatorID field - public LLUUID CreatorID; - /// ItemID field - public LLUUID ItemID; - /// FolderID field - public LLUUID FolderID; - /// EveryoneMask field - public uint EveryoneMask; - private byte[] _description; - /// Description field + } + /// InvType field + public sbyte InvType; + /// Type field + public sbyte Type; + /// AssetID field + public LLUUID AssetID; + /// GroupID field + public LLUUID GroupID; + /// SalePrice field + public int SalePrice; + /// OwnerID field + public LLUUID OwnerID; + /// CreatorID field + public LLUUID CreatorID; + /// ItemID field + public LLUUID ItemID; + /// FolderID field + public LLUUID FolderID; + /// EveryoneMask field + public uint EveryoneMask; + private byte[] _description; + /// Description field public byte[] Description - { - get { return _description; } + { + get { return _description; } set - { - if (value == null) { _description = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } + { + if (value == null) { _description = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } } - } - /// Flags field - public uint Flags; - /// NextOwnerMask field - public uint NextOwnerMask; - /// GroupMask field - public uint GroupMask; - /// OwnerMask field - public uint OwnerMask; - - /// Length of this block serialized in bytes + } + /// Flags field + public uint Flags; + /// NextOwnerMask field + public uint NextOwnerMask; + /// GroupMask field + public uint GroupMask; + /// OwnerMask field + public uint OwnerMask; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 140; - if (Name != null) { length += 1 + Name.Length; } - if (Description != null) { length += 1 + Description.Length; } - return length; + { + int length = 140; + if (Name != null) { length += 1 + Name.Length; } + if (Description != null) { length += 1 + Description.Length; } + return length; } } - - /// Default constructor - public ItemDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ItemDataBlock() { } + /// Constructor for building the block from a byte array public ItemDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - GroupOwned = (bytes[i++] != 0) ? (bool)true : (bool)false; - CRC = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - CreationDate = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - SaleType = (byte)bytes[i++]; - CallbackID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - BaseMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; - InvType = (sbyte)bytes[i++]; - Type = (sbyte)bytes[i++]; - AssetID = new LLUUID(bytes, i); i += 16; - GroupID = new LLUUID(bytes, i); i += 16; - SalePrice = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - OwnerID = new LLUUID(bytes, i); i += 16; - CreatorID = new LLUUID(bytes, i); i += 16; - ItemID = new LLUUID(bytes, i); i += 16; - FolderID = new LLUUID(bytes, i); i += 16; - EveryoneMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _description = new byte[length]; - Array.Copy(bytes, i, _description, 0, length); i += length; - Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - NextOwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - GroupMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - OwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + GroupOwned = (bytes[i++] != 0) ? (bool)true : (bool)false; + CRC = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + CreationDate = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + SaleType = (byte)bytes[i++]; + CallbackID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + BaseMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; + InvType = (sbyte)bytes[i++]; + Type = (sbyte)bytes[i++]; + AssetID = new LLUUID(bytes, i); i += 16; + GroupID = new LLUUID(bytes, i); i += 16; + SalePrice = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + OwnerID = new LLUUID(bytes, i); i += 16; + CreatorID = new LLUUID(bytes, i); i += 16; + ItemID = new LLUUID(bytes, i); i += 16; + FolderID = new LLUUID(bytes, i); i += 16; + EveryoneMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _description = new byte[length]; + Array.Copy(bytes, i, _description, 0, length); i += length; + Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + NextOwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + GroupMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + OwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)((GroupOwned) ? 1 : 0); - bytes[i++] = (byte)(CRC % 256); - bytes[i++] = (byte)((CRC >> 8) % 256); - bytes[i++] = (byte)((CRC >> 16) % 256); - bytes[i++] = (byte)((CRC >> 24) % 256); - bytes[i++] = (byte)(CreationDate % 256); - bytes[i++] = (byte)((CreationDate >> 8) % 256); - bytes[i++] = (byte)((CreationDate >> 16) % 256); - bytes[i++] = (byte)((CreationDate >> 24) % 256); - bytes[i++] = SaleType; - bytes[i++] = (byte)(CallbackID % 256); - bytes[i++] = (byte)((CallbackID >> 8) % 256); - bytes[i++] = (byte)((CallbackID >> 16) % 256); - bytes[i++] = (byte)((CallbackID >> 24) % 256); - bytes[i++] = (byte)(BaseMask % 256); - bytes[i++] = (byte)((BaseMask >> 8) % 256); - bytes[i++] = (byte)((BaseMask >> 16) % 256); - bytes[i++] = (byte)((BaseMask >> 24) % 256); - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; - bytes[i++] = (byte)InvType; - bytes[i++] = (byte)Type; - if(AssetID == null) { Console.WriteLine("Warning: AssetID is null, in " + this.GetType()); } - Array.Copy(AssetID.GetBytes(), 0, bytes, i, 16); i += 16; - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(SalePrice % 256); - bytes[i++] = (byte)((SalePrice >> 8) % 256); - bytes[i++] = (byte)((SalePrice >> 16) % 256); - bytes[i++] = (byte)((SalePrice >> 24) % 256); - if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } - Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; - if(CreatorID == null) { Console.WriteLine("Warning: CreatorID is null, in " + this.GetType()); } - Array.Copy(CreatorID.GetBytes(), 0, bytes, i, 16); i += 16; - if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } - Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; - if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } - Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(EveryoneMask % 256); - bytes[i++] = (byte)((EveryoneMask >> 8) % 256); - bytes[i++] = (byte)((EveryoneMask >> 16) % 256); - bytes[i++] = (byte)((EveryoneMask >> 24) % 256); - if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } - bytes[i++] = (byte)Description.Length; - Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; - bytes[i++] = (byte)(Flags % 256); - bytes[i++] = (byte)((Flags >> 8) % 256); - bytes[i++] = (byte)((Flags >> 16) % 256); - bytes[i++] = (byte)((Flags >> 24) % 256); - bytes[i++] = (byte)(NextOwnerMask % 256); - bytes[i++] = (byte)((NextOwnerMask >> 8) % 256); - bytes[i++] = (byte)((NextOwnerMask >> 16) % 256); - bytes[i++] = (byte)((NextOwnerMask >> 24) % 256); - bytes[i++] = (byte)(GroupMask % 256); - bytes[i++] = (byte)((GroupMask >> 8) % 256); - bytes[i++] = (byte)((GroupMask >> 16) % 256); - bytes[i++] = (byte)((GroupMask >> 24) % 256); - bytes[i++] = (byte)(OwnerMask % 256); - bytes[i++] = (byte)((OwnerMask >> 8) % 256); - bytes[i++] = (byte)((OwnerMask >> 16) % 256); - bytes[i++] = (byte)((OwnerMask >> 24) % 256); + { + bytes[i++] = (byte)((GroupOwned) ? 1 : 0); + bytes[i++] = (byte)(CRC % 256); + bytes[i++] = (byte)((CRC >> 8) % 256); + bytes[i++] = (byte)((CRC >> 16) % 256); + bytes[i++] = (byte)((CRC >> 24) % 256); + bytes[i++] = (byte)(CreationDate % 256); + bytes[i++] = (byte)((CreationDate >> 8) % 256); + bytes[i++] = (byte)((CreationDate >> 16) % 256); + bytes[i++] = (byte)((CreationDate >> 24) % 256); + bytes[i++] = SaleType; + bytes[i++] = (byte)(CallbackID % 256); + bytes[i++] = (byte)((CallbackID >> 8) % 256); + bytes[i++] = (byte)((CallbackID >> 16) % 256); + bytes[i++] = (byte)((CallbackID >> 24) % 256); + bytes[i++] = (byte)(BaseMask % 256); + bytes[i++] = (byte)((BaseMask >> 8) % 256); + bytes[i++] = (byte)((BaseMask >> 16) % 256); + bytes[i++] = (byte)((BaseMask >> 24) % 256); + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + bytes[i++] = (byte)InvType; + bytes[i++] = (byte)Type; + if(AssetID == null) { Console.WriteLine("Warning: AssetID is null, in " + this.GetType()); } + Array.Copy(AssetID.GetBytes(), 0, bytes, i, 16); i += 16; + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(SalePrice % 256); + bytes[i++] = (byte)((SalePrice >> 8) % 256); + bytes[i++] = (byte)((SalePrice >> 16) % 256); + bytes[i++] = (byte)((SalePrice >> 24) % 256); + if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } + Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; + if(CreatorID == null) { Console.WriteLine("Warning: CreatorID is null, in " + this.GetType()); } + Array.Copy(CreatorID.GetBytes(), 0, bytes, i, 16); i += 16; + if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } + Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; + if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } + Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(EveryoneMask % 256); + bytes[i++] = (byte)((EveryoneMask >> 8) % 256); + bytes[i++] = (byte)((EveryoneMask >> 16) % 256); + bytes[i++] = (byte)((EveryoneMask >> 24) % 256); + if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } + bytes[i++] = (byte)Description.Length; + Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; + bytes[i++] = (byte)(Flags % 256); + bytes[i++] = (byte)((Flags >> 8) % 256); + bytes[i++] = (byte)((Flags >> 16) % 256); + bytes[i++] = (byte)((Flags >> 24) % 256); + bytes[i++] = (byte)(NextOwnerMask % 256); + bytes[i++] = (byte)((NextOwnerMask >> 8) % 256); + bytes[i++] = (byte)((NextOwnerMask >> 16) % 256); + bytes[i++] = (byte)((NextOwnerMask >> 24) % 256); + bytes[i++] = (byte)(GroupMask % 256); + bytes[i++] = (byte)((GroupMask >> 8) % 256); + bytes[i++] = (byte)((GroupMask >> 16) % 256); + bytes[i++] = (byte)((GroupMask >> 24) % 256); + bytes[i++] = (byte)(OwnerMask % 256); + bytes[i++] = (byte)((OwnerMask >> 8) % 256); + bytes[i++] = (byte)((OwnerMask >> 16) % 256); + bytes[i++] = (byte)((OwnerMask >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ItemData --\n"; - output += "GroupOwned: " + GroupOwned.ToString() + "\n"; - output += "CRC: " + CRC.ToString() + "\n"; - output += "CreationDate: " + CreationDate.ToString() + "\n"; - output += "SaleType: " + SaleType.ToString() + "\n"; - output += "CallbackID: " + CallbackID.ToString() + "\n"; - output += "BaseMask: " + BaseMask.ToString() + "\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; - output += "InvType: " + InvType.ToString() + "\n"; - output += "Type: " + Type.ToString() + "\n"; - output += "AssetID: " + AssetID.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; - output += "SalePrice: " + SalePrice.ToString() + "\n"; - output += "OwnerID: " + OwnerID.ToString() + "\n"; - output += "CreatorID: " + CreatorID.ToString() + "\n"; - output += "ItemID: " + ItemID.ToString() + "\n"; - output += "FolderID: " + FolderID.ToString() + "\n"; - output += "EveryoneMask: " + EveryoneMask.ToString() + "\n"; - output += Helpers.FieldToString(Description, "Description") + "\n"; - output += "Flags: " + Flags.ToString() + "\n"; - output += "NextOwnerMask: " + NextOwnerMask.ToString() + "\n"; - output += "GroupMask: " + GroupMask.ToString() + "\n"; - output += "OwnerMask: " + OwnerMask.ToString() + "\n"; + { + string output = "-- ItemData --\n"; + output += "GroupOwned: " + GroupOwned.ToString() + "\n"; + output += "CRC: " + CRC.ToString() + "\n"; + output += "CreationDate: " + CreationDate.ToString() + "\n"; + output += "SaleType: " + SaleType.ToString() + "\n"; + output += "CallbackID: " + CallbackID.ToString() + "\n"; + output += "BaseMask: " + BaseMask.ToString() + "\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; + output += "InvType: " + InvType.ToString() + "\n"; + output += "Type: " + Type.ToString() + "\n"; + output += "AssetID: " + AssetID.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; + output += "SalePrice: " + SalePrice.ToString() + "\n"; + output += "OwnerID: " + OwnerID.ToString() + "\n"; + output += "CreatorID: " + CreatorID.ToString() + "\n"; + output += "ItemID: " + ItemID.ToString() + "\n"; + output += "FolderID: " + FolderID.ToString() + "\n"; + output += "EveryoneMask: " + EveryoneMask.ToString() + "\n"; + output += Helpers.FieldToString(Description, "Description") + "\n"; + output += "Flags: " + Flags.ToString() + "\n"; + output += "NextOwnerMask: " + NextOwnerMask.ToString() + "\n"; + output += "GroupMask: " + GroupMask.ToString() + "\n"; + output += "OwnerMask: " + OwnerMask.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// TransactionID field - public LLUUID TransactionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// TransactionID field + public LLUUID TransactionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - TransactionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + TransactionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } - Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } + Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "TransactionID: " + TransactionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "TransactionID: " + TransactionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// FolderData block + + /// FolderData block public class FolderDataBlock - { - private byte[] _name; - /// Name field + { + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - /// ParentID field - public LLUUID ParentID; - /// Type field - public sbyte Type; - /// FolderID field - public LLUUID FolderID; - - /// Length of this block serialized in bytes + } + /// ParentID field + public LLUUID ParentID; + /// Type field + public sbyte Type; + /// FolderID field + public LLUUID FolderID; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 33; - if (Name != null) { length += 1 + Name.Length; } - return length; + { + int length = 33; + if (Name != null) { length += 1 + Name.Length; } + return length; } } - - /// Default constructor - public FolderDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public FolderDataBlock() { } + /// Constructor for building the block from a byte array public FolderDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; - ParentID = new LLUUID(bytes, i); i += 16; - Type = (sbyte)bytes[i++]; - FolderID = new LLUUID(bytes, i); i += 16; + { + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; + ParentID = new LLUUID(bytes, i); i += 16; + Type = (sbyte)bytes[i++]; + FolderID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; - if(ParentID == null) { Console.WriteLine("Warning: ParentID is null, in " + this.GetType()); } - Array.Copy(ParentID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)Type; - if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } - Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + if(ParentID == null) { Console.WriteLine("Warning: ParentID is null, in " + this.GetType()); } + Array.Copy(ParentID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)Type; + if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } + Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- FolderData --\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; - output += "ParentID: " + ParentID.ToString() + "\n"; - output += "Type: " + Type.ToString() + "\n"; - output += "FolderID: " + FolderID.ToString() + "\n"; + { + string output = "-- FolderData --\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; + output += "ParentID: " + ParentID.ToString() + "\n"; + output += "Type: " + Type.ToString() + "\n"; + output += "FolderID: " + FolderID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.BulkUpdateInventory - public override PacketType Type { get { return PacketType.BulkUpdateInventory; } } - /// ItemData block - public ItemDataBlock[] ItemData; - /// AgentData block - public AgentDataBlock AgentData; - /// FolderData block - public FolderDataBlock[] FolderData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.BulkUpdateInventory + public override PacketType Type { get { return PacketType.BulkUpdateInventory; } } + /// ItemData block + public ItemDataBlock[] ItemData; + /// AgentData block + public AgentDataBlock AgentData; + /// FolderData block + public FolderDataBlock[] FolderData; + + /// Default constructor public BulkUpdateInventoryPacket() - { - Header = new LowHeader(); - Header.ID = 331; - Header.Reliable = true; - Header.Zerocoded = true; - ItemData = new ItemDataBlock[0]; - AgentData = new AgentDataBlock(); - FolderData = new FolderDataBlock[0]; + { + Header = new LowHeader(); + Header.ID = 331; + Header.Reliable = true; + Header.Zerocoded = true; + ItemData = new ItemDataBlock[0]; + AgentData = new AgentDataBlock(); + FolderData = new FolderDataBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public BulkUpdateInventoryPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ItemData = new ItemDataBlock[count]; - for (int j = 0; j < count; j++) - { ItemData[j] = new ItemDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); - count = (int)bytes[i++]; - FolderData = new FolderDataBlock[count]; - for (int j = 0; j < count; j++) - { FolderData[j] = new FolderDataBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ItemData = new ItemDataBlock[count]; + for (int j = 0; j < count; j++) + { ItemData[j] = new ItemDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); + count = (int)bytes[i++]; + FolderData = new FolderDataBlock[count]; + for (int j = 0; j < count; j++) + { FolderData[j] = new FolderDataBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public BulkUpdateInventoryPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ItemData = new ItemDataBlock[count]; - for (int j = 0; j < count; j++) - { ItemData[j] = new ItemDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); - count = (int)bytes[i++]; - FolderData = new FolderDataBlock[count]; - for (int j = 0; j < count; j++) - { FolderData[j] = new FolderDataBlock(bytes, ref i); } + { + Header = head; + int count = (int)bytes[i++]; + ItemData = new ItemDataBlock[count]; + for (int j = 0; j < count; j++) + { ItemData[j] = new ItemDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); + count = (int)bytes[i++]; + FolderData = new FolderDataBlock[count]; + for (int j = 0; j < count; j++) + { FolderData[j] = new FolderDataBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < ItemData.Length; j++) { length += ItemData[j].Length; } - length++; - for (int j = 0; j < FolderData.Length; j++) { length += FolderData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ItemData.Length; - for (int j = 0; j < ItemData.Length; j++) { ItemData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - bytes[i++] = (byte)FolderData.Length; - for (int j = 0; j < FolderData.Length; j++) { FolderData[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < ItemData.Length; j++) { length += ItemData[j].Length; } + length++; + for (int j = 0; j < FolderData.Length; j++) { length += FolderData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ItemData.Length; + for (int j = 0; j < ItemData.Length; j++) { ItemData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + bytes[i++] = (byte)FolderData.Length; + for (int j = 0; j < FolderData.Length; j++) { FolderData[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- BulkUpdateInventory ---\n"; + { + string output = "--- BulkUpdateInventory ---\n"; for (int j = 0; j < ItemData.Length; j++) - { + { output += ItemData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; for (int j = 0; j < FolderData.Length; j++) - { + { output += FolderData[j].ToString() + "\n"; - } + } return output; } - + } - - /// RequestInventoryAsset packet + + /// RequestInventoryAsset packet public class RequestInventoryAssetPacket : Packet - { - /// QueryData block + { + /// QueryData block public class QueryDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// QueryID field - public LLUUID QueryID; - /// OwnerID field - public LLUUID OwnerID; - /// ItemID field - public LLUUID ItemID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// QueryID field + public LLUUID QueryID; + /// OwnerID field + public LLUUID OwnerID; + /// ItemID field + public LLUUID ItemID; + + /// Length of this block serialized in bytes public int Length { get - { - return 64; + { + return 64; } } - - /// Default constructor - public QueryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public QueryDataBlock() { } + /// Constructor for building the block from a byte array public QueryDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - QueryID = new LLUUID(bytes, i); i += 16; - OwnerID = new LLUUID(bytes, i); i += 16; - ItemID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + QueryID = new LLUUID(bytes, i); i += 16; + OwnerID = new LLUUID(bytes, i); i += 16; + ItemID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } - Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; - if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } - Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; - if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } - Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } + Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; + if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } + Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; + if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } + Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- QueryData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "QueryID: " + QueryID.ToString() + "\n"; - output += "OwnerID: " + OwnerID.ToString() + "\n"; - output += "ItemID: " + ItemID.ToString() + "\n"; + { + string output = "-- QueryData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "QueryID: " + QueryID.ToString() + "\n"; + output += "OwnerID: " + OwnerID.ToString() + "\n"; + output += "ItemID: " + ItemID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.RequestInventoryAsset - public override PacketType Type { get { return PacketType.RequestInventoryAsset; } } - /// QueryData block - public QueryDataBlock QueryData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.RequestInventoryAsset + public override PacketType Type { get { return PacketType.RequestInventoryAsset; } } + /// QueryData block + public QueryDataBlock QueryData; + + /// Default constructor public RequestInventoryAssetPacket() - { - Header = new LowHeader(); - Header.ID = 332; - Header.Reliable = true; - QueryData = new QueryDataBlock(); + { + Header = new LowHeader(); + Header.ID = 332; + Header.Reliable = true; + QueryData = new QueryDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public RequestInventoryAssetPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - QueryData = new QueryDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + QueryData = new QueryDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public RequestInventoryAssetPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - QueryData = new QueryDataBlock(bytes, ref i); + { + Header = head; + QueryData = new QueryDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += QueryData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - QueryData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += QueryData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + QueryData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- RequestInventoryAsset ---\n"; - output += QueryData.ToString() + "\n"; + { + string output = "--- RequestInventoryAsset ---\n"; + output += QueryData.ToString() + "\n"; return output; } - + } - - /// InventoryAssetResponse packet + + /// InventoryAssetResponse packet public class InventoryAssetResponsePacket : Packet - { - /// QueryData block + { + /// QueryData block public class QueryDataBlock - { - /// QueryID field - public LLUUID QueryID; - /// AssetID field - public LLUUID AssetID; - /// IsReadable field - public bool IsReadable; - - /// Length of this block serialized in bytes + { + /// QueryID field + public LLUUID QueryID; + /// AssetID field + public LLUUID AssetID; + /// IsReadable field + public bool IsReadable; + + /// Length of this block serialized in bytes public int Length { get - { - return 33; + { + return 33; } } - - /// Default constructor - public QueryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public QueryDataBlock() { } + /// Constructor for building the block from a byte array public QueryDataBlock(byte[] bytes, ref int i) - { + { try - { - QueryID = new LLUUID(bytes, i); i += 16; - AssetID = new LLUUID(bytes, i); i += 16; - IsReadable = (bytes[i++] != 0) ? (bool)true : (bool)false; + { + QueryID = new LLUUID(bytes, i); i += 16; + AssetID = new LLUUID(bytes, i); i += 16; + IsReadable = (bytes[i++] != 0) ? (bool)true : (bool)false; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } - Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; - if(AssetID == null) { Console.WriteLine("Warning: AssetID is null, in " + this.GetType()); } - Array.Copy(AssetID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((IsReadable) ? 1 : 0); + { + if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } + Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; + if(AssetID == null) { Console.WriteLine("Warning: AssetID is null, in " + this.GetType()); } + Array.Copy(AssetID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((IsReadable) ? 1 : 0); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- QueryData --\n"; - output += "QueryID: " + QueryID.ToString() + "\n"; - output += "AssetID: " + AssetID.ToString() + "\n"; - output += "IsReadable: " + IsReadable.ToString() + "\n"; + { + string output = "-- QueryData --\n"; + output += "QueryID: " + QueryID.ToString() + "\n"; + output += "AssetID: " + AssetID.ToString() + "\n"; + output += "IsReadable: " + IsReadable.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.InventoryAssetResponse - public override PacketType Type { get { return PacketType.InventoryAssetResponse; } } - /// QueryData block - public QueryDataBlock QueryData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.InventoryAssetResponse + public override PacketType Type { get { return PacketType.InventoryAssetResponse; } } + /// QueryData block + public QueryDataBlock QueryData; + + /// Default constructor public InventoryAssetResponsePacket() - { - Header = new LowHeader(); - Header.ID = 333; - Header.Reliable = true; - QueryData = new QueryDataBlock(); + { + Header = new LowHeader(); + Header.ID = 333; + Header.Reliable = true; + QueryData = new QueryDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public InventoryAssetResponsePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - QueryData = new QueryDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + QueryData = new QueryDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public InventoryAssetResponsePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - QueryData = new QueryDataBlock(bytes, ref i); + { + Header = head; + QueryData = new QueryDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += QueryData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - QueryData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += QueryData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + QueryData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- InventoryAssetResponse ---\n"; - output += QueryData.ToString() + "\n"; + { + string output = "--- InventoryAssetResponse ---\n"; + output += QueryData.ToString() + "\n"; return output; } - + } - - /// RemoveInventoryObjects packet + + /// RemoveInventoryObjects packet public class RemoveInventoryObjectsPacket : Packet - { - /// ItemData block + { + /// ItemData block public class ItemDataBlock - { - /// ItemID field - public LLUUID ItemID; - - /// Length of this block serialized in bytes + { + /// ItemID field + public LLUUID ItemID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public ItemDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ItemDataBlock() { } + /// Constructor for building the block from a byte array public ItemDataBlock(byte[] bytes, ref int i) - { + { try - { - ItemID = new LLUUID(bytes, i); i += 16; + { + ItemID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } - Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } + Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ItemData --\n"; - output += "ItemID: " + ItemID.ToString() + "\n"; + { + string output = "-- ItemData --\n"; + output += "ItemID: " + ItemID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// FolderData block + + /// FolderData block public class FolderDataBlock - { - /// FolderID field - public LLUUID FolderID; - - /// Length of this block serialized in bytes + { + /// FolderID field + public LLUUID FolderID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public FolderDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public FolderDataBlock() { } + /// Constructor for building the block from a byte array public FolderDataBlock(byte[] bytes, ref int i) - { + { try - { - FolderID = new LLUUID(bytes, i); i += 16; + { + FolderID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } - Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } + Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- FolderData --\n"; - output += "FolderID: " + FolderID.ToString() + "\n"; + { + string output = "-- FolderData --\n"; + output += "FolderID: " + FolderID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.RemoveInventoryObjects - public override PacketType Type { get { return PacketType.RemoveInventoryObjects; } } - /// ItemData block - public ItemDataBlock[] ItemData; - /// AgentData block - public AgentDataBlock AgentData; - /// FolderData block - public FolderDataBlock[] FolderData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.RemoveInventoryObjects + public override PacketType Type { get { return PacketType.RemoveInventoryObjects; } } + /// ItemData block + public ItemDataBlock[] ItemData; + /// AgentData block + public AgentDataBlock AgentData; + /// FolderData block + public FolderDataBlock[] FolderData; + + /// Default constructor public RemoveInventoryObjectsPacket() - { - Header = new LowHeader(); - Header.ID = 334; - Header.Reliable = true; - ItemData = new ItemDataBlock[0]; - AgentData = new AgentDataBlock(); - FolderData = new FolderDataBlock[0]; + { + Header = new LowHeader(); + Header.ID = 334; + Header.Reliable = true; + ItemData = new ItemDataBlock[0]; + AgentData = new AgentDataBlock(); + FolderData = new FolderDataBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public RemoveInventoryObjectsPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ItemData = new ItemDataBlock[count]; - for (int j = 0; j < count; j++) - { ItemData[j] = new ItemDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); - count = (int)bytes[i++]; - FolderData = new FolderDataBlock[count]; - for (int j = 0; j < count; j++) - { FolderData[j] = new FolderDataBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ItemData = new ItemDataBlock[count]; + for (int j = 0; j < count; j++) + { ItemData[j] = new ItemDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); + count = (int)bytes[i++]; + FolderData = new FolderDataBlock[count]; + for (int j = 0; j < count; j++) + { FolderData[j] = new FolderDataBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public RemoveInventoryObjectsPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ItemData = new ItemDataBlock[count]; - for (int j = 0; j < count; j++) - { ItemData[j] = new ItemDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); - count = (int)bytes[i++]; - FolderData = new FolderDataBlock[count]; - for (int j = 0; j < count; j++) - { FolderData[j] = new FolderDataBlock(bytes, ref i); } + { + Header = head; + int count = (int)bytes[i++]; + ItemData = new ItemDataBlock[count]; + for (int j = 0; j < count; j++) + { ItemData[j] = new ItemDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); + count = (int)bytes[i++]; + FolderData = new FolderDataBlock[count]; + for (int j = 0; j < count; j++) + { FolderData[j] = new FolderDataBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < ItemData.Length; j++) { length += ItemData[j].Length; } - length++; - for (int j = 0; j < FolderData.Length; j++) { length += FolderData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ItemData.Length; - for (int j = 0; j < ItemData.Length; j++) { ItemData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - bytes[i++] = (byte)FolderData.Length; - for (int j = 0; j < FolderData.Length; j++) { FolderData[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < ItemData.Length; j++) { length += ItemData[j].Length; } + length++; + for (int j = 0; j < FolderData.Length; j++) { length += FolderData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ItemData.Length; + for (int j = 0; j < ItemData.Length; j++) { ItemData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + bytes[i++] = (byte)FolderData.Length; + for (int j = 0; j < FolderData.Length; j++) { FolderData[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- RemoveInventoryObjects ---\n"; + { + string output = "--- RemoveInventoryObjects ---\n"; for (int j = 0; j < ItemData.Length; j++) - { + { output += ItemData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; for (int j = 0; j < FolderData.Length; j++) - { + { output += FolderData[j].ToString() + "\n"; - } + } return output; } - + } - - /// PurgeInventoryDescendents packet + + /// PurgeInventoryDescendents packet public class PurgeInventoryDescendentsPacket : Packet - { - /// InventoryData block + { + /// InventoryData block public class InventoryDataBlock - { - /// FolderID field - public LLUUID FolderID; - - /// Length of this block serialized in bytes + { + /// FolderID field + public LLUUID FolderID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public InventoryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public InventoryDataBlock() { } + /// Constructor for building the block from a byte array public InventoryDataBlock(byte[] bytes, ref int i) - { + { try - { - FolderID = new LLUUID(bytes, i); i += 16; + { + FolderID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } - Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } + Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- InventoryData --\n"; - output += "FolderID: " + FolderID.ToString() + "\n"; + { + string output = "-- InventoryData --\n"; + output += "FolderID: " + FolderID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.PurgeInventoryDescendents - public override PacketType Type { get { return PacketType.PurgeInventoryDescendents; } } - /// InventoryData block - public InventoryDataBlock InventoryData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.PurgeInventoryDescendents + public override PacketType Type { get { return PacketType.PurgeInventoryDescendents; } } + /// InventoryData block + public InventoryDataBlock InventoryData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public PurgeInventoryDescendentsPacket() - { - Header = new LowHeader(); - Header.ID = 335; - Header.Reliable = true; - Header.Zerocoded = true; - InventoryData = new InventoryDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 335; + Header.Reliable = true; + Header.Zerocoded = true; + InventoryData = new InventoryDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public PurgeInventoryDescendentsPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - InventoryData = new InventoryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + InventoryData = new InventoryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public PurgeInventoryDescendentsPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - InventoryData = new InventoryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + InventoryData = new InventoryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += InventoryData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - InventoryData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += InventoryData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + InventoryData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- PurgeInventoryDescendents ---\n"; - output += InventoryData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- PurgeInventoryDescendents ---\n"; + output += InventoryData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// UpdateTaskInventory packet + + /// UpdateTaskInventory packet public class UpdateTaskInventoryPacket : Packet - { - /// InventoryData block + { + /// InventoryData block public class InventoryDataBlock - { - /// GroupOwned field - public bool GroupOwned; - /// CRC field - public uint CRC; - /// CreationDate field - public int CreationDate; - /// SaleType field - public byte SaleType; - /// BaseMask field - public uint BaseMask; - private byte[] _name; - /// Name field + { + /// GroupOwned field + public bool GroupOwned; + /// CRC field + public uint CRC; + /// CreationDate field + public int CreationDate; + /// SaleType field + public byte SaleType; + /// BaseMask field + public uint BaseMask; + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - /// InvType field - public sbyte InvType; - /// Type field - public sbyte Type; - /// GroupID field - public LLUUID GroupID; - /// SalePrice field - public int SalePrice; - /// OwnerID field - public LLUUID OwnerID; - /// CreatorID field - public LLUUID CreatorID; - /// ItemID field - public LLUUID ItemID; - /// FolderID field - public LLUUID FolderID; - /// EveryoneMask field - public uint EveryoneMask; - private byte[] _description; - /// Description field + } + /// InvType field + public sbyte InvType; + /// Type field + public sbyte Type; + /// GroupID field + public LLUUID GroupID; + /// SalePrice field + public int SalePrice; + /// OwnerID field + public LLUUID OwnerID; + /// CreatorID field + public LLUUID CreatorID; + /// ItemID field + public LLUUID ItemID; + /// FolderID field + public LLUUID FolderID; + /// EveryoneMask field + public uint EveryoneMask; + private byte[] _description; + /// Description field public byte[] Description - { - get { return _description; } + { + get { return _description; } set - { - if (value == null) { _description = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } + { + if (value == null) { _description = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } } - } - /// Flags field - public uint Flags; - /// NextOwnerMask field - public uint NextOwnerMask; - /// TransactionID field - public LLUUID TransactionID; - /// GroupMask field - public uint GroupMask; - /// OwnerMask field - public uint OwnerMask; - - /// Length of this block serialized in bytes + } + /// Flags field + public uint Flags; + /// NextOwnerMask field + public uint NextOwnerMask; + /// TransactionID field + public LLUUID TransactionID; + /// GroupMask field + public uint GroupMask; + /// OwnerMask field + public uint OwnerMask; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 136; - if (Name != null) { length += 1 + Name.Length; } - if (Description != null) { length += 1 + Description.Length; } - return length; + { + int length = 136; + if (Name != null) { length += 1 + Name.Length; } + if (Description != null) { length += 1 + Description.Length; } + return length; } } - - /// Default constructor - public InventoryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public InventoryDataBlock() { } + /// Constructor for building the block from a byte array public InventoryDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - GroupOwned = (bytes[i++] != 0) ? (bool)true : (bool)false; - CRC = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - CreationDate = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - SaleType = (byte)bytes[i++]; - BaseMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; - InvType = (sbyte)bytes[i++]; - Type = (sbyte)bytes[i++]; - GroupID = new LLUUID(bytes, i); i += 16; - SalePrice = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - OwnerID = new LLUUID(bytes, i); i += 16; - CreatorID = new LLUUID(bytes, i); i += 16; - ItemID = new LLUUID(bytes, i); i += 16; - FolderID = new LLUUID(bytes, i); i += 16; - EveryoneMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _description = new byte[length]; - Array.Copy(bytes, i, _description, 0, length); i += length; - Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - NextOwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - TransactionID = new LLUUID(bytes, i); i += 16; - GroupMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - OwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + GroupOwned = (bytes[i++] != 0) ? (bool)true : (bool)false; + CRC = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + CreationDate = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + SaleType = (byte)bytes[i++]; + BaseMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; + InvType = (sbyte)bytes[i++]; + Type = (sbyte)bytes[i++]; + GroupID = new LLUUID(bytes, i); i += 16; + SalePrice = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + OwnerID = new LLUUID(bytes, i); i += 16; + CreatorID = new LLUUID(bytes, i); i += 16; + ItemID = new LLUUID(bytes, i); i += 16; + FolderID = new LLUUID(bytes, i); i += 16; + EveryoneMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _description = new byte[length]; + Array.Copy(bytes, i, _description, 0, length); i += length; + Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + NextOwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + TransactionID = new LLUUID(bytes, i); i += 16; + GroupMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + OwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)((GroupOwned) ? 1 : 0); - bytes[i++] = (byte)(CRC % 256); - bytes[i++] = (byte)((CRC >> 8) % 256); - bytes[i++] = (byte)((CRC >> 16) % 256); - bytes[i++] = (byte)((CRC >> 24) % 256); - bytes[i++] = (byte)(CreationDate % 256); - bytes[i++] = (byte)((CreationDate >> 8) % 256); - bytes[i++] = (byte)((CreationDate >> 16) % 256); - bytes[i++] = (byte)((CreationDate >> 24) % 256); - bytes[i++] = SaleType; - bytes[i++] = (byte)(BaseMask % 256); - bytes[i++] = (byte)((BaseMask >> 8) % 256); - bytes[i++] = (byte)((BaseMask >> 16) % 256); - bytes[i++] = (byte)((BaseMask >> 24) % 256); - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; - bytes[i++] = (byte)InvType; - bytes[i++] = (byte)Type; - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(SalePrice % 256); - bytes[i++] = (byte)((SalePrice >> 8) % 256); - bytes[i++] = (byte)((SalePrice >> 16) % 256); - bytes[i++] = (byte)((SalePrice >> 24) % 256); - if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } - Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; - if(CreatorID == null) { Console.WriteLine("Warning: CreatorID is null, in " + this.GetType()); } - Array.Copy(CreatorID.GetBytes(), 0, bytes, i, 16); i += 16; - if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } - Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; - if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } - Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(EveryoneMask % 256); - bytes[i++] = (byte)((EveryoneMask >> 8) % 256); - bytes[i++] = (byte)((EveryoneMask >> 16) % 256); - bytes[i++] = (byte)((EveryoneMask >> 24) % 256); - if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } - bytes[i++] = (byte)Description.Length; - Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; - bytes[i++] = (byte)(Flags % 256); - bytes[i++] = (byte)((Flags >> 8) % 256); - bytes[i++] = (byte)((Flags >> 16) % 256); - bytes[i++] = (byte)((Flags >> 24) % 256); - bytes[i++] = (byte)(NextOwnerMask % 256); - bytes[i++] = (byte)((NextOwnerMask >> 8) % 256); - bytes[i++] = (byte)((NextOwnerMask >> 16) % 256); - bytes[i++] = (byte)((NextOwnerMask >> 24) % 256); - if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } - Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(GroupMask % 256); - bytes[i++] = (byte)((GroupMask >> 8) % 256); - bytes[i++] = (byte)((GroupMask >> 16) % 256); - bytes[i++] = (byte)((GroupMask >> 24) % 256); - bytes[i++] = (byte)(OwnerMask % 256); - bytes[i++] = (byte)((OwnerMask >> 8) % 256); - bytes[i++] = (byte)((OwnerMask >> 16) % 256); - bytes[i++] = (byte)((OwnerMask >> 24) % 256); + { + bytes[i++] = (byte)((GroupOwned) ? 1 : 0); + bytes[i++] = (byte)(CRC % 256); + bytes[i++] = (byte)((CRC >> 8) % 256); + bytes[i++] = (byte)((CRC >> 16) % 256); + bytes[i++] = (byte)((CRC >> 24) % 256); + bytes[i++] = (byte)(CreationDate % 256); + bytes[i++] = (byte)((CreationDate >> 8) % 256); + bytes[i++] = (byte)((CreationDate >> 16) % 256); + bytes[i++] = (byte)((CreationDate >> 24) % 256); + bytes[i++] = SaleType; + bytes[i++] = (byte)(BaseMask % 256); + bytes[i++] = (byte)((BaseMask >> 8) % 256); + bytes[i++] = (byte)((BaseMask >> 16) % 256); + bytes[i++] = (byte)((BaseMask >> 24) % 256); + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + bytes[i++] = (byte)InvType; + bytes[i++] = (byte)Type; + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(SalePrice % 256); + bytes[i++] = (byte)((SalePrice >> 8) % 256); + bytes[i++] = (byte)((SalePrice >> 16) % 256); + bytes[i++] = (byte)((SalePrice >> 24) % 256); + if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } + Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; + if(CreatorID == null) { Console.WriteLine("Warning: CreatorID is null, in " + this.GetType()); } + Array.Copy(CreatorID.GetBytes(), 0, bytes, i, 16); i += 16; + if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } + Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; + if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } + Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(EveryoneMask % 256); + bytes[i++] = (byte)((EveryoneMask >> 8) % 256); + bytes[i++] = (byte)((EveryoneMask >> 16) % 256); + bytes[i++] = (byte)((EveryoneMask >> 24) % 256); + if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } + bytes[i++] = (byte)Description.Length; + Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; + bytes[i++] = (byte)(Flags % 256); + bytes[i++] = (byte)((Flags >> 8) % 256); + bytes[i++] = (byte)((Flags >> 16) % 256); + bytes[i++] = (byte)((Flags >> 24) % 256); + bytes[i++] = (byte)(NextOwnerMask % 256); + bytes[i++] = (byte)((NextOwnerMask >> 8) % 256); + bytes[i++] = (byte)((NextOwnerMask >> 16) % 256); + bytes[i++] = (byte)((NextOwnerMask >> 24) % 256); + if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } + Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(GroupMask % 256); + bytes[i++] = (byte)((GroupMask >> 8) % 256); + bytes[i++] = (byte)((GroupMask >> 16) % 256); + bytes[i++] = (byte)((GroupMask >> 24) % 256); + bytes[i++] = (byte)(OwnerMask % 256); + bytes[i++] = (byte)((OwnerMask >> 8) % 256); + bytes[i++] = (byte)((OwnerMask >> 16) % 256); + bytes[i++] = (byte)((OwnerMask >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- InventoryData --\n"; - output += "GroupOwned: " + GroupOwned.ToString() + "\n"; - output += "CRC: " + CRC.ToString() + "\n"; - output += "CreationDate: " + CreationDate.ToString() + "\n"; - output += "SaleType: " + SaleType.ToString() + "\n"; - output += "BaseMask: " + BaseMask.ToString() + "\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; - output += "InvType: " + InvType.ToString() + "\n"; - output += "Type: " + Type.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; - output += "SalePrice: " + SalePrice.ToString() + "\n"; - output += "OwnerID: " + OwnerID.ToString() + "\n"; - output += "CreatorID: " + CreatorID.ToString() + "\n"; - output += "ItemID: " + ItemID.ToString() + "\n"; - output += "FolderID: " + FolderID.ToString() + "\n"; - output += "EveryoneMask: " + EveryoneMask.ToString() + "\n"; - output += Helpers.FieldToString(Description, "Description") + "\n"; - output += "Flags: " + Flags.ToString() + "\n"; - output += "NextOwnerMask: " + NextOwnerMask.ToString() + "\n"; - output += "TransactionID: " + TransactionID.ToString() + "\n"; - output += "GroupMask: " + GroupMask.ToString() + "\n"; - output += "OwnerMask: " + OwnerMask.ToString() + "\n"; + { + string output = "-- InventoryData --\n"; + output += "GroupOwned: " + GroupOwned.ToString() + "\n"; + output += "CRC: " + CRC.ToString() + "\n"; + output += "CreationDate: " + CreationDate.ToString() + "\n"; + output += "SaleType: " + SaleType.ToString() + "\n"; + output += "BaseMask: " + BaseMask.ToString() + "\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; + output += "InvType: " + InvType.ToString() + "\n"; + output += "Type: " + Type.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; + output += "SalePrice: " + SalePrice.ToString() + "\n"; + output += "OwnerID: " + OwnerID.ToString() + "\n"; + output += "CreatorID: " + CreatorID.ToString() + "\n"; + output += "ItemID: " + ItemID.ToString() + "\n"; + output += "FolderID: " + FolderID.ToString() + "\n"; + output += "EveryoneMask: " + EveryoneMask.ToString() + "\n"; + output += Helpers.FieldToString(Description, "Description") + "\n"; + output += "Flags: " + Flags.ToString() + "\n"; + output += "NextOwnerMask: " + NextOwnerMask.ToString() + "\n"; + output += "TransactionID: " + TransactionID.ToString() + "\n"; + output += "GroupMask: " + GroupMask.ToString() + "\n"; + output += "OwnerMask: " + OwnerMask.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// UpdateData block + + /// UpdateData block public class UpdateDataBlock - { - /// Key field - public byte Key; - /// LocalID field - public uint LocalID; - - /// Length of this block serialized in bytes + { + /// Key field + public byte Key; + /// LocalID field + public uint LocalID; + + /// Length of this block serialized in bytes public int Length { get - { - return 5; + { + return 5; } } - - /// Default constructor - public UpdateDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public UpdateDataBlock() { } + /// Constructor for building the block from a byte array public UpdateDataBlock(byte[] bytes, ref int i) - { + { try - { - Key = (byte)bytes[i++]; - LocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + Key = (byte)bytes[i++]; + LocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = Key; - bytes[i++] = (byte)(LocalID % 256); - bytes[i++] = (byte)((LocalID >> 8) % 256); - bytes[i++] = (byte)((LocalID >> 16) % 256); - bytes[i++] = (byte)((LocalID >> 24) % 256); + { + bytes[i++] = Key; + bytes[i++] = (byte)(LocalID % 256); + bytes[i++] = (byte)((LocalID >> 8) % 256); + bytes[i++] = (byte)((LocalID >> 16) % 256); + bytes[i++] = (byte)((LocalID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- UpdateData --\n"; - output += "Key: " + Key.ToString() + "\n"; - output += "LocalID: " + LocalID.ToString() + "\n"; + { + string output = "-- UpdateData --\n"; + output += "Key: " + Key.ToString() + "\n"; + output += "LocalID: " + LocalID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.UpdateTaskInventory - public override PacketType Type { get { return PacketType.UpdateTaskInventory; } } - /// InventoryData block - public InventoryDataBlock InventoryData; - /// UpdateData block - public UpdateDataBlock UpdateData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.UpdateTaskInventory + public override PacketType Type { get { return PacketType.UpdateTaskInventory; } } + /// InventoryData block + public InventoryDataBlock InventoryData; + /// UpdateData block + public UpdateDataBlock UpdateData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public UpdateTaskInventoryPacket() - { - Header = new LowHeader(); - Header.ID = 336; - Header.Reliable = true; - Header.Zerocoded = true; - InventoryData = new InventoryDataBlock(); - UpdateData = new UpdateDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 336; + Header.Reliable = true; + Header.Zerocoded = true; + InventoryData = new InventoryDataBlock(); + UpdateData = new UpdateDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public UpdateTaskInventoryPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - InventoryData = new InventoryDataBlock(bytes, ref i); - UpdateData = new UpdateDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + InventoryData = new InventoryDataBlock(bytes, ref i); + UpdateData = new UpdateDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public UpdateTaskInventoryPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - InventoryData = new InventoryDataBlock(bytes, ref i); - UpdateData = new UpdateDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + InventoryData = new InventoryDataBlock(bytes, ref i); + UpdateData = new UpdateDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += InventoryData.Length; length += UpdateData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - InventoryData.ToBytes(bytes, ref i); - UpdateData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += InventoryData.Length; length += UpdateData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + InventoryData.ToBytes(bytes, ref i); + UpdateData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- UpdateTaskInventory ---\n"; - output += InventoryData.ToString() + "\n"; - output += UpdateData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- UpdateTaskInventory ---\n"; + output += InventoryData.ToString() + "\n"; + output += UpdateData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// RemoveTaskInventory packet + + /// RemoveTaskInventory packet public class RemoveTaskInventoryPacket : Packet - { - /// InventoryData block + { + /// InventoryData block public class InventoryDataBlock - { - /// LocalID field - public uint LocalID; - /// ItemID field - public LLUUID ItemID; - - /// Length of this block serialized in bytes + { + /// LocalID field + public uint LocalID; + /// ItemID field + public LLUUID ItemID; + + /// Length of this block serialized in bytes public int Length { get - { - return 20; + { + return 20; } } - - /// Default constructor - public InventoryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public InventoryDataBlock() { } + /// Constructor for building the block from a byte array public InventoryDataBlock(byte[] bytes, ref int i) - { + { try - { - LocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - ItemID = new LLUUID(bytes, i); i += 16; + { + LocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + ItemID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(LocalID % 256); - bytes[i++] = (byte)((LocalID >> 8) % 256); - bytes[i++] = (byte)((LocalID >> 16) % 256); - bytes[i++] = (byte)((LocalID >> 24) % 256); - if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } - Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; + { + bytes[i++] = (byte)(LocalID % 256); + bytes[i++] = (byte)((LocalID >> 8) % 256); + bytes[i++] = (byte)((LocalID >> 16) % 256); + bytes[i++] = (byte)((LocalID >> 24) % 256); + if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } + Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- InventoryData --\n"; - output += "LocalID: " + LocalID.ToString() + "\n"; - output += "ItemID: " + ItemID.ToString() + "\n"; + { + string output = "-- InventoryData --\n"; + output += "LocalID: " + LocalID.ToString() + "\n"; + output += "ItemID: " + ItemID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.RemoveTaskInventory - public override PacketType Type { get { return PacketType.RemoveTaskInventory; } } - /// InventoryData block - public InventoryDataBlock InventoryData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.RemoveTaskInventory + public override PacketType Type { get { return PacketType.RemoveTaskInventory; } } + /// InventoryData block + public InventoryDataBlock InventoryData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public RemoveTaskInventoryPacket() - { - Header = new LowHeader(); - Header.ID = 337; - Header.Reliable = true; - Header.Zerocoded = true; - InventoryData = new InventoryDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 337; + Header.Reliable = true; + Header.Zerocoded = true; + InventoryData = new InventoryDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public RemoveTaskInventoryPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - InventoryData = new InventoryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + InventoryData = new InventoryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public RemoveTaskInventoryPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - InventoryData = new InventoryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + InventoryData = new InventoryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += InventoryData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - InventoryData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += InventoryData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + InventoryData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- RemoveTaskInventory ---\n"; - output += InventoryData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- RemoveTaskInventory ---\n"; + output += InventoryData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// MoveTaskInventory packet + + /// MoveTaskInventory packet public class MoveTaskInventoryPacket : Packet - { - /// InventoryData block + { + /// InventoryData block public class InventoryDataBlock - { - /// LocalID field - public uint LocalID; - /// ItemID field - public LLUUID ItemID; - - /// Length of this block serialized in bytes + { + /// LocalID field + public uint LocalID; + /// ItemID field + public LLUUID ItemID; + + /// Length of this block serialized in bytes public int Length { get - { - return 20; + { + return 20; } } - - /// Default constructor - public InventoryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public InventoryDataBlock() { } + /// Constructor for building the block from a byte array public InventoryDataBlock(byte[] bytes, ref int i) - { + { try - { - LocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - ItemID = new LLUUID(bytes, i); i += 16; + { + LocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + ItemID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(LocalID % 256); - bytes[i++] = (byte)((LocalID >> 8) % 256); - bytes[i++] = (byte)((LocalID >> 16) % 256); - bytes[i++] = (byte)((LocalID >> 24) % 256); - if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } - Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; + { + bytes[i++] = (byte)(LocalID % 256); + bytes[i++] = (byte)((LocalID >> 8) % 256); + bytes[i++] = (byte)((LocalID >> 16) % 256); + bytes[i++] = (byte)((LocalID >> 24) % 256); + if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } + Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- InventoryData --\n"; - output += "LocalID: " + LocalID.ToString() + "\n"; - output += "ItemID: " + ItemID.ToString() + "\n"; + { + string output = "-- InventoryData --\n"; + output += "LocalID: " + LocalID.ToString() + "\n"; + output += "ItemID: " + ItemID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - /// FolderID field - public LLUUID FolderID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + /// FolderID field + public LLUUID FolderID; + + /// Length of this block serialized in bytes public int Length { get - { - return 48; + { + return 48; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; - FolderID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; + FolderID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } - Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } + Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "FolderID: " + FolderID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "FolderID: " + FolderID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.MoveTaskInventory - public override PacketType Type { get { return PacketType.MoveTaskInventory; } } - /// InventoryData block - public InventoryDataBlock InventoryData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.MoveTaskInventory + public override PacketType Type { get { return PacketType.MoveTaskInventory; } } + /// InventoryData block + public InventoryDataBlock InventoryData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public MoveTaskInventoryPacket() - { - Header = new LowHeader(); - Header.ID = 338; - Header.Reliable = true; - InventoryData = new InventoryDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 338; + Header.Reliable = true; + InventoryData = new InventoryDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public MoveTaskInventoryPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - InventoryData = new InventoryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + InventoryData = new InventoryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public MoveTaskInventoryPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - InventoryData = new InventoryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + InventoryData = new InventoryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += InventoryData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - InventoryData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += InventoryData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + InventoryData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- MoveTaskInventory ---\n"; - output += InventoryData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- MoveTaskInventory ---\n"; + output += InventoryData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// RequestTaskInventory packet + + /// RequestTaskInventory packet public class RequestTaskInventoryPacket : Packet - { - /// InventoryData block + { + /// InventoryData block public class InventoryDataBlock - { - /// LocalID field - public uint LocalID; - - /// Length of this block serialized in bytes + { + /// LocalID field + public uint LocalID; + + /// Length of this block serialized in bytes public int Length { get - { - return 4; + { + return 4; } } - - /// Default constructor - public InventoryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public InventoryDataBlock() { } + /// Constructor for building the block from a byte array public InventoryDataBlock(byte[] bytes, ref int i) - { + { try - { - LocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + LocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(LocalID % 256); - bytes[i++] = (byte)((LocalID >> 8) % 256); - bytes[i++] = (byte)((LocalID >> 16) % 256); - bytes[i++] = (byte)((LocalID >> 24) % 256); + { + bytes[i++] = (byte)(LocalID % 256); + bytes[i++] = (byte)((LocalID >> 8) % 256); + bytes[i++] = (byte)((LocalID >> 16) % 256); + bytes[i++] = (byte)((LocalID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- InventoryData --\n"; - output += "LocalID: " + LocalID.ToString() + "\n"; + { + string output = "-- InventoryData --\n"; + output += "LocalID: " + LocalID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.RequestTaskInventory - public override PacketType Type { get { return PacketType.RequestTaskInventory; } } - /// InventoryData block - public InventoryDataBlock InventoryData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.RequestTaskInventory + public override PacketType Type { get { return PacketType.RequestTaskInventory; } } + /// InventoryData block + public InventoryDataBlock InventoryData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public RequestTaskInventoryPacket() - { - Header = new LowHeader(); - Header.ID = 339; - Header.Reliable = true; - InventoryData = new InventoryDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 339; + Header.Reliable = true; + InventoryData = new InventoryDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public RequestTaskInventoryPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - InventoryData = new InventoryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + InventoryData = new InventoryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public RequestTaskInventoryPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - InventoryData = new InventoryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + InventoryData = new InventoryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += InventoryData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - InventoryData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += InventoryData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + InventoryData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- RequestTaskInventory ---\n"; - output += InventoryData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- RequestTaskInventory ---\n"; + output += InventoryData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ReplyTaskInventory packet + + /// ReplyTaskInventory packet public class ReplyTaskInventoryPacket : Packet - { - /// InventoryData block + { + /// InventoryData block public class InventoryDataBlock - { - /// TaskID field - public LLUUID TaskID; - private byte[] _filename; - /// Filename field + { + /// TaskID field + public LLUUID TaskID; + private byte[] _filename; + /// Filename field public byte[] Filename - { - get { return _filename; } + { + get { return _filename; } set - { - if (value == null) { _filename = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _filename = new byte[value.Length]; Array.Copy(value, _filename, value.Length); } + { + if (value == null) { _filename = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _filename = new byte[value.Length]; Array.Copy(value, _filename, value.Length); } } - } - /// Serial field - public short Serial; - - /// Length of this block serialized in bytes + } + /// Serial field + public short Serial; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 18; - if (Filename != null) { length += 1 + Filename.Length; } - return length; + { + int length = 18; + if (Filename != null) { length += 1 + Filename.Length; } + return length; } } - - /// Default constructor - public InventoryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public InventoryDataBlock() { } + /// Constructor for building the block from a byte array public InventoryDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - TaskID = new LLUUID(bytes, i); i += 16; - length = (ushort)bytes[i++]; - _filename = new byte[length]; - Array.Copy(bytes, i, _filename, 0, length); i += length; - Serial = (short)(bytes[i++] + (bytes[i++] << 8)); + { + TaskID = new LLUUID(bytes, i); i += 16; + length = (ushort)bytes[i++]; + _filename = new byte[length]; + Array.Copy(bytes, i, _filename, 0, length); i += length; + Serial = (short)(bytes[i++] + (bytes[i++] << 8)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(TaskID == null) { Console.WriteLine("Warning: TaskID is null, in " + this.GetType()); } - Array.Copy(TaskID.GetBytes(), 0, bytes, i, 16); i += 16; - if(Filename == null) { Console.WriteLine("Warning: Filename is null, in " + this.GetType()); } - bytes[i++] = (byte)Filename.Length; - Array.Copy(Filename, 0, bytes, i, Filename.Length); i += Filename.Length; - bytes[i++] = (byte)(Serial % 256); - bytes[i++] = (byte)((Serial >> 8) % 256); + { + if(TaskID == null) { Console.WriteLine("Warning: TaskID is null, in " + this.GetType()); } + Array.Copy(TaskID.GetBytes(), 0, bytes, i, 16); i += 16; + if(Filename == null) { Console.WriteLine("Warning: Filename is null, in " + this.GetType()); } + bytes[i++] = (byte)Filename.Length; + Array.Copy(Filename, 0, bytes, i, Filename.Length); i += Filename.Length; + bytes[i++] = (byte)(Serial % 256); + bytes[i++] = (byte)((Serial >> 8) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- InventoryData --\n"; - output += "TaskID: " + TaskID.ToString() + "\n"; - output += Helpers.FieldToString(Filename, "Filename") + "\n"; - output += "Serial: " + Serial.ToString() + "\n"; + { + string output = "-- InventoryData --\n"; + output += "TaskID: " + TaskID.ToString() + "\n"; + output += Helpers.FieldToString(Filename, "Filename") + "\n"; + output += "Serial: " + Serial.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ReplyTaskInventory - public override PacketType Type { get { return PacketType.ReplyTaskInventory; } } - /// InventoryData block - public InventoryDataBlock InventoryData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ReplyTaskInventory + public override PacketType Type { get { return PacketType.ReplyTaskInventory; } } + /// InventoryData block + public InventoryDataBlock InventoryData; + + /// Default constructor public ReplyTaskInventoryPacket() - { - Header = new LowHeader(); - Header.ID = 340; - Header.Reliable = true; - Header.Zerocoded = true; - InventoryData = new InventoryDataBlock(); + { + Header = new LowHeader(); + Header.ID = 340; + Header.Reliable = true; + Header.Zerocoded = true; + InventoryData = new InventoryDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ReplyTaskInventoryPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - InventoryData = new InventoryDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + InventoryData = new InventoryDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ReplyTaskInventoryPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - InventoryData = new InventoryDataBlock(bytes, ref i); + { + Header = head; + InventoryData = new InventoryDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += InventoryData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - InventoryData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += InventoryData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + InventoryData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ReplyTaskInventory ---\n"; - output += InventoryData.ToString() + "\n"; + { + string output = "--- ReplyTaskInventory ---\n"; + output += InventoryData.ToString() + "\n"; return output; } - + } - - /// DeRezObject packet + + /// DeRezObject packet public class DeRezObjectPacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - /// ObjectLocalID field - public uint ObjectLocalID; - - /// Length of this block serialized in bytes + { + /// ObjectLocalID field + public uint ObjectLocalID; + + /// Length of this block serialized in bytes public int Length { get - { - return 4; + { + return 4; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { + { try - { - ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(ObjectLocalID % 256); - bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); + { + bytes[i++] = (byte)(ObjectLocalID % 256); + bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; + { + string output = "-- ObjectData --\n"; + output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentBlock block + + /// AgentBlock block public class AgentBlockBlock - { - /// GroupID field - public LLUUID GroupID; - /// Destination field - public byte Destination; - /// PacketNumber field - public byte PacketNumber; - /// PacketCount field - public byte PacketCount; - /// TransactionID field - public LLUUID TransactionID; - /// DestinationID field - public LLUUID DestinationID; - - /// Length of this block serialized in bytes + { + /// GroupID field + public LLUUID GroupID; + /// Destination field + public byte Destination; + /// PacketNumber field + public byte PacketNumber; + /// PacketCount field + public byte PacketCount; + /// TransactionID field + public LLUUID TransactionID; + /// DestinationID field + public LLUUID DestinationID; + + /// Length of this block serialized in bytes public int Length { get - { - return 51; + { + return 51; } } - - /// Default constructor - public AgentBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentBlockBlock() { } + /// Constructor for building the block from a byte array public AgentBlockBlock(byte[] bytes, ref int i) - { + { try - { - GroupID = new LLUUID(bytes, i); i += 16; - Destination = (byte)bytes[i++]; - PacketNumber = (byte)bytes[i++]; - PacketCount = (byte)bytes[i++]; - TransactionID = new LLUUID(bytes, i); i += 16; - DestinationID = new LLUUID(bytes, i); i += 16; + { + GroupID = new LLUUID(bytes, i); i += 16; + Destination = (byte)bytes[i++]; + PacketNumber = (byte)bytes[i++]; + PacketCount = (byte)bytes[i++]; + TransactionID = new LLUUID(bytes, i); i += 16; + DestinationID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = Destination; - bytes[i++] = PacketNumber; - bytes[i++] = PacketCount; - if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } - Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; - if(DestinationID == null) { Console.WriteLine("Warning: DestinationID is null, in " + this.GetType()); } - Array.Copy(DestinationID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = Destination; + bytes[i++] = PacketNumber; + bytes[i++] = PacketCount; + if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } + Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; + if(DestinationID == null) { Console.WriteLine("Warning: DestinationID is null, in " + this.GetType()); } + Array.Copy(DestinationID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentBlock --\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; - output += "Destination: " + Destination.ToString() + "\n"; - output += "PacketNumber: " + PacketNumber.ToString() + "\n"; - output += "PacketCount: " + PacketCount.ToString() + "\n"; - output += "TransactionID: " + TransactionID.ToString() + "\n"; - output += "DestinationID: " + DestinationID.ToString() + "\n"; + { + string output = "-- AgentBlock --\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; + output += "Destination: " + Destination.ToString() + "\n"; + output += "PacketNumber: " + PacketNumber.ToString() + "\n"; + output += "PacketCount: " + PacketCount.ToString() + "\n"; + output += "TransactionID: " + TransactionID.ToString() + "\n"; + output += "DestinationID: " + DestinationID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.DeRezObject - public override PacketType Type { get { return PacketType.DeRezObject; } } - /// ObjectData block - public ObjectDataBlock[] ObjectData; - /// AgentBlock block - public AgentBlockBlock AgentBlock; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.DeRezObject + public override PacketType Type { get { return PacketType.DeRezObject; } } + /// ObjectData block + public ObjectDataBlock[] ObjectData; + /// AgentBlock block + public AgentBlockBlock AgentBlock; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public DeRezObjectPacket() - { - Header = new LowHeader(); - Header.ID = 341; - Header.Reliable = true; - Header.Zerocoded = true; - ObjectData = new ObjectDataBlock[0]; - AgentBlock = new AgentBlockBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 341; + Header.Reliable = true; + Header.Zerocoded = true; + ObjectData = new ObjectDataBlock[0]; + AgentBlock = new AgentBlockBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public DeRezObjectPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentBlock = new AgentBlockBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentBlock = new AgentBlockBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public DeRezObjectPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentBlock = new AgentBlockBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentBlock = new AgentBlockBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentBlock.Length; length += AgentData.Length;; - length++; - for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ObjectData.Length; - for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } - AgentBlock.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentBlock.Length; length += AgentData.Length;; + length++; + for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ObjectData.Length; + for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } + AgentBlock.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- DeRezObject ---\n"; + { + string output = "--- DeRezObject ---\n"; for (int j = 0; j < ObjectData.Length; j++) - { + { output += ObjectData[j].ToString() + "\n"; - } - output += AgentBlock.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + } + output += AgentBlock.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// DeRezAck packet + + /// DeRezAck packet public class DeRezAckPacket : Packet - { - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.DeRezAck - public override PacketType Type { get { return PacketType.DeRezAck; } } - - /// Default constructor + { + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.DeRezAck + public override PacketType Type { get { return PacketType.DeRezAck; } } + + /// Default constructor public DeRezAckPacket() - { - Header = new LowHeader(); - Header.ID = 342; - Header.Reliable = true; + { + Header = new LowHeader(); + Header.ID = 342; + Header.Reliable = true; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public DeRezAckPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public DeRezAckPacket(Header head, byte[] bytes, ref int i) - { - Header = head; + { + Header = head; } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; -; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; +; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- DeRezAck ---\n"; + { + string output = "--- DeRezAck ---\n"; return output; } - + } - - /// RezObject packet + + /// RezObject packet public class RezObjectPacket : Packet - { - /// InventoryData block + { + /// InventoryData block public class InventoryDataBlock - { - /// GroupOwned field - public bool GroupOwned; - /// CRC field - public uint CRC; - /// CreationDate field - public int CreationDate; - /// SaleType field - public byte SaleType; - /// BaseMask field - public uint BaseMask; - private byte[] _name; - /// Name field + { + /// GroupOwned field + public bool GroupOwned; + /// CRC field + public uint CRC; + /// CreationDate field + public int CreationDate; + /// SaleType field + public byte SaleType; + /// BaseMask field + public uint BaseMask; + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - /// InvType field - public sbyte InvType; - /// Type field - public sbyte Type; - /// GroupID field - public LLUUID GroupID; - /// SalePrice field - public int SalePrice; - /// OwnerID field - public LLUUID OwnerID; - /// CreatorID field - public LLUUID CreatorID; - /// ItemID field - public LLUUID ItemID; - /// FolderID field - public LLUUID FolderID; - /// EveryoneMask field - public uint EveryoneMask; - private byte[] _description; - /// Description field + } + /// InvType field + public sbyte InvType; + /// Type field + public sbyte Type; + /// GroupID field + public LLUUID GroupID; + /// SalePrice field + public int SalePrice; + /// OwnerID field + public LLUUID OwnerID; + /// CreatorID field + public LLUUID CreatorID; + /// ItemID field + public LLUUID ItemID; + /// FolderID field + public LLUUID FolderID; + /// EveryoneMask field + public uint EveryoneMask; + private byte[] _description; + /// Description field public byte[] Description - { - get { return _description; } + { + get { return _description; } set - { - if (value == null) { _description = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } + { + if (value == null) { _description = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } } - } - /// Flags field - public uint Flags; - /// NextOwnerMask field - public uint NextOwnerMask; - /// TransactionID field - public LLUUID TransactionID; - /// GroupMask field - public uint GroupMask; - /// OwnerMask field - public uint OwnerMask; - - /// Length of this block serialized in bytes + } + /// Flags field + public uint Flags; + /// NextOwnerMask field + public uint NextOwnerMask; + /// TransactionID field + public LLUUID TransactionID; + /// GroupMask field + public uint GroupMask; + /// OwnerMask field + public uint OwnerMask; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 136; - if (Name != null) { length += 1 + Name.Length; } - if (Description != null) { length += 1 + Description.Length; } - return length; + { + int length = 136; + if (Name != null) { length += 1 + Name.Length; } + if (Description != null) { length += 1 + Description.Length; } + return length; } } - - /// Default constructor - public InventoryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public InventoryDataBlock() { } + /// Constructor for building the block from a byte array public InventoryDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - GroupOwned = (bytes[i++] != 0) ? (bool)true : (bool)false; - CRC = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - CreationDate = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - SaleType = (byte)bytes[i++]; - BaseMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; - InvType = (sbyte)bytes[i++]; - Type = (sbyte)bytes[i++]; - GroupID = new LLUUID(bytes, i); i += 16; - SalePrice = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - OwnerID = new LLUUID(bytes, i); i += 16; - CreatorID = new LLUUID(bytes, i); i += 16; - ItemID = new LLUUID(bytes, i); i += 16; - FolderID = new LLUUID(bytes, i); i += 16; - EveryoneMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _description = new byte[length]; - Array.Copy(bytes, i, _description, 0, length); i += length; - Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - NextOwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - TransactionID = new LLUUID(bytes, i); i += 16; - GroupMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - OwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + GroupOwned = (bytes[i++] != 0) ? (bool)true : (bool)false; + CRC = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + CreationDate = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + SaleType = (byte)bytes[i++]; + BaseMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; + InvType = (sbyte)bytes[i++]; + Type = (sbyte)bytes[i++]; + GroupID = new LLUUID(bytes, i); i += 16; + SalePrice = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + OwnerID = new LLUUID(bytes, i); i += 16; + CreatorID = new LLUUID(bytes, i); i += 16; + ItemID = new LLUUID(bytes, i); i += 16; + FolderID = new LLUUID(bytes, i); i += 16; + EveryoneMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _description = new byte[length]; + Array.Copy(bytes, i, _description, 0, length); i += length; + Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + NextOwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + TransactionID = new LLUUID(bytes, i); i += 16; + GroupMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + OwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)((GroupOwned) ? 1 : 0); - bytes[i++] = (byte)(CRC % 256); - bytes[i++] = (byte)((CRC >> 8) % 256); - bytes[i++] = (byte)((CRC >> 16) % 256); - bytes[i++] = (byte)((CRC >> 24) % 256); - bytes[i++] = (byte)(CreationDate % 256); - bytes[i++] = (byte)((CreationDate >> 8) % 256); - bytes[i++] = (byte)((CreationDate >> 16) % 256); - bytes[i++] = (byte)((CreationDate >> 24) % 256); - bytes[i++] = SaleType; - bytes[i++] = (byte)(BaseMask % 256); - bytes[i++] = (byte)((BaseMask >> 8) % 256); - bytes[i++] = (byte)((BaseMask >> 16) % 256); - bytes[i++] = (byte)((BaseMask >> 24) % 256); - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; - bytes[i++] = (byte)InvType; - bytes[i++] = (byte)Type; - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(SalePrice % 256); - bytes[i++] = (byte)((SalePrice >> 8) % 256); - bytes[i++] = (byte)((SalePrice >> 16) % 256); - bytes[i++] = (byte)((SalePrice >> 24) % 256); - if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } - Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; - if(CreatorID == null) { Console.WriteLine("Warning: CreatorID is null, in " + this.GetType()); } - Array.Copy(CreatorID.GetBytes(), 0, bytes, i, 16); i += 16; - if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } - Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; - if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } - Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(EveryoneMask % 256); - bytes[i++] = (byte)((EveryoneMask >> 8) % 256); - bytes[i++] = (byte)((EveryoneMask >> 16) % 256); - bytes[i++] = (byte)((EveryoneMask >> 24) % 256); - if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } - bytes[i++] = (byte)Description.Length; - Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; - bytes[i++] = (byte)(Flags % 256); - bytes[i++] = (byte)((Flags >> 8) % 256); - bytes[i++] = (byte)((Flags >> 16) % 256); - bytes[i++] = (byte)((Flags >> 24) % 256); - bytes[i++] = (byte)(NextOwnerMask % 256); - bytes[i++] = (byte)((NextOwnerMask >> 8) % 256); - bytes[i++] = (byte)((NextOwnerMask >> 16) % 256); - bytes[i++] = (byte)((NextOwnerMask >> 24) % 256); - if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } - Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(GroupMask % 256); - bytes[i++] = (byte)((GroupMask >> 8) % 256); - bytes[i++] = (byte)((GroupMask >> 16) % 256); - bytes[i++] = (byte)((GroupMask >> 24) % 256); - bytes[i++] = (byte)(OwnerMask % 256); - bytes[i++] = (byte)((OwnerMask >> 8) % 256); - bytes[i++] = (byte)((OwnerMask >> 16) % 256); - bytes[i++] = (byte)((OwnerMask >> 24) % 256); + { + bytes[i++] = (byte)((GroupOwned) ? 1 : 0); + bytes[i++] = (byte)(CRC % 256); + bytes[i++] = (byte)((CRC >> 8) % 256); + bytes[i++] = (byte)((CRC >> 16) % 256); + bytes[i++] = (byte)((CRC >> 24) % 256); + bytes[i++] = (byte)(CreationDate % 256); + bytes[i++] = (byte)((CreationDate >> 8) % 256); + bytes[i++] = (byte)((CreationDate >> 16) % 256); + bytes[i++] = (byte)((CreationDate >> 24) % 256); + bytes[i++] = SaleType; + bytes[i++] = (byte)(BaseMask % 256); + bytes[i++] = (byte)((BaseMask >> 8) % 256); + bytes[i++] = (byte)((BaseMask >> 16) % 256); + bytes[i++] = (byte)((BaseMask >> 24) % 256); + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + bytes[i++] = (byte)InvType; + bytes[i++] = (byte)Type; + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(SalePrice % 256); + bytes[i++] = (byte)((SalePrice >> 8) % 256); + bytes[i++] = (byte)((SalePrice >> 16) % 256); + bytes[i++] = (byte)((SalePrice >> 24) % 256); + if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } + Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; + if(CreatorID == null) { Console.WriteLine("Warning: CreatorID is null, in " + this.GetType()); } + Array.Copy(CreatorID.GetBytes(), 0, bytes, i, 16); i += 16; + if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } + Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; + if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } + Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(EveryoneMask % 256); + bytes[i++] = (byte)((EveryoneMask >> 8) % 256); + bytes[i++] = (byte)((EveryoneMask >> 16) % 256); + bytes[i++] = (byte)((EveryoneMask >> 24) % 256); + if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } + bytes[i++] = (byte)Description.Length; + Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; + bytes[i++] = (byte)(Flags % 256); + bytes[i++] = (byte)((Flags >> 8) % 256); + bytes[i++] = (byte)((Flags >> 16) % 256); + bytes[i++] = (byte)((Flags >> 24) % 256); + bytes[i++] = (byte)(NextOwnerMask % 256); + bytes[i++] = (byte)((NextOwnerMask >> 8) % 256); + bytes[i++] = (byte)((NextOwnerMask >> 16) % 256); + bytes[i++] = (byte)((NextOwnerMask >> 24) % 256); + if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } + Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(GroupMask % 256); + bytes[i++] = (byte)((GroupMask >> 8) % 256); + bytes[i++] = (byte)((GroupMask >> 16) % 256); + bytes[i++] = (byte)((GroupMask >> 24) % 256); + bytes[i++] = (byte)(OwnerMask % 256); + bytes[i++] = (byte)((OwnerMask >> 8) % 256); + bytes[i++] = (byte)((OwnerMask >> 16) % 256); + bytes[i++] = (byte)((OwnerMask >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- InventoryData --\n"; - output += "GroupOwned: " + GroupOwned.ToString() + "\n"; - output += "CRC: " + CRC.ToString() + "\n"; - output += "CreationDate: " + CreationDate.ToString() + "\n"; - output += "SaleType: " + SaleType.ToString() + "\n"; - output += "BaseMask: " + BaseMask.ToString() + "\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; - output += "InvType: " + InvType.ToString() + "\n"; - output += "Type: " + Type.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; - output += "SalePrice: " + SalePrice.ToString() + "\n"; - output += "OwnerID: " + OwnerID.ToString() + "\n"; - output += "CreatorID: " + CreatorID.ToString() + "\n"; - output += "ItemID: " + ItemID.ToString() + "\n"; - output += "FolderID: " + FolderID.ToString() + "\n"; - output += "EveryoneMask: " + EveryoneMask.ToString() + "\n"; - output += Helpers.FieldToString(Description, "Description") + "\n"; - output += "Flags: " + Flags.ToString() + "\n"; - output += "NextOwnerMask: " + NextOwnerMask.ToString() + "\n"; - output += "TransactionID: " + TransactionID.ToString() + "\n"; - output += "GroupMask: " + GroupMask.ToString() + "\n"; - output += "OwnerMask: " + OwnerMask.ToString() + "\n"; + { + string output = "-- InventoryData --\n"; + output += "GroupOwned: " + GroupOwned.ToString() + "\n"; + output += "CRC: " + CRC.ToString() + "\n"; + output += "CreationDate: " + CreationDate.ToString() + "\n"; + output += "SaleType: " + SaleType.ToString() + "\n"; + output += "BaseMask: " + BaseMask.ToString() + "\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; + output += "InvType: " + InvType.ToString() + "\n"; + output += "Type: " + Type.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; + output += "SalePrice: " + SalePrice.ToString() + "\n"; + output += "OwnerID: " + OwnerID.ToString() + "\n"; + output += "CreatorID: " + CreatorID.ToString() + "\n"; + output += "ItemID: " + ItemID.ToString() + "\n"; + output += "FolderID: " + FolderID.ToString() + "\n"; + output += "EveryoneMask: " + EveryoneMask.ToString() + "\n"; + output += Helpers.FieldToString(Description, "Description") + "\n"; + output += "Flags: " + Flags.ToString() + "\n"; + output += "NextOwnerMask: " + NextOwnerMask.ToString() + "\n"; + output += "TransactionID: " + TransactionID.ToString() + "\n"; + output += "GroupMask: " + GroupMask.ToString() + "\n"; + output += "OwnerMask: " + OwnerMask.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// RezData block + + /// RezData block public class RezDataBlock - { - /// RezSelected field - public bool RezSelected; - /// RemoveItem field - public bool RemoveItem; - /// RayStart field - public LLVector3 RayStart; - /// ItemFlags field - public uint ItemFlags; - /// FromTaskID field - public LLUUID FromTaskID; - /// RayEndIsIntersection field - public bool RayEndIsIntersection; - /// RayEnd field - public LLVector3 RayEnd; - /// BypassRaycast field - public byte BypassRaycast; - /// EveryoneMask field - public uint EveryoneMask; - /// NextOwnerMask field - public uint NextOwnerMask; - /// GroupMask field - public uint GroupMask; - /// RayTargetID field - public LLUUID RayTargetID; - - /// Length of this block serialized in bytes + { + /// RezSelected field + public bool RezSelected; + /// RemoveItem field + public bool RemoveItem; + /// RayStart field + public LLVector3 RayStart; + /// ItemFlags field + public uint ItemFlags; + /// FromTaskID field + public LLUUID FromTaskID; + /// RayEndIsIntersection field + public bool RayEndIsIntersection; + /// RayEnd field + public LLVector3 RayEnd; + /// BypassRaycast field + public byte BypassRaycast; + /// EveryoneMask field + public uint EveryoneMask; + /// NextOwnerMask field + public uint NextOwnerMask; + /// GroupMask field + public uint GroupMask; + /// RayTargetID field + public LLUUID RayTargetID; + + /// Length of this block serialized in bytes public int Length { get - { - return 76; + { + return 76; } } - - /// Default constructor - public RezDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public RezDataBlock() { } + /// Constructor for building the block from a byte array public RezDataBlock(byte[] bytes, ref int i) - { + { try - { - RezSelected = (bytes[i++] != 0) ? (bool)true : (bool)false; - RemoveItem = (bytes[i++] != 0) ? (bool)true : (bool)false; - RayStart = new LLVector3(bytes, i); i += 12; - ItemFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - FromTaskID = new LLUUID(bytes, i); i += 16; - RayEndIsIntersection = (bytes[i++] != 0) ? (bool)true : (bool)false; - RayEnd = new LLVector3(bytes, i); i += 12; - BypassRaycast = (byte)bytes[i++]; - EveryoneMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - NextOwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - GroupMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - RayTargetID = new LLUUID(bytes, i); i += 16; + { + RezSelected = (bytes[i++] != 0) ? (bool)true : (bool)false; + RemoveItem = (bytes[i++] != 0) ? (bool)true : (bool)false; + RayStart = new LLVector3(bytes, i); i += 12; + ItemFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + FromTaskID = new LLUUID(bytes, i); i += 16; + RayEndIsIntersection = (bytes[i++] != 0) ? (bool)true : (bool)false; + RayEnd = new LLVector3(bytes, i); i += 12; + BypassRaycast = (byte)bytes[i++]; + EveryoneMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + NextOwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + GroupMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + RayTargetID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)((RezSelected) ? 1 : 0); - bytes[i++] = (byte)((RemoveItem) ? 1 : 0); - if(RayStart == null) { Console.WriteLine("Warning: RayStart is null, in " + this.GetType()); } - Array.Copy(RayStart.GetBytes(), 0, bytes, i, 12); i += 12; - bytes[i++] = (byte)(ItemFlags % 256); - bytes[i++] = (byte)((ItemFlags >> 8) % 256); - bytes[i++] = (byte)((ItemFlags >> 16) % 256); - bytes[i++] = (byte)((ItemFlags >> 24) % 256); - if(FromTaskID == null) { Console.WriteLine("Warning: FromTaskID is null, in " + this.GetType()); } - Array.Copy(FromTaskID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((RayEndIsIntersection) ? 1 : 0); - if(RayEnd == null) { Console.WriteLine("Warning: RayEnd is null, in " + this.GetType()); } - Array.Copy(RayEnd.GetBytes(), 0, bytes, i, 12); i += 12; - bytes[i++] = BypassRaycast; - bytes[i++] = (byte)(EveryoneMask % 256); - bytes[i++] = (byte)((EveryoneMask >> 8) % 256); - bytes[i++] = (byte)((EveryoneMask >> 16) % 256); - bytes[i++] = (byte)((EveryoneMask >> 24) % 256); - bytes[i++] = (byte)(NextOwnerMask % 256); - bytes[i++] = (byte)((NextOwnerMask >> 8) % 256); - bytes[i++] = (byte)((NextOwnerMask >> 16) % 256); - bytes[i++] = (byte)((NextOwnerMask >> 24) % 256); - bytes[i++] = (byte)(GroupMask % 256); - bytes[i++] = (byte)((GroupMask >> 8) % 256); - bytes[i++] = (byte)((GroupMask >> 16) % 256); - bytes[i++] = (byte)((GroupMask >> 24) % 256); - if(RayTargetID == null) { Console.WriteLine("Warning: RayTargetID is null, in " + this.GetType()); } - Array.Copy(RayTargetID.GetBytes(), 0, bytes, i, 16); i += 16; + { + bytes[i++] = (byte)((RezSelected) ? 1 : 0); + bytes[i++] = (byte)((RemoveItem) ? 1 : 0); + if(RayStart == null) { Console.WriteLine("Warning: RayStart is null, in " + this.GetType()); } + Array.Copy(RayStart.GetBytes(), 0, bytes, i, 12); i += 12; + bytes[i++] = (byte)(ItemFlags % 256); + bytes[i++] = (byte)((ItemFlags >> 8) % 256); + bytes[i++] = (byte)((ItemFlags >> 16) % 256); + bytes[i++] = (byte)((ItemFlags >> 24) % 256); + if(FromTaskID == null) { Console.WriteLine("Warning: FromTaskID is null, in " + this.GetType()); } + Array.Copy(FromTaskID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((RayEndIsIntersection) ? 1 : 0); + if(RayEnd == null) { Console.WriteLine("Warning: RayEnd is null, in " + this.GetType()); } + Array.Copy(RayEnd.GetBytes(), 0, bytes, i, 12); i += 12; + bytes[i++] = BypassRaycast; + bytes[i++] = (byte)(EveryoneMask % 256); + bytes[i++] = (byte)((EveryoneMask >> 8) % 256); + bytes[i++] = (byte)((EveryoneMask >> 16) % 256); + bytes[i++] = (byte)((EveryoneMask >> 24) % 256); + bytes[i++] = (byte)(NextOwnerMask % 256); + bytes[i++] = (byte)((NextOwnerMask >> 8) % 256); + bytes[i++] = (byte)((NextOwnerMask >> 16) % 256); + bytes[i++] = (byte)((NextOwnerMask >> 24) % 256); + bytes[i++] = (byte)(GroupMask % 256); + bytes[i++] = (byte)((GroupMask >> 8) % 256); + bytes[i++] = (byte)((GroupMask >> 16) % 256); + bytes[i++] = (byte)((GroupMask >> 24) % 256); + if(RayTargetID == null) { Console.WriteLine("Warning: RayTargetID is null, in " + this.GetType()); } + Array.Copy(RayTargetID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- RezData --\n"; - output += "RezSelected: " + RezSelected.ToString() + "\n"; - output += "RemoveItem: " + RemoveItem.ToString() + "\n"; - output += "RayStart: " + RayStart.ToString() + "\n"; - output += "ItemFlags: " + ItemFlags.ToString() + "\n"; - output += "FromTaskID: " + FromTaskID.ToString() + "\n"; - output += "RayEndIsIntersection: " + RayEndIsIntersection.ToString() + "\n"; - output += "RayEnd: " + RayEnd.ToString() + "\n"; - output += "BypassRaycast: " + BypassRaycast.ToString() + "\n"; - output += "EveryoneMask: " + EveryoneMask.ToString() + "\n"; - output += "NextOwnerMask: " + NextOwnerMask.ToString() + "\n"; - output += "GroupMask: " + GroupMask.ToString() + "\n"; - output += "RayTargetID: " + RayTargetID.ToString() + "\n"; + { + string output = "-- RezData --\n"; + output += "RezSelected: " + RezSelected.ToString() + "\n"; + output += "RemoveItem: " + RemoveItem.ToString() + "\n"; + output += "RayStart: " + RayStart.ToString() + "\n"; + output += "ItemFlags: " + ItemFlags.ToString() + "\n"; + output += "FromTaskID: " + FromTaskID.ToString() + "\n"; + output += "RayEndIsIntersection: " + RayEndIsIntersection.ToString() + "\n"; + output += "RayEnd: " + RayEnd.ToString() + "\n"; + output += "BypassRaycast: " + BypassRaycast.ToString() + "\n"; + output += "EveryoneMask: " + EveryoneMask.ToString() + "\n"; + output += "NextOwnerMask: " + NextOwnerMask.ToString() + "\n"; + output += "GroupMask: " + GroupMask.ToString() + "\n"; + output += "RayTargetID: " + RayTargetID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - /// GroupID field - public LLUUID GroupID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + /// GroupID field + public LLUUID GroupID; + + /// Length of this block serialized in bytes public int Length { get - { - return 48; + { + return 48; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; - GroupID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; + GroupID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.RezObject - public override PacketType Type { get { return PacketType.RezObject; } } - /// InventoryData block - public InventoryDataBlock InventoryData; - /// RezData block - public RezDataBlock RezData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.RezObject + public override PacketType Type { get { return PacketType.RezObject; } } + /// InventoryData block + public InventoryDataBlock InventoryData; + /// RezData block + public RezDataBlock RezData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public RezObjectPacket() - { - Header = new LowHeader(); - Header.ID = 343; - Header.Reliable = true; - Header.Zerocoded = true; - InventoryData = new InventoryDataBlock(); - RezData = new RezDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 343; + Header.Reliable = true; + Header.Zerocoded = true; + InventoryData = new InventoryDataBlock(); + RezData = new RezDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public RezObjectPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - InventoryData = new InventoryDataBlock(bytes, ref i); - RezData = new RezDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + InventoryData = new InventoryDataBlock(bytes, ref i); + RezData = new RezDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public RezObjectPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - InventoryData = new InventoryDataBlock(bytes, ref i); - RezData = new RezDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + InventoryData = new InventoryDataBlock(bytes, ref i); + RezData = new RezDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += InventoryData.Length; length += RezData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - InventoryData.ToBytes(bytes, ref i); - RezData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += InventoryData.Length; length += RezData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + InventoryData.ToBytes(bytes, ref i); + RezData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- RezObject ---\n"; - output += InventoryData.ToString() + "\n"; - output += RezData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- RezObject ---\n"; + output += InventoryData.ToString() + "\n"; + output += RezData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// RezObjectFromNotecard packet + + /// RezObjectFromNotecard packet public class RezObjectFromNotecardPacket : Packet - { - /// InventoryData block + { + /// InventoryData block public class InventoryDataBlock - { - /// ItemID field - public LLUUID ItemID; - - /// Length of this block serialized in bytes + { + /// ItemID field + public LLUUID ItemID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public InventoryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public InventoryDataBlock() { } + /// Constructor for building the block from a byte array public InventoryDataBlock(byte[] bytes, ref int i) - { + { try - { - ItemID = new LLUUID(bytes, i); i += 16; + { + ItemID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } - Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } + Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- InventoryData --\n"; - output += "ItemID: " + ItemID.ToString() + "\n"; + { + string output = "-- InventoryData --\n"; + output += "ItemID: " + ItemID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// RezData block + + /// RezData block public class RezDataBlock - { - /// RezSelected field - public bool RezSelected; - /// RemoveItem field - public bool RemoveItem; - /// RayStart field - public LLVector3 RayStart; - /// ItemFlags field - public uint ItemFlags; - /// FromTaskID field - public LLUUID FromTaskID; - /// RayEndIsIntersection field - public bool RayEndIsIntersection; - /// RayEnd field - public LLVector3 RayEnd; - /// BypassRaycast field - public byte BypassRaycast; - /// EveryoneMask field - public uint EveryoneMask; - /// NextOwnerMask field - public uint NextOwnerMask; - /// GroupMask field - public uint GroupMask; - /// RayTargetID field - public LLUUID RayTargetID; - - /// Length of this block serialized in bytes + { + /// RezSelected field + public bool RezSelected; + /// RemoveItem field + public bool RemoveItem; + /// RayStart field + public LLVector3 RayStart; + /// ItemFlags field + public uint ItemFlags; + /// FromTaskID field + public LLUUID FromTaskID; + /// RayEndIsIntersection field + public bool RayEndIsIntersection; + /// RayEnd field + public LLVector3 RayEnd; + /// BypassRaycast field + public byte BypassRaycast; + /// EveryoneMask field + public uint EveryoneMask; + /// NextOwnerMask field + public uint NextOwnerMask; + /// GroupMask field + public uint GroupMask; + /// RayTargetID field + public LLUUID RayTargetID; + + /// Length of this block serialized in bytes public int Length { get - { - return 76; + { + return 76; } } - - /// Default constructor - public RezDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public RezDataBlock() { } + /// Constructor for building the block from a byte array public RezDataBlock(byte[] bytes, ref int i) - { + { try - { - RezSelected = (bytes[i++] != 0) ? (bool)true : (bool)false; - RemoveItem = (bytes[i++] != 0) ? (bool)true : (bool)false; - RayStart = new LLVector3(bytes, i); i += 12; - ItemFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - FromTaskID = new LLUUID(bytes, i); i += 16; - RayEndIsIntersection = (bytes[i++] != 0) ? (bool)true : (bool)false; - RayEnd = new LLVector3(bytes, i); i += 12; - BypassRaycast = (byte)bytes[i++]; - EveryoneMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - NextOwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - GroupMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - RayTargetID = new LLUUID(bytes, i); i += 16; + { + RezSelected = (bytes[i++] != 0) ? (bool)true : (bool)false; + RemoveItem = (bytes[i++] != 0) ? (bool)true : (bool)false; + RayStart = new LLVector3(bytes, i); i += 12; + ItemFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + FromTaskID = new LLUUID(bytes, i); i += 16; + RayEndIsIntersection = (bytes[i++] != 0) ? (bool)true : (bool)false; + RayEnd = new LLVector3(bytes, i); i += 12; + BypassRaycast = (byte)bytes[i++]; + EveryoneMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + NextOwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + GroupMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + RayTargetID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)((RezSelected) ? 1 : 0); - bytes[i++] = (byte)((RemoveItem) ? 1 : 0); - if(RayStart == null) { Console.WriteLine("Warning: RayStart is null, in " + this.GetType()); } - Array.Copy(RayStart.GetBytes(), 0, bytes, i, 12); i += 12; - bytes[i++] = (byte)(ItemFlags % 256); - bytes[i++] = (byte)((ItemFlags >> 8) % 256); - bytes[i++] = (byte)((ItemFlags >> 16) % 256); - bytes[i++] = (byte)((ItemFlags >> 24) % 256); - if(FromTaskID == null) { Console.WriteLine("Warning: FromTaskID is null, in " + this.GetType()); } - Array.Copy(FromTaskID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((RayEndIsIntersection) ? 1 : 0); - if(RayEnd == null) { Console.WriteLine("Warning: RayEnd is null, in " + this.GetType()); } - Array.Copy(RayEnd.GetBytes(), 0, bytes, i, 12); i += 12; - bytes[i++] = BypassRaycast; - bytes[i++] = (byte)(EveryoneMask % 256); - bytes[i++] = (byte)((EveryoneMask >> 8) % 256); - bytes[i++] = (byte)((EveryoneMask >> 16) % 256); - bytes[i++] = (byte)((EveryoneMask >> 24) % 256); - bytes[i++] = (byte)(NextOwnerMask % 256); - bytes[i++] = (byte)((NextOwnerMask >> 8) % 256); - bytes[i++] = (byte)((NextOwnerMask >> 16) % 256); - bytes[i++] = (byte)((NextOwnerMask >> 24) % 256); - bytes[i++] = (byte)(GroupMask % 256); - bytes[i++] = (byte)((GroupMask >> 8) % 256); - bytes[i++] = (byte)((GroupMask >> 16) % 256); - bytes[i++] = (byte)((GroupMask >> 24) % 256); - if(RayTargetID == null) { Console.WriteLine("Warning: RayTargetID is null, in " + this.GetType()); } - Array.Copy(RayTargetID.GetBytes(), 0, bytes, i, 16); i += 16; + { + bytes[i++] = (byte)((RezSelected) ? 1 : 0); + bytes[i++] = (byte)((RemoveItem) ? 1 : 0); + if(RayStart == null) { Console.WriteLine("Warning: RayStart is null, in " + this.GetType()); } + Array.Copy(RayStart.GetBytes(), 0, bytes, i, 12); i += 12; + bytes[i++] = (byte)(ItemFlags % 256); + bytes[i++] = (byte)((ItemFlags >> 8) % 256); + bytes[i++] = (byte)((ItemFlags >> 16) % 256); + bytes[i++] = (byte)((ItemFlags >> 24) % 256); + if(FromTaskID == null) { Console.WriteLine("Warning: FromTaskID is null, in " + this.GetType()); } + Array.Copy(FromTaskID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((RayEndIsIntersection) ? 1 : 0); + if(RayEnd == null) { Console.WriteLine("Warning: RayEnd is null, in " + this.GetType()); } + Array.Copy(RayEnd.GetBytes(), 0, bytes, i, 12); i += 12; + bytes[i++] = BypassRaycast; + bytes[i++] = (byte)(EveryoneMask % 256); + bytes[i++] = (byte)((EveryoneMask >> 8) % 256); + bytes[i++] = (byte)((EveryoneMask >> 16) % 256); + bytes[i++] = (byte)((EveryoneMask >> 24) % 256); + bytes[i++] = (byte)(NextOwnerMask % 256); + bytes[i++] = (byte)((NextOwnerMask >> 8) % 256); + bytes[i++] = (byte)((NextOwnerMask >> 16) % 256); + bytes[i++] = (byte)((NextOwnerMask >> 24) % 256); + bytes[i++] = (byte)(GroupMask % 256); + bytes[i++] = (byte)((GroupMask >> 8) % 256); + bytes[i++] = (byte)((GroupMask >> 16) % 256); + bytes[i++] = (byte)((GroupMask >> 24) % 256); + if(RayTargetID == null) { Console.WriteLine("Warning: RayTargetID is null, in " + this.GetType()); } + Array.Copy(RayTargetID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- RezData --\n"; - output += "RezSelected: " + RezSelected.ToString() + "\n"; - output += "RemoveItem: " + RemoveItem.ToString() + "\n"; - output += "RayStart: " + RayStart.ToString() + "\n"; - output += "ItemFlags: " + ItemFlags.ToString() + "\n"; - output += "FromTaskID: " + FromTaskID.ToString() + "\n"; - output += "RayEndIsIntersection: " + RayEndIsIntersection.ToString() + "\n"; - output += "RayEnd: " + RayEnd.ToString() + "\n"; - output += "BypassRaycast: " + BypassRaycast.ToString() + "\n"; - output += "EveryoneMask: " + EveryoneMask.ToString() + "\n"; - output += "NextOwnerMask: " + NextOwnerMask.ToString() + "\n"; - output += "GroupMask: " + GroupMask.ToString() + "\n"; - output += "RayTargetID: " + RayTargetID.ToString() + "\n"; + { + string output = "-- RezData --\n"; + output += "RezSelected: " + RezSelected.ToString() + "\n"; + output += "RemoveItem: " + RemoveItem.ToString() + "\n"; + output += "RayStart: " + RayStart.ToString() + "\n"; + output += "ItemFlags: " + ItemFlags.ToString() + "\n"; + output += "FromTaskID: " + FromTaskID.ToString() + "\n"; + output += "RayEndIsIntersection: " + RayEndIsIntersection.ToString() + "\n"; + output += "RayEnd: " + RayEnd.ToString() + "\n"; + output += "BypassRaycast: " + BypassRaycast.ToString() + "\n"; + output += "EveryoneMask: " + EveryoneMask.ToString() + "\n"; + output += "NextOwnerMask: " + NextOwnerMask.ToString() + "\n"; + output += "GroupMask: " + GroupMask.ToString() + "\n"; + output += "RayTargetID: " + RayTargetID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// NotecardData block + + /// NotecardData block public class NotecardDataBlock - { - /// ObjectID field - public LLUUID ObjectID; - /// NotecardItemID field - public LLUUID NotecardItemID; - - /// Length of this block serialized in bytes + { + /// ObjectID field + public LLUUID ObjectID; + /// NotecardItemID field + public LLUUID NotecardItemID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public NotecardDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public NotecardDataBlock() { } + /// Constructor for building the block from a byte array public NotecardDataBlock(byte[] bytes, ref int i) - { + { try - { - ObjectID = new LLUUID(bytes, i); i += 16; - NotecardItemID = new LLUUID(bytes, i); i += 16; + { + ObjectID = new LLUUID(bytes, i); i += 16; + NotecardItemID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } - Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; - if(NotecardItemID == null) { Console.WriteLine("Warning: NotecardItemID is null, in " + this.GetType()); } - Array.Copy(NotecardItemID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } + Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; + if(NotecardItemID == null) { Console.WriteLine("Warning: NotecardItemID is null, in " + this.GetType()); } + Array.Copy(NotecardItemID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- NotecardData --\n"; - output += "ObjectID: " + ObjectID.ToString() + "\n"; - output += "NotecardItemID: " + NotecardItemID.ToString() + "\n"; + { + string output = "-- NotecardData --\n"; + output += "ObjectID: " + ObjectID.ToString() + "\n"; + output += "NotecardItemID: " + NotecardItemID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - /// GroupID field - public LLUUID GroupID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + /// GroupID field + public LLUUID GroupID; + + /// Length of this block serialized in bytes public int Length { get - { - return 48; + { + return 48; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; - GroupID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; + GroupID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.RezObjectFromNotecard - public override PacketType Type { get { return PacketType.RezObjectFromNotecard; } } - /// InventoryData block - public InventoryDataBlock[] InventoryData; - /// RezData block - public RezDataBlock RezData; - /// NotecardData block - public NotecardDataBlock NotecardData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.RezObjectFromNotecard + public override PacketType Type { get { return PacketType.RezObjectFromNotecard; } } + /// InventoryData block + public InventoryDataBlock[] InventoryData; + /// RezData block + public RezDataBlock RezData; + /// NotecardData block + public NotecardDataBlock NotecardData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public RezObjectFromNotecardPacket() - { - Header = new LowHeader(); - Header.ID = 344; - Header.Reliable = true; - Header.Zerocoded = true; - InventoryData = new InventoryDataBlock[0]; - RezData = new RezDataBlock(); - NotecardData = new NotecardDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 344; + Header.Reliable = true; + Header.Zerocoded = true; + InventoryData = new InventoryDataBlock[0]; + RezData = new RezDataBlock(); + NotecardData = new NotecardDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public RezObjectFromNotecardPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - InventoryData = new InventoryDataBlock[count]; - for (int j = 0; j < count; j++) - { InventoryData[j] = new InventoryDataBlock(bytes, ref i); } - RezData = new RezDataBlock(bytes, ref i); - NotecardData = new NotecardDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + InventoryData = new InventoryDataBlock[count]; + for (int j = 0; j < count; j++) + { InventoryData[j] = new InventoryDataBlock(bytes, ref i); } + RezData = new RezDataBlock(bytes, ref i); + NotecardData = new NotecardDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public RezObjectFromNotecardPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - InventoryData = new InventoryDataBlock[count]; - for (int j = 0; j < count; j++) - { InventoryData[j] = new InventoryDataBlock(bytes, ref i); } - RezData = new RezDataBlock(bytes, ref i); - NotecardData = new NotecardDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + InventoryData = new InventoryDataBlock[count]; + for (int j = 0; j < count; j++) + { InventoryData[j] = new InventoryDataBlock(bytes, ref i); } + RezData = new RezDataBlock(bytes, ref i); + NotecardData = new NotecardDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += RezData.Length; length += NotecardData.Length; length += AgentData.Length;; - length++; - for (int j = 0; j < InventoryData.Length; j++) { length += InventoryData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)InventoryData.Length; - for (int j = 0; j < InventoryData.Length; j++) { InventoryData[j].ToBytes(bytes, ref i); } - RezData.ToBytes(bytes, ref i); - NotecardData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += RezData.Length; length += NotecardData.Length; length += AgentData.Length;; + length++; + for (int j = 0; j < InventoryData.Length; j++) { length += InventoryData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)InventoryData.Length; + for (int j = 0; j < InventoryData.Length; j++) { InventoryData[j].ToBytes(bytes, ref i); } + RezData.ToBytes(bytes, ref i); + NotecardData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- RezObjectFromNotecard ---\n"; + { + string output = "--- RezObjectFromNotecard ---\n"; for (int j = 0; j < InventoryData.Length; j++) - { + { output += InventoryData[j].ToString() + "\n"; - } - output += RezData.ToString() + "\n"; - output += NotecardData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + } + output += RezData.ToString() + "\n"; + output += NotecardData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// DeclineInventory packet + + /// DeclineInventory packet public class DeclineInventoryPacket : Packet - { - /// InfoBlock block + { + /// InfoBlock block public class InfoBlockBlock - { - /// TransactionID field - public LLUUID TransactionID; - - /// Length of this block serialized in bytes + { + /// TransactionID field + public LLUUID TransactionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public InfoBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public InfoBlockBlock() { } + /// Constructor for building the block from a byte array public InfoBlockBlock(byte[] bytes, ref int i) - { + { try - { - TransactionID = new LLUUID(bytes, i); i += 16; + { + TransactionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } - Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } + Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- InfoBlock --\n"; - output += "TransactionID: " + TransactionID.ToString() + "\n"; + { + string output = "-- InfoBlock --\n"; + output += "TransactionID: " + TransactionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.DeclineInventory - public override PacketType Type { get { return PacketType.DeclineInventory; } } - /// InfoBlock block - public InfoBlockBlock InfoBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.DeclineInventory + public override PacketType Type { get { return PacketType.DeclineInventory; } } + /// InfoBlock block + public InfoBlockBlock InfoBlock; + + /// Default constructor public DeclineInventoryPacket() - { - Header = new LowHeader(); - Header.ID = 345; - Header.Reliable = true; - InfoBlock = new InfoBlockBlock(); + { + Header = new LowHeader(); + Header.ID = 345; + Header.Reliable = true; + InfoBlock = new InfoBlockBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public DeclineInventoryPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - InfoBlock = new InfoBlockBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + InfoBlock = new InfoBlockBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public DeclineInventoryPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - InfoBlock = new InfoBlockBlock(bytes, ref i); + { + Header = head; + InfoBlock = new InfoBlockBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += InfoBlock.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - InfoBlock.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += InfoBlock.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + InfoBlock.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- DeclineInventory ---\n"; - output += InfoBlock.ToString() + "\n"; + { + string output = "--- DeclineInventory ---\n"; + output += InfoBlock.ToString() + "\n"; return output; } - + } - - /// TransferInventory packet + + /// TransferInventory packet public class TransferInventoryPacket : Packet - { - /// InfoBlock block + { + /// InfoBlock block public class InfoBlockBlock - { - /// DestID field - public LLUUID DestID; - /// SourceID field - public LLUUID SourceID; - /// TransactionID field - public LLUUID TransactionID; - - /// Length of this block serialized in bytes + { + /// DestID field + public LLUUID DestID; + /// SourceID field + public LLUUID SourceID; + /// TransactionID field + public LLUUID TransactionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 48; + { + return 48; } } - - /// Default constructor - public InfoBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public InfoBlockBlock() { } + /// Constructor for building the block from a byte array public InfoBlockBlock(byte[] bytes, ref int i) - { + { try - { - DestID = new LLUUID(bytes, i); i += 16; - SourceID = new LLUUID(bytes, i); i += 16; - TransactionID = new LLUUID(bytes, i); i += 16; + { + DestID = new LLUUID(bytes, i); i += 16; + SourceID = new LLUUID(bytes, i); i += 16; + TransactionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(DestID == null) { Console.WriteLine("Warning: DestID is null, in " + this.GetType()); } - Array.Copy(DestID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SourceID == null) { Console.WriteLine("Warning: SourceID is null, in " + this.GetType()); } - Array.Copy(SourceID.GetBytes(), 0, bytes, i, 16); i += 16; - if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } - Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(DestID == null) { Console.WriteLine("Warning: DestID is null, in " + this.GetType()); } + Array.Copy(DestID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SourceID == null) { Console.WriteLine("Warning: SourceID is null, in " + this.GetType()); } + Array.Copy(SourceID.GetBytes(), 0, bytes, i, 16); i += 16; + if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } + Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- InfoBlock --\n"; - output += "DestID: " + DestID.ToString() + "\n"; - output += "SourceID: " + SourceID.ToString() + "\n"; - output += "TransactionID: " + TransactionID.ToString() + "\n"; + { + string output = "-- InfoBlock --\n"; + output += "DestID: " + DestID.ToString() + "\n"; + output += "SourceID: " + SourceID.ToString() + "\n"; + output += "TransactionID: " + TransactionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// InventoryBlock block + + /// InventoryBlock block public class InventoryBlockBlock - { - /// Type field - public sbyte Type; - /// InventoryID field - public LLUUID InventoryID; - - /// Length of this block serialized in bytes + { + /// Type field + public sbyte Type; + /// InventoryID field + public LLUUID InventoryID; + + /// Length of this block serialized in bytes public int Length { get - { - return 17; + { + return 17; } } - - /// Default constructor - public InventoryBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public InventoryBlockBlock() { } + /// Constructor for building the block from a byte array public InventoryBlockBlock(byte[] bytes, ref int i) - { + { try - { - Type = (sbyte)bytes[i++]; - InventoryID = new LLUUID(bytes, i); i += 16; + { + Type = (sbyte)bytes[i++]; + InventoryID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)Type; - if(InventoryID == null) { Console.WriteLine("Warning: InventoryID is null, in " + this.GetType()); } - Array.Copy(InventoryID.GetBytes(), 0, bytes, i, 16); i += 16; + { + bytes[i++] = (byte)Type; + if(InventoryID == null) { Console.WriteLine("Warning: InventoryID is null, in " + this.GetType()); } + Array.Copy(InventoryID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- InventoryBlock --\n"; - output += "Type: " + Type.ToString() + "\n"; - output += "InventoryID: " + InventoryID.ToString() + "\n"; + { + string output = "-- InventoryBlock --\n"; + output += "Type: " + Type.ToString() + "\n"; + output += "InventoryID: " + InventoryID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.TransferInventory - public override PacketType Type { get { return PacketType.TransferInventory; } } - /// InfoBlock block - public InfoBlockBlock InfoBlock; - /// InventoryBlock block - public InventoryBlockBlock[] InventoryBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.TransferInventory + public override PacketType Type { get { return PacketType.TransferInventory; } } + /// InfoBlock block + public InfoBlockBlock InfoBlock; + /// InventoryBlock block + public InventoryBlockBlock[] InventoryBlock; + + /// Default constructor public TransferInventoryPacket() - { - Header = new LowHeader(); - Header.ID = 346; - Header.Reliable = true; - Header.Zerocoded = true; - InfoBlock = new InfoBlockBlock(); - InventoryBlock = new InventoryBlockBlock[0]; + { + Header = new LowHeader(); + Header.ID = 346; + Header.Reliable = true; + Header.Zerocoded = true; + InfoBlock = new InfoBlockBlock(); + InventoryBlock = new InventoryBlockBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public TransferInventoryPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - InfoBlock = new InfoBlockBlock(bytes, ref i); - int count = (int)bytes[i++]; - InventoryBlock = new InventoryBlockBlock[count]; - for (int j = 0; j < count; j++) - { InventoryBlock[j] = new InventoryBlockBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + InfoBlock = new InfoBlockBlock(bytes, ref i); + int count = (int)bytes[i++]; + InventoryBlock = new InventoryBlockBlock[count]; + for (int j = 0; j < count; j++) + { InventoryBlock[j] = new InventoryBlockBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public TransferInventoryPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - InfoBlock = new InfoBlockBlock(bytes, ref i); - int count = (int)bytes[i++]; - InventoryBlock = new InventoryBlockBlock[count]; - for (int j = 0; j < count; j++) - { InventoryBlock[j] = new InventoryBlockBlock(bytes, ref i); } + { + Header = head; + InfoBlock = new InfoBlockBlock(bytes, ref i); + int count = (int)bytes[i++]; + InventoryBlock = new InventoryBlockBlock[count]; + for (int j = 0; j < count; j++) + { InventoryBlock[j] = new InventoryBlockBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += InfoBlock.Length;; - length++; - for (int j = 0; j < InventoryBlock.Length; j++) { length += InventoryBlock[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - InfoBlock.ToBytes(bytes, ref i); - bytes[i++] = (byte)InventoryBlock.Length; - for (int j = 0; j < InventoryBlock.Length; j++) { InventoryBlock[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += InfoBlock.Length;; + length++; + for (int j = 0; j < InventoryBlock.Length; j++) { length += InventoryBlock[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + InfoBlock.ToBytes(bytes, ref i); + bytes[i++] = (byte)InventoryBlock.Length; + for (int j = 0; j < InventoryBlock.Length; j++) { InventoryBlock[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- TransferInventory ---\n"; - output += InfoBlock.ToString() + "\n"; + { + string output = "--- TransferInventory ---\n"; + output += InfoBlock.ToString() + "\n"; for (int j = 0; j < InventoryBlock.Length; j++) - { + { output += InventoryBlock[j].ToString() + "\n"; - } + } return output; } - + } - - /// TransferInventoryAck packet + + /// TransferInventoryAck packet public class TransferInventoryAckPacket : Packet - { - /// InfoBlock block + { + /// InfoBlock block public class InfoBlockBlock - { - /// InventoryID field - public LLUUID InventoryID; - /// TransactionID field - public LLUUID TransactionID; - - /// Length of this block serialized in bytes + { + /// InventoryID field + public LLUUID InventoryID; + /// TransactionID field + public LLUUID TransactionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public InfoBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public InfoBlockBlock() { } + /// Constructor for building the block from a byte array public InfoBlockBlock(byte[] bytes, ref int i) - { + { try - { - InventoryID = new LLUUID(bytes, i); i += 16; - TransactionID = new LLUUID(bytes, i); i += 16; + { + InventoryID = new LLUUID(bytes, i); i += 16; + TransactionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(InventoryID == null) { Console.WriteLine("Warning: InventoryID is null, in " + this.GetType()); } - Array.Copy(InventoryID.GetBytes(), 0, bytes, i, 16); i += 16; - if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } - Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(InventoryID == null) { Console.WriteLine("Warning: InventoryID is null, in " + this.GetType()); } + Array.Copy(InventoryID.GetBytes(), 0, bytes, i, 16); i += 16; + if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } + Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- InfoBlock --\n"; - output += "InventoryID: " + InventoryID.ToString() + "\n"; - output += "TransactionID: " + TransactionID.ToString() + "\n"; + { + string output = "-- InfoBlock --\n"; + output += "InventoryID: " + InventoryID.ToString() + "\n"; + output += "TransactionID: " + TransactionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.TransferInventoryAck - public override PacketType Type { get { return PacketType.TransferInventoryAck; } } - /// InfoBlock block - public InfoBlockBlock InfoBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.TransferInventoryAck + public override PacketType Type { get { return PacketType.TransferInventoryAck; } } + /// InfoBlock block + public InfoBlockBlock InfoBlock; + + /// Default constructor public TransferInventoryAckPacket() - { - Header = new LowHeader(); - Header.ID = 347; - Header.Reliable = true; - Header.Zerocoded = true; - InfoBlock = new InfoBlockBlock(); + { + Header = new LowHeader(); + Header.ID = 347; + Header.Reliable = true; + Header.Zerocoded = true; + InfoBlock = new InfoBlockBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public TransferInventoryAckPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - InfoBlock = new InfoBlockBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + InfoBlock = new InfoBlockBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public TransferInventoryAckPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - InfoBlock = new InfoBlockBlock(bytes, ref i); + { + Header = head; + InfoBlock = new InfoBlockBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += InfoBlock.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - InfoBlock.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += InfoBlock.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + InfoBlock.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- TransferInventoryAck ---\n"; - output += InfoBlock.ToString() + "\n"; + { + string output = "--- TransferInventoryAck ---\n"; + output += InfoBlock.ToString() + "\n"; return output; } - + } - - /// RequestFriendship packet + + /// RequestFriendship packet public class RequestFriendshipPacket : Packet - { - /// AgentBlock block + { + /// AgentBlock block public class AgentBlockBlock - { - /// DestID field - public LLUUID DestID; - /// FolderID field - public LLUUID FolderID; - /// TransactionID field - public LLUUID TransactionID; - - /// Length of this block serialized in bytes + { + /// DestID field + public LLUUID DestID; + /// FolderID field + public LLUUID FolderID; + /// TransactionID field + public LLUUID TransactionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 48; + { + return 48; } } - - /// Default constructor - public AgentBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentBlockBlock() { } + /// Constructor for building the block from a byte array public AgentBlockBlock(byte[] bytes, ref int i) - { + { try - { - DestID = new LLUUID(bytes, i); i += 16; - FolderID = new LLUUID(bytes, i); i += 16; - TransactionID = new LLUUID(bytes, i); i += 16; + { + DestID = new LLUUID(bytes, i); i += 16; + FolderID = new LLUUID(bytes, i); i += 16; + TransactionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(DestID == null) { Console.WriteLine("Warning: DestID is null, in " + this.GetType()); } - Array.Copy(DestID.GetBytes(), 0, bytes, i, 16); i += 16; - if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } - Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; - if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } - Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(DestID == null) { Console.WriteLine("Warning: DestID is null, in " + this.GetType()); } + Array.Copy(DestID.GetBytes(), 0, bytes, i, 16); i += 16; + if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } + Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; + if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } + Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentBlock --\n"; - output += "DestID: " + DestID.ToString() + "\n"; - output += "FolderID: " + FolderID.ToString() + "\n"; - output += "TransactionID: " + TransactionID.ToString() + "\n"; + { + string output = "-- AgentBlock --\n"; + output += "DestID: " + DestID.ToString() + "\n"; + output += "FolderID: " + FolderID.ToString() + "\n"; + output += "TransactionID: " + TransactionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.RequestFriendship - public override PacketType Type { get { return PacketType.RequestFriendship; } } - /// AgentBlock block - public AgentBlockBlock AgentBlock; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.RequestFriendship + public override PacketType Type { get { return PacketType.RequestFriendship; } } + /// AgentBlock block + public AgentBlockBlock AgentBlock; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public RequestFriendshipPacket() - { - Header = new LowHeader(); - Header.ID = 348; - Header.Reliable = true; - AgentBlock = new AgentBlockBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 348; + Header.Reliable = true; + AgentBlock = new AgentBlockBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public RequestFriendshipPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentBlock = new AgentBlockBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentBlock = new AgentBlockBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public RequestFriendshipPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentBlock = new AgentBlockBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + AgentBlock = new AgentBlockBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentBlock.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentBlock.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentBlock.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentBlock.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- RequestFriendship ---\n"; - output += AgentBlock.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- RequestFriendship ---\n"; + output += AgentBlock.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// AcceptFriendship packet + + /// AcceptFriendship packet public class AcceptFriendshipPacket : Packet - { - /// TransactionBlock block + { + /// TransactionBlock block public class TransactionBlockBlock - { - /// TransactionID field - public LLUUID TransactionID; - - /// Length of this block serialized in bytes + { + /// TransactionID field + public LLUUID TransactionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public TransactionBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public TransactionBlockBlock() { } + /// Constructor for building the block from a byte array public TransactionBlockBlock(byte[] bytes, ref int i) - { + { try - { - TransactionID = new LLUUID(bytes, i); i += 16; + { + TransactionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } - Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } + Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- TransactionBlock --\n"; - output += "TransactionID: " + TransactionID.ToString() + "\n"; + { + string output = "-- TransactionBlock --\n"; + output += "TransactionID: " + TransactionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// FolderData block + + /// FolderData block public class FolderDataBlock - { - /// FolderID field - public LLUUID FolderID; - - /// Length of this block serialized in bytes + { + /// FolderID field + public LLUUID FolderID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public FolderDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public FolderDataBlock() { } + /// Constructor for building the block from a byte array public FolderDataBlock(byte[] bytes, ref int i) - { + { try - { - FolderID = new LLUUID(bytes, i); i += 16; + { + FolderID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } - Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } + Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- FolderData --\n"; - output += "FolderID: " + FolderID.ToString() + "\n"; + { + string output = "-- FolderData --\n"; + output += "FolderID: " + FolderID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AcceptFriendship - public override PacketType Type { get { return PacketType.AcceptFriendship; } } - /// TransactionBlock block - public TransactionBlockBlock TransactionBlock; - /// AgentData block - public AgentDataBlock AgentData; - /// FolderData block - public FolderDataBlock[] FolderData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AcceptFriendship + public override PacketType Type { get { return PacketType.AcceptFriendship; } } + /// TransactionBlock block + public TransactionBlockBlock TransactionBlock; + /// AgentData block + public AgentDataBlock AgentData; + /// FolderData block + public FolderDataBlock[] FolderData; + + /// Default constructor public AcceptFriendshipPacket() - { - Header = new LowHeader(); - Header.ID = 349; - Header.Reliable = true; - TransactionBlock = new TransactionBlockBlock(); - AgentData = new AgentDataBlock(); - FolderData = new FolderDataBlock[0]; + { + Header = new LowHeader(); + Header.ID = 349; + Header.Reliable = true; + TransactionBlock = new TransactionBlockBlock(); + AgentData = new AgentDataBlock(); + FolderData = new FolderDataBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AcceptFriendshipPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - TransactionBlock = new TransactionBlockBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); - int count = (int)bytes[i++]; - FolderData = new FolderDataBlock[count]; - for (int j = 0; j < count; j++) - { FolderData[j] = new FolderDataBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + TransactionBlock = new TransactionBlockBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); + int count = (int)bytes[i++]; + FolderData = new FolderDataBlock[count]; + for (int j = 0; j < count; j++) + { FolderData[j] = new FolderDataBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AcceptFriendshipPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - TransactionBlock = new TransactionBlockBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); - int count = (int)bytes[i++]; - FolderData = new FolderDataBlock[count]; - for (int j = 0; j < count; j++) - { FolderData[j] = new FolderDataBlock(bytes, ref i); } + { + Header = head; + TransactionBlock = new TransactionBlockBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); + int count = (int)bytes[i++]; + FolderData = new FolderDataBlock[count]; + for (int j = 0; j < count; j++) + { FolderData[j] = new FolderDataBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += TransactionBlock.Length; length += AgentData.Length;; - length++; - for (int j = 0; j < FolderData.Length; j++) { length += FolderData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - TransactionBlock.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - bytes[i++] = (byte)FolderData.Length; - for (int j = 0; j < FolderData.Length; j++) { FolderData[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += TransactionBlock.Length; length += AgentData.Length;; + length++; + for (int j = 0; j < FolderData.Length; j++) { length += FolderData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + TransactionBlock.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + bytes[i++] = (byte)FolderData.Length; + for (int j = 0; j < FolderData.Length; j++) { FolderData[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AcceptFriendship ---\n"; - output += TransactionBlock.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- AcceptFriendship ---\n"; + output += TransactionBlock.ToString() + "\n"; + output += AgentData.ToString() + "\n"; for (int j = 0; j < FolderData.Length; j++) - { + { output += FolderData[j].ToString() + "\n"; - } + } return output; } - + } - - /// DeclineFriendship packet + + /// DeclineFriendship packet public class DeclineFriendshipPacket : Packet - { - /// TransactionBlock block + { + /// TransactionBlock block public class TransactionBlockBlock - { - /// TransactionID field - public LLUUID TransactionID; - - /// Length of this block serialized in bytes + { + /// TransactionID field + public LLUUID TransactionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public TransactionBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public TransactionBlockBlock() { } + /// Constructor for building the block from a byte array public TransactionBlockBlock(byte[] bytes, ref int i) - { + { try - { - TransactionID = new LLUUID(bytes, i); i += 16; + { + TransactionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } - Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } + Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- TransactionBlock --\n"; - output += "TransactionID: " + TransactionID.ToString() + "\n"; + { + string output = "-- TransactionBlock --\n"; + output += "TransactionID: " + TransactionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.DeclineFriendship - public override PacketType Type { get { return PacketType.DeclineFriendship; } } - /// TransactionBlock block - public TransactionBlockBlock TransactionBlock; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.DeclineFriendship + public override PacketType Type { get { return PacketType.DeclineFriendship; } } + /// TransactionBlock block + public TransactionBlockBlock TransactionBlock; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public DeclineFriendshipPacket() - { - Header = new LowHeader(); - Header.ID = 350; - Header.Reliable = true; - TransactionBlock = new TransactionBlockBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 350; + Header.Reliable = true; + TransactionBlock = new TransactionBlockBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public DeclineFriendshipPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - TransactionBlock = new TransactionBlockBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + TransactionBlock = new TransactionBlockBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public DeclineFriendshipPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - TransactionBlock = new TransactionBlockBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + TransactionBlock = new TransactionBlockBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += TransactionBlock.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - TransactionBlock.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += TransactionBlock.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + TransactionBlock.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- DeclineFriendship ---\n"; - output += TransactionBlock.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- DeclineFriendship ---\n"; + output += TransactionBlock.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// FormFriendship packet + + /// FormFriendship packet public class FormFriendshipPacket : Packet - { - /// AgentBlock block + { + /// AgentBlock block public class AgentBlockBlock - { - /// DestID field - public LLUUID DestID; - /// SourceID field - public LLUUID SourceID; - - /// Length of this block serialized in bytes + { + /// DestID field + public LLUUID DestID; + /// SourceID field + public LLUUID SourceID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentBlockBlock() { } + /// Constructor for building the block from a byte array public AgentBlockBlock(byte[] bytes, ref int i) - { + { try - { - DestID = new LLUUID(bytes, i); i += 16; - SourceID = new LLUUID(bytes, i); i += 16; + { + DestID = new LLUUID(bytes, i); i += 16; + SourceID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(DestID == null) { Console.WriteLine("Warning: DestID is null, in " + this.GetType()); } - Array.Copy(DestID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SourceID == null) { Console.WriteLine("Warning: SourceID is null, in " + this.GetType()); } - Array.Copy(SourceID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(DestID == null) { Console.WriteLine("Warning: DestID is null, in " + this.GetType()); } + Array.Copy(DestID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SourceID == null) { Console.WriteLine("Warning: SourceID is null, in " + this.GetType()); } + Array.Copy(SourceID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentBlock --\n"; - output += "DestID: " + DestID.ToString() + "\n"; - output += "SourceID: " + SourceID.ToString() + "\n"; + { + string output = "-- AgentBlock --\n"; + output += "DestID: " + DestID.ToString() + "\n"; + output += "SourceID: " + SourceID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.FormFriendship - public override PacketType Type { get { return PacketType.FormFriendship; } } - /// AgentBlock block - public AgentBlockBlock AgentBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.FormFriendship + public override PacketType Type { get { return PacketType.FormFriendship; } } + /// AgentBlock block + public AgentBlockBlock AgentBlock; + + /// Default constructor public FormFriendshipPacket() - { - Header = new LowHeader(); - Header.ID = 351; - Header.Reliable = true; - AgentBlock = new AgentBlockBlock(); + { + Header = new LowHeader(); + Header.ID = 351; + Header.Reliable = true; + AgentBlock = new AgentBlockBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public FormFriendshipPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentBlock = new AgentBlockBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentBlock = new AgentBlockBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public FormFriendshipPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentBlock = new AgentBlockBlock(bytes, ref i); + { + Header = head; + AgentBlock = new AgentBlockBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentBlock.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentBlock.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentBlock.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentBlock.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- FormFriendship ---\n"; - output += AgentBlock.ToString() + "\n"; + { + string output = "--- FormFriendship ---\n"; + output += AgentBlock.ToString() + "\n"; return output; } - + } - - /// TerminateFriendship packet + + /// TerminateFriendship packet public class TerminateFriendshipPacket : Packet - { - /// ExBlock block + { + /// ExBlock block public class ExBlockBlock - { - /// OtherID field - public LLUUID OtherID; - - /// Length of this block serialized in bytes + { + /// OtherID field + public LLUUID OtherID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public ExBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ExBlockBlock() { } + /// Constructor for building the block from a byte array public ExBlockBlock(byte[] bytes, ref int i) - { + { try - { - OtherID = new LLUUID(bytes, i); i += 16; + { + OtherID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(OtherID == null) { Console.WriteLine("Warning: OtherID is null, in " + this.GetType()); } - Array.Copy(OtherID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(OtherID == null) { Console.WriteLine("Warning: OtherID is null, in " + this.GetType()); } + Array.Copy(OtherID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ExBlock --\n"; - output += "OtherID: " + OtherID.ToString() + "\n"; + { + string output = "-- ExBlock --\n"; + output += "OtherID: " + OtherID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.TerminateFriendship - public override PacketType Type { get { return PacketType.TerminateFriendship; } } - /// ExBlock block - public ExBlockBlock ExBlock; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.TerminateFriendship + public override PacketType Type { get { return PacketType.TerminateFriendship; } } + /// ExBlock block + public ExBlockBlock ExBlock; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public TerminateFriendshipPacket() - { - Header = new LowHeader(); - Header.ID = 352; - Header.Reliable = true; - ExBlock = new ExBlockBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 352; + Header.Reliable = true; + ExBlock = new ExBlockBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public TerminateFriendshipPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - ExBlock = new ExBlockBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + ExBlock = new ExBlockBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public TerminateFriendshipPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - ExBlock = new ExBlockBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + ExBlock = new ExBlockBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += ExBlock.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - ExBlock.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += ExBlock.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + ExBlock.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- TerminateFriendship ---\n"; - output += ExBlock.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- TerminateFriendship ---\n"; + output += ExBlock.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// OfferCallingCard packet + + /// OfferCallingCard packet public class OfferCallingCardPacket : Packet - { - /// AgentBlock block + { + /// AgentBlock block public class AgentBlockBlock - { - /// DestID field - public LLUUID DestID; - /// TransactionID field - public LLUUID TransactionID; - - /// Length of this block serialized in bytes + { + /// DestID field + public LLUUID DestID; + /// TransactionID field + public LLUUID TransactionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentBlockBlock() { } + /// Constructor for building the block from a byte array public AgentBlockBlock(byte[] bytes, ref int i) - { + { try - { - DestID = new LLUUID(bytes, i); i += 16; - TransactionID = new LLUUID(bytes, i); i += 16; + { + DestID = new LLUUID(bytes, i); i += 16; + TransactionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(DestID == null) { Console.WriteLine("Warning: DestID is null, in " + this.GetType()); } - Array.Copy(DestID.GetBytes(), 0, bytes, i, 16); i += 16; - if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } - Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(DestID == null) { Console.WriteLine("Warning: DestID is null, in " + this.GetType()); } + Array.Copy(DestID.GetBytes(), 0, bytes, i, 16); i += 16; + if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } + Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentBlock --\n"; - output += "DestID: " + DestID.ToString() + "\n"; - output += "TransactionID: " + TransactionID.ToString() + "\n"; + { + string output = "-- AgentBlock --\n"; + output += "DestID: " + DestID.ToString() + "\n"; + output += "TransactionID: " + TransactionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.OfferCallingCard - public override PacketType Type { get { return PacketType.OfferCallingCard; } } - /// AgentBlock block - public AgentBlockBlock AgentBlock; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.OfferCallingCard + public override PacketType Type { get { return PacketType.OfferCallingCard; } } + /// AgentBlock block + public AgentBlockBlock AgentBlock; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public OfferCallingCardPacket() - { - Header = new LowHeader(); - Header.ID = 353; - Header.Reliable = true; - AgentBlock = new AgentBlockBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 353; + Header.Reliable = true; + AgentBlock = new AgentBlockBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public OfferCallingCardPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentBlock = new AgentBlockBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentBlock = new AgentBlockBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public OfferCallingCardPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentBlock = new AgentBlockBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + AgentBlock = new AgentBlockBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentBlock.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentBlock.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentBlock.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentBlock.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- OfferCallingCard ---\n"; - output += AgentBlock.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- OfferCallingCard ---\n"; + output += AgentBlock.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// AcceptCallingCard packet + + /// AcceptCallingCard packet public class AcceptCallingCardPacket : Packet - { - /// TransactionBlock block + { + /// TransactionBlock block public class TransactionBlockBlock - { - /// TransactionID field - public LLUUID TransactionID; - - /// Length of this block serialized in bytes + { + /// TransactionID field + public LLUUID TransactionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public TransactionBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public TransactionBlockBlock() { } + /// Constructor for building the block from a byte array public TransactionBlockBlock(byte[] bytes, ref int i) - { + { try - { - TransactionID = new LLUUID(bytes, i); i += 16; + { + TransactionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } - Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } + Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- TransactionBlock --\n"; - output += "TransactionID: " + TransactionID.ToString() + "\n"; + { + string output = "-- TransactionBlock --\n"; + output += "TransactionID: " + TransactionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// FolderData block + + /// FolderData block public class FolderDataBlock - { - /// FolderID field - public LLUUID FolderID; - - /// Length of this block serialized in bytes + { + /// FolderID field + public LLUUID FolderID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public FolderDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public FolderDataBlock() { } + /// Constructor for building the block from a byte array public FolderDataBlock(byte[] bytes, ref int i) - { + { try - { - FolderID = new LLUUID(bytes, i); i += 16; + { + FolderID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } - Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } + Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- FolderData --\n"; - output += "FolderID: " + FolderID.ToString() + "\n"; + { + string output = "-- FolderData --\n"; + output += "FolderID: " + FolderID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AcceptCallingCard - public override PacketType Type { get { return PacketType.AcceptCallingCard; } } - /// TransactionBlock block - public TransactionBlockBlock TransactionBlock; - /// AgentData block - public AgentDataBlock AgentData; - /// FolderData block - public FolderDataBlock[] FolderData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AcceptCallingCard + public override PacketType Type { get { return PacketType.AcceptCallingCard; } } + /// TransactionBlock block + public TransactionBlockBlock TransactionBlock; + /// AgentData block + public AgentDataBlock AgentData; + /// FolderData block + public FolderDataBlock[] FolderData; + + /// Default constructor public AcceptCallingCardPacket() - { - Header = new LowHeader(); - Header.ID = 354; - Header.Reliable = true; - TransactionBlock = new TransactionBlockBlock(); - AgentData = new AgentDataBlock(); - FolderData = new FolderDataBlock[0]; + { + Header = new LowHeader(); + Header.ID = 354; + Header.Reliable = true; + TransactionBlock = new TransactionBlockBlock(); + AgentData = new AgentDataBlock(); + FolderData = new FolderDataBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AcceptCallingCardPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - TransactionBlock = new TransactionBlockBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); - int count = (int)bytes[i++]; - FolderData = new FolderDataBlock[count]; - for (int j = 0; j < count; j++) - { FolderData[j] = new FolderDataBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + TransactionBlock = new TransactionBlockBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); + int count = (int)bytes[i++]; + FolderData = new FolderDataBlock[count]; + for (int j = 0; j < count; j++) + { FolderData[j] = new FolderDataBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AcceptCallingCardPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - TransactionBlock = new TransactionBlockBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); - int count = (int)bytes[i++]; - FolderData = new FolderDataBlock[count]; - for (int j = 0; j < count; j++) - { FolderData[j] = new FolderDataBlock(bytes, ref i); } + { + Header = head; + TransactionBlock = new TransactionBlockBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); + int count = (int)bytes[i++]; + FolderData = new FolderDataBlock[count]; + for (int j = 0; j < count; j++) + { FolderData[j] = new FolderDataBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += TransactionBlock.Length; length += AgentData.Length;; - length++; - for (int j = 0; j < FolderData.Length; j++) { length += FolderData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - TransactionBlock.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - bytes[i++] = (byte)FolderData.Length; - for (int j = 0; j < FolderData.Length; j++) { FolderData[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += TransactionBlock.Length; length += AgentData.Length;; + length++; + for (int j = 0; j < FolderData.Length; j++) { length += FolderData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + TransactionBlock.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + bytes[i++] = (byte)FolderData.Length; + for (int j = 0; j < FolderData.Length; j++) { FolderData[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AcceptCallingCard ---\n"; - output += TransactionBlock.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- AcceptCallingCard ---\n"; + output += TransactionBlock.ToString() + "\n"; + output += AgentData.ToString() + "\n"; for (int j = 0; j < FolderData.Length; j++) - { + { output += FolderData[j].ToString() + "\n"; - } + } return output; } - + } - - /// DeclineCallingCard packet + + /// DeclineCallingCard packet public class DeclineCallingCardPacket : Packet - { - /// TransactionBlock block + { + /// TransactionBlock block public class TransactionBlockBlock - { - /// TransactionID field - public LLUUID TransactionID; - - /// Length of this block serialized in bytes + { + /// TransactionID field + public LLUUID TransactionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public TransactionBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public TransactionBlockBlock() { } + /// Constructor for building the block from a byte array public TransactionBlockBlock(byte[] bytes, ref int i) - { + { try - { - TransactionID = new LLUUID(bytes, i); i += 16; + { + TransactionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } - Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } + Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- TransactionBlock --\n"; - output += "TransactionID: " + TransactionID.ToString() + "\n"; + { + string output = "-- TransactionBlock --\n"; + output += "TransactionID: " + TransactionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.DeclineCallingCard - public override PacketType Type { get { return PacketType.DeclineCallingCard; } } - /// TransactionBlock block - public TransactionBlockBlock TransactionBlock; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.DeclineCallingCard + public override PacketType Type { get { return PacketType.DeclineCallingCard; } } + /// TransactionBlock block + public TransactionBlockBlock TransactionBlock; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public DeclineCallingCardPacket() - { - Header = new LowHeader(); - Header.ID = 355; - Header.Reliable = true; - TransactionBlock = new TransactionBlockBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 355; + Header.Reliable = true; + TransactionBlock = new TransactionBlockBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public DeclineCallingCardPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - TransactionBlock = new TransactionBlockBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + TransactionBlock = new TransactionBlockBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public DeclineCallingCardPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - TransactionBlock = new TransactionBlockBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + TransactionBlock = new TransactionBlockBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += TransactionBlock.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - TransactionBlock.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += TransactionBlock.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + TransactionBlock.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- DeclineCallingCard ---\n"; - output += TransactionBlock.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- DeclineCallingCard ---\n"; + output += TransactionBlock.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// RezScript packet + + /// RezScript packet public class RezScriptPacket : Packet - { - /// UpdateBlock block + { + /// UpdateBlock block public class UpdateBlockBlock - { - /// Enabled field - public bool Enabled; - /// ObjectLocalID field - public uint ObjectLocalID; - - /// Length of this block serialized in bytes + { + /// Enabled field + public bool Enabled; + /// ObjectLocalID field + public uint ObjectLocalID; + + /// Length of this block serialized in bytes public int Length { get - { - return 5; + { + return 5; } } - - /// Default constructor - public UpdateBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public UpdateBlockBlock() { } + /// Constructor for building the block from a byte array public UpdateBlockBlock(byte[] bytes, ref int i) - { + { try - { - Enabled = (bytes[i++] != 0) ? (bool)true : (bool)false; - ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + Enabled = (bytes[i++] != 0) ? (bool)true : (bool)false; + ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)((Enabled) ? 1 : 0); - bytes[i++] = (byte)(ObjectLocalID % 256); - bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); + { + bytes[i++] = (byte)((Enabled) ? 1 : 0); + bytes[i++] = (byte)(ObjectLocalID % 256); + bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- UpdateBlock --\n"; - output += "Enabled: " + Enabled.ToString() + "\n"; - output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; + { + string output = "-- UpdateBlock --\n"; + output += "Enabled: " + Enabled.ToString() + "\n"; + output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// InventoryBlock block + + /// InventoryBlock block public class InventoryBlockBlock - { - /// GroupOwned field - public bool GroupOwned; - /// CRC field - public uint CRC; - /// CreationDate field - public int CreationDate; - /// SaleType field - public byte SaleType; - /// BaseMask field - public uint BaseMask; - private byte[] _name; - /// Name field + { + /// GroupOwned field + public bool GroupOwned; + /// CRC field + public uint CRC; + /// CreationDate field + public int CreationDate; + /// SaleType field + public byte SaleType; + /// BaseMask field + public uint BaseMask; + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - /// InvType field - public sbyte InvType; - /// Type field - public sbyte Type; - /// GroupID field - public LLUUID GroupID; - /// SalePrice field - public int SalePrice; - /// OwnerID field - public LLUUID OwnerID; - /// CreatorID field - public LLUUID CreatorID; - /// ItemID field - public LLUUID ItemID; - /// FolderID field - public LLUUID FolderID; - /// EveryoneMask field - public uint EveryoneMask; - private byte[] _description; - /// Description field + } + /// InvType field + public sbyte InvType; + /// Type field + public sbyte Type; + /// GroupID field + public LLUUID GroupID; + /// SalePrice field + public int SalePrice; + /// OwnerID field + public LLUUID OwnerID; + /// CreatorID field + public LLUUID CreatorID; + /// ItemID field + public LLUUID ItemID; + /// FolderID field + public LLUUID FolderID; + /// EveryoneMask field + public uint EveryoneMask; + private byte[] _description; + /// Description field public byte[] Description - { - get { return _description; } + { + get { return _description; } set - { - if (value == null) { _description = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } + { + if (value == null) { _description = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } } - } - /// Flags field - public uint Flags; - /// NextOwnerMask field - public uint NextOwnerMask; - /// TransactionID field - public LLUUID TransactionID; - /// GroupMask field - public uint GroupMask; - /// OwnerMask field - public uint OwnerMask; - - /// Length of this block serialized in bytes + } + /// Flags field + public uint Flags; + /// NextOwnerMask field + public uint NextOwnerMask; + /// TransactionID field + public LLUUID TransactionID; + /// GroupMask field + public uint GroupMask; + /// OwnerMask field + public uint OwnerMask; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 136; - if (Name != null) { length += 1 + Name.Length; } - if (Description != null) { length += 1 + Description.Length; } - return length; + { + int length = 136; + if (Name != null) { length += 1 + Name.Length; } + if (Description != null) { length += 1 + Description.Length; } + return length; } } - - /// Default constructor - public InventoryBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public InventoryBlockBlock() { } + /// Constructor for building the block from a byte array public InventoryBlockBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - GroupOwned = (bytes[i++] != 0) ? (bool)true : (bool)false; - CRC = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - CreationDate = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - SaleType = (byte)bytes[i++]; - BaseMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; - InvType = (sbyte)bytes[i++]; - Type = (sbyte)bytes[i++]; - GroupID = new LLUUID(bytes, i); i += 16; - SalePrice = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - OwnerID = new LLUUID(bytes, i); i += 16; - CreatorID = new LLUUID(bytes, i); i += 16; - ItemID = new LLUUID(bytes, i); i += 16; - FolderID = new LLUUID(bytes, i); i += 16; - EveryoneMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _description = new byte[length]; - Array.Copy(bytes, i, _description, 0, length); i += length; - Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - NextOwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - TransactionID = new LLUUID(bytes, i); i += 16; - GroupMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - OwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + GroupOwned = (bytes[i++] != 0) ? (bool)true : (bool)false; + CRC = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + CreationDate = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + SaleType = (byte)bytes[i++]; + BaseMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; + InvType = (sbyte)bytes[i++]; + Type = (sbyte)bytes[i++]; + GroupID = new LLUUID(bytes, i); i += 16; + SalePrice = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + OwnerID = new LLUUID(bytes, i); i += 16; + CreatorID = new LLUUID(bytes, i); i += 16; + ItemID = new LLUUID(bytes, i); i += 16; + FolderID = new LLUUID(bytes, i); i += 16; + EveryoneMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _description = new byte[length]; + Array.Copy(bytes, i, _description, 0, length); i += length; + Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + NextOwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + TransactionID = new LLUUID(bytes, i); i += 16; + GroupMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + OwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)((GroupOwned) ? 1 : 0); - bytes[i++] = (byte)(CRC % 256); - bytes[i++] = (byte)((CRC >> 8) % 256); - bytes[i++] = (byte)((CRC >> 16) % 256); - bytes[i++] = (byte)((CRC >> 24) % 256); - bytes[i++] = (byte)(CreationDate % 256); - bytes[i++] = (byte)((CreationDate >> 8) % 256); - bytes[i++] = (byte)((CreationDate >> 16) % 256); - bytes[i++] = (byte)((CreationDate >> 24) % 256); - bytes[i++] = SaleType; - bytes[i++] = (byte)(BaseMask % 256); - bytes[i++] = (byte)((BaseMask >> 8) % 256); - bytes[i++] = (byte)((BaseMask >> 16) % 256); - bytes[i++] = (byte)((BaseMask >> 24) % 256); - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; - bytes[i++] = (byte)InvType; - bytes[i++] = (byte)Type; - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(SalePrice % 256); - bytes[i++] = (byte)((SalePrice >> 8) % 256); - bytes[i++] = (byte)((SalePrice >> 16) % 256); - bytes[i++] = (byte)((SalePrice >> 24) % 256); - if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } - Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; - if(CreatorID == null) { Console.WriteLine("Warning: CreatorID is null, in " + this.GetType()); } - Array.Copy(CreatorID.GetBytes(), 0, bytes, i, 16); i += 16; - if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } - Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; - if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } - Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(EveryoneMask % 256); - bytes[i++] = (byte)((EveryoneMask >> 8) % 256); - bytes[i++] = (byte)((EveryoneMask >> 16) % 256); - bytes[i++] = (byte)((EveryoneMask >> 24) % 256); - if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } - bytes[i++] = (byte)Description.Length; - Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; - bytes[i++] = (byte)(Flags % 256); - bytes[i++] = (byte)((Flags >> 8) % 256); - bytes[i++] = (byte)((Flags >> 16) % 256); - bytes[i++] = (byte)((Flags >> 24) % 256); - bytes[i++] = (byte)(NextOwnerMask % 256); - bytes[i++] = (byte)((NextOwnerMask >> 8) % 256); - bytes[i++] = (byte)((NextOwnerMask >> 16) % 256); - bytes[i++] = (byte)((NextOwnerMask >> 24) % 256); - if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } - Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(GroupMask % 256); - bytes[i++] = (byte)((GroupMask >> 8) % 256); - bytes[i++] = (byte)((GroupMask >> 16) % 256); - bytes[i++] = (byte)((GroupMask >> 24) % 256); - bytes[i++] = (byte)(OwnerMask % 256); - bytes[i++] = (byte)((OwnerMask >> 8) % 256); - bytes[i++] = (byte)((OwnerMask >> 16) % 256); - bytes[i++] = (byte)((OwnerMask >> 24) % 256); + { + bytes[i++] = (byte)((GroupOwned) ? 1 : 0); + bytes[i++] = (byte)(CRC % 256); + bytes[i++] = (byte)((CRC >> 8) % 256); + bytes[i++] = (byte)((CRC >> 16) % 256); + bytes[i++] = (byte)((CRC >> 24) % 256); + bytes[i++] = (byte)(CreationDate % 256); + bytes[i++] = (byte)((CreationDate >> 8) % 256); + bytes[i++] = (byte)((CreationDate >> 16) % 256); + bytes[i++] = (byte)((CreationDate >> 24) % 256); + bytes[i++] = SaleType; + bytes[i++] = (byte)(BaseMask % 256); + bytes[i++] = (byte)((BaseMask >> 8) % 256); + bytes[i++] = (byte)((BaseMask >> 16) % 256); + bytes[i++] = (byte)((BaseMask >> 24) % 256); + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + bytes[i++] = (byte)InvType; + bytes[i++] = (byte)Type; + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(SalePrice % 256); + bytes[i++] = (byte)((SalePrice >> 8) % 256); + bytes[i++] = (byte)((SalePrice >> 16) % 256); + bytes[i++] = (byte)((SalePrice >> 24) % 256); + if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } + Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; + if(CreatorID == null) { Console.WriteLine("Warning: CreatorID is null, in " + this.GetType()); } + Array.Copy(CreatorID.GetBytes(), 0, bytes, i, 16); i += 16; + if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } + Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; + if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } + Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(EveryoneMask % 256); + bytes[i++] = (byte)((EveryoneMask >> 8) % 256); + bytes[i++] = (byte)((EveryoneMask >> 16) % 256); + bytes[i++] = (byte)((EveryoneMask >> 24) % 256); + if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } + bytes[i++] = (byte)Description.Length; + Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; + bytes[i++] = (byte)(Flags % 256); + bytes[i++] = (byte)((Flags >> 8) % 256); + bytes[i++] = (byte)((Flags >> 16) % 256); + bytes[i++] = (byte)((Flags >> 24) % 256); + bytes[i++] = (byte)(NextOwnerMask % 256); + bytes[i++] = (byte)((NextOwnerMask >> 8) % 256); + bytes[i++] = (byte)((NextOwnerMask >> 16) % 256); + bytes[i++] = (byte)((NextOwnerMask >> 24) % 256); + if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } + Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(GroupMask % 256); + bytes[i++] = (byte)((GroupMask >> 8) % 256); + bytes[i++] = (byte)((GroupMask >> 16) % 256); + bytes[i++] = (byte)((GroupMask >> 24) % 256); + bytes[i++] = (byte)(OwnerMask % 256); + bytes[i++] = (byte)((OwnerMask >> 8) % 256); + bytes[i++] = (byte)((OwnerMask >> 16) % 256); + bytes[i++] = (byte)((OwnerMask >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- InventoryBlock --\n"; - output += "GroupOwned: " + GroupOwned.ToString() + "\n"; - output += "CRC: " + CRC.ToString() + "\n"; - output += "CreationDate: " + CreationDate.ToString() + "\n"; - output += "SaleType: " + SaleType.ToString() + "\n"; - output += "BaseMask: " + BaseMask.ToString() + "\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; - output += "InvType: " + InvType.ToString() + "\n"; - output += "Type: " + Type.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; - output += "SalePrice: " + SalePrice.ToString() + "\n"; - output += "OwnerID: " + OwnerID.ToString() + "\n"; - output += "CreatorID: " + CreatorID.ToString() + "\n"; - output += "ItemID: " + ItemID.ToString() + "\n"; - output += "FolderID: " + FolderID.ToString() + "\n"; - output += "EveryoneMask: " + EveryoneMask.ToString() + "\n"; - output += Helpers.FieldToString(Description, "Description") + "\n"; - output += "Flags: " + Flags.ToString() + "\n"; - output += "NextOwnerMask: " + NextOwnerMask.ToString() + "\n"; - output += "TransactionID: " + TransactionID.ToString() + "\n"; - output += "GroupMask: " + GroupMask.ToString() + "\n"; - output += "OwnerMask: " + OwnerMask.ToString() + "\n"; + { + string output = "-- InventoryBlock --\n"; + output += "GroupOwned: " + GroupOwned.ToString() + "\n"; + output += "CRC: " + CRC.ToString() + "\n"; + output += "CreationDate: " + CreationDate.ToString() + "\n"; + output += "SaleType: " + SaleType.ToString() + "\n"; + output += "BaseMask: " + BaseMask.ToString() + "\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; + output += "InvType: " + InvType.ToString() + "\n"; + output += "Type: " + Type.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; + output += "SalePrice: " + SalePrice.ToString() + "\n"; + output += "OwnerID: " + OwnerID.ToString() + "\n"; + output += "CreatorID: " + CreatorID.ToString() + "\n"; + output += "ItemID: " + ItemID.ToString() + "\n"; + output += "FolderID: " + FolderID.ToString() + "\n"; + output += "EveryoneMask: " + EveryoneMask.ToString() + "\n"; + output += Helpers.FieldToString(Description, "Description") + "\n"; + output += "Flags: " + Flags.ToString() + "\n"; + output += "NextOwnerMask: " + NextOwnerMask.ToString() + "\n"; + output += "TransactionID: " + TransactionID.ToString() + "\n"; + output += "GroupMask: " + GroupMask.ToString() + "\n"; + output += "OwnerMask: " + OwnerMask.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - /// GroupID field - public LLUUID GroupID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + /// GroupID field + public LLUUID GroupID; + + /// Length of this block serialized in bytes public int Length { get - { - return 48; + { + return 48; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; - GroupID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; + GroupID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.RezScript - public override PacketType Type { get { return PacketType.RezScript; } } - /// UpdateBlock block - public UpdateBlockBlock UpdateBlock; - /// InventoryBlock block - public InventoryBlockBlock InventoryBlock; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.RezScript + public override PacketType Type { get { return PacketType.RezScript; } } + /// UpdateBlock block + public UpdateBlockBlock UpdateBlock; + /// InventoryBlock block + public InventoryBlockBlock InventoryBlock; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public RezScriptPacket() - { - Header = new LowHeader(); - Header.ID = 356; - Header.Reliable = true; - Header.Zerocoded = true; - UpdateBlock = new UpdateBlockBlock(); - InventoryBlock = new InventoryBlockBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 356; + Header.Reliable = true; + Header.Zerocoded = true; + UpdateBlock = new UpdateBlockBlock(); + InventoryBlock = new InventoryBlockBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public RezScriptPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - UpdateBlock = new UpdateBlockBlock(bytes, ref i); - InventoryBlock = new InventoryBlockBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + UpdateBlock = new UpdateBlockBlock(bytes, ref i); + InventoryBlock = new InventoryBlockBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public RezScriptPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - UpdateBlock = new UpdateBlockBlock(bytes, ref i); - InventoryBlock = new InventoryBlockBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + UpdateBlock = new UpdateBlockBlock(bytes, ref i); + InventoryBlock = new InventoryBlockBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += UpdateBlock.Length; length += InventoryBlock.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - UpdateBlock.ToBytes(bytes, ref i); - InventoryBlock.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += UpdateBlock.Length; length += InventoryBlock.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + UpdateBlock.ToBytes(bytes, ref i); + InventoryBlock.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- RezScript ---\n"; - output += UpdateBlock.ToString() + "\n"; - output += InventoryBlock.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- RezScript ---\n"; + output += UpdateBlock.ToString() + "\n"; + output += InventoryBlock.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// CreateInventoryItem packet + + /// CreateInventoryItem packet public class CreateInventoryItemPacket : Packet - { - /// InventoryBlock block + { + /// InventoryBlock block public class InventoryBlockBlock - { - /// CallbackID field - public uint CallbackID; - /// WearableType field - public byte WearableType; - private byte[] _name; - /// Name field + { + /// CallbackID field + public uint CallbackID; + /// WearableType field + public byte WearableType; + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - /// InvType field - public sbyte InvType; - /// Type field - public sbyte Type; - /// FolderID field - public LLUUID FolderID; - private byte[] _description; - /// Description field + } + /// InvType field + public sbyte InvType; + /// Type field + public sbyte Type; + /// FolderID field + public LLUUID FolderID; + private byte[] _description; + /// Description field public byte[] Description - { - get { return _description; } + { + get { return _description; } set - { - if (value == null) { _description = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } + { + if (value == null) { _description = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } } - } - /// NextOwnerMask field - public uint NextOwnerMask; - /// TransactionID field - public LLUUID TransactionID; - - /// Length of this block serialized in bytes + } + /// NextOwnerMask field + public uint NextOwnerMask; + /// TransactionID field + public LLUUID TransactionID; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 43; - if (Name != null) { length += 1 + Name.Length; } - if (Description != null) { length += 1 + Description.Length; } - return length; + { + int length = 43; + if (Name != null) { length += 1 + Name.Length; } + if (Description != null) { length += 1 + Description.Length; } + return length; } } - - /// Default constructor - public InventoryBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public InventoryBlockBlock() { } + /// Constructor for building the block from a byte array public InventoryBlockBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - CallbackID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - WearableType = (byte)bytes[i++]; - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; - InvType = (sbyte)bytes[i++]; - Type = (sbyte)bytes[i++]; - FolderID = new LLUUID(bytes, i); i += 16; - length = (ushort)bytes[i++]; - _description = new byte[length]; - Array.Copy(bytes, i, _description, 0, length); i += length; - NextOwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - TransactionID = new LLUUID(bytes, i); i += 16; + { + CallbackID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + WearableType = (byte)bytes[i++]; + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; + InvType = (sbyte)bytes[i++]; + Type = (sbyte)bytes[i++]; + FolderID = new LLUUID(bytes, i); i += 16; + length = (ushort)bytes[i++]; + _description = new byte[length]; + Array.Copy(bytes, i, _description, 0, length); i += length; + NextOwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + TransactionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(CallbackID % 256); - bytes[i++] = (byte)((CallbackID >> 8) % 256); - bytes[i++] = (byte)((CallbackID >> 16) % 256); - bytes[i++] = (byte)((CallbackID >> 24) % 256); - bytes[i++] = WearableType; - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; - bytes[i++] = (byte)InvType; - bytes[i++] = (byte)Type; - if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } - Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; - if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } - bytes[i++] = (byte)Description.Length; - Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; - bytes[i++] = (byte)(NextOwnerMask % 256); - bytes[i++] = (byte)((NextOwnerMask >> 8) % 256); - bytes[i++] = (byte)((NextOwnerMask >> 16) % 256); - bytes[i++] = (byte)((NextOwnerMask >> 24) % 256); - if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } - Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + bytes[i++] = (byte)(CallbackID % 256); + bytes[i++] = (byte)((CallbackID >> 8) % 256); + bytes[i++] = (byte)((CallbackID >> 16) % 256); + bytes[i++] = (byte)((CallbackID >> 24) % 256); + bytes[i++] = WearableType; + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + bytes[i++] = (byte)InvType; + bytes[i++] = (byte)Type; + if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } + Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; + if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } + bytes[i++] = (byte)Description.Length; + Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; + bytes[i++] = (byte)(NextOwnerMask % 256); + bytes[i++] = (byte)((NextOwnerMask >> 8) % 256); + bytes[i++] = (byte)((NextOwnerMask >> 16) % 256); + bytes[i++] = (byte)((NextOwnerMask >> 24) % 256); + if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } + Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- InventoryBlock --\n"; - output += "CallbackID: " + CallbackID.ToString() + "\n"; - output += "WearableType: " + WearableType.ToString() + "\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; - output += "InvType: " + InvType.ToString() + "\n"; - output += "Type: " + Type.ToString() + "\n"; - output += "FolderID: " + FolderID.ToString() + "\n"; - output += Helpers.FieldToString(Description, "Description") + "\n"; - output += "NextOwnerMask: " + NextOwnerMask.ToString() + "\n"; - output += "TransactionID: " + TransactionID.ToString() + "\n"; + { + string output = "-- InventoryBlock --\n"; + output += "CallbackID: " + CallbackID.ToString() + "\n"; + output += "WearableType: " + WearableType.ToString() + "\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; + output += "InvType: " + InvType.ToString() + "\n"; + output += "Type: " + Type.ToString() + "\n"; + output += "FolderID: " + FolderID.ToString() + "\n"; + output += Helpers.FieldToString(Description, "Description") + "\n"; + output += "NextOwnerMask: " + NextOwnerMask.ToString() + "\n"; + output += "TransactionID: " + TransactionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.CreateInventoryItem - public override PacketType Type { get { return PacketType.CreateInventoryItem; } } - /// InventoryBlock block - public InventoryBlockBlock InventoryBlock; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.CreateInventoryItem + public override PacketType Type { get { return PacketType.CreateInventoryItem; } } + /// InventoryBlock block + public InventoryBlockBlock InventoryBlock; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public CreateInventoryItemPacket() - { - Header = new LowHeader(); - Header.ID = 357; - Header.Reliable = true; - Header.Zerocoded = true; - InventoryBlock = new InventoryBlockBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 357; + Header.Reliable = true; + Header.Zerocoded = true; + InventoryBlock = new InventoryBlockBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public CreateInventoryItemPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - InventoryBlock = new InventoryBlockBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + InventoryBlock = new InventoryBlockBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public CreateInventoryItemPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - InventoryBlock = new InventoryBlockBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + InventoryBlock = new InventoryBlockBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += InventoryBlock.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - InventoryBlock.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += InventoryBlock.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + InventoryBlock.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- CreateInventoryItem ---\n"; - output += InventoryBlock.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- CreateInventoryItem ---\n"; + output += InventoryBlock.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// CreateLandmarkForEvent packet + + /// CreateLandmarkForEvent packet public class CreateLandmarkForEventPacket : Packet - { - /// InventoryBlock block + { + /// InventoryBlock block public class InventoryBlockBlock - { - private byte[] _name; - /// Name field + { + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - /// FolderID field - public LLUUID FolderID; - - /// Length of this block serialized in bytes + } + /// FolderID field + public LLUUID FolderID; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 16; - if (Name != null) { length += 1 + Name.Length; } - return length; + { + int length = 16; + if (Name != null) { length += 1 + Name.Length; } + return length; } } - - /// Default constructor - public InventoryBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public InventoryBlockBlock() { } + /// Constructor for building the block from a byte array public InventoryBlockBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; - FolderID = new LLUUID(bytes, i); i += 16; + { + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; + FolderID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; - if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } - Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } + Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- InventoryBlock --\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; - output += "FolderID: " + FolderID.ToString() + "\n"; + { + string output = "-- InventoryBlock --\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; + output += "FolderID: " + FolderID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// EventData block + + /// EventData block public class EventDataBlock - { - /// EventID field - public uint EventID; - - /// Length of this block serialized in bytes + { + /// EventID field + public uint EventID; + + /// Length of this block serialized in bytes public int Length { get - { - return 4; + { + return 4; } } - - /// Default constructor - public EventDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public EventDataBlock() { } + /// Constructor for building the block from a byte array public EventDataBlock(byte[] bytes, ref int i) - { + { try - { - EventID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + EventID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(EventID % 256); - bytes[i++] = (byte)((EventID >> 8) % 256); - bytes[i++] = (byte)((EventID >> 16) % 256); - bytes[i++] = (byte)((EventID >> 24) % 256); + { + bytes[i++] = (byte)(EventID % 256); + bytes[i++] = (byte)((EventID >> 8) % 256); + bytes[i++] = (byte)((EventID >> 16) % 256); + bytes[i++] = (byte)((EventID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- EventData --\n"; - output += "EventID: " + EventID.ToString() + "\n"; + { + string output = "-- EventData --\n"; + output += "EventID: " + EventID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.CreateLandmarkForEvent - public override PacketType Type { get { return PacketType.CreateLandmarkForEvent; } } - /// InventoryBlock block - public InventoryBlockBlock InventoryBlock; - /// EventData block - public EventDataBlock EventData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.CreateLandmarkForEvent + public override PacketType Type { get { return PacketType.CreateLandmarkForEvent; } } + /// InventoryBlock block + public InventoryBlockBlock InventoryBlock; + /// EventData block + public EventDataBlock EventData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public CreateLandmarkForEventPacket() - { - Header = new LowHeader(); - Header.ID = 358; - Header.Reliable = true; - Header.Zerocoded = true; - InventoryBlock = new InventoryBlockBlock(); - EventData = new EventDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 358; + Header.Reliable = true; + Header.Zerocoded = true; + InventoryBlock = new InventoryBlockBlock(); + EventData = new EventDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public CreateLandmarkForEventPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - InventoryBlock = new InventoryBlockBlock(bytes, ref i); - EventData = new EventDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + InventoryBlock = new InventoryBlockBlock(bytes, ref i); + EventData = new EventDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public CreateLandmarkForEventPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - InventoryBlock = new InventoryBlockBlock(bytes, ref i); - EventData = new EventDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + InventoryBlock = new InventoryBlockBlock(bytes, ref i); + EventData = new EventDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += InventoryBlock.Length; length += EventData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - InventoryBlock.ToBytes(bytes, ref i); - EventData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += InventoryBlock.Length; length += EventData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + InventoryBlock.ToBytes(bytes, ref i); + EventData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- CreateLandmarkForEvent ---\n"; - output += InventoryBlock.ToString() + "\n"; - output += EventData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- CreateLandmarkForEvent ---\n"; + output += InventoryBlock.ToString() + "\n"; + output += EventData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// EventLocationRequest packet + + /// EventLocationRequest packet public class EventLocationRequestPacket : Packet - { - /// EventData block + { + /// EventData block public class EventDataBlock - { - /// EventID field - public uint EventID; - - /// Length of this block serialized in bytes + { + /// EventID field + public uint EventID; + + /// Length of this block serialized in bytes public int Length { get - { - return 4; + { + return 4; } } - - /// Default constructor - public EventDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public EventDataBlock() { } + /// Constructor for building the block from a byte array public EventDataBlock(byte[] bytes, ref int i) - { + { try - { - EventID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + EventID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(EventID % 256); - bytes[i++] = (byte)((EventID >> 8) % 256); - bytes[i++] = (byte)((EventID >> 16) % 256); - bytes[i++] = (byte)((EventID >> 24) % 256); + { + bytes[i++] = (byte)(EventID % 256); + bytes[i++] = (byte)((EventID >> 8) % 256); + bytes[i++] = (byte)((EventID >> 16) % 256); + bytes[i++] = (byte)((EventID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- EventData --\n"; - output += "EventID: " + EventID.ToString() + "\n"; + { + string output = "-- EventData --\n"; + output += "EventID: " + EventID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// QueryData block + + /// QueryData block public class QueryDataBlock - { - /// QueryID field - public LLUUID QueryID; - - /// Length of this block serialized in bytes + { + /// QueryID field + public LLUUID QueryID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public QueryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public QueryDataBlock() { } + /// Constructor for building the block from a byte array public QueryDataBlock(byte[] bytes, ref int i) - { + { try - { - QueryID = new LLUUID(bytes, i); i += 16; + { + QueryID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } - Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } + Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- QueryData --\n"; - output += "QueryID: " + QueryID.ToString() + "\n"; + { + string output = "-- QueryData --\n"; + output += "QueryID: " + QueryID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.EventLocationRequest - public override PacketType Type { get { return PacketType.EventLocationRequest; } } - /// EventData block - public EventDataBlock EventData; - /// QueryData block - public QueryDataBlock QueryData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.EventLocationRequest + public override PacketType Type { get { return PacketType.EventLocationRequest; } } + /// EventData block + public EventDataBlock EventData; + /// QueryData block + public QueryDataBlock QueryData; + + /// Default constructor public EventLocationRequestPacket() - { - Header = new LowHeader(); - Header.ID = 359; - Header.Reliable = true; - Header.Zerocoded = true; - EventData = new EventDataBlock(); - QueryData = new QueryDataBlock(); + { + Header = new LowHeader(); + Header.ID = 359; + Header.Reliable = true; + Header.Zerocoded = true; + EventData = new EventDataBlock(); + QueryData = new QueryDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public EventLocationRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - EventData = new EventDataBlock(bytes, ref i); - QueryData = new QueryDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + EventData = new EventDataBlock(bytes, ref i); + QueryData = new QueryDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public EventLocationRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - EventData = new EventDataBlock(bytes, ref i); - QueryData = new QueryDataBlock(bytes, ref i); + { + Header = head; + EventData = new EventDataBlock(bytes, ref i); + QueryData = new QueryDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += EventData.Length; length += QueryData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - EventData.ToBytes(bytes, ref i); - QueryData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += EventData.Length; length += QueryData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + EventData.ToBytes(bytes, ref i); + QueryData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- EventLocationRequest ---\n"; - output += EventData.ToString() + "\n"; - output += QueryData.ToString() + "\n"; + { + string output = "--- EventLocationRequest ---\n"; + output += EventData.ToString() + "\n"; + output += QueryData.ToString() + "\n"; return output; } - + } - - /// EventLocationReply packet + + /// EventLocationReply packet public class EventLocationReplyPacket : Packet - { - /// EventData block + { + /// EventData block public class EventDataBlock - { - /// RegionID field - public LLUUID RegionID; - /// Success field - public bool Success; - /// RegionPos field - public LLVector3 RegionPos; - - /// Length of this block serialized in bytes + { + /// RegionID field + public LLUUID RegionID; + /// Success field + public bool Success; + /// RegionPos field + public LLVector3 RegionPos; + + /// Length of this block serialized in bytes public int Length { get - { - return 29; + { + return 29; } } - - /// Default constructor - public EventDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public EventDataBlock() { } + /// Constructor for building the block from a byte array public EventDataBlock(byte[] bytes, ref int i) - { + { try - { - RegionID = new LLUUID(bytes, i); i += 16; - Success = (bytes[i++] != 0) ? (bool)true : (bool)false; - RegionPos = new LLVector3(bytes, i); i += 12; + { + RegionID = new LLUUID(bytes, i); i += 16; + Success = (bytes[i++] != 0) ? (bool)true : (bool)false; + RegionPos = new LLVector3(bytes, i); i += 12; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(RegionID == null) { Console.WriteLine("Warning: RegionID is null, in " + this.GetType()); } - Array.Copy(RegionID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((Success) ? 1 : 0); - if(RegionPos == null) { Console.WriteLine("Warning: RegionPos is null, in " + this.GetType()); } - Array.Copy(RegionPos.GetBytes(), 0, bytes, i, 12); i += 12; + { + if(RegionID == null) { Console.WriteLine("Warning: RegionID is null, in " + this.GetType()); } + Array.Copy(RegionID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((Success) ? 1 : 0); + if(RegionPos == null) { Console.WriteLine("Warning: RegionPos is null, in " + this.GetType()); } + Array.Copy(RegionPos.GetBytes(), 0, bytes, i, 12); i += 12; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- EventData --\n"; - output += "RegionID: " + RegionID.ToString() + "\n"; - output += "Success: " + Success.ToString() + "\n"; - output += "RegionPos: " + RegionPos.ToString() + "\n"; + { + string output = "-- EventData --\n"; + output += "RegionID: " + RegionID.ToString() + "\n"; + output += "Success: " + Success.ToString() + "\n"; + output += "RegionPos: " + RegionPos.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// QueryData block + + /// QueryData block public class QueryDataBlock - { - /// QueryID field - public LLUUID QueryID; - - /// Length of this block serialized in bytes + { + /// QueryID field + public LLUUID QueryID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public QueryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public QueryDataBlock() { } + /// Constructor for building the block from a byte array public QueryDataBlock(byte[] bytes, ref int i) - { + { try - { - QueryID = new LLUUID(bytes, i); i += 16; + { + QueryID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } - Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(QueryID == null) { Console.WriteLine("Warning: QueryID is null, in " + this.GetType()); } + Array.Copy(QueryID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- QueryData --\n"; - output += "QueryID: " + QueryID.ToString() + "\n"; + { + string output = "-- QueryData --\n"; + output += "QueryID: " + QueryID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.EventLocationReply - public override PacketType Type { get { return PacketType.EventLocationReply; } } - /// EventData block - public EventDataBlock EventData; - /// QueryData block - public QueryDataBlock QueryData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.EventLocationReply + public override PacketType Type { get { return PacketType.EventLocationReply; } } + /// EventData block + public EventDataBlock EventData; + /// QueryData block + public QueryDataBlock QueryData; + + /// Default constructor public EventLocationReplyPacket() - { - Header = new LowHeader(); - Header.ID = 360; - Header.Reliable = true; - Header.Zerocoded = true; - EventData = new EventDataBlock(); - QueryData = new QueryDataBlock(); + { + Header = new LowHeader(); + Header.ID = 360; + Header.Reliable = true; + Header.Zerocoded = true; + EventData = new EventDataBlock(); + QueryData = new QueryDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public EventLocationReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - EventData = new EventDataBlock(bytes, ref i); - QueryData = new QueryDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + EventData = new EventDataBlock(bytes, ref i); + QueryData = new QueryDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public EventLocationReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - EventData = new EventDataBlock(bytes, ref i); - QueryData = new QueryDataBlock(bytes, ref i); + { + Header = head; + EventData = new EventDataBlock(bytes, ref i); + QueryData = new QueryDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += EventData.Length; length += QueryData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - EventData.ToBytes(bytes, ref i); - QueryData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += EventData.Length; length += QueryData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + EventData.ToBytes(bytes, ref i); + QueryData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- EventLocationReply ---\n"; - output += EventData.ToString() + "\n"; - output += QueryData.ToString() + "\n"; + { + string output = "--- EventLocationReply ---\n"; + output += EventData.ToString() + "\n"; + output += QueryData.ToString() + "\n"; return output; } - + } - - /// RegionHandleRequest packet + + /// RegionHandleRequest packet public class RegionHandleRequestPacket : Packet - { - /// RequestBlock block + { + /// RequestBlock block public class RequestBlockBlock - { - /// RegionID field - public LLUUID RegionID; - - /// Length of this block serialized in bytes + { + /// RegionID field + public LLUUID RegionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public RequestBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public RequestBlockBlock() { } + /// Constructor for building the block from a byte array public RequestBlockBlock(byte[] bytes, ref int i) - { + { try - { - RegionID = new LLUUID(bytes, i); i += 16; + { + RegionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(RegionID == null) { Console.WriteLine("Warning: RegionID is null, in " + this.GetType()); } - Array.Copy(RegionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(RegionID == null) { Console.WriteLine("Warning: RegionID is null, in " + this.GetType()); } + Array.Copy(RegionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- RequestBlock --\n"; - output += "RegionID: " + RegionID.ToString() + "\n"; + { + string output = "-- RequestBlock --\n"; + output += "RegionID: " + RegionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.RegionHandleRequest - public override PacketType Type { get { return PacketType.RegionHandleRequest; } } - /// RequestBlock block - public RequestBlockBlock RequestBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.RegionHandleRequest + public override PacketType Type { get { return PacketType.RegionHandleRequest; } } + /// RequestBlock block + public RequestBlockBlock RequestBlock; + + /// Default constructor public RegionHandleRequestPacket() - { - Header = new LowHeader(); - Header.ID = 361; - Header.Reliable = true; - RequestBlock = new RequestBlockBlock(); + { + Header = new LowHeader(); + Header.ID = 361; + Header.Reliable = true; + RequestBlock = new RequestBlockBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public RegionHandleRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - RequestBlock = new RequestBlockBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + RequestBlock = new RequestBlockBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public RegionHandleRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - RequestBlock = new RequestBlockBlock(bytes, ref i); + { + Header = head; + RequestBlock = new RequestBlockBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += RequestBlock.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - RequestBlock.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += RequestBlock.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + RequestBlock.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- RegionHandleRequest ---\n"; - output += RequestBlock.ToString() + "\n"; + { + string output = "--- RegionHandleRequest ---\n"; + output += RequestBlock.ToString() + "\n"; return output; } - + } - - /// RegionIDAndHandleReply packet + + /// RegionIDAndHandleReply packet public class RegionIDAndHandleReplyPacket : Packet - { - /// ReplyBlock block + { + /// ReplyBlock block public class ReplyBlockBlock - { - /// RegionID field - public LLUUID RegionID; - /// RegionHandle field - public ulong RegionHandle; - - /// Length of this block serialized in bytes + { + /// RegionID field + public LLUUID RegionID; + /// RegionHandle field + public ulong RegionHandle; + + /// Length of this block serialized in bytes public int Length { get - { - return 24; + { + return 24; } } - - /// Default constructor - public ReplyBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ReplyBlockBlock() { } + /// Constructor for building the block from a byte array public ReplyBlockBlock(byte[] bytes, ref int i) - { + { try - { - RegionID = new LLUUID(bytes, i); i += 16; - RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + { + RegionID = new LLUUID(bytes, i); i += 16; + RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(RegionID == null) { Console.WriteLine("Warning: RegionID is null, in " + this.GetType()); } - Array.Copy(RegionID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(RegionHandle % 256); - bytes[i++] = (byte)((RegionHandle >> 8) % 256); - bytes[i++] = (byte)((RegionHandle >> 16) % 256); - bytes[i++] = (byte)((RegionHandle >> 24) % 256); - bytes[i++] = (byte)((RegionHandle >> 32) % 256); - bytes[i++] = (byte)((RegionHandle >> 40) % 256); - bytes[i++] = (byte)((RegionHandle >> 48) % 256); - bytes[i++] = (byte)((RegionHandle >> 56) % 256); + { + if(RegionID == null) { Console.WriteLine("Warning: RegionID is null, in " + this.GetType()); } + Array.Copy(RegionID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(RegionHandle % 256); + bytes[i++] = (byte)((RegionHandle >> 8) % 256); + bytes[i++] = (byte)((RegionHandle >> 16) % 256); + bytes[i++] = (byte)((RegionHandle >> 24) % 256); + bytes[i++] = (byte)((RegionHandle >> 32) % 256); + bytes[i++] = (byte)((RegionHandle >> 40) % 256); + bytes[i++] = (byte)((RegionHandle >> 48) % 256); + bytes[i++] = (byte)((RegionHandle >> 56) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ReplyBlock --\n"; - output += "RegionID: " + RegionID.ToString() + "\n"; - output += "RegionHandle: " + RegionHandle.ToString() + "\n"; + { + string output = "-- ReplyBlock --\n"; + output += "RegionID: " + RegionID.ToString() + "\n"; + output += "RegionHandle: " + RegionHandle.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.RegionIDAndHandleReply - public override PacketType Type { get { return PacketType.RegionIDAndHandleReply; } } - /// ReplyBlock block - public ReplyBlockBlock ReplyBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.RegionIDAndHandleReply + public override PacketType Type { get { return PacketType.RegionIDAndHandleReply; } } + /// ReplyBlock block + public ReplyBlockBlock ReplyBlock; + + /// Default constructor public RegionIDAndHandleReplyPacket() - { - Header = new LowHeader(); - Header.ID = 362; - Header.Reliable = true; - ReplyBlock = new ReplyBlockBlock(); + { + Header = new LowHeader(); + Header.ID = 362; + Header.Reliable = true; + ReplyBlock = new ReplyBlockBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public RegionIDAndHandleReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - ReplyBlock = new ReplyBlockBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + ReplyBlock = new ReplyBlockBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public RegionIDAndHandleReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - ReplyBlock = new ReplyBlockBlock(bytes, ref i); + { + Header = head; + ReplyBlock = new ReplyBlockBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += ReplyBlock.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - ReplyBlock.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += ReplyBlock.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + ReplyBlock.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- RegionIDAndHandleReply ---\n"; - output += ReplyBlock.ToString() + "\n"; + { + string output = "--- RegionIDAndHandleReply ---\n"; + output += ReplyBlock.ToString() + "\n"; return output; } - + } - - /// MoneyTransferRequest packet + + /// MoneyTransferRequest packet public class MoneyTransferRequestPacket : Packet - { - /// MoneyData block + { + /// MoneyData block public class MoneyDataBlock - { - /// AggregatePermInventory field - public byte AggregatePermInventory; - /// AggregatePermNextOwner field - public byte AggregatePermNextOwner; - /// DestID field - public LLUUID DestID; - /// Amount field - public int Amount; - private byte[] _description; - /// Description field + { + /// AggregatePermInventory field + public byte AggregatePermInventory; + /// AggregatePermNextOwner field + public byte AggregatePermNextOwner; + /// DestID field + public LLUUID DestID; + /// Amount field + public int Amount; + private byte[] _description; + /// Description field public byte[] Description - { - get { return _description; } + { + get { return _description; } set - { - if (value == null) { _description = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } + { + if (value == null) { _description = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } } - } - /// Flags field - public byte Flags; - /// SourceID field - public LLUUID SourceID; - /// TransactionType field - public int TransactionType; - - /// Length of this block serialized in bytes + } + /// Flags field + public byte Flags; + /// SourceID field + public LLUUID SourceID; + /// TransactionType field + public int TransactionType; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 43; - if (Description != null) { length += 1 + Description.Length; } - return length; + { + int length = 43; + if (Description != null) { length += 1 + Description.Length; } + return length; } } - - /// Default constructor - public MoneyDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public MoneyDataBlock() { } + /// Constructor for building the block from a byte array public MoneyDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - AggregatePermInventory = (byte)bytes[i++]; - AggregatePermNextOwner = (byte)bytes[i++]; - DestID = new LLUUID(bytes, i); i += 16; - Amount = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _description = new byte[length]; - Array.Copy(bytes, i, _description, 0, length); i += length; - Flags = (byte)bytes[i++]; - SourceID = new LLUUID(bytes, i); i += 16; - TransactionType = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + AggregatePermInventory = (byte)bytes[i++]; + AggregatePermNextOwner = (byte)bytes[i++]; + DestID = new LLUUID(bytes, i); i += 16; + Amount = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _description = new byte[length]; + Array.Copy(bytes, i, _description, 0, length); i += length; + Flags = (byte)bytes[i++]; + SourceID = new LLUUID(bytes, i); i += 16; + TransactionType = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = AggregatePermInventory; - bytes[i++] = AggregatePermNextOwner; - if(DestID == null) { Console.WriteLine("Warning: DestID is null, in " + this.GetType()); } - Array.Copy(DestID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(Amount % 256); - bytes[i++] = (byte)((Amount >> 8) % 256); - bytes[i++] = (byte)((Amount >> 16) % 256); - bytes[i++] = (byte)((Amount >> 24) % 256); - if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } - bytes[i++] = (byte)Description.Length; - Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; - bytes[i++] = Flags; - if(SourceID == null) { Console.WriteLine("Warning: SourceID is null, in " + this.GetType()); } - Array.Copy(SourceID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(TransactionType % 256); - bytes[i++] = (byte)((TransactionType >> 8) % 256); - bytes[i++] = (byte)((TransactionType >> 16) % 256); - bytes[i++] = (byte)((TransactionType >> 24) % 256); + { + bytes[i++] = AggregatePermInventory; + bytes[i++] = AggregatePermNextOwner; + if(DestID == null) { Console.WriteLine("Warning: DestID is null, in " + this.GetType()); } + Array.Copy(DestID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(Amount % 256); + bytes[i++] = (byte)((Amount >> 8) % 256); + bytes[i++] = (byte)((Amount >> 16) % 256); + bytes[i++] = (byte)((Amount >> 24) % 256); + if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } + bytes[i++] = (byte)Description.Length; + Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; + bytes[i++] = Flags; + if(SourceID == null) { Console.WriteLine("Warning: SourceID is null, in " + this.GetType()); } + Array.Copy(SourceID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(TransactionType % 256); + bytes[i++] = (byte)((TransactionType >> 8) % 256); + bytes[i++] = (byte)((TransactionType >> 16) % 256); + bytes[i++] = (byte)((TransactionType >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- MoneyData --\n"; - output += "AggregatePermInventory: " + AggregatePermInventory.ToString() + "\n"; - output += "AggregatePermNextOwner: " + AggregatePermNextOwner.ToString() + "\n"; - output += "DestID: " + DestID.ToString() + "\n"; - output += "Amount: " + Amount.ToString() + "\n"; - output += Helpers.FieldToString(Description, "Description") + "\n"; - output += "Flags: " + Flags.ToString() + "\n"; - output += "SourceID: " + SourceID.ToString() + "\n"; - output += "TransactionType: " + TransactionType.ToString() + "\n"; + { + string output = "-- MoneyData --\n"; + output += "AggregatePermInventory: " + AggregatePermInventory.ToString() + "\n"; + output += "AggregatePermNextOwner: " + AggregatePermNextOwner.ToString() + "\n"; + output += "DestID: " + DestID.ToString() + "\n"; + output += "Amount: " + Amount.ToString() + "\n"; + output += Helpers.FieldToString(Description, "Description") + "\n"; + output += "Flags: " + Flags.ToString() + "\n"; + output += "SourceID: " + SourceID.ToString() + "\n"; + output += "TransactionType: " + TransactionType.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.MoneyTransferRequest - public override PacketType Type { get { return PacketType.MoneyTransferRequest; } } - /// MoneyData block - public MoneyDataBlock MoneyData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.MoneyTransferRequest + public override PacketType Type { get { return PacketType.MoneyTransferRequest; } } + /// MoneyData block + public MoneyDataBlock MoneyData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public MoneyTransferRequestPacket() - { - Header = new LowHeader(); - Header.ID = 363; - Header.Reliable = true; - Header.Zerocoded = true; - MoneyData = new MoneyDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 363; + Header.Reliable = true; + Header.Zerocoded = true; + MoneyData = new MoneyDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public MoneyTransferRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - MoneyData = new MoneyDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + MoneyData = new MoneyDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public MoneyTransferRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - MoneyData = new MoneyDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + MoneyData = new MoneyDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += MoneyData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - MoneyData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += MoneyData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + MoneyData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- MoneyTransferRequest ---\n"; - output += MoneyData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- MoneyTransferRequest ---\n"; + output += MoneyData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// MoneyTransferBackend packet + + /// MoneyTransferBackend packet public class MoneyTransferBackendPacket : Packet - { - /// MoneyData block + { + /// MoneyData block public class MoneyDataBlock - { - /// AggregatePermInventory field - public byte AggregatePermInventory; - /// AggregatePermNextOwner field - public byte AggregatePermNextOwner; - /// DestID field - public LLUUID DestID; - /// Amount field - public int Amount; - private byte[] _description; - /// Description field + { + /// AggregatePermInventory field + public byte AggregatePermInventory; + /// AggregatePermNextOwner field + public byte AggregatePermNextOwner; + /// DestID field + public LLUUID DestID; + /// Amount field + public int Amount; + private byte[] _description; + /// Description field public byte[] Description - { - get { return _description; } + { + get { return _description; } set - { - if (value == null) { _description = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } + { + if (value == null) { _description = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } } - } - /// Flags field - public byte Flags; - /// SourceID field - public LLUUID SourceID; - /// TransactionID field - public LLUUID TransactionID; - /// TransactionTime field - public uint TransactionTime; - /// TransactionType field - public int TransactionType; - - /// Length of this block serialized in bytes + } + /// Flags field + public byte Flags; + /// SourceID field + public LLUUID SourceID; + /// TransactionID field + public LLUUID TransactionID; + /// TransactionTime field + public uint TransactionTime; + /// TransactionType field + public int TransactionType; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 63; - if (Description != null) { length += 1 + Description.Length; } - return length; + { + int length = 63; + if (Description != null) { length += 1 + Description.Length; } + return length; } } - - /// Default constructor - public MoneyDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public MoneyDataBlock() { } + /// Constructor for building the block from a byte array public MoneyDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - AggregatePermInventory = (byte)bytes[i++]; - AggregatePermNextOwner = (byte)bytes[i++]; - DestID = new LLUUID(bytes, i); i += 16; - Amount = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _description = new byte[length]; - Array.Copy(bytes, i, _description, 0, length); i += length; - Flags = (byte)bytes[i++]; - SourceID = new LLUUID(bytes, i); i += 16; - TransactionID = new LLUUID(bytes, i); i += 16; - TransactionTime = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - TransactionType = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + AggregatePermInventory = (byte)bytes[i++]; + AggregatePermNextOwner = (byte)bytes[i++]; + DestID = new LLUUID(bytes, i); i += 16; + Amount = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _description = new byte[length]; + Array.Copy(bytes, i, _description, 0, length); i += length; + Flags = (byte)bytes[i++]; + SourceID = new LLUUID(bytes, i); i += 16; + TransactionID = new LLUUID(bytes, i); i += 16; + TransactionTime = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + TransactionType = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = AggregatePermInventory; - bytes[i++] = AggregatePermNextOwner; - if(DestID == null) { Console.WriteLine("Warning: DestID is null, in " + this.GetType()); } - Array.Copy(DestID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(Amount % 256); - bytes[i++] = (byte)((Amount >> 8) % 256); - bytes[i++] = (byte)((Amount >> 16) % 256); - bytes[i++] = (byte)((Amount >> 24) % 256); - if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } - bytes[i++] = (byte)Description.Length; - Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; - bytes[i++] = Flags; - if(SourceID == null) { Console.WriteLine("Warning: SourceID is null, in " + this.GetType()); } - Array.Copy(SourceID.GetBytes(), 0, bytes, i, 16); i += 16; - if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } - Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(TransactionTime % 256); - bytes[i++] = (byte)((TransactionTime >> 8) % 256); - bytes[i++] = (byte)((TransactionTime >> 16) % 256); - bytes[i++] = (byte)((TransactionTime >> 24) % 256); - bytes[i++] = (byte)(TransactionType % 256); - bytes[i++] = (byte)((TransactionType >> 8) % 256); - bytes[i++] = (byte)((TransactionType >> 16) % 256); - bytes[i++] = (byte)((TransactionType >> 24) % 256); + { + bytes[i++] = AggregatePermInventory; + bytes[i++] = AggregatePermNextOwner; + if(DestID == null) { Console.WriteLine("Warning: DestID is null, in " + this.GetType()); } + Array.Copy(DestID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(Amount % 256); + bytes[i++] = (byte)((Amount >> 8) % 256); + bytes[i++] = (byte)((Amount >> 16) % 256); + bytes[i++] = (byte)((Amount >> 24) % 256); + if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } + bytes[i++] = (byte)Description.Length; + Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; + bytes[i++] = Flags; + if(SourceID == null) { Console.WriteLine("Warning: SourceID is null, in " + this.GetType()); } + Array.Copy(SourceID.GetBytes(), 0, bytes, i, 16); i += 16; + if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } + Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(TransactionTime % 256); + bytes[i++] = (byte)((TransactionTime >> 8) % 256); + bytes[i++] = (byte)((TransactionTime >> 16) % 256); + bytes[i++] = (byte)((TransactionTime >> 24) % 256); + bytes[i++] = (byte)(TransactionType % 256); + bytes[i++] = (byte)((TransactionType >> 8) % 256); + bytes[i++] = (byte)((TransactionType >> 16) % 256); + bytes[i++] = (byte)((TransactionType >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- MoneyData --\n"; - output += "AggregatePermInventory: " + AggregatePermInventory.ToString() + "\n"; - output += "AggregatePermNextOwner: " + AggregatePermNextOwner.ToString() + "\n"; - output += "DestID: " + DestID.ToString() + "\n"; - output += "Amount: " + Amount.ToString() + "\n"; - output += Helpers.FieldToString(Description, "Description") + "\n"; - output += "Flags: " + Flags.ToString() + "\n"; - output += "SourceID: " + SourceID.ToString() + "\n"; - output += "TransactionID: " + TransactionID.ToString() + "\n"; - output += "TransactionTime: " + TransactionTime.ToString() + "\n"; - output += "TransactionType: " + TransactionType.ToString() + "\n"; + { + string output = "-- MoneyData --\n"; + output += "AggregatePermInventory: " + AggregatePermInventory.ToString() + "\n"; + output += "AggregatePermNextOwner: " + AggregatePermNextOwner.ToString() + "\n"; + output += "DestID: " + DestID.ToString() + "\n"; + output += "Amount: " + Amount.ToString() + "\n"; + output += Helpers.FieldToString(Description, "Description") + "\n"; + output += "Flags: " + Flags.ToString() + "\n"; + output += "SourceID: " + SourceID.ToString() + "\n"; + output += "TransactionID: " + TransactionID.ToString() + "\n"; + output += "TransactionTime: " + TransactionTime.ToString() + "\n"; + output += "TransactionType: " + TransactionType.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.MoneyTransferBackend - public override PacketType Type { get { return PacketType.MoneyTransferBackend; } } - /// MoneyData block - public MoneyDataBlock MoneyData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.MoneyTransferBackend + public override PacketType Type { get { return PacketType.MoneyTransferBackend; } } + /// MoneyData block + public MoneyDataBlock MoneyData; + + /// Default constructor public MoneyTransferBackendPacket() - { - Header = new LowHeader(); - Header.ID = 364; - Header.Reliable = true; - Header.Zerocoded = true; - MoneyData = new MoneyDataBlock(); + { + Header = new LowHeader(); + Header.ID = 364; + Header.Reliable = true; + Header.Zerocoded = true; + MoneyData = new MoneyDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public MoneyTransferBackendPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - MoneyData = new MoneyDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + MoneyData = new MoneyDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public MoneyTransferBackendPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - MoneyData = new MoneyDataBlock(bytes, ref i); + { + Header = head; + MoneyData = new MoneyDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += MoneyData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - MoneyData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += MoneyData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + MoneyData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- MoneyTransferBackend ---\n"; - output += MoneyData.ToString() + "\n"; + { + string output = "--- MoneyTransferBackend ---\n"; + output += MoneyData.ToString() + "\n"; return output; } - + } - - /// BulkMoneyTransfer packet + + /// BulkMoneyTransfer packet public class BulkMoneyTransferPacket : Packet - { - /// MoneyData block + { + /// MoneyData block public class MoneyDataBlock - { - /// DestID field - public LLUUID DestID; - /// Amount field - public int Amount; - private byte[] _description; - /// Description field + { + /// DestID field + public LLUUID DestID; + /// Amount field + public int Amount; + private byte[] _description; + /// Description field public byte[] Description - { - get { return _description; } + { + get { return _description; } set - { - if (value == null) { _description = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } + { + if (value == null) { _description = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } } - } - /// Flags field - public byte Flags; - /// TransactionID field - public LLUUID TransactionID; - /// TransactionType field - public int TransactionType; - - /// Length of this block serialized in bytes + } + /// Flags field + public byte Flags; + /// TransactionID field + public LLUUID TransactionID; + /// TransactionType field + public int TransactionType; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 41; - if (Description != null) { length += 1 + Description.Length; } - return length; + { + int length = 41; + if (Description != null) { length += 1 + Description.Length; } + return length; } } - - /// Default constructor - public MoneyDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public MoneyDataBlock() { } + /// Constructor for building the block from a byte array public MoneyDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - DestID = new LLUUID(bytes, i); i += 16; - Amount = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _description = new byte[length]; - Array.Copy(bytes, i, _description, 0, length); i += length; - Flags = (byte)bytes[i++]; - TransactionID = new LLUUID(bytes, i); i += 16; - TransactionType = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + DestID = new LLUUID(bytes, i); i += 16; + Amount = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _description = new byte[length]; + Array.Copy(bytes, i, _description, 0, length); i += length; + Flags = (byte)bytes[i++]; + TransactionID = new LLUUID(bytes, i); i += 16; + TransactionType = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(DestID == null) { Console.WriteLine("Warning: DestID is null, in " + this.GetType()); } - Array.Copy(DestID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(Amount % 256); - bytes[i++] = (byte)((Amount >> 8) % 256); - bytes[i++] = (byte)((Amount >> 16) % 256); - bytes[i++] = (byte)((Amount >> 24) % 256); - if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } - bytes[i++] = (byte)Description.Length; - Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; - bytes[i++] = Flags; - if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } - Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(TransactionType % 256); - bytes[i++] = (byte)((TransactionType >> 8) % 256); - bytes[i++] = (byte)((TransactionType >> 16) % 256); - bytes[i++] = (byte)((TransactionType >> 24) % 256); + { + if(DestID == null) { Console.WriteLine("Warning: DestID is null, in " + this.GetType()); } + Array.Copy(DestID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(Amount % 256); + bytes[i++] = (byte)((Amount >> 8) % 256); + bytes[i++] = (byte)((Amount >> 16) % 256); + bytes[i++] = (byte)((Amount >> 24) % 256); + if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } + bytes[i++] = (byte)Description.Length; + Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; + bytes[i++] = Flags; + if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } + Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(TransactionType % 256); + bytes[i++] = (byte)((TransactionType >> 8) % 256); + bytes[i++] = (byte)((TransactionType >> 16) % 256); + bytes[i++] = (byte)((TransactionType >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- MoneyData --\n"; - output += "DestID: " + DestID.ToString() + "\n"; - output += "Amount: " + Amount.ToString() + "\n"; - output += Helpers.FieldToString(Description, "Description") + "\n"; - output += "Flags: " + Flags.ToString() + "\n"; - output += "TransactionID: " + TransactionID.ToString() + "\n"; - output += "TransactionType: " + TransactionType.ToString() + "\n"; + { + string output = "-- MoneyData --\n"; + output += "DestID: " + DestID.ToString() + "\n"; + output += "Amount: " + Amount.ToString() + "\n"; + output += Helpers.FieldToString(Description, "Description") + "\n"; + output += "Flags: " + Flags.ToString() + "\n"; + output += "TransactionID: " + TransactionID.ToString() + "\n"; + output += "TransactionType: " + TransactionType.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// RegionX field - public uint RegionX; - /// RegionY field - public uint RegionY; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// RegionX field + public uint RegionX; + /// RegionY field + public uint RegionY; + + /// Length of this block serialized in bytes public int Length { get - { - return 24; + { + return 24; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - RegionX = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - RegionY = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + AgentID = new LLUUID(bytes, i); i += 16; + RegionX = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + RegionY = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(RegionX % 256); - bytes[i++] = (byte)((RegionX >> 8) % 256); - bytes[i++] = (byte)((RegionX >> 16) % 256); - bytes[i++] = (byte)((RegionX >> 24) % 256); - bytes[i++] = (byte)(RegionY % 256); - bytes[i++] = (byte)((RegionY >> 8) % 256); - bytes[i++] = (byte)((RegionY >> 16) % 256); - bytes[i++] = (byte)((RegionY >> 24) % 256); + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(RegionX % 256); + bytes[i++] = (byte)((RegionX >> 8) % 256); + bytes[i++] = (byte)((RegionX >> 16) % 256); + bytes[i++] = (byte)((RegionX >> 24) % 256); + bytes[i++] = (byte)(RegionY % 256); + bytes[i++] = (byte)((RegionY >> 8) % 256); + bytes[i++] = (byte)((RegionY >> 16) % 256); + bytes[i++] = (byte)((RegionY >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "RegionX: " + RegionX.ToString() + "\n"; - output += "RegionY: " + RegionY.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "RegionX: " + RegionX.ToString() + "\n"; + output += "RegionY: " + RegionY.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.BulkMoneyTransfer - public override PacketType Type { get { return PacketType.BulkMoneyTransfer; } } - /// MoneyData block - public MoneyDataBlock[] MoneyData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.BulkMoneyTransfer + public override PacketType Type { get { return PacketType.BulkMoneyTransfer; } } + /// MoneyData block + public MoneyDataBlock[] MoneyData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public BulkMoneyTransferPacket() - { - Header = new LowHeader(); - Header.ID = 365; - Header.Reliable = true; - Header.Zerocoded = true; - MoneyData = new MoneyDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 365; + Header.Reliable = true; + Header.Zerocoded = true; + MoneyData = new MoneyDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public BulkMoneyTransferPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - MoneyData = new MoneyDataBlock[count]; - for (int j = 0; j < count; j++) - { MoneyData[j] = new MoneyDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + MoneyData = new MoneyDataBlock[count]; + for (int j = 0; j < count; j++) + { MoneyData[j] = new MoneyDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public BulkMoneyTransferPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - MoneyData = new MoneyDataBlock[count]; - for (int j = 0; j < count; j++) - { MoneyData[j] = new MoneyDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + MoneyData = new MoneyDataBlock[count]; + for (int j = 0; j < count; j++) + { MoneyData[j] = new MoneyDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < MoneyData.Length; j++) { length += MoneyData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)MoneyData.Length; - for (int j = 0; j < MoneyData.Length; j++) { MoneyData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < MoneyData.Length; j++) { length += MoneyData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)MoneyData.Length; + for (int j = 0; j < MoneyData.Length; j++) { MoneyData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- BulkMoneyTransfer ---\n"; + { + string output = "--- BulkMoneyTransfer ---\n"; for (int j = 0; j < MoneyData.Length; j++) - { + { output += MoneyData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// AdjustBalance packet + + /// AdjustBalance packet public class AdjustBalancePacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// Delta field - public int Delta; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// Delta field + public int Delta; + + /// Length of this block serialized in bytes public int Length { get - { - return 20; + { + return 20; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - Delta = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + AgentID = new LLUUID(bytes, i); i += 16; + Delta = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(Delta % 256); - bytes[i++] = (byte)((Delta >> 8) % 256); - bytes[i++] = (byte)((Delta >> 16) % 256); - bytes[i++] = (byte)((Delta >> 24) % 256); + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(Delta % 256); + bytes[i++] = (byte)((Delta >> 8) % 256); + bytes[i++] = (byte)((Delta >> 16) % 256); + bytes[i++] = (byte)((Delta >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "Delta: " + Delta.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "Delta: " + Delta.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AdjustBalance - public override PacketType Type { get { return PacketType.AdjustBalance; } } - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AdjustBalance + public override PacketType Type { get { return PacketType.AdjustBalance; } } + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public AdjustBalancePacket() - { - Header = new LowHeader(); - Header.ID = 366; - Header.Reliable = true; - Header.Zerocoded = true; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 366; + Header.Reliable = true; + Header.Zerocoded = true; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AdjustBalancePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AdjustBalancePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AdjustBalance ---\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- AdjustBalance ---\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// MoneyBalanceRequest packet + + /// MoneyBalanceRequest packet public class MoneyBalanceRequestPacket : Packet - { - /// MoneyData block + { + /// MoneyData block public class MoneyDataBlock - { - /// TransactionID field - public LLUUID TransactionID; - - /// Length of this block serialized in bytes + { + /// TransactionID field + public LLUUID TransactionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public MoneyDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public MoneyDataBlock() { } + /// Constructor for building the block from a byte array public MoneyDataBlock(byte[] bytes, ref int i) - { + { try - { - TransactionID = new LLUUID(bytes, i); i += 16; + { + TransactionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } - Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } + Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- MoneyData --\n"; - output += "TransactionID: " + TransactionID.ToString() + "\n"; + { + string output = "-- MoneyData --\n"; + output += "TransactionID: " + TransactionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.MoneyBalanceRequest - public override PacketType Type { get { return PacketType.MoneyBalanceRequest; } } - /// MoneyData block - public MoneyDataBlock MoneyData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.MoneyBalanceRequest + public override PacketType Type { get { return PacketType.MoneyBalanceRequest; } } + /// MoneyData block + public MoneyDataBlock MoneyData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public MoneyBalanceRequestPacket() - { - Header = new LowHeader(); - Header.ID = 367; - Header.Reliable = true; - Header.Zerocoded = true; - MoneyData = new MoneyDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 367; + Header.Reliable = true; + Header.Zerocoded = true; + MoneyData = new MoneyDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public MoneyBalanceRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - MoneyData = new MoneyDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + MoneyData = new MoneyDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public MoneyBalanceRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - MoneyData = new MoneyDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + MoneyData = new MoneyDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += MoneyData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - MoneyData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += MoneyData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + MoneyData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- MoneyBalanceRequest ---\n"; - output += MoneyData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- MoneyBalanceRequest ---\n"; + output += MoneyData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// MoneyBalanceReply packet + + /// MoneyBalanceReply packet public class MoneyBalanceReplyPacket : Packet - { - /// MoneyData block + { + /// MoneyData block public class MoneyDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// MoneyBalance field - public int MoneyBalance; - /// SquareMetersCredit field - public int SquareMetersCredit; - private byte[] _description; - /// Description field + { + /// AgentID field + public LLUUID AgentID; + /// MoneyBalance field + public int MoneyBalance; + /// SquareMetersCredit field + public int SquareMetersCredit; + private byte[] _description; + /// Description field public byte[] Description - { - get { return _description; } + { + get { return _description; } set - { - if (value == null) { _description = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } + { + if (value == null) { _description = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } } - } - /// SquareMetersCommitted field - public int SquareMetersCommitted; - /// TransactionID field - public LLUUID TransactionID; - /// TransactionSuccess field - public bool TransactionSuccess; - - /// Length of this block serialized in bytes + } + /// SquareMetersCommitted field + public int SquareMetersCommitted; + /// TransactionID field + public LLUUID TransactionID; + /// TransactionSuccess field + public bool TransactionSuccess; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 45; - if (Description != null) { length += 1 + Description.Length; } - return length; + { + int length = 45; + if (Description != null) { length += 1 + Description.Length; } + return length; } } - - /// Default constructor - public MoneyDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public MoneyDataBlock() { } + /// Constructor for building the block from a byte array public MoneyDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - AgentID = new LLUUID(bytes, i); i += 16; - MoneyBalance = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - SquareMetersCredit = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _description = new byte[length]; - Array.Copy(bytes, i, _description, 0, length); i += length; - SquareMetersCommitted = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - TransactionID = new LLUUID(bytes, i); i += 16; - TransactionSuccess = (bytes[i++] != 0) ? (bool)true : (bool)false; + { + AgentID = new LLUUID(bytes, i); i += 16; + MoneyBalance = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + SquareMetersCredit = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _description = new byte[length]; + Array.Copy(bytes, i, _description, 0, length); i += length; + SquareMetersCommitted = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + TransactionID = new LLUUID(bytes, i); i += 16; + TransactionSuccess = (bytes[i++] != 0) ? (bool)true : (bool)false; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(MoneyBalance % 256); - bytes[i++] = (byte)((MoneyBalance >> 8) % 256); - bytes[i++] = (byte)((MoneyBalance >> 16) % 256); - bytes[i++] = (byte)((MoneyBalance >> 24) % 256); - bytes[i++] = (byte)(SquareMetersCredit % 256); - bytes[i++] = (byte)((SquareMetersCredit >> 8) % 256); - bytes[i++] = (byte)((SquareMetersCredit >> 16) % 256); - bytes[i++] = (byte)((SquareMetersCredit >> 24) % 256); - if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } - bytes[i++] = (byte)Description.Length; - Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; - bytes[i++] = (byte)(SquareMetersCommitted % 256); - bytes[i++] = (byte)((SquareMetersCommitted >> 8) % 256); - bytes[i++] = (byte)((SquareMetersCommitted >> 16) % 256); - bytes[i++] = (byte)((SquareMetersCommitted >> 24) % 256); - if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } - Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((TransactionSuccess) ? 1 : 0); + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(MoneyBalance % 256); + bytes[i++] = (byte)((MoneyBalance >> 8) % 256); + bytes[i++] = (byte)((MoneyBalance >> 16) % 256); + bytes[i++] = (byte)((MoneyBalance >> 24) % 256); + bytes[i++] = (byte)(SquareMetersCredit % 256); + bytes[i++] = (byte)((SquareMetersCredit >> 8) % 256); + bytes[i++] = (byte)((SquareMetersCredit >> 16) % 256); + bytes[i++] = (byte)((SquareMetersCredit >> 24) % 256); + if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } + bytes[i++] = (byte)Description.Length; + Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; + bytes[i++] = (byte)(SquareMetersCommitted % 256); + bytes[i++] = (byte)((SquareMetersCommitted >> 8) % 256); + bytes[i++] = (byte)((SquareMetersCommitted >> 16) % 256); + bytes[i++] = (byte)((SquareMetersCommitted >> 24) % 256); + if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } + Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((TransactionSuccess) ? 1 : 0); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- MoneyData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "MoneyBalance: " + MoneyBalance.ToString() + "\n"; - output += "SquareMetersCredit: " + SquareMetersCredit.ToString() + "\n"; - output += Helpers.FieldToString(Description, "Description") + "\n"; - output += "SquareMetersCommitted: " + SquareMetersCommitted.ToString() + "\n"; - output += "TransactionID: " + TransactionID.ToString() + "\n"; - output += "TransactionSuccess: " + TransactionSuccess.ToString() + "\n"; + { + string output = "-- MoneyData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "MoneyBalance: " + MoneyBalance.ToString() + "\n"; + output += "SquareMetersCredit: " + SquareMetersCredit.ToString() + "\n"; + output += Helpers.FieldToString(Description, "Description") + "\n"; + output += "SquareMetersCommitted: " + SquareMetersCommitted.ToString() + "\n"; + output += "TransactionID: " + TransactionID.ToString() + "\n"; + output += "TransactionSuccess: " + TransactionSuccess.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.MoneyBalanceReply - public override PacketType Type { get { return PacketType.MoneyBalanceReply; } } - /// MoneyData block - public MoneyDataBlock MoneyData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.MoneyBalanceReply + public override PacketType Type { get { return PacketType.MoneyBalanceReply; } } + /// MoneyData block + public MoneyDataBlock MoneyData; + + /// Default constructor public MoneyBalanceReplyPacket() - { - Header = new LowHeader(); - Header.ID = 368; - Header.Reliable = true; - Header.Zerocoded = true; - MoneyData = new MoneyDataBlock(); + { + Header = new LowHeader(); + Header.ID = 368; + Header.Reliable = true; + Header.Zerocoded = true; + MoneyData = new MoneyDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public MoneyBalanceReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - MoneyData = new MoneyDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + MoneyData = new MoneyDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public MoneyBalanceReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - MoneyData = new MoneyDataBlock(bytes, ref i); + { + Header = head; + MoneyData = new MoneyDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += MoneyData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - MoneyData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += MoneyData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + MoneyData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- MoneyBalanceReply ---\n"; - output += MoneyData.ToString() + "\n"; + { + string output = "--- MoneyBalanceReply ---\n"; + output += MoneyData.ToString() + "\n"; return output; } - + } - - /// RoutedMoneyBalanceReply packet + + /// RoutedMoneyBalanceReply packet public class RoutedMoneyBalanceReplyPacket : Packet - { - /// TargetBlock block + { + /// TargetBlock block public class TargetBlockBlock - { - /// TargetIP field - public uint TargetIP; - /// TargetPort field - public ushort TargetPort; - - /// Length of this block serialized in bytes + { + /// TargetIP field + public uint TargetIP; + /// TargetPort field + public ushort TargetPort; + + /// Length of this block serialized in bytes public int Length { get - { - return 6; + { + return 6; } } - - /// Default constructor - public TargetBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public TargetBlockBlock() { } + /// Constructor for building the block from a byte array public TargetBlockBlock(byte[] bytes, ref int i) - { + { try - { - TargetIP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - TargetPort = (ushort)((bytes[i++] << 8) + bytes[i++]); + { + TargetIP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + TargetPort = (ushort)((bytes[i++] << 8) + bytes[i++]); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(TargetIP % 256); - bytes[i++] = (byte)((TargetIP >> 8) % 256); - bytes[i++] = (byte)((TargetIP >> 16) % 256); - bytes[i++] = (byte)((TargetIP >> 24) % 256); - bytes[i++] = (byte)((TargetPort >> 8) % 256); - bytes[i++] = (byte)(TargetPort % 256); + { + bytes[i++] = (byte)(TargetIP % 256); + bytes[i++] = (byte)((TargetIP >> 8) % 256); + bytes[i++] = (byte)((TargetIP >> 16) % 256); + bytes[i++] = (byte)((TargetIP >> 24) % 256); + bytes[i++] = (byte)((TargetPort >> 8) % 256); + bytes[i++] = (byte)(TargetPort % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- TargetBlock --\n"; - output += "TargetIP: " + TargetIP.ToString() + "\n"; - output += "TargetPort: " + TargetPort.ToString() + "\n"; + { + string output = "-- TargetBlock --\n"; + output += "TargetIP: " + TargetIP.ToString() + "\n"; + output += "TargetPort: " + TargetPort.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// MoneyData block + + /// MoneyData block public class MoneyDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// MoneyBalance field - public int MoneyBalance; - /// SquareMetersCredit field - public int SquareMetersCredit; - private byte[] _description; - /// Description field + { + /// AgentID field + public LLUUID AgentID; + /// MoneyBalance field + public int MoneyBalance; + /// SquareMetersCredit field + public int SquareMetersCredit; + private byte[] _description; + /// Description field public byte[] Description - { - get { return _description; } + { + get { return _description; } set - { - if (value == null) { _description = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } + { + if (value == null) { _description = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } } - } - /// SquareMetersCommitted field - public int SquareMetersCommitted; - /// TransactionID field - public LLUUID TransactionID; - /// TransactionSuccess field - public bool TransactionSuccess; - - /// Length of this block serialized in bytes + } + /// SquareMetersCommitted field + public int SquareMetersCommitted; + /// TransactionID field + public LLUUID TransactionID; + /// TransactionSuccess field + public bool TransactionSuccess; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 45; - if (Description != null) { length += 1 + Description.Length; } - return length; + { + int length = 45; + if (Description != null) { length += 1 + Description.Length; } + return length; } } - - /// Default constructor - public MoneyDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public MoneyDataBlock() { } + /// Constructor for building the block from a byte array public MoneyDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - AgentID = new LLUUID(bytes, i); i += 16; - MoneyBalance = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - SquareMetersCredit = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _description = new byte[length]; - Array.Copy(bytes, i, _description, 0, length); i += length; - SquareMetersCommitted = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - TransactionID = new LLUUID(bytes, i); i += 16; - TransactionSuccess = (bytes[i++] != 0) ? (bool)true : (bool)false; + { + AgentID = new LLUUID(bytes, i); i += 16; + MoneyBalance = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + SquareMetersCredit = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _description = new byte[length]; + Array.Copy(bytes, i, _description, 0, length); i += length; + SquareMetersCommitted = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + TransactionID = new LLUUID(bytes, i); i += 16; + TransactionSuccess = (bytes[i++] != 0) ? (bool)true : (bool)false; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(MoneyBalance % 256); - bytes[i++] = (byte)((MoneyBalance >> 8) % 256); - bytes[i++] = (byte)((MoneyBalance >> 16) % 256); - bytes[i++] = (byte)((MoneyBalance >> 24) % 256); - bytes[i++] = (byte)(SquareMetersCredit % 256); - bytes[i++] = (byte)((SquareMetersCredit >> 8) % 256); - bytes[i++] = (byte)((SquareMetersCredit >> 16) % 256); - bytes[i++] = (byte)((SquareMetersCredit >> 24) % 256); - if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } - bytes[i++] = (byte)Description.Length; - Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; - bytes[i++] = (byte)(SquareMetersCommitted % 256); - bytes[i++] = (byte)((SquareMetersCommitted >> 8) % 256); - bytes[i++] = (byte)((SquareMetersCommitted >> 16) % 256); - bytes[i++] = (byte)((SquareMetersCommitted >> 24) % 256); - if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } - Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((TransactionSuccess) ? 1 : 0); + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(MoneyBalance % 256); + bytes[i++] = (byte)((MoneyBalance >> 8) % 256); + bytes[i++] = (byte)((MoneyBalance >> 16) % 256); + bytes[i++] = (byte)((MoneyBalance >> 24) % 256); + bytes[i++] = (byte)(SquareMetersCredit % 256); + bytes[i++] = (byte)((SquareMetersCredit >> 8) % 256); + bytes[i++] = (byte)((SquareMetersCredit >> 16) % 256); + bytes[i++] = (byte)((SquareMetersCredit >> 24) % 256); + if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } + bytes[i++] = (byte)Description.Length; + Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; + bytes[i++] = (byte)(SquareMetersCommitted % 256); + bytes[i++] = (byte)((SquareMetersCommitted >> 8) % 256); + bytes[i++] = (byte)((SquareMetersCommitted >> 16) % 256); + bytes[i++] = (byte)((SquareMetersCommitted >> 24) % 256); + if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } + Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((TransactionSuccess) ? 1 : 0); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- MoneyData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "MoneyBalance: " + MoneyBalance.ToString() + "\n"; - output += "SquareMetersCredit: " + SquareMetersCredit.ToString() + "\n"; - output += Helpers.FieldToString(Description, "Description") + "\n"; - output += "SquareMetersCommitted: " + SquareMetersCommitted.ToString() + "\n"; - output += "TransactionID: " + TransactionID.ToString() + "\n"; - output += "TransactionSuccess: " + TransactionSuccess.ToString() + "\n"; + { + string output = "-- MoneyData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "MoneyBalance: " + MoneyBalance.ToString() + "\n"; + output += "SquareMetersCredit: " + SquareMetersCredit.ToString() + "\n"; + output += Helpers.FieldToString(Description, "Description") + "\n"; + output += "SquareMetersCommitted: " + SquareMetersCommitted.ToString() + "\n"; + output += "TransactionID: " + TransactionID.ToString() + "\n"; + output += "TransactionSuccess: " + TransactionSuccess.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.RoutedMoneyBalanceReply - public override PacketType Type { get { return PacketType.RoutedMoneyBalanceReply; } } - /// TargetBlock block - public TargetBlockBlock TargetBlock; - /// MoneyData block - public MoneyDataBlock MoneyData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.RoutedMoneyBalanceReply + public override PacketType Type { get { return PacketType.RoutedMoneyBalanceReply; } } + /// TargetBlock block + public TargetBlockBlock TargetBlock; + /// MoneyData block + public MoneyDataBlock MoneyData; + + /// Default constructor public RoutedMoneyBalanceReplyPacket() - { - Header = new LowHeader(); - Header.ID = 369; - Header.Reliable = true; - Header.Zerocoded = true; - TargetBlock = new TargetBlockBlock(); - MoneyData = new MoneyDataBlock(); + { + Header = new LowHeader(); + Header.ID = 369; + Header.Reliable = true; + Header.Zerocoded = true; + TargetBlock = new TargetBlockBlock(); + MoneyData = new MoneyDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public RoutedMoneyBalanceReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - TargetBlock = new TargetBlockBlock(bytes, ref i); - MoneyData = new MoneyDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + TargetBlock = new TargetBlockBlock(bytes, ref i); + MoneyData = new MoneyDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public RoutedMoneyBalanceReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - TargetBlock = new TargetBlockBlock(bytes, ref i); - MoneyData = new MoneyDataBlock(bytes, ref i); + { + Header = head; + TargetBlock = new TargetBlockBlock(bytes, ref i); + MoneyData = new MoneyDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += TargetBlock.Length; length += MoneyData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - TargetBlock.ToBytes(bytes, ref i); - MoneyData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += TargetBlock.Length; length += MoneyData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + TargetBlock.ToBytes(bytes, ref i); + MoneyData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- RoutedMoneyBalanceReply ---\n"; - output += TargetBlock.ToString() + "\n"; - output += MoneyData.ToString() + "\n"; + { + string output = "--- RoutedMoneyBalanceReply ---\n"; + output += TargetBlock.ToString() + "\n"; + output += MoneyData.ToString() + "\n"; return output; } - + } - - /// MoneyHistoryRequest packet + + /// MoneyHistoryRequest packet public class MoneyHistoryRequestPacket : Packet - { - /// MoneyData block + { + /// MoneyData block public class MoneyDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// StartPeriod field - public int StartPeriod; - /// EndPeriod field - public int EndPeriod; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// StartPeriod field + public int StartPeriod; + /// EndPeriod field + public int EndPeriod; + + /// Length of this block serialized in bytes public int Length { get - { - return 24; + { + return 24; } } - - /// Default constructor - public MoneyDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public MoneyDataBlock() { } + /// Constructor for building the block from a byte array public MoneyDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - StartPeriod = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - EndPeriod = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + AgentID = new LLUUID(bytes, i); i += 16; + StartPeriod = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + EndPeriod = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(StartPeriod % 256); - bytes[i++] = (byte)((StartPeriod >> 8) % 256); - bytes[i++] = (byte)((StartPeriod >> 16) % 256); - bytes[i++] = (byte)((StartPeriod >> 24) % 256); - bytes[i++] = (byte)(EndPeriod % 256); - bytes[i++] = (byte)((EndPeriod >> 8) % 256); - bytes[i++] = (byte)((EndPeriod >> 16) % 256); - bytes[i++] = (byte)((EndPeriod >> 24) % 256); + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(StartPeriod % 256); + bytes[i++] = (byte)((StartPeriod >> 8) % 256); + bytes[i++] = (byte)((StartPeriod >> 16) % 256); + bytes[i++] = (byte)((StartPeriod >> 24) % 256); + bytes[i++] = (byte)(EndPeriod % 256); + bytes[i++] = (byte)((EndPeriod >> 8) % 256); + bytes[i++] = (byte)((EndPeriod >> 16) % 256); + bytes[i++] = (byte)((EndPeriod >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- MoneyData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "StartPeriod: " + StartPeriod.ToString() + "\n"; - output += "EndPeriod: " + EndPeriod.ToString() + "\n"; + { + string output = "-- MoneyData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "StartPeriod: " + StartPeriod.ToString() + "\n"; + output += "EndPeriod: " + EndPeriod.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.MoneyHistoryRequest - public override PacketType Type { get { return PacketType.MoneyHistoryRequest; } } - /// MoneyData block - public MoneyDataBlock MoneyData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.MoneyHistoryRequest + public override PacketType Type { get { return PacketType.MoneyHistoryRequest; } } + /// MoneyData block + public MoneyDataBlock MoneyData; + + /// Default constructor public MoneyHistoryRequestPacket() - { - Header = new LowHeader(); - Header.ID = 370; - Header.Reliable = true; - MoneyData = new MoneyDataBlock(); + { + Header = new LowHeader(); + Header.ID = 370; + Header.Reliable = true; + MoneyData = new MoneyDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public MoneyHistoryRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - MoneyData = new MoneyDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + MoneyData = new MoneyDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public MoneyHistoryRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - MoneyData = new MoneyDataBlock(bytes, ref i); + { + Header = head; + MoneyData = new MoneyDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += MoneyData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - MoneyData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += MoneyData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + MoneyData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- MoneyHistoryRequest ---\n"; - output += MoneyData.ToString() + "\n"; + { + string output = "--- MoneyHistoryRequest ---\n"; + output += MoneyData.ToString() + "\n"; return output; } - + } - - /// MoneyHistoryReply packet + + /// MoneyHistoryReply packet public class MoneyHistoryReplyPacket : Packet - { - /// MoneyData block + { + /// MoneyData block public class MoneyDataBlock - { - /// Balance field - public int Balance; - /// TaxEstimate field - public int TaxEstimate; - private byte[] _startdate; - /// StartDate field + { + /// Balance field + public int Balance; + /// TaxEstimate field + public int TaxEstimate; + private byte[] _startdate; + /// StartDate field public byte[] StartDate - { - get { return _startdate; } + { + get { return _startdate; } set - { - if (value == null) { _startdate = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _startdate = new byte[value.Length]; Array.Copy(value, _startdate, value.Length); } + { + if (value == null) { _startdate = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _startdate = new byte[value.Length]; Array.Copy(value, _startdate, value.Length); } } - } - /// StartPeriod field - public int StartPeriod; - /// StipendEstimate field - public int StipendEstimate; - /// EndPeriod field - public int EndPeriod; - /// BonusEstimate field - public int BonusEstimate; - - /// Length of this block serialized in bytes + } + /// StartPeriod field + public int StartPeriod; + /// StipendEstimate field + public int StipendEstimate; + /// EndPeriod field + public int EndPeriod; + /// BonusEstimate field + public int BonusEstimate; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 24; - if (StartDate != null) { length += 1 + StartDate.Length; } - return length; + { + int length = 24; + if (StartDate != null) { length += 1 + StartDate.Length; } + return length; } } - - /// Default constructor - public MoneyDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public MoneyDataBlock() { } + /// Constructor for building the block from a byte array public MoneyDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - Balance = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - TaxEstimate = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _startdate = new byte[length]; - Array.Copy(bytes, i, _startdate, 0, length); i += length; - StartPeriod = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - StipendEstimate = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - EndPeriod = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - BonusEstimate = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + Balance = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + TaxEstimate = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _startdate = new byte[length]; + Array.Copy(bytes, i, _startdate, 0, length); i += length; + StartPeriod = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + StipendEstimate = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + EndPeriod = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + BonusEstimate = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(Balance % 256); - bytes[i++] = (byte)((Balance >> 8) % 256); - bytes[i++] = (byte)((Balance >> 16) % 256); - bytes[i++] = (byte)((Balance >> 24) % 256); - bytes[i++] = (byte)(TaxEstimate % 256); - bytes[i++] = (byte)((TaxEstimate >> 8) % 256); - bytes[i++] = (byte)((TaxEstimate >> 16) % 256); - bytes[i++] = (byte)((TaxEstimate >> 24) % 256); - if(StartDate == null) { Console.WriteLine("Warning: StartDate is null, in " + this.GetType()); } - bytes[i++] = (byte)StartDate.Length; - Array.Copy(StartDate, 0, bytes, i, StartDate.Length); i += StartDate.Length; - bytes[i++] = (byte)(StartPeriod % 256); - bytes[i++] = (byte)((StartPeriod >> 8) % 256); - bytes[i++] = (byte)((StartPeriod >> 16) % 256); - bytes[i++] = (byte)((StartPeriod >> 24) % 256); - bytes[i++] = (byte)(StipendEstimate % 256); - bytes[i++] = (byte)((StipendEstimate >> 8) % 256); - bytes[i++] = (byte)((StipendEstimate >> 16) % 256); - bytes[i++] = (byte)((StipendEstimate >> 24) % 256); - bytes[i++] = (byte)(EndPeriod % 256); - bytes[i++] = (byte)((EndPeriod >> 8) % 256); - bytes[i++] = (byte)((EndPeriod >> 16) % 256); - bytes[i++] = (byte)((EndPeriod >> 24) % 256); - bytes[i++] = (byte)(BonusEstimate % 256); - bytes[i++] = (byte)((BonusEstimate >> 8) % 256); - bytes[i++] = (byte)((BonusEstimate >> 16) % 256); - bytes[i++] = (byte)((BonusEstimate >> 24) % 256); + { + bytes[i++] = (byte)(Balance % 256); + bytes[i++] = (byte)((Balance >> 8) % 256); + bytes[i++] = (byte)((Balance >> 16) % 256); + bytes[i++] = (byte)((Balance >> 24) % 256); + bytes[i++] = (byte)(TaxEstimate % 256); + bytes[i++] = (byte)((TaxEstimate >> 8) % 256); + bytes[i++] = (byte)((TaxEstimate >> 16) % 256); + bytes[i++] = (byte)((TaxEstimate >> 24) % 256); + if(StartDate == null) { Console.WriteLine("Warning: StartDate is null, in " + this.GetType()); } + bytes[i++] = (byte)StartDate.Length; + Array.Copy(StartDate, 0, bytes, i, StartDate.Length); i += StartDate.Length; + bytes[i++] = (byte)(StartPeriod % 256); + bytes[i++] = (byte)((StartPeriod >> 8) % 256); + bytes[i++] = (byte)((StartPeriod >> 16) % 256); + bytes[i++] = (byte)((StartPeriod >> 24) % 256); + bytes[i++] = (byte)(StipendEstimate % 256); + bytes[i++] = (byte)((StipendEstimate >> 8) % 256); + bytes[i++] = (byte)((StipendEstimate >> 16) % 256); + bytes[i++] = (byte)((StipendEstimate >> 24) % 256); + bytes[i++] = (byte)(EndPeriod % 256); + bytes[i++] = (byte)((EndPeriod >> 8) % 256); + bytes[i++] = (byte)((EndPeriod >> 16) % 256); + bytes[i++] = (byte)((EndPeriod >> 24) % 256); + bytes[i++] = (byte)(BonusEstimate % 256); + bytes[i++] = (byte)((BonusEstimate >> 8) % 256); + bytes[i++] = (byte)((BonusEstimate >> 16) % 256); + bytes[i++] = (byte)((BonusEstimate >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- MoneyData --\n"; - output += "Balance: " + Balance.ToString() + "\n"; - output += "TaxEstimate: " + TaxEstimate.ToString() + "\n"; - output += Helpers.FieldToString(StartDate, "StartDate") + "\n"; - output += "StartPeriod: " + StartPeriod.ToString() + "\n"; - output += "StipendEstimate: " + StipendEstimate.ToString() + "\n"; - output += "EndPeriod: " + EndPeriod.ToString() + "\n"; - output += "BonusEstimate: " + BonusEstimate.ToString() + "\n"; + { + string output = "-- MoneyData --\n"; + output += "Balance: " + Balance.ToString() + "\n"; + output += "TaxEstimate: " + TaxEstimate.ToString() + "\n"; + output += Helpers.FieldToString(StartDate, "StartDate") + "\n"; + output += "StartPeriod: " + StartPeriod.ToString() + "\n"; + output += "StipendEstimate: " + StipendEstimate.ToString() + "\n"; + output += "EndPeriod: " + EndPeriod.ToString() + "\n"; + output += "BonusEstimate: " + BonusEstimate.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// HistoryData block + + /// HistoryData block public class HistoryDataBlock - { - /// Amount field - public int Amount; - private byte[] _description; - /// Description field + { + /// Amount field + public int Amount; + private byte[] _description; + /// Description field public byte[] Description - { - get { return _description; } + { + get { return _description; } set - { - if (value == null) { _description = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } + { + if (value == null) { _description = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 4; - if (Description != null) { length += 1 + Description.Length; } - return length; + { + int length = 4; + if (Description != null) { length += 1 + Description.Length; } + return length; } } - - /// Default constructor - public HistoryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public HistoryDataBlock() { } + /// Constructor for building the block from a byte array public HistoryDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - Amount = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _description = new byte[length]; - Array.Copy(bytes, i, _description, 0, length); i += length; + { + Amount = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _description = new byte[length]; + Array.Copy(bytes, i, _description, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(Amount % 256); - bytes[i++] = (byte)((Amount >> 8) % 256); - bytes[i++] = (byte)((Amount >> 16) % 256); - bytes[i++] = (byte)((Amount >> 24) % 256); - if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } - bytes[i++] = (byte)Description.Length; - Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; + { + bytes[i++] = (byte)(Amount % 256); + bytes[i++] = (byte)((Amount >> 8) % 256); + bytes[i++] = (byte)((Amount >> 16) % 256); + bytes[i++] = (byte)((Amount >> 24) % 256); + if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } + bytes[i++] = (byte)Description.Length; + Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- HistoryData --\n"; - output += "Amount: " + Amount.ToString() + "\n"; - output += Helpers.FieldToString(Description, "Description") + "\n"; + { + string output = "-- HistoryData --\n"; + output += "Amount: " + Amount.ToString() + "\n"; + output += Helpers.FieldToString(Description, "Description") + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.MoneyHistoryReply - public override PacketType Type { get { return PacketType.MoneyHistoryReply; } } - /// MoneyData block - public MoneyDataBlock MoneyData; - /// HistoryData block - public HistoryDataBlock[] HistoryData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.MoneyHistoryReply + public override PacketType Type { get { return PacketType.MoneyHistoryReply; } } + /// MoneyData block + public MoneyDataBlock MoneyData; + /// HistoryData block + public HistoryDataBlock[] HistoryData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public MoneyHistoryReplyPacket() - { - Header = new LowHeader(); - Header.ID = 371; - Header.Reliable = true; - Header.Zerocoded = true; - MoneyData = new MoneyDataBlock(); - HistoryData = new HistoryDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 371; + Header.Reliable = true; + Header.Zerocoded = true; + MoneyData = new MoneyDataBlock(); + HistoryData = new HistoryDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public MoneyHistoryReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - MoneyData = new MoneyDataBlock(bytes, ref i); - int count = (int)bytes[i++]; - HistoryData = new HistoryDataBlock[count]; - for (int j = 0; j < count; j++) - { HistoryData[j] = new HistoryDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + MoneyData = new MoneyDataBlock(bytes, ref i); + int count = (int)bytes[i++]; + HistoryData = new HistoryDataBlock[count]; + for (int j = 0; j < count; j++) + { HistoryData[j] = new HistoryDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public MoneyHistoryReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - MoneyData = new MoneyDataBlock(bytes, ref i); - int count = (int)bytes[i++]; - HistoryData = new HistoryDataBlock[count]; - for (int j = 0; j < count; j++) - { HistoryData[j] = new HistoryDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + MoneyData = new MoneyDataBlock(bytes, ref i); + int count = (int)bytes[i++]; + HistoryData = new HistoryDataBlock[count]; + for (int j = 0; j < count; j++) + { HistoryData[j] = new HistoryDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += MoneyData.Length; length += AgentData.Length;; - length++; - for (int j = 0; j < HistoryData.Length; j++) { length += HistoryData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - MoneyData.ToBytes(bytes, ref i); - bytes[i++] = (byte)HistoryData.Length; - for (int j = 0; j < HistoryData.Length; j++) { HistoryData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += MoneyData.Length; length += AgentData.Length;; + length++; + for (int j = 0; j < HistoryData.Length; j++) { length += HistoryData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + MoneyData.ToBytes(bytes, ref i); + bytes[i++] = (byte)HistoryData.Length; + for (int j = 0; j < HistoryData.Length; j++) { HistoryData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- MoneyHistoryReply ---\n"; - output += MoneyData.ToString() + "\n"; + { + string output = "--- MoneyHistoryReply ---\n"; + output += MoneyData.ToString() + "\n"; for (int j = 0; j < HistoryData.Length; j++) - { + { output += HistoryData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// MoneySummaryRequest packet + + /// MoneySummaryRequest packet public class MoneySummaryRequestPacket : Packet - { - /// MoneyData block + { + /// MoneyData block public class MoneyDataBlock - { - /// RequestID field - public LLUUID RequestID; - /// IntervalDays field - public int IntervalDays; - /// CurrentInterval field - public int CurrentInterval; - - /// Length of this block serialized in bytes + { + /// RequestID field + public LLUUID RequestID; + /// IntervalDays field + public int IntervalDays; + /// CurrentInterval field + public int CurrentInterval; + + /// Length of this block serialized in bytes public int Length { get - { - return 24; + { + return 24; } } - - /// Default constructor - public MoneyDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public MoneyDataBlock() { } + /// Constructor for building the block from a byte array public MoneyDataBlock(byte[] bytes, ref int i) - { + { try - { - RequestID = new LLUUID(bytes, i); i += 16; - IntervalDays = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - CurrentInterval = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + RequestID = new LLUUID(bytes, i); i += 16; + IntervalDays = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + CurrentInterval = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(RequestID == null) { Console.WriteLine("Warning: RequestID is null, in " + this.GetType()); } - Array.Copy(RequestID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(IntervalDays % 256); - bytes[i++] = (byte)((IntervalDays >> 8) % 256); - bytes[i++] = (byte)((IntervalDays >> 16) % 256); - bytes[i++] = (byte)((IntervalDays >> 24) % 256); - bytes[i++] = (byte)(CurrentInterval % 256); - bytes[i++] = (byte)((CurrentInterval >> 8) % 256); - bytes[i++] = (byte)((CurrentInterval >> 16) % 256); - bytes[i++] = (byte)((CurrentInterval >> 24) % 256); + { + if(RequestID == null) { Console.WriteLine("Warning: RequestID is null, in " + this.GetType()); } + Array.Copy(RequestID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(IntervalDays % 256); + bytes[i++] = (byte)((IntervalDays >> 8) % 256); + bytes[i++] = (byte)((IntervalDays >> 16) % 256); + bytes[i++] = (byte)((IntervalDays >> 24) % 256); + bytes[i++] = (byte)(CurrentInterval % 256); + bytes[i++] = (byte)((CurrentInterval >> 8) % 256); + bytes[i++] = (byte)((CurrentInterval >> 16) % 256); + bytes[i++] = (byte)((CurrentInterval >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- MoneyData --\n"; - output += "RequestID: " + RequestID.ToString() + "\n"; - output += "IntervalDays: " + IntervalDays.ToString() + "\n"; - output += "CurrentInterval: " + CurrentInterval.ToString() + "\n"; + { + string output = "-- MoneyData --\n"; + output += "RequestID: " + RequestID.ToString() + "\n"; + output += "IntervalDays: " + IntervalDays.ToString() + "\n"; + output += "CurrentInterval: " + CurrentInterval.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.MoneySummaryRequest - public override PacketType Type { get { return PacketType.MoneySummaryRequest; } } - /// MoneyData block - public MoneyDataBlock MoneyData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.MoneySummaryRequest + public override PacketType Type { get { return PacketType.MoneySummaryRequest; } } + /// MoneyData block + public MoneyDataBlock MoneyData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public MoneySummaryRequestPacket() - { - Header = new LowHeader(); - Header.ID = 372; - Header.Reliable = true; - MoneyData = new MoneyDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 372; + Header.Reliable = true; + MoneyData = new MoneyDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public MoneySummaryRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - MoneyData = new MoneyDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + MoneyData = new MoneyDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public MoneySummaryRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - MoneyData = new MoneyDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + MoneyData = new MoneyDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += MoneyData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - MoneyData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += MoneyData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + MoneyData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- MoneySummaryRequest ---\n"; - output += MoneyData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- MoneySummaryRequest ---\n"; + output += MoneyData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// MoneySummaryReply packet + + /// MoneySummaryReply packet public class MoneySummaryReplyPacket : Packet - { - /// MoneyData block + { + /// MoneyData block public class MoneyDataBlock - { - /// ParcelDirFeeCurrent field - public int ParcelDirFeeCurrent; - private byte[] _taxdate; - /// TaxDate field + { + /// ParcelDirFeeCurrent field + public int ParcelDirFeeCurrent; + private byte[] _taxdate; + /// TaxDate field public byte[] TaxDate - { - get { return _taxdate; } + { + get { return _taxdate; } set - { - if (value == null) { _taxdate = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _taxdate = new byte[value.Length]; Array.Copy(value, _taxdate, value.Length); } + { + if (value == null) { _taxdate = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _taxdate = new byte[value.Length]; Array.Copy(value, _taxdate, value.Length); } } - } - /// Balance field - public int Balance; - /// ParcelDirFeeEstimate field - public int ParcelDirFeeEstimate; - /// RequestID field - public LLUUID RequestID; - /// ObjectTaxCurrent field - public int ObjectTaxCurrent; - /// LightTaxCurrent field - public int LightTaxCurrent; - /// LandTaxCurrent field - public int LandTaxCurrent; - /// GroupTaxCurrent field - public int GroupTaxCurrent; - /// TotalDebits field - public int TotalDebits; - /// IntervalDays field - public int IntervalDays; - /// ObjectTaxEstimate field - public int ObjectTaxEstimate; - /// LightTaxEstimate field - public int LightTaxEstimate; - /// LandTaxEstimate field - public int LandTaxEstimate; - /// GroupTaxEstimate field - public int GroupTaxEstimate; - private byte[] _lasttaxdate; - /// LastTaxDate field + } + /// Balance field + public int Balance; + /// ParcelDirFeeEstimate field + public int ParcelDirFeeEstimate; + /// RequestID field + public LLUUID RequestID; + /// ObjectTaxCurrent field + public int ObjectTaxCurrent; + /// LightTaxCurrent field + public int LightTaxCurrent; + /// LandTaxCurrent field + public int LandTaxCurrent; + /// GroupTaxCurrent field + public int GroupTaxCurrent; + /// TotalDebits field + public int TotalDebits; + /// IntervalDays field + public int IntervalDays; + /// ObjectTaxEstimate field + public int ObjectTaxEstimate; + /// LightTaxEstimate field + public int LightTaxEstimate; + /// LandTaxEstimate field + public int LandTaxEstimate; + /// GroupTaxEstimate field + public int GroupTaxEstimate; + private byte[] _lasttaxdate; + /// LastTaxDate field public byte[] LastTaxDate - { - get { return _lasttaxdate; } + { + get { return _lasttaxdate; } set - { - if (value == null) { _lasttaxdate = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _lasttaxdate = new byte[value.Length]; Array.Copy(value, _lasttaxdate, value.Length); } + { + if (value == null) { _lasttaxdate = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _lasttaxdate = new byte[value.Length]; Array.Copy(value, _lasttaxdate, value.Length); } } - } - private byte[] _startdate; - /// StartDate field + } + private byte[] _startdate; + /// StartDate field public byte[] StartDate - { - get { return _startdate; } + { + get { return _startdate; } set - { - if (value == null) { _startdate = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _startdate = new byte[value.Length]; Array.Copy(value, _startdate, value.Length); } + { + if (value == null) { _startdate = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _startdate = new byte[value.Length]; Array.Copy(value, _startdate, value.Length); } } - } - /// TotalCredits field - public int TotalCredits; - /// StipendEstimate field - public int StipendEstimate; - /// CurrentInterval field - public int CurrentInterval; - /// BonusEstimate field - public int BonusEstimate; - - /// Length of this block serialized in bytes + } + /// TotalCredits field + public int TotalCredits; + /// StipendEstimate field + public int StipendEstimate; + /// CurrentInterval field + public int CurrentInterval; + /// BonusEstimate field + public int BonusEstimate; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 84; - if (TaxDate != null) { length += 1 + TaxDate.Length; } - if (LastTaxDate != null) { length += 1 + LastTaxDate.Length; } - if (StartDate != null) { length += 1 + StartDate.Length; } - return length; + { + int length = 84; + if (TaxDate != null) { length += 1 + TaxDate.Length; } + if (LastTaxDate != null) { length += 1 + LastTaxDate.Length; } + if (StartDate != null) { length += 1 + StartDate.Length; } + return length; } } - - /// Default constructor - public MoneyDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public MoneyDataBlock() { } + /// Constructor for building the block from a byte array public MoneyDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - ParcelDirFeeCurrent = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _taxdate = new byte[length]; - Array.Copy(bytes, i, _taxdate, 0, length); i += length; - Balance = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - ParcelDirFeeEstimate = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - RequestID = new LLUUID(bytes, i); i += 16; - ObjectTaxCurrent = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - LightTaxCurrent = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - LandTaxCurrent = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - GroupTaxCurrent = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - TotalDebits = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - IntervalDays = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - ObjectTaxEstimate = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - LightTaxEstimate = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - LandTaxEstimate = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - GroupTaxEstimate = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _lasttaxdate = new byte[length]; - Array.Copy(bytes, i, _lasttaxdate, 0, length); i += length; - length = (ushort)bytes[i++]; - _startdate = new byte[length]; - Array.Copy(bytes, i, _startdate, 0, length); i += length; - TotalCredits = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - StipendEstimate = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - CurrentInterval = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - BonusEstimate = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + ParcelDirFeeCurrent = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _taxdate = new byte[length]; + Array.Copy(bytes, i, _taxdate, 0, length); i += length; + Balance = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + ParcelDirFeeEstimate = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + RequestID = new LLUUID(bytes, i); i += 16; + ObjectTaxCurrent = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + LightTaxCurrent = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + LandTaxCurrent = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + GroupTaxCurrent = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + TotalDebits = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + IntervalDays = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + ObjectTaxEstimate = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + LightTaxEstimate = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + LandTaxEstimate = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + GroupTaxEstimate = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _lasttaxdate = new byte[length]; + Array.Copy(bytes, i, _lasttaxdate, 0, length); i += length; + length = (ushort)bytes[i++]; + _startdate = new byte[length]; + Array.Copy(bytes, i, _startdate, 0, length); i += length; + TotalCredits = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + StipendEstimate = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + CurrentInterval = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + BonusEstimate = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(ParcelDirFeeCurrent % 256); - bytes[i++] = (byte)((ParcelDirFeeCurrent >> 8) % 256); - bytes[i++] = (byte)((ParcelDirFeeCurrent >> 16) % 256); - bytes[i++] = (byte)((ParcelDirFeeCurrent >> 24) % 256); - if(TaxDate == null) { Console.WriteLine("Warning: TaxDate is null, in " + this.GetType()); } - bytes[i++] = (byte)TaxDate.Length; - Array.Copy(TaxDate, 0, bytes, i, TaxDate.Length); i += TaxDate.Length; - bytes[i++] = (byte)(Balance % 256); - bytes[i++] = (byte)((Balance >> 8) % 256); - bytes[i++] = (byte)((Balance >> 16) % 256); - bytes[i++] = (byte)((Balance >> 24) % 256); - bytes[i++] = (byte)(ParcelDirFeeEstimate % 256); - bytes[i++] = (byte)((ParcelDirFeeEstimate >> 8) % 256); - bytes[i++] = (byte)((ParcelDirFeeEstimate >> 16) % 256); - bytes[i++] = (byte)((ParcelDirFeeEstimate >> 24) % 256); - if(RequestID == null) { Console.WriteLine("Warning: RequestID is null, in " + this.GetType()); } - Array.Copy(RequestID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(ObjectTaxCurrent % 256); - bytes[i++] = (byte)((ObjectTaxCurrent >> 8) % 256); - bytes[i++] = (byte)((ObjectTaxCurrent >> 16) % 256); - bytes[i++] = (byte)((ObjectTaxCurrent >> 24) % 256); - bytes[i++] = (byte)(LightTaxCurrent % 256); - bytes[i++] = (byte)((LightTaxCurrent >> 8) % 256); - bytes[i++] = (byte)((LightTaxCurrent >> 16) % 256); - bytes[i++] = (byte)((LightTaxCurrent >> 24) % 256); - bytes[i++] = (byte)(LandTaxCurrent % 256); - bytes[i++] = (byte)((LandTaxCurrent >> 8) % 256); - bytes[i++] = (byte)((LandTaxCurrent >> 16) % 256); - bytes[i++] = (byte)((LandTaxCurrent >> 24) % 256); - bytes[i++] = (byte)(GroupTaxCurrent % 256); - bytes[i++] = (byte)((GroupTaxCurrent >> 8) % 256); - bytes[i++] = (byte)((GroupTaxCurrent >> 16) % 256); - bytes[i++] = (byte)((GroupTaxCurrent >> 24) % 256); - bytes[i++] = (byte)(TotalDebits % 256); - bytes[i++] = (byte)((TotalDebits >> 8) % 256); - bytes[i++] = (byte)((TotalDebits >> 16) % 256); - bytes[i++] = (byte)((TotalDebits >> 24) % 256); - bytes[i++] = (byte)(IntervalDays % 256); - bytes[i++] = (byte)((IntervalDays >> 8) % 256); - bytes[i++] = (byte)((IntervalDays >> 16) % 256); - bytes[i++] = (byte)((IntervalDays >> 24) % 256); - bytes[i++] = (byte)(ObjectTaxEstimate % 256); - bytes[i++] = (byte)((ObjectTaxEstimate >> 8) % 256); - bytes[i++] = (byte)((ObjectTaxEstimate >> 16) % 256); - bytes[i++] = (byte)((ObjectTaxEstimate >> 24) % 256); - bytes[i++] = (byte)(LightTaxEstimate % 256); - bytes[i++] = (byte)((LightTaxEstimate >> 8) % 256); - bytes[i++] = (byte)((LightTaxEstimate >> 16) % 256); - bytes[i++] = (byte)((LightTaxEstimate >> 24) % 256); - bytes[i++] = (byte)(LandTaxEstimate % 256); - bytes[i++] = (byte)((LandTaxEstimate >> 8) % 256); - bytes[i++] = (byte)((LandTaxEstimate >> 16) % 256); - bytes[i++] = (byte)((LandTaxEstimate >> 24) % 256); - bytes[i++] = (byte)(GroupTaxEstimate % 256); - bytes[i++] = (byte)((GroupTaxEstimate >> 8) % 256); - bytes[i++] = (byte)((GroupTaxEstimate >> 16) % 256); - bytes[i++] = (byte)((GroupTaxEstimate >> 24) % 256); - if(LastTaxDate == null) { Console.WriteLine("Warning: LastTaxDate is null, in " + this.GetType()); } - bytes[i++] = (byte)LastTaxDate.Length; - Array.Copy(LastTaxDate, 0, bytes, i, LastTaxDate.Length); i += LastTaxDate.Length; - if(StartDate == null) { Console.WriteLine("Warning: StartDate is null, in " + this.GetType()); } - bytes[i++] = (byte)StartDate.Length; - Array.Copy(StartDate, 0, bytes, i, StartDate.Length); i += StartDate.Length; - bytes[i++] = (byte)(TotalCredits % 256); - bytes[i++] = (byte)((TotalCredits >> 8) % 256); - bytes[i++] = (byte)((TotalCredits >> 16) % 256); - bytes[i++] = (byte)((TotalCredits >> 24) % 256); - bytes[i++] = (byte)(StipendEstimate % 256); - bytes[i++] = (byte)((StipendEstimate >> 8) % 256); - bytes[i++] = (byte)((StipendEstimate >> 16) % 256); - bytes[i++] = (byte)((StipendEstimate >> 24) % 256); - bytes[i++] = (byte)(CurrentInterval % 256); - bytes[i++] = (byte)((CurrentInterval >> 8) % 256); - bytes[i++] = (byte)((CurrentInterval >> 16) % 256); - bytes[i++] = (byte)((CurrentInterval >> 24) % 256); - bytes[i++] = (byte)(BonusEstimate % 256); - bytes[i++] = (byte)((BonusEstimate >> 8) % 256); - bytes[i++] = (byte)((BonusEstimate >> 16) % 256); - bytes[i++] = (byte)((BonusEstimate >> 24) % 256); + { + bytes[i++] = (byte)(ParcelDirFeeCurrent % 256); + bytes[i++] = (byte)((ParcelDirFeeCurrent >> 8) % 256); + bytes[i++] = (byte)((ParcelDirFeeCurrent >> 16) % 256); + bytes[i++] = (byte)((ParcelDirFeeCurrent >> 24) % 256); + if(TaxDate == null) { Console.WriteLine("Warning: TaxDate is null, in " + this.GetType()); } + bytes[i++] = (byte)TaxDate.Length; + Array.Copy(TaxDate, 0, bytes, i, TaxDate.Length); i += TaxDate.Length; + bytes[i++] = (byte)(Balance % 256); + bytes[i++] = (byte)((Balance >> 8) % 256); + bytes[i++] = (byte)((Balance >> 16) % 256); + bytes[i++] = (byte)((Balance >> 24) % 256); + bytes[i++] = (byte)(ParcelDirFeeEstimate % 256); + bytes[i++] = (byte)((ParcelDirFeeEstimate >> 8) % 256); + bytes[i++] = (byte)((ParcelDirFeeEstimate >> 16) % 256); + bytes[i++] = (byte)((ParcelDirFeeEstimate >> 24) % 256); + if(RequestID == null) { Console.WriteLine("Warning: RequestID is null, in " + this.GetType()); } + Array.Copy(RequestID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(ObjectTaxCurrent % 256); + bytes[i++] = (byte)((ObjectTaxCurrent >> 8) % 256); + bytes[i++] = (byte)((ObjectTaxCurrent >> 16) % 256); + bytes[i++] = (byte)((ObjectTaxCurrent >> 24) % 256); + bytes[i++] = (byte)(LightTaxCurrent % 256); + bytes[i++] = (byte)((LightTaxCurrent >> 8) % 256); + bytes[i++] = (byte)((LightTaxCurrent >> 16) % 256); + bytes[i++] = (byte)((LightTaxCurrent >> 24) % 256); + bytes[i++] = (byte)(LandTaxCurrent % 256); + bytes[i++] = (byte)((LandTaxCurrent >> 8) % 256); + bytes[i++] = (byte)((LandTaxCurrent >> 16) % 256); + bytes[i++] = (byte)((LandTaxCurrent >> 24) % 256); + bytes[i++] = (byte)(GroupTaxCurrent % 256); + bytes[i++] = (byte)((GroupTaxCurrent >> 8) % 256); + bytes[i++] = (byte)((GroupTaxCurrent >> 16) % 256); + bytes[i++] = (byte)((GroupTaxCurrent >> 24) % 256); + bytes[i++] = (byte)(TotalDebits % 256); + bytes[i++] = (byte)((TotalDebits >> 8) % 256); + bytes[i++] = (byte)((TotalDebits >> 16) % 256); + bytes[i++] = (byte)((TotalDebits >> 24) % 256); + bytes[i++] = (byte)(IntervalDays % 256); + bytes[i++] = (byte)((IntervalDays >> 8) % 256); + bytes[i++] = (byte)((IntervalDays >> 16) % 256); + bytes[i++] = (byte)((IntervalDays >> 24) % 256); + bytes[i++] = (byte)(ObjectTaxEstimate % 256); + bytes[i++] = (byte)((ObjectTaxEstimate >> 8) % 256); + bytes[i++] = (byte)((ObjectTaxEstimate >> 16) % 256); + bytes[i++] = (byte)((ObjectTaxEstimate >> 24) % 256); + bytes[i++] = (byte)(LightTaxEstimate % 256); + bytes[i++] = (byte)((LightTaxEstimate >> 8) % 256); + bytes[i++] = (byte)((LightTaxEstimate >> 16) % 256); + bytes[i++] = (byte)((LightTaxEstimate >> 24) % 256); + bytes[i++] = (byte)(LandTaxEstimate % 256); + bytes[i++] = (byte)((LandTaxEstimate >> 8) % 256); + bytes[i++] = (byte)((LandTaxEstimate >> 16) % 256); + bytes[i++] = (byte)((LandTaxEstimate >> 24) % 256); + bytes[i++] = (byte)(GroupTaxEstimate % 256); + bytes[i++] = (byte)((GroupTaxEstimate >> 8) % 256); + bytes[i++] = (byte)((GroupTaxEstimate >> 16) % 256); + bytes[i++] = (byte)((GroupTaxEstimate >> 24) % 256); + if(LastTaxDate == null) { Console.WriteLine("Warning: LastTaxDate is null, in " + this.GetType()); } + bytes[i++] = (byte)LastTaxDate.Length; + Array.Copy(LastTaxDate, 0, bytes, i, LastTaxDate.Length); i += LastTaxDate.Length; + if(StartDate == null) { Console.WriteLine("Warning: StartDate is null, in " + this.GetType()); } + bytes[i++] = (byte)StartDate.Length; + Array.Copy(StartDate, 0, bytes, i, StartDate.Length); i += StartDate.Length; + bytes[i++] = (byte)(TotalCredits % 256); + bytes[i++] = (byte)((TotalCredits >> 8) % 256); + bytes[i++] = (byte)((TotalCredits >> 16) % 256); + bytes[i++] = (byte)((TotalCredits >> 24) % 256); + bytes[i++] = (byte)(StipendEstimate % 256); + bytes[i++] = (byte)((StipendEstimate >> 8) % 256); + bytes[i++] = (byte)((StipendEstimate >> 16) % 256); + bytes[i++] = (byte)((StipendEstimate >> 24) % 256); + bytes[i++] = (byte)(CurrentInterval % 256); + bytes[i++] = (byte)((CurrentInterval >> 8) % 256); + bytes[i++] = (byte)((CurrentInterval >> 16) % 256); + bytes[i++] = (byte)((CurrentInterval >> 24) % 256); + bytes[i++] = (byte)(BonusEstimate % 256); + bytes[i++] = (byte)((BonusEstimate >> 8) % 256); + bytes[i++] = (byte)((BonusEstimate >> 16) % 256); + bytes[i++] = (byte)((BonusEstimate >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- MoneyData --\n"; - output += "ParcelDirFeeCurrent: " + ParcelDirFeeCurrent.ToString() + "\n"; - output += Helpers.FieldToString(TaxDate, "TaxDate") + "\n"; - output += "Balance: " + Balance.ToString() + "\n"; - output += "ParcelDirFeeEstimate: " + ParcelDirFeeEstimate.ToString() + "\n"; - output += "RequestID: " + RequestID.ToString() + "\n"; - output += "ObjectTaxCurrent: " + ObjectTaxCurrent.ToString() + "\n"; - output += "LightTaxCurrent: " + LightTaxCurrent.ToString() + "\n"; - output += "LandTaxCurrent: " + LandTaxCurrent.ToString() + "\n"; - output += "GroupTaxCurrent: " + GroupTaxCurrent.ToString() + "\n"; - output += "TotalDebits: " + TotalDebits.ToString() + "\n"; - output += "IntervalDays: " + IntervalDays.ToString() + "\n"; - output += "ObjectTaxEstimate: " + ObjectTaxEstimate.ToString() + "\n"; - output += "LightTaxEstimate: " + LightTaxEstimate.ToString() + "\n"; - output += "LandTaxEstimate: " + LandTaxEstimate.ToString() + "\n"; - output += "GroupTaxEstimate: " + GroupTaxEstimate.ToString() + "\n"; - output += Helpers.FieldToString(LastTaxDate, "LastTaxDate") + "\n"; - output += Helpers.FieldToString(StartDate, "StartDate") + "\n"; - output += "TotalCredits: " + TotalCredits.ToString() + "\n"; - output += "StipendEstimate: " + StipendEstimate.ToString() + "\n"; - output += "CurrentInterval: " + CurrentInterval.ToString() + "\n"; - output += "BonusEstimate: " + BonusEstimate.ToString() + "\n"; + { + string output = "-- MoneyData --\n"; + output += "ParcelDirFeeCurrent: " + ParcelDirFeeCurrent.ToString() + "\n"; + output += Helpers.FieldToString(TaxDate, "TaxDate") + "\n"; + output += "Balance: " + Balance.ToString() + "\n"; + output += "ParcelDirFeeEstimate: " + ParcelDirFeeEstimate.ToString() + "\n"; + output += "RequestID: " + RequestID.ToString() + "\n"; + output += "ObjectTaxCurrent: " + ObjectTaxCurrent.ToString() + "\n"; + output += "LightTaxCurrent: " + LightTaxCurrent.ToString() + "\n"; + output += "LandTaxCurrent: " + LandTaxCurrent.ToString() + "\n"; + output += "GroupTaxCurrent: " + GroupTaxCurrent.ToString() + "\n"; + output += "TotalDebits: " + TotalDebits.ToString() + "\n"; + output += "IntervalDays: " + IntervalDays.ToString() + "\n"; + output += "ObjectTaxEstimate: " + ObjectTaxEstimate.ToString() + "\n"; + output += "LightTaxEstimate: " + LightTaxEstimate.ToString() + "\n"; + output += "LandTaxEstimate: " + LandTaxEstimate.ToString() + "\n"; + output += "GroupTaxEstimate: " + GroupTaxEstimate.ToString() + "\n"; + output += Helpers.FieldToString(LastTaxDate, "LastTaxDate") + "\n"; + output += Helpers.FieldToString(StartDate, "StartDate") + "\n"; + output += "TotalCredits: " + TotalCredits.ToString() + "\n"; + output += "StipendEstimate: " + StipendEstimate.ToString() + "\n"; + output += "CurrentInterval: " + CurrentInterval.ToString() + "\n"; + output += "BonusEstimate: " + BonusEstimate.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.MoneySummaryReply - public override PacketType Type { get { return PacketType.MoneySummaryReply; } } - /// MoneyData block - public MoneyDataBlock MoneyData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.MoneySummaryReply + public override PacketType Type { get { return PacketType.MoneySummaryReply; } } + /// MoneyData block + public MoneyDataBlock MoneyData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public MoneySummaryReplyPacket() - { - Header = new LowHeader(); - Header.ID = 373; - Header.Reliable = true; - Header.Zerocoded = true; - MoneyData = new MoneyDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 373; + Header.Reliable = true; + Header.Zerocoded = true; + MoneyData = new MoneyDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public MoneySummaryReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - MoneyData = new MoneyDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + MoneyData = new MoneyDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public MoneySummaryReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - MoneyData = new MoneyDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + MoneyData = new MoneyDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += MoneyData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - MoneyData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += MoneyData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + MoneyData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- MoneySummaryReply ---\n"; - output += MoneyData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- MoneySummaryReply ---\n"; + output += MoneyData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// MoneyDetailsRequest packet + + /// MoneyDetailsRequest packet public class MoneyDetailsRequestPacket : Packet - { - /// MoneyData block + { + /// MoneyData block public class MoneyDataBlock - { - /// RequestID field - public LLUUID RequestID; - /// IntervalDays field - public int IntervalDays; - /// CurrentInterval field - public int CurrentInterval; - - /// Length of this block serialized in bytes + { + /// RequestID field + public LLUUID RequestID; + /// IntervalDays field + public int IntervalDays; + /// CurrentInterval field + public int CurrentInterval; + + /// Length of this block serialized in bytes public int Length { get - { - return 24; + { + return 24; } } - - /// Default constructor - public MoneyDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public MoneyDataBlock() { } + /// Constructor for building the block from a byte array public MoneyDataBlock(byte[] bytes, ref int i) - { + { try - { - RequestID = new LLUUID(bytes, i); i += 16; - IntervalDays = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - CurrentInterval = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + RequestID = new LLUUID(bytes, i); i += 16; + IntervalDays = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + CurrentInterval = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(RequestID == null) { Console.WriteLine("Warning: RequestID is null, in " + this.GetType()); } - Array.Copy(RequestID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(IntervalDays % 256); - bytes[i++] = (byte)((IntervalDays >> 8) % 256); - bytes[i++] = (byte)((IntervalDays >> 16) % 256); - bytes[i++] = (byte)((IntervalDays >> 24) % 256); - bytes[i++] = (byte)(CurrentInterval % 256); - bytes[i++] = (byte)((CurrentInterval >> 8) % 256); - bytes[i++] = (byte)((CurrentInterval >> 16) % 256); - bytes[i++] = (byte)((CurrentInterval >> 24) % 256); + { + if(RequestID == null) { Console.WriteLine("Warning: RequestID is null, in " + this.GetType()); } + Array.Copy(RequestID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(IntervalDays % 256); + bytes[i++] = (byte)((IntervalDays >> 8) % 256); + bytes[i++] = (byte)((IntervalDays >> 16) % 256); + bytes[i++] = (byte)((IntervalDays >> 24) % 256); + bytes[i++] = (byte)(CurrentInterval % 256); + bytes[i++] = (byte)((CurrentInterval >> 8) % 256); + bytes[i++] = (byte)((CurrentInterval >> 16) % 256); + bytes[i++] = (byte)((CurrentInterval >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- MoneyData --\n"; - output += "RequestID: " + RequestID.ToString() + "\n"; - output += "IntervalDays: " + IntervalDays.ToString() + "\n"; - output += "CurrentInterval: " + CurrentInterval.ToString() + "\n"; + { + string output = "-- MoneyData --\n"; + output += "RequestID: " + RequestID.ToString() + "\n"; + output += "IntervalDays: " + IntervalDays.ToString() + "\n"; + output += "CurrentInterval: " + CurrentInterval.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.MoneyDetailsRequest - public override PacketType Type { get { return PacketType.MoneyDetailsRequest; } } - /// MoneyData block - public MoneyDataBlock MoneyData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.MoneyDetailsRequest + public override PacketType Type { get { return PacketType.MoneyDetailsRequest; } } + /// MoneyData block + public MoneyDataBlock MoneyData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public MoneyDetailsRequestPacket() - { - Header = new LowHeader(); - Header.ID = 374; - Header.Reliable = true; - MoneyData = new MoneyDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 374; + Header.Reliable = true; + MoneyData = new MoneyDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public MoneyDetailsRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - MoneyData = new MoneyDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + MoneyData = new MoneyDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public MoneyDetailsRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - MoneyData = new MoneyDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + MoneyData = new MoneyDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += MoneyData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - MoneyData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += MoneyData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + MoneyData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- MoneyDetailsRequest ---\n"; - output += MoneyData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- MoneyDetailsRequest ---\n"; + output += MoneyData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// MoneyDetailsReply packet + + /// MoneyDetailsReply packet public class MoneyDetailsReplyPacket : Packet - { - /// MoneyData block + { + /// MoneyData block public class MoneyDataBlock - { - /// RequestID field - public LLUUID RequestID; - /// IntervalDays field - public int IntervalDays; - private byte[] _startdate; - /// StartDate field + { + /// RequestID field + public LLUUID RequestID; + /// IntervalDays field + public int IntervalDays; + private byte[] _startdate; + /// StartDate field public byte[] StartDate - { - get { return _startdate; } + { + get { return _startdate; } set - { - if (value == null) { _startdate = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _startdate = new byte[value.Length]; Array.Copy(value, _startdate, value.Length); } + { + if (value == null) { _startdate = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _startdate = new byte[value.Length]; Array.Copy(value, _startdate, value.Length); } } - } - /// CurrentInterval field - public int CurrentInterval; - - /// Length of this block serialized in bytes + } + /// CurrentInterval field + public int CurrentInterval; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 24; - if (StartDate != null) { length += 1 + StartDate.Length; } - return length; + { + int length = 24; + if (StartDate != null) { length += 1 + StartDate.Length; } + return length; } } - - /// Default constructor - public MoneyDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public MoneyDataBlock() { } + /// Constructor for building the block from a byte array public MoneyDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - RequestID = new LLUUID(bytes, i); i += 16; - IntervalDays = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _startdate = new byte[length]; - Array.Copy(bytes, i, _startdate, 0, length); i += length; - CurrentInterval = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + RequestID = new LLUUID(bytes, i); i += 16; + IntervalDays = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _startdate = new byte[length]; + Array.Copy(bytes, i, _startdate, 0, length); i += length; + CurrentInterval = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(RequestID == null) { Console.WriteLine("Warning: RequestID is null, in " + this.GetType()); } - Array.Copy(RequestID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(IntervalDays % 256); - bytes[i++] = (byte)((IntervalDays >> 8) % 256); - bytes[i++] = (byte)((IntervalDays >> 16) % 256); - bytes[i++] = (byte)((IntervalDays >> 24) % 256); - if(StartDate == null) { Console.WriteLine("Warning: StartDate is null, in " + this.GetType()); } - bytes[i++] = (byte)StartDate.Length; - Array.Copy(StartDate, 0, bytes, i, StartDate.Length); i += StartDate.Length; - bytes[i++] = (byte)(CurrentInterval % 256); - bytes[i++] = (byte)((CurrentInterval >> 8) % 256); - bytes[i++] = (byte)((CurrentInterval >> 16) % 256); - bytes[i++] = (byte)((CurrentInterval >> 24) % 256); + { + if(RequestID == null) { Console.WriteLine("Warning: RequestID is null, in " + this.GetType()); } + Array.Copy(RequestID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(IntervalDays % 256); + bytes[i++] = (byte)((IntervalDays >> 8) % 256); + bytes[i++] = (byte)((IntervalDays >> 16) % 256); + bytes[i++] = (byte)((IntervalDays >> 24) % 256); + if(StartDate == null) { Console.WriteLine("Warning: StartDate is null, in " + this.GetType()); } + bytes[i++] = (byte)StartDate.Length; + Array.Copy(StartDate, 0, bytes, i, StartDate.Length); i += StartDate.Length; + bytes[i++] = (byte)(CurrentInterval % 256); + bytes[i++] = (byte)((CurrentInterval >> 8) % 256); + bytes[i++] = (byte)((CurrentInterval >> 16) % 256); + bytes[i++] = (byte)((CurrentInterval >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- MoneyData --\n"; - output += "RequestID: " + RequestID.ToString() + "\n"; - output += "IntervalDays: " + IntervalDays.ToString() + "\n"; - output += Helpers.FieldToString(StartDate, "StartDate") + "\n"; - output += "CurrentInterval: " + CurrentInterval.ToString() + "\n"; + { + string output = "-- MoneyData --\n"; + output += "RequestID: " + RequestID.ToString() + "\n"; + output += "IntervalDays: " + IntervalDays.ToString() + "\n"; + output += Helpers.FieldToString(StartDate, "StartDate") + "\n"; + output += "CurrentInterval: " + CurrentInterval.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// HistoryData block + + /// HistoryData block public class HistoryDataBlock - { - /// Amount field - public int Amount; - private byte[] _description; - /// Description field + { + /// Amount field + public int Amount; + private byte[] _description; + /// Description field public byte[] Description - { - get { return _description; } + { + get { return _description; } set - { - if (value == null) { _description = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } + { + if (value == null) { _description = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 4; - if (Description != null) { length += 1 + Description.Length; } - return length; + { + int length = 4; + if (Description != null) { length += 1 + Description.Length; } + return length; } } - - /// Default constructor - public HistoryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public HistoryDataBlock() { } + /// Constructor for building the block from a byte array public HistoryDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - Amount = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _description = new byte[length]; - Array.Copy(bytes, i, _description, 0, length); i += length; + { + Amount = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _description = new byte[length]; + Array.Copy(bytes, i, _description, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(Amount % 256); - bytes[i++] = (byte)((Amount >> 8) % 256); - bytes[i++] = (byte)((Amount >> 16) % 256); - bytes[i++] = (byte)((Amount >> 24) % 256); - if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } - bytes[i++] = (byte)Description.Length; - Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; + { + bytes[i++] = (byte)(Amount % 256); + bytes[i++] = (byte)((Amount >> 8) % 256); + bytes[i++] = (byte)((Amount >> 16) % 256); + bytes[i++] = (byte)((Amount >> 24) % 256); + if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } + bytes[i++] = (byte)Description.Length; + Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- HistoryData --\n"; - output += "Amount: " + Amount.ToString() + "\n"; - output += Helpers.FieldToString(Description, "Description") + "\n"; + { + string output = "-- HistoryData --\n"; + output += "Amount: " + Amount.ToString() + "\n"; + output += Helpers.FieldToString(Description, "Description") + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.MoneyDetailsReply - public override PacketType Type { get { return PacketType.MoneyDetailsReply; } } - /// MoneyData block - public MoneyDataBlock MoneyData; - /// HistoryData block - public HistoryDataBlock[] HistoryData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.MoneyDetailsReply + public override PacketType Type { get { return PacketType.MoneyDetailsReply; } } + /// MoneyData block + public MoneyDataBlock MoneyData; + /// HistoryData block + public HistoryDataBlock[] HistoryData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public MoneyDetailsReplyPacket() - { - Header = new LowHeader(); - Header.ID = 375; - Header.Reliable = true; - Header.Zerocoded = true; - MoneyData = new MoneyDataBlock(); - HistoryData = new HistoryDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 375; + Header.Reliable = true; + Header.Zerocoded = true; + MoneyData = new MoneyDataBlock(); + HistoryData = new HistoryDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public MoneyDetailsReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - MoneyData = new MoneyDataBlock(bytes, ref i); - int count = (int)bytes[i++]; - HistoryData = new HistoryDataBlock[count]; - for (int j = 0; j < count; j++) - { HistoryData[j] = new HistoryDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + MoneyData = new MoneyDataBlock(bytes, ref i); + int count = (int)bytes[i++]; + HistoryData = new HistoryDataBlock[count]; + for (int j = 0; j < count; j++) + { HistoryData[j] = new HistoryDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public MoneyDetailsReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - MoneyData = new MoneyDataBlock(bytes, ref i); - int count = (int)bytes[i++]; - HistoryData = new HistoryDataBlock[count]; - for (int j = 0; j < count; j++) - { HistoryData[j] = new HistoryDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + MoneyData = new MoneyDataBlock(bytes, ref i); + int count = (int)bytes[i++]; + HistoryData = new HistoryDataBlock[count]; + for (int j = 0; j < count; j++) + { HistoryData[j] = new HistoryDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += MoneyData.Length; length += AgentData.Length;; - length++; - for (int j = 0; j < HistoryData.Length; j++) { length += HistoryData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - MoneyData.ToBytes(bytes, ref i); - bytes[i++] = (byte)HistoryData.Length; - for (int j = 0; j < HistoryData.Length; j++) { HistoryData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += MoneyData.Length; length += AgentData.Length;; + length++; + for (int j = 0; j < HistoryData.Length; j++) { length += HistoryData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + MoneyData.ToBytes(bytes, ref i); + bytes[i++] = (byte)HistoryData.Length; + for (int j = 0; j < HistoryData.Length; j++) { HistoryData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- MoneyDetailsReply ---\n"; - output += MoneyData.ToString() + "\n"; + { + string output = "--- MoneyDetailsReply ---\n"; + output += MoneyData.ToString() + "\n"; for (int j = 0; j < HistoryData.Length; j++) - { + { output += HistoryData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// MoneyTransactionsRequest packet + + /// MoneyTransactionsRequest packet public class MoneyTransactionsRequestPacket : Packet - { - /// MoneyData block + { + /// MoneyData block public class MoneyDataBlock - { - /// RequestID field - public LLUUID RequestID; - /// IntervalDays field - public int IntervalDays; - /// CurrentInterval field - public int CurrentInterval; - - /// Length of this block serialized in bytes + { + /// RequestID field + public LLUUID RequestID; + /// IntervalDays field + public int IntervalDays; + /// CurrentInterval field + public int CurrentInterval; + + /// Length of this block serialized in bytes public int Length { get - { - return 24; + { + return 24; } } - - /// Default constructor - public MoneyDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public MoneyDataBlock() { } + /// Constructor for building the block from a byte array public MoneyDataBlock(byte[] bytes, ref int i) - { + { try - { - RequestID = new LLUUID(bytes, i); i += 16; - IntervalDays = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - CurrentInterval = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + RequestID = new LLUUID(bytes, i); i += 16; + IntervalDays = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + CurrentInterval = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(RequestID == null) { Console.WriteLine("Warning: RequestID is null, in " + this.GetType()); } - Array.Copy(RequestID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(IntervalDays % 256); - bytes[i++] = (byte)((IntervalDays >> 8) % 256); - bytes[i++] = (byte)((IntervalDays >> 16) % 256); - bytes[i++] = (byte)((IntervalDays >> 24) % 256); - bytes[i++] = (byte)(CurrentInterval % 256); - bytes[i++] = (byte)((CurrentInterval >> 8) % 256); - bytes[i++] = (byte)((CurrentInterval >> 16) % 256); - bytes[i++] = (byte)((CurrentInterval >> 24) % 256); + { + if(RequestID == null) { Console.WriteLine("Warning: RequestID is null, in " + this.GetType()); } + Array.Copy(RequestID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(IntervalDays % 256); + bytes[i++] = (byte)((IntervalDays >> 8) % 256); + bytes[i++] = (byte)((IntervalDays >> 16) % 256); + bytes[i++] = (byte)((IntervalDays >> 24) % 256); + bytes[i++] = (byte)(CurrentInterval % 256); + bytes[i++] = (byte)((CurrentInterval >> 8) % 256); + bytes[i++] = (byte)((CurrentInterval >> 16) % 256); + bytes[i++] = (byte)((CurrentInterval >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- MoneyData --\n"; - output += "RequestID: " + RequestID.ToString() + "\n"; - output += "IntervalDays: " + IntervalDays.ToString() + "\n"; - output += "CurrentInterval: " + CurrentInterval.ToString() + "\n"; + { + string output = "-- MoneyData --\n"; + output += "RequestID: " + RequestID.ToString() + "\n"; + output += "IntervalDays: " + IntervalDays.ToString() + "\n"; + output += "CurrentInterval: " + CurrentInterval.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.MoneyTransactionsRequest - public override PacketType Type { get { return PacketType.MoneyTransactionsRequest; } } - /// MoneyData block - public MoneyDataBlock MoneyData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.MoneyTransactionsRequest + public override PacketType Type { get { return PacketType.MoneyTransactionsRequest; } } + /// MoneyData block + public MoneyDataBlock MoneyData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public MoneyTransactionsRequestPacket() - { - Header = new LowHeader(); - Header.ID = 376; - Header.Reliable = true; - MoneyData = new MoneyDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 376; + Header.Reliable = true; + MoneyData = new MoneyDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public MoneyTransactionsRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - MoneyData = new MoneyDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + MoneyData = new MoneyDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public MoneyTransactionsRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - MoneyData = new MoneyDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + MoneyData = new MoneyDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += MoneyData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - MoneyData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += MoneyData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + MoneyData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- MoneyTransactionsRequest ---\n"; - output += MoneyData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- MoneyTransactionsRequest ---\n"; + output += MoneyData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// MoneyTransactionsReply packet + + /// MoneyTransactionsReply packet public class MoneyTransactionsReplyPacket : Packet - { - /// MoneyData block + { + /// MoneyData block public class MoneyDataBlock - { - /// RequestID field - public LLUUID RequestID; - /// IntervalDays field - public int IntervalDays; - private byte[] _startdate; - /// StartDate field + { + /// RequestID field + public LLUUID RequestID; + /// IntervalDays field + public int IntervalDays; + private byte[] _startdate; + /// StartDate field public byte[] StartDate - { - get { return _startdate; } + { + get { return _startdate; } set - { - if (value == null) { _startdate = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _startdate = new byte[value.Length]; Array.Copy(value, _startdate, value.Length); } + { + if (value == null) { _startdate = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _startdate = new byte[value.Length]; Array.Copy(value, _startdate, value.Length); } } - } - /// CurrentInterval field - public int CurrentInterval; - - /// Length of this block serialized in bytes + } + /// CurrentInterval field + public int CurrentInterval; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 24; - if (StartDate != null) { length += 1 + StartDate.Length; } - return length; + { + int length = 24; + if (StartDate != null) { length += 1 + StartDate.Length; } + return length; } } - - /// Default constructor - public MoneyDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public MoneyDataBlock() { } + /// Constructor for building the block from a byte array public MoneyDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - RequestID = new LLUUID(bytes, i); i += 16; - IntervalDays = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _startdate = new byte[length]; - Array.Copy(bytes, i, _startdate, 0, length); i += length; - CurrentInterval = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + RequestID = new LLUUID(bytes, i); i += 16; + IntervalDays = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _startdate = new byte[length]; + Array.Copy(bytes, i, _startdate, 0, length); i += length; + CurrentInterval = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(RequestID == null) { Console.WriteLine("Warning: RequestID is null, in " + this.GetType()); } - Array.Copy(RequestID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(IntervalDays % 256); - bytes[i++] = (byte)((IntervalDays >> 8) % 256); - bytes[i++] = (byte)((IntervalDays >> 16) % 256); - bytes[i++] = (byte)((IntervalDays >> 24) % 256); - if(StartDate == null) { Console.WriteLine("Warning: StartDate is null, in " + this.GetType()); } - bytes[i++] = (byte)StartDate.Length; - Array.Copy(StartDate, 0, bytes, i, StartDate.Length); i += StartDate.Length; - bytes[i++] = (byte)(CurrentInterval % 256); - bytes[i++] = (byte)((CurrentInterval >> 8) % 256); - bytes[i++] = (byte)((CurrentInterval >> 16) % 256); - bytes[i++] = (byte)((CurrentInterval >> 24) % 256); + { + if(RequestID == null) { Console.WriteLine("Warning: RequestID is null, in " + this.GetType()); } + Array.Copy(RequestID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(IntervalDays % 256); + bytes[i++] = (byte)((IntervalDays >> 8) % 256); + bytes[i++] = (byte)((IntervalDays >> 16) % 256); + bytes[i++] = (byte)((IntervalDays >> 24) % 256); + if(StartDate == null) { Console.WriteLine("Warning: StartDate is null, in " + this.GetType()); } + bytes[i++] = (byte)StartDate.Length; + Array.Copy(StartDate, 0, bytes, i, StartDate.Length); i += StartDate.Length; + bytes[i++] = (byte)(CurrentInterval % 256); + bytes[i++] = (byte)((CurrentInterval >> 8) % 256); + bytes[i++] = (byte)((CurrentInterval >> 16) % 256); + bytes[i++] = (byte)((CurrentInterval >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- MoneyData --\n"; - output += "RequestID: " + RequestID.ToString() + "\n"; - output += "IntervalDays: " + IntervalDays.ToString() + "\n"; - output += Helpers.FieldToString(StartDate, "StartDate") + "\n"; - output += "CurrentInterval: " + CurrentInterval.ToString() + "\n"; + { + string output = "-- MoneyData --\n"; + output += "RequestID: " + RequestID.ToString() + "\n"; + output += "IntervalDays: " + IntervalDays.ToString() + "\n"; + output += Helpers.FieldToString(StartDate, "StartDate") + "\n"; + output += "CurrentInterval: " + CurrentInterval.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// HistoryData block + + /// HistoryData block public class HistoryDataBlock - { - private byte[] _time; - /// Time field + { + private byte[] _time; + /// Time field public byte[] Time - { - get { return _time; } + { + get { return _time; } set - { - if (value == null) { _time = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _time = new byte[value.Length]; Array.Copy(value, _time, value.Length); } + { + if (value == null) { _time = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _time = new byte[value.Length]; Array.Copy(value, _time, value.Length); } } - } - private byte[] _item; - /// Item field + } + private byte[] _item; + /// Item field public byte[] Item - { - get { return _item; } + { + get { return _item; } set - { - if (value == null) { _item = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _item = new byte[value.Length]; Array.Copy(value, _item, value.Length); } + { + if (value == null) { _item = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _item = new byte[value.Length]; Array.Copy(value, _item, value.Length); } } - } - private byte[] _user; - /// User field + } + private byte[] _user; + /// User field public byte[] User - { - get { return _user; } + { + get { return _user; } set - { - if (value == null) { _user = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _user = new byte[value.Length]; Array.Copy(value, _user, value.Length); } + { + if (value == null) { _user = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _user = new byte[value.Length]; Array.Copy(value, _user, value.Length); } } - } - /// Type field - public int Type; - /// Amount field - public int Amount; - - /// Length of this block serialized in bytes + } + /// Type field + public int Type; + /// Amount field + public int Amount; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 8; - if (Time != null) { length += 1 + Time.Length; } - if (Item != null) { length += 1 + Item.Length; } - if (User != null) { length += 1 + User.Length; } - return length; + { + int length = 8; + if (Time != null) { length += 1 + Time.Length; } + if (Item != null) { length += 1 + Item.Length; } + if (User != null) { length += 1 + User.Length; } + return length; } } - - /// Default constructor - public HistoryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public HistoryDataBlock() { } + /// Constructor for building the block from a byte array public HistoryDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _time = new byte[length]; - Array.Copy(bytes, i, _time, 0, length); i += length; - length = (ushort)bytes[i++]; - _item = new byte[length]; - Array.Copy(bytes, i, _item, 0, length); i += length; - length = (ushort)bytes[i++]; - _user = new byte[length]; - Array.Copy(bytes, i, _user, 0, length); i += length; - Type = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Amount = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + length = (ushort)bytes[i++]; + _time = new byte[length]; + Array.Copy(bytes, i, _time, 0, length); i += length; + length = (ushort)bytes[i++]; + _item = new byte[length]; + Array.Copy(bytes, i, _item, 0, length); i += length; + length = (ushort)bytes[i++]; + _user = new byte[length]; + Array.Copy(bytes, i, _user, 0, length); i += length; + Type = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Amount = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(Time == null) { Console.WriteLine("Warning: Time is null, in " + this.GetType()); } - bytes[i++] = (byte)Time.Length; - Array.Copy(Time, 0, bytes, i, Time.Length); i += Time.Length; - if(Item == null) { Console.WriteLine("Warning: Item is null, in " + this.GetType()); } - bytes[i++] = (byte)Item.Length; - Array.Copy(Item, 0, bytes, i, Item.Length); i += Item.Length; - if(User == null) { Console.WriteLine("Warning: User is null, in " + this.GetType()); } - bytes[i++] = (byte)User.Length; - Array.Copy(User, 0, bytes, i, User.Length); i += User.Length; - bytes[i++] = (byte)(Type % 256); - bytes[i++] = (byte)((Type >> 8) % 256); - bytes[i++] = (byte)((Type >> 16) % 256); - bytes[i++] = (byte)((Type >> 24) % 256); - bytes[i++] = (byte)(Amount % 256); - bytes[i++] = (byte)((Amount >> 8) % 256); - bytes[i++] = (byte)((Amount >> 16) % 256); - bytes[i++] = (byte)((Amount >> 24) % 256); + { + if(Time == null) { Console.WriteLine("Warning: Time is null, in " + this.GetType()); } + bytes[i++] = (byte)Time.Length; + Array.Copy(Time, 0, bytes, i, Time.Length); i += Time.Length; + if(Item == null) { Console.WriteLine("Warning: Item is null, in " + this.GetType()); } + bytes[i++] = (byte)Item.Length; + Array.Copy(Item, 0, bytes, i, Item.Length); i += Item.Length; + if(User == null) { Console.WriteLine("Warning: User is null, in " + this.GetType()); } + bytes[i++] = (byte)User.Length; + Array.Copy(User, 0, bytes, i, User.Length); i += User.Length; + bytes[i++] = (byte)(Type % 256); + bytes[i++] = (byte)((Type >> 8) % 256); + bytes[i++] = (byte)((Type >> 16) % 256); + bytes[i++] = (byte)((Type >> 24) % 256); + bytes[i++] = (byte)(Amount % 256); + bytes[i++] = (byte)((Amount >> 8) % 256); + bytes[i++] = (byte)((Amount >> 16) % 256); + bytes[i++] = (byte)((Amount >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- HistoryData --\n"; - output += Helpers.FieldToString(Time, "Time") + "\n"; - output += Helpers.FieldToString(Item, "Item") + "\n"; - output += Helpers.FieldToString(User, "User") + "\n"; - output += "Type: " + Type.ToString() + "\n"; - output += "Amount: " + Amount.ToString() + "\n"; + { + string output = "-- HistoryData --\n"; + output += Helpers.FieldToString(Time, "Time") + "\n"; + output += Helpers.FieldToString(Item, "Item") + "\n"; + output += Helpers.FieldToString(User, "User") + "\n"; + output += "Type: " + Type.ToString() + "\n"; + output += "Amount: " + Amount.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.MoneyTransactionsReply - public override PacketType Type { get { return PacketType.MoneyTransactionsReply; } } - /// MoneyData block - public MoneyDataBlock MoneyData; - /// HistoryData block - public HistoryDataBlock[] HistoryData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.MoneyTransactionsReply + public override PacketType Type { get { return PacketType.MoneyTransactionsReply; } } + /// MoneyData block + public MoneyDataBlock MoneyData; + /// HistoryData block + public HistoryDataBlock[] HistoryData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public MoneyTransactionsReplyPacket() - { - Header = new LowHeader(); - Header.ID = 377; - Header.Reliable = true; - Header.Zerocoded = true; - MoneyData = new MoneyDataBlock(); - HistoryData = new HistoryDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 377; + Header.Reliable = true; + Header.Zerocoded = true; + MoneyData = new MoneyDataBlock(); + HistoryData = new HistoryDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public MoneyTransactionsReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - MoneyData = new MoneyDataBlock(bytes, ref i); - int count = (int)bytes[i++]; - HistoryData = new HistoryDataBlock[count]; - for (int j = 0; j < count; j++) - { HistoryData[j] = new HistoryDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + MoneyData = new MoneyDataBlock(bytes, ref i); + int count = (int)bytes[i++]; + HistoryData = new HistoryDataBlock[count]; + for (int j = 0; j < count; j++) + { HistoryData[j] = new HistoryDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public MoneyTransactionsReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - MoneyData = new MoneyDataBlock(bytes, ref i); - int count = (int)bytes[i++]; - HistoryData = new HistoryDataBlock[count]; - for (int j = 0; j < count; j++) - { HistoryData[j] = new HistoryDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + MoneyData = new MoneyDataBlock(bytes, ref i); + int count = (int)bytes[i++]; + HistoryData = new HistoryDataBlock[count]; + for (int j = 0; j < count; j++) + { HistoryData[j] = new HistoryDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += MoneyData.Length; length += AgentData.Length;; - length++; - for (int j = 0; j < HistoryData.Length; j++) { length += HistoryData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - MoneyData.ToBytes(bytes, ref i); - bytes[i++] = (byte)HistoryData.Length; - for (int j = 0; j < HistoryData.Length; j++) { HistoryData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += MoneyData.Length; length += AgentData.Length;; + length++; + for (int j = 0; j < HistoryData.Length; j++) { length += HistoryData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + MoneyData.ToBytes(bytes, ref i); + bytes[i++] = (byte)HistoryData.Length; + for (int j = 0; j < HistoryData.Length; j++) { HistoryData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- MoneyTransactionsReply ---\n"; - output += MoneyData.ToString() + "\n"; + { + string output = "--- MoneyTransactionsReply ---\n"; + output += MoneyData.ToString() + "\n"; for (int j = 0; j < HistoryData.Length; j++) - { + { output += HistoryData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// GestureRequest packet + + /// GestureRequest packet public class GestureRequestPacket : Packet - { - /// AgentBlock block + { + /// AgentBlock block public class AgentBlockBlock - { - /// AgentID field - public LLUUID AgentID; - /// Reset field - public bool Reset; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// Reset field + public bool Reset; + + /// Length of this block serialized in bytes public int Length { get - { - return 17; + { + return 17; } } - - /// Default constructor - public AgentBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentBlockBlock() { } + /// Constructor for building the block from a byte array public AgentBlockBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - Reset = (bytes[i++] != 0) ? (bool)true : (bool)false; + { + AgentID = new LLUUID(bytes, i); i += 16; + Reset = (bytes[i++] != 0) ? (bool)true : (bool)false; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((Reset) ? 1 : 0); + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((Reset) ? 1 : 0); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentBlock --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "Reset: " + Reset.ToString() + "\n"; + { + string output = "-- AgentBlock --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "Reset: " + Reset.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.GestureRequest - public override PacketType Type { get { return PacketType.GestureRequest; } } - /// AgentBlock block - public AgentBlockBlock AgentBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.GestureRequest + public override PacketType Type { get { return PacketType.GestureRequest; } } + /// AgentBlock block + public AgentBlockBlock AgentBlock; + + /// Default constructor public GestureRequestPacket() - { - Header = new LowHeader(); - Header.ID = 378; - Header.Reliable = true; - AgentBlock = new AgentBlockBlock(); + { + Header = new LowHeader(); + Header.ID = 378; + Header.Reliable = true; + AgentBlock = new AgentBlockBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public GestureRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentBlock = new AgentBlockBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentBlock = new AgentBlockBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public GestureRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentBlock = new AgentBlockBlock(bytes, ref i); + { + Header = head; + AgentBlock = new AgentBlockBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentBlock.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentBlock.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentBlock.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentBlock.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- GestureRequest ---\n"; - output += AgentBlock.ToString() + "\n"; + { + string output = "--- GestureRequest ---\n"; + output += AgentBlock.ToString() + "\n"; return output; } - + } - - /// ActivateGestures packet + + /// ActivateGestures packet public class ActivateGesturesPacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - /// AssetID field - public LLUUID AssetID; - /// GestureFlags field - public uint GestureFlags; - /// ItemID field - public LLUUID ItemID; - - /// Length of this block serialized in bytes + { + /// AssetID field + public LLUUID AssetID; + /// GestureFlags field + public uint GestureFlags; + /// ItemID field + public LLUUID ItemID; + + /// Length of this block serialized in bytes public int Length { get - { - return 36; + { + return 36; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { + { try - { - AssetID = new LLUUID(bytes, i); i += 16; - GestureFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - ItemID = new LLUUID(bytes, i); i += 16; + { + AssetID = new LLUUID(bytes, i); i += 16; + GestureFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + ItemID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AssetID == null) { Console.WriteLine("Warning: AssetID is null, in " + this.GetType()); } - Array.Copy(AssetID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(GestureFlags % 256); - bytes[i++] = (byte)((GestureFlags >> 8) % 256); - bytes[i++] = (byte)((GestureFlags >> 16) % 256); - bytes[i++] = (byte)((GestureFlags >> 24) % 256); - if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } - Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AssetID == null) { Console.WriteLine("Warning: AssetID is null, in " + this.GetType()); } + Array.Copy(AssetID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(GestureFlags % 256); + bytes[i++] = (byte)((GestureFlags >> 8) % 256); + bytes[i++] = (byte)((GestureFlags >> 16) % 256); + bytes[i++] = (byte)((GestureFlags >> 24) % 256); + if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } + Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "AssetID: " + AssetID.ToString() + "\n"; - output += "GestureFlags: " + GestureFlags.ToString() + "\n"; - output += "ItemID: " + ItemID.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += "AssetID: " + AssetID.ToString() + "\n"; + output += "GestureFlags: " + GestureFlags.ToString() + "\n"; + output += "ItemID: " + ItemID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - /// Flags field - public uint Flags; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + /// Flags field + public uint Flags; + + /// Length of this block serialized in bytes public int Length { get - { - return 36; + { + return 36; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; - Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; + Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(Flags % 256); - bytes[i++] = (byte)((Flags >> 8) % 256); - bytes[i++] = (byte)((Flags >> 16) % 256); - bytes[i++] = (byte)((Flags >> 24) % 256); + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(Flags % 256); + bytes[i++] = (byte)((Flags >> 8) % 256); + bytes[i++] = (byte)((Flags >> 16) % 256); + bytes[i++] = (byte)((Flags >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "Flags: " + Flags.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "Flags: " + Flags.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ActivateGestures - public override PacketType Type { get { return PacketType.ActivateGestures; } } - /// Data block - public DataBlock[] Data; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ActivateGestures + public override PacketType Type { get { return PacketType.ActivateGestures; } } + /// Data block + public DataBlock[] Data; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ActivateGesturesPacket() - { - Header = new LowHeader(); - Header.ID = 379; - Header.Reliable = true; - Data = new DataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 379; + Header.Reliable = true; + Data = new DataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ActivateGesturesPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - Data = new DataBlock[count]; - for (int j = 0; j < count; j++) - { Data[j] = new DataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + Data = new DataBlock[count]; + for (int j = 0; j < count; j++) + { Data[j] = new DataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ActivateGesturesPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - Data = new DataBlock[count]; - for (int j = 0; j < count; j++) - { Data[j] = new DataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + Data = new DataBlock[count]; + for (int j = 0; j < count; j++) + { Data[j] = new DataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < Data.Length; j++) { length += Data[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)Data.Length; - for (int j = 0; j < Data.Length; j++) { Data[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < Data.Length; j++) { length += Data[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)Data.Length; + for (int j = 0; j < Data.Length; j++) { Data[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ActivateGestures ---\n"; + { + string output = "--- ActivateGestures ---\n"; for (int j = 0; j < Data.Length; j++) - { + { output += Data[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// DeactivateGestures packet + + /// DeactivateGestures packet public class DeactivateGesturesPacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - /// GestureFlags field - public uint GestureFlags; - /// ItemID field - public LLUUID ItemID; - - /// Length of this block serialized in bytes + { + /// GestureFlags field + public uint GestureFlags; + /// ItemID field + public LLUUID ItemID; + + /// Length of this block serialized in bytes public int Length { get - { - return 20; + { + return 20; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { + { try - { - GestureFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - ItemID = new LLUUID(bytes, i); i += 16; + { + GestureFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + ItemID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(GestureFlags % 256); - bytes[i++] = (byte)((GestureFlags >> 8) % 256); - bytes[i++] = (byte)((GestureFlags >> 16) % 256); - bytes[i++] = (byte)((GestureFlags >> 24) % 256); - if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } - Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; + { + bytes[i++] = (byte)(GestureFlags % 256); + bytes[i++] = (byte)((GestureFlags >> 8) % 256); + bytes[i++] = (byte)((GestureFlags >> 16) % 256); + bytes[i++] = (byte)((GestureFlags >> 24) % 256); + if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } + Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "GestureFlags: " + GestureFlags.ToString() + "\n"; - output += "ItemID: " + ItemID.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += "GestureFlags: " + GestureFlags.ToString() + "\n"; + output += "ItemID: " + ItemID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - /// Flags field - public uint Flags; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + /// Flags field + public uint Flags; + + /// Length of this block serialized in bytes public int Length { get - { - return 36; + { + return 36; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; - Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; + Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(Flags % 256); - bytes[i++] = (byte)((Flags >> 8) % 256); - bytes[i++] = (byte)((Flags >> 16) % 256); - bytes[i++] = (byte)((Flags >> 24) % 256); + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(Flags % 256); + bytes[i++] = (byte)((Flags >> 8) % 256); + bytes[i++] = (byte)((Flags >> 16) % 256); + bytes[i++] = (byte)((Flags >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "Flags: " + Flags.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "Flags: " + Flags.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.DeactivateGestures - public override PacketType Type { get { return PacketType.DeactivateGestures; } } - /// Data block - public DataBlock[] Data; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.DeactivateGestures + public override PacketType Type { get { return PacketType.DeactivateGestures; } } + /// Data block + public DataBlock[] Data; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public DeactivateGesturesPacket() - { - Header = new LowHeader(); - Header.ID = 380; - Header.Reliable = true; - Data = new DataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 380; + Header.Reliable = true; + Data = new DataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public DeactivateGesturesPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - Data = new DataBlock[count]; - for (int j = 0; j < count; j++) - { Data[j] = new DataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + Data = new DataBlock[count]; + for (int j = 0; j < count; j++) + { Data[j] = new DataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public DeactivateGesturesPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - Data = new DataBlock[count]; - for (int j = 0; j < count; j++) - { Data[j] = new DataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + Data = new DataBlock[count]; + for (int j = 0; j < count; j++) + { Data[j] = new DataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < Data.Length; j++) { length += Data[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)Data.Length; - for (int j = 0; j < Data.Length; j++) { Data[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < Data.Length; j++) { length += Data[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)Data.Length; + for (int j = 0; j < Data.Length; j++) { Data[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- DeactivateGestures ---\n"; + { + string output = "--- DeactivateGestures ---\n"; for (int j = 0; j < Data.Length; j++) - { + { output += Data[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// InventoryUpdate packet + + /// InventoryUpdate packet public class InventoryUpdatePacket : Packet - { - /// InventoryData block + { + /// InventoryData block public class InventoryDataBlock - { - /// IsComplete field - public byte IsComplete; - private byte[] _filename; - /// Filename field + { + /// IsComplete field + public byte IsComplete; + private byte[] _filename; + /// Filename field public byte[] Filename - { - get { return _filename; } + { + get { return _filename; } set - { - if (value == null) { _filename = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _filename = new byte[value.Length]; Array.Copy(value, _filename, value.Length); } + { + if (value == null) { _filename = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _filename = new byte[value.Length]; Array.Copy(value, _filename, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 1; - if (Filename != null) { length += 1 + Filename.Length; } - return length; + { + int length = 1; + if (Filename != null) { length += 1 + Filename.Length; } + return length; } } - - /// Default constructor - public InventoryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public InventoryDataBlock() { } + /// Constructor for building the block from a byte array public InventoryDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - IsComplete = (byte)bytes[i++]; - length = (ushort)bytes[i++]; - _filename = new byte[length]; - Array.Copy(bytes, i, _filename, 0, length); i += length; + { + IsComplete = (byte)bytes[i++]; + length = (ushort)bytes[i++]; + _filename = new byte[length]; + Array.Copy(bytes, i, _filename, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = IsComplete; - if(Filename == null) { Console.WriteLine("Warning: Filename is null, in " + this.GetType()); } - bytes[i++] = (byte)Filename.Length; - Array.Copy(Filename, 0, bytes, i, Filename.Length); i += Filename.Length; + { + bytes[i++] = IsComplete; + if(Filename == null) { Console.WriteLine("Warning: Filename is null, in " + this.GetType()); } + bytes[i++] = (byte)Filename.Length; + Array.Copy(Filename, 0, bytes, i, Filename.Length); i += Filename.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- InventoryData --\n"; - output += "IsComplete: " + IsComplete.ToString() + "\n"; - output += Helpers.FieldToString(Filename, "Filename") + "\n"; + { + string output = "-- InventoryData --\n"; + output += "IsComplete: " + IsComplete.ToString() + "\n"; + output += Helpers.FieldToString(Filename, "Filename") + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.InventoryUpdate - public override PacketType Type { get { return PacketType.InventoryUpdate; } } - /// InventoryData block - public InventoryDataBlock InventoryData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.InventoryUpdate + public override PacketType Type { get { return PacketType.InventoryUpdate; } } + /// InventoryData block + public InventoryDataBlock InventoryData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public InventoryUpdatePacket() - { - Header = new LowHeader(); - Header.ID = 381; - Header.Reliable = true; - InventoryData = new InventoryDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 381; + Header.Reliable = true; + InventoryData = new InventoryDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public InventoryUpdatePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - InventoryData = new InventoryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + InventoryData = new InventoryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public InventoryUpdatePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - InventoryData = new InventoryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + InventoryData = new InventoryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += InventoryData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - InventoryData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += InventoryData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + InventoryData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- InventoryUpdate ---\n"; - output += InventoryData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- InventoryUpdate ---\n"; + output += InventoryData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// MuteListUpdate packet + + /// MuteListUpdate packet public class MuteListUpdatePacket : Packet - { - /// MuteData block + { + /// MuteData block public class MuteDataBlock - { - /// AgentID field - public LLUUID AgentID; - private byte[] _filename; - /// Filename field + { + /// AgentID field + public LLUUID AgentID; + private byte[] _filename; + /// Filename field public byte[] Filename - { - get { return _filename; } + { + get { return _filename; } set - { - if (value == null) { _filename = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _filename = new byte[value.Length]; Array.Copy(value, _filename, value.Length); } + { + if (value == null) { _filename = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _filename = new byte[value.Length]; Array.Copy(value, _filename, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 16; - if (Filename != null) { length += 1 + Filename.Length; } - return length; + { + int length = 16; + if (Filename != null) { length += 1 + Filename.Length; } + return length; } } - - /// Default constructor - public MuteDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public MuteDataBlock() { } + /// Constructor for building the block from a byte array public MuteDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - AgentID = new LLUUID(bytes, i); i += 16; - length = (ushort)bytes[i++]; - _filename = new byte[length]; - Array.Copy(bytes, i, _filename, 0, length); i += length; + { + AgentID = new LLUUID(bytes, i); i += 16; + length = (ushort)bytes[i++]; + _filename = new byte[length]; + Array.Copy(bytes, i, _filename, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(Filename == null) { Console.WriteLine("Warning: Filename is null, in " + this.GetType()); } - bytes[i++] = (byte)Filename.Length; - Array.Copy(Filename, 0, bytes, i, Filename.Length); i += Filename.Length; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(Filename == null) { Console.WriteLine("Warning: Filename is null, in " + this.GetType()); } + bytes[i++] = (byte)Filename.Length; + Array.Copy(Filename, 0, bytes, i, Filename.Length); i += Filename.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- MuteData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += Helpers.FieldToString(Filename, "Filename") + "\n"; + { + string output = "-- MuteData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += Helpers.FieldToString(Filename, "Filename") + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.MuteListUpdate - public override PacketType Type { get { return PacketType.MuteListUpdate; } } - /// MuteData block - public MuteDataBlock MuteData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.MuteListUpdate + public override PacketType Type { get { return PacketType.MuteListUpdate; } } + /// MuteData block + public MuteDataBlock MuteData; + + /// Default constructor public MuteListUpdatePacket() - { - Header = new LowHeader(); - Header.ID = 382; - Header.Reliable = true; - MuteData = new MuteDataBlock(); + { + Header = new LowHeader(); + Header.ID = 382; + Header.Reliable = true; + MuteData = new MuteDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public MuteListUpdatePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - MuteData = new MuteDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + MuteData = new MuteDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public MuteListUpdatePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - MuteData = new MuteDataBlock(bytes, ref i); + { + Header = head; + MuteData = new MuteDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += MuteData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - MuteData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += MuteData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + MuteData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- MuteListUpdate ---\n"; - output += MuteData.ToString() + "\n"; + { + string output = "--- MuteListUpdate ---\n"; + output += MuteData.ToString() + "\n"; return output; } - + } - - /// UseCachedMuteList packet + + /// UseCachedMuteList packet public class UseCachedMuteListPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.UseCachedMuteList - public override PacketType Type { get { return PacketType.UseCachedMuteList; } } - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.UseCachedMuteList + public override PacketType Type { get { return PacketType.UseCachedMuteList; } } + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public UseCachedMuteListPacket() - { - Header = new LowHeader(); - Header.ID = 383; - Header.Reliable = true; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 383; + Header.Reliable = true; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public UseCachedMuteListPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public UseCachedMuteListPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- UseCachedMuteList ---\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- UseCachedMuteList ---\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// UserLoginLocationReply packet + + /// UserLoginLocationReply packet public class UserLoginLocationReplyPacket : Packet - { - /// URLBlock block + { + /// URLBlock block public class URLBlockBlock - { - /// LocationID field - public uint LocationID; - /// LocationLookAt field - public LLVector3 LocationLookAt; - - /// Length of this block serialized in bytes + { + /// LocationID field + public uint LocationID; + /// LocationLookAt field + public LLVector3 LocationLookAt; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public URLBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public URLBlockBlock() { } + /// Constructor for building the block from a byte array public URLBlockBlock(byte[] bytes, ref int i) - { + { try - { - LocationID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - LocationLookAt = new LLVector3(bytes, i); i += 12; + { + LocationID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + LocationLookAt = new LLVector3(bytes, i); i += 12; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(LocationID % 256); - bytes[i++] = (byte)((LocationID >> 8) % 256); - bytes[i++] = (byte)((LocationID >> 16) % 256); - bytes[i++] = (byte)((LocationID >> 24) % 256); - if(LocationLookAt == null) { Console.WriteLine("Warning: LocationLookAt is null, in " + this.GetType()); } - Array.Copy(LocationLookAt.GetBytes(), 0, bytes, i, 12); i += 12; + { + bytes[i++] = (byte)(LocationID % 256); + bytes[i++] = (byte)((LocationID >> 8) % 256); + bytes[i++] = (byte)((LocationID >> 16) % 256); + bytes[i++] = (byte)((LocationID >> 24) % 256); + if(LocationLookAt == null) { Console.WriteLine("Warning: LocationLookAt is null, in " + this.GetType()); } + Array.Copy(LocationLookAt.GetBytes(), 0, bytes, i, 12); i += 12; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- URLBlock --\n"; - output += "LocationID: " + LocationID.ToString() + "\n"; - output += "LocationLookAt: " + LocationLookAt.ToString() + "\n"; + { + string output = "-- URLBlock --\n"; + output += "LocationID: " + LocationID.ToString() + "\n"; + output += "LocationLookAt: " + LocationLookAt.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// SimulatorBlock block + + /// SimulatorBlock block public class SimulatorBlockBlock - { - /// IP field - public uint IP; - /// Port field - public ushort Port; - - /// Length of this block serialized in bytes + { + /// IP field + public uint IP; + /// Port field + public ushort Port; + + /// Length of this block serialized in bytes public int Length { get - { - return 6; + { + return 6; } } - - /// Default constructor - public SimulatorBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public SimulatorBlockBlock() { } + /// Constructor for building the block from a byte array public SimulatorBlockBlock(byte[] bytes, ref int i) - { + { try - { - IP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Port = (ushort)((bytes[i++] << 8) + bytes[i++]); + { + IP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Port = (ushort)((bytes[i++] << 8) + bytes[i++]); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(IP % 256); - bytes[i++] = (byte)((IP >> 8) % 256); - bytes[i++] = (byte)((IP >> 16) % 256); - bytes[i++] = (byte)((IP >> 24) % 256); - bytes[i++] = (byte)((Port >> 8) % 256); - bytes[i++] = (byte)(Port % 256); + { + bytes[i++] = (byte)(IP % 256); + bytes[i++] = (byte)((IP >> 8) % 256); + bytes[i++] = (byte)((IP >> 16) % 256); + bytes[i++] = (byte)((IP >> 24) % 256); + bytes[i++] = (byte)((Port >> 8) % 256); + bytes[i++] = (byte)(Port % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- SimulatorBlock --\n"; - output += "IP: " + IP.ToString() + "\n"; - output += "Port: " + Port.ToString() + "\n"; + { + string output = "-- SimulatorBlock --\n"; + output += "IP: " + IP.ToString() + "\n"; + output += "Port: " + Port.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// RegionInfo block + + /// RegionInfo block public class RegionInfoBlock - { - /// SecPerDay field - public uint SecPerDay; - /// MetersPerGrid field - public float MetersPerGrid; - /// UsecSinceStart field - public ulong UsecSinceStart; - /// LocationValid field - public bool LocationValid; - /// SecPerYear field - public uint SecPerYear; - /// GridsPerEdge field - public uint GridsPerEdge; - /// Handle field - public ulong Handle; - /// SunAngVelocity field - public LLVector3 SunAngVelocity; - /// SunDirection field - public LLVector3 SunDirection; - - /// Length of this block serialized in bytes + { + /// SecPerDay field + public uint SecPerDay; + /// MetersPerGrid field + public float MetersPerGrid; + /// UsecSinceStart field + public ulong UsecSinceStart; + /// LocationValid field + public bool LocationValid; + /// SecPerYear field + public uint SecPerYear; + /// GridsPerEdge field + public uint GridsPerEdge; + /// Handle field + public ulong Handle; + /// SunAngVelocity field + public LLVector3 SunAngVelocity; + /// SunDirection field + public LLVector3 SunDirection; + + /// Length of this block serialized in bytes public int Length { get - { - return 57; + { + return 57; } } - - /// Default constructor - public RegionInfoBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public RegionInfoBlock() { } + /// Constructor for building the block from a byte array public RegionInfoBlock(byte[] bytes, ref int i) - { + { try - { - SecPerDay = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - MetersPerGrid = BitConverter.ToSingle(bytes, i); i += 4; - UsecSinceStart = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); - LocationValid = (bytes[i++] != 0) ? (bool)true : (bool)false; - SecPerYear = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - GridsPerEdge = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Handle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); - SunAngVelocity = new LLVector3(bytes, i); i += 12; - SunDirection = new LLVector3(bytes, i); i += 12; + { + SecPerDay = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + MetersPerGrid = BitConverter.ToSingle(bytes, i); i += 4; + UsecSinceStart = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + LocationValid = (bytes[i++] != 0) ? (bool)true : (bool)false; + SecPerYear = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + GridsPerEdge = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Handle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + SunAngVelocity = new LLVector3(bytes, i); i += 12; + SunDirection = new LLVector3(bytes, i); i += 12; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; - bytes[i++] = (byte)(SecPerDay % 256); - bytes[i++] = (byte)((SecPerDay >> 8) % 256); - bytes[i++] = (byte)((SecPerDay >> 16) % 256); - bytes[i++] = (byte)((SecPerDay >> 24) % 256); + { + byte[] ba; + bytes[i++] = (byte)(SecPerDay % 256); + bytes[i++] = (byte)((SecPerDay >> 8) % 256); + bytes[i++] = (byte)((SecPerDay >> 16) % 256); + bytes[i++] = (byte)((SecPerDay >> 24) % 256); ba = BitConverter.GetBytes(MetersPerGrid); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - bytes[i++] = (byte)(UsecSinceStart % 256); - bytes[i++] = (byte)((UsecSinceStart >> 8) % 256); - bytes[i++] = (byte)((UsecSinceStart >> 16) % 256); - bytes[i++] = (byte)((UsecSinceStart >> 24) % 256); - bytes[i++] = (byte)((UsecSinceStart >> 32) % 256); - bytes[i++] = (byte)((UsecSinceStart >> 40) % 256); - bytes[i++] = (byte)((UsecSinceStart >> 48) % 256); - bytes[i++] = (byte)((UsecSinceStart >> 56) % 256); - bytes[i++] = (byte)((LocationValid) ? 1 : 0); - bytes[i++] = (byte)(SecPerYear % 256); - bytes[i++] = (byte)((SecPerYear >> 8) % 256); - bytes[i++] = (byte)((SecPerYear >> 16) % 256); - bytes[i++] = (byte)((SecPerYear >> 24) % 256); - bytes[i++] = (byte)(GridsPerEdge % 256); - bytes[i++] = (byte)((GridsPerEdge >> 8) % 256); - bytes[i++] = (byte)((GridsPerEdge >> 16) % 256); - bytes[i++] = (byte)((GridsPerEdge >> 24) % 256); - bytes[i++] = (byte)(Handle % 256); - bytes[i++] = (byte)((Handle >> 8) % 256); - bytes[i++] = (byte)((Handle >> 16) % 256); - bytes[i++] = (byte)((Handle >> 24) % 256); - bytes[i++] = (byte)((Handle >> 32) % 256); - bytes[i++] = (byte)((Handle >> 40) % 256); - bytes[i++] = (byte)((Handle >> 48) % 256); - bytes[i++] = (byte)((Handle >> 56) % 256); - if(SunAngVelocity == null) { Console.WriteLine("Warning: SunAngVelocity is null, in " + this.GetType()); } - Array.Copy(SunAngVelocity.GetBytes(), 0, bytes, i, 12); i += 12; - if(SunDirection == null) { Console.WriteLine("Warning: SunDirection is null, in " + this.GetType()); } - Array.Copy(SunDirection.GetBytes(), 0, bytes, i, 12); i += 12; + Array.Copy(ba, 0, bytes, i, 4); i += 4; + bytes[i++] = (byte)(UsecSinceStart % 256); + bytes[i++] = (byte)((UsecSinceStart >> 8) % 256); + bytes[i++] = (byte)((UsecSinceStart >> 16) % 256); + bytes[i++] = (byte)((UsecSinceStart >> 24) % 256); + bytes[i++] = (byte)((UsecSinceStart >> 32) % 256); + bytes[i++] = (byte)((UsecSinceStart >> 40) % 256); + bytes[i++] = (byte)((UsecSinceStart >> 48) % 256); + bytes[i++] = (byte)((UsecSinceStart >> 56) % 256); + bytes[i++] = (byte)((LocationValid) ? 1 : 0); + bytes[i++] = (byte)(SecPerYear % 256); + bytes[i++] = (byte)((SecPerYear >> 8) % 256); + bytes[i++] = (byte)((SecPerYear >> 16) % 256); + bytes[i++] = (byte)((SecPerYear >> 24) % 256); + bytes[i++] = (byte)(GridsPerEdge % 256); + bytes[i++] = (byte)((GridsPerEdge >> 8) % 256); + bytes[i++] = (byte)((GridsPerEdge >> 16) % 256); + bytes[i++] = (byte)((GridsPerEdge >> 24) % 256); + bytes[i++] = (byte)(Handle % 256); + bytes[i++] = (byte)((Handle >> 8) % 256); + bytes[i++] = (byte)((Handle >> 16) % 256); + bytes[i++] = (byte)((Handle >> 24) % 256); + bytes[i++] = (byte)((Handle >> 32) % 256); + bytes[i++] = (byte)((Handle >> 40) % 256); + bytes[i++] = (byte)((Handle >> 48) % 256); + bytes[i++] = (byte)((Handle >> 56) % 256); + if(SunAngVelocity == null) { Console.WriteLine("Warning: SunAngVelocity is null, in " + this.GetType()); } + Array.Copy(SunAngVelocity.GetBytes(), 0, bytes, i, 12); i += 12; + if(SunDirection == null) { Console.WriteLine("Warning: SunDirection is null, in " + this.GetType()); } + Array.Copy(SunDirection.GetBytes(), 0, bytes, i, 12); i += 12; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- RegionInfo --\n"; - output += "SecPerDay: " + SecPerDay.ToString() + "\n"; - output += "MetersPerGrid: " + MetersPerGrid.ToString() + "\n"; - output += "UsecSinceStart: " + UsecSinceStart.ToString() + "\n"; - output += "LocationValid: " + LocationValid.ToString() + "\n"; - output += "SecPerYear: " + SecPerYear.ToString() + "\n"; - output += "GridsPerEdge: " + GridsPerEdge.ToString() + "\n"; - output += "Handle: " + Handle.ToString() + "\n"; - output += "SunAngVelocity: " + SunAngVelocity.ToString() + "\n"; - output += "SunDirection: " + SunDirection.ToString() + "\n"; + { + string output = "-- RegionInfo --\n"; + output += "SecPerDay: " + SecPerDay.ToString() + "\n"; + output += "MetersPerGrid: " + MetersPerGrid.ToString() + "\n"; + output += "UsecSinceStart: " + UsecSinceStart.ToString() + "\n"; + output += "LocationValid: " + LocationValid.ToString() + "\n"; + output += "SecPerYear: " + SecPerYear.ToString() + "\n"; + output += "GridsPerEdge: " + GridsPerEdge.ToString() + "\n"; + output += "Handle: " + Handle.ToString() + "\n"; + output += "SunAngVelocity: " + SunAngVelocity.ToString() + "\n"; + output += "SunDirection: " + SunDirection.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - private byte[] _message; - /// Message field + { + private byte[] _message; + /// Message field public byte[] Message - { - get { return _message; } + { + get { return _message; } set - { - if (value == null) { _message = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _message = new byte[value.Length]; Array.Copy(value, _message, value.Length); } + { + if (value == null) { _message = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _message = new byte[value.Length]; Array.Copy(value, _message, value.Length); } } - } - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + } + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 16; - if (Message != null) { length += 1 + Message.Length; } - return length; + { + int length = 16; + if (Message != null) { length += 1 + Message.Length; } + return length; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _message = new byte[length]; - Array.Copy(bytes, i, _message, 0, length); i += length; - SessionID = new LLUUID(bytes, i); i += 16; + { + length = (ushort)bytes[i++]; + _message = new byte[length]; + Array.Copy(bytes, i, _message, 0, length); i += length; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(Message == null) { Console.WriteLine("Warning: Message is null, in " + this.GetType()); } - bytes[i++] = (byte)Message.Length; - Array.Copy(Message, 0, bytes, i, Message.Length); i += Message.Length; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(Message == null) { Console.WriteLine("Warning: Message is null, in " + this.GetType()); } + bytes[i++] = (byte)Message.Length; + Array.Copy(Message, 0, bytes, i, Message.Length); i += Message.Length; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += Helpers.FieldToString(Message, "Message") + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += Helpers.FieldToString(Message, "Message") + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.UserLoginLocationReply - public override PacketType Type { get { return PacketType.UserLoginLocationReply; } } - /// URLBlock block - public URLBlockBlock URLBlock; - /// SimulatorBlock block - public SimulatorBlockBlock SimulatorBlock; - /// RegionInfo block - public RegionInfoBlock RegionInfo; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.UserLoginLocationReply + public override PacketType Type { get { return PacketType.UserLoginLocationReply; } } + /// URLBlock block + public URLBlockBlock URLBlock; + /// SimulatorBlock block + public SimulatorBlockBlock SimulatorBlock; + /// RegionInfo block + public RegionInfoBlock RegionInfo; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public UserLoginLocationReplyPacket() - { - Header = new LowHeader(); - Header.ID = 384; - Header.Reliable = true; - Header.Zerocoded = true; - URLBlock = new URLBlockBlock(); - SimulatorBlock = new SimulatorBlockBlock(); - RegionInfo = new RegionInfoBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 384; + Header.Reliable = true; + Header.Zerocoded = true; + URLBlock = new URLBlockBlock(); + SimulatorBlock = new SimulatorBlockBlock(); + RegionInfo = new RegionInfoBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public UserLoginLocationReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - URLBlock = new URLBlockBlock(bytes, ref i); - SimulatorBlock = new SimulatorBlockBlock(bytes, ref i); - RegionInfo = new RegionInfoBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + URLBlock = new URLBlockBlock(bytes, ref i); + SimulatorBlock = new SimulatorBlockBlock(bytes, ref i); + RegionInfo = new RegionInfoBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public UserLoginLocationReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - URLBlock = new URLBlockBlock(bytes, ref i); - SimulatorBlock = new SimulatorBlockBlock(bytes, ref i); - RegionInfo = new RegionInfoBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + URLBlock = new URLBlockBlock(bytes, ref i); + SimulatorBlock = new SimulatorBlockBlock(bytes, ref i); + RegionInfo = new RegionInfoBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += URLBlock.Length; length += SimulatorBlock.Length; length += RegionInfo.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - URLBlock.ToBytes(bytes, ref i); - SimulatorBlock.ToBytes(bytes, ref i); - RegionInfo.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += URLBlock.Length; length += SimulatorBlock.Length; length += RegionInfo.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + URLBlock.ToBytes(bytes, ref i); + SimulatorBlock.ToBytes(bytes, ref i); + RegionInfo.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- UserLoginLocationReply ---\n"; - output += URLBlock.ToString() + "\n"; - output += SimulatorBlock.ToString() + "\n"; - output += RegionInfo.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- UserLoginLocationReply ---\n"; + output += URLBlock.ToString() + "\n"; + output += SimulatorBlock.ToString() + "\n"; + output += RegionInfo.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// UserSimLocationReply packet + + /// UserSimLocationReply packet public class UserSimLocationReplyPacket : Packet - { - /// SimulatorBlock block + { + /// SimulatorBlock block public class SimulatorBlockBlock - { - private byte[] _simname; - /// SimName field + { + private byte[] _simname; + /// SimName field public byte[] SimName - { - get { return _simname; } + { + get { return _simname; } set - { - if (value == null) { _simname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _simname = new byte[value.Length]; Array.Copy(value, _simname, value.Length); } + { + if (value == null) { _simname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _simname = new byte[value.Length]; Array.Copy(value, _simname, value.Length); } } - } - /// AccessOK field - public byte AccessOK; - /// SimHandle field - public ulong SimHandle; - - /// Length of this block serialized in bytes + } + /// AccessOK field + public byte AccessOK; + /// SimHandle field + public ulong SimHandle; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 9; - if (SimName != null) { length += 1 + SimName.Length; } - return length; + { + int length = 9; + if (SimName != null) { length += 1 + SimName.Length; } + return length; } } - - /// Default constructor - public SimulatorBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public SimulatorBlockBlock() { } + /// Constructor for building the block from a byte array public SimulatorBlockBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _simname = new byte[length]; - Array.Copy(bytes, i, _simname, 0, length); i += length; - AccessOK = (byte)bytes[i++]; - SimHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + { + length = (ushort)bytes[i++]; + _simname = new byte[length]; + Array.Copy(bytes, i, _simname, 0, length); i += length; + AccessOK = (byte)bytes[i++]; + SimHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(SimName == null) { Console.WriteLine("Warning: SimName is null, in " + this.GetType()); } - bytes[i++] = (byte)SimName.Length; - Array.Copy(SimName, 0, bytes, i, SimName.Length); i += SimName.Length; - bytes[i++] = AccessOK; - bytes[i++] = (byte)(SimHandle % 256); - bytes[i++] = (byte)((SimHandle >> 8) % 256); - bytes[i++] = (byte)((SimHandle >> 16) % 256); - bytes[i++] = (byte)((SimHandle >> 24) % 256); - bytes[i++] = (byte)((SimHandle >> 32) % 256); - bytes[i++] = (byte)((SimHandle >> 40) % 256); - bytes[i++] = (byte)((SimHandle >> 48) % 256); - bytes[i++] = (byte)((SimHandle >> 56) % 256); + { + if(SimName == null) { Console.WriteLine("Warning: SimName is null, in " + this.GetType()); } + bytes[i++] = (byte)SimName.Length; + Array.Copy(SimName, 0, bytes, i, SimName.Length); i += SimName.Length; + bytes[i++] = AccessOK; + bytes[i++] = (byte)(SimHandle % 256); + bytes[i++] = (byte)((SimHandle >> 8) % 256); + bytes[i++] = (byte)((SimHandle >> 16) % 256); + bytes[i++] = (byte)((SimHandle >> 24) % 256); + bytes[i++] = (byte)((SimHandle >> 32) % 256); + bytes[i++] = (byte)((SimHandle >> 40) % 256); + bytes[i++] = (byte)((SimHandle >> 48) % 256); + bytes[i++] = (byte)((SimHandle >> 56) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- SimulatorBlock --\n"; - output += Helpers.FieldToString(SimName, "SimName") + "\n"; - output += "AccessOK: " + AccessOK.ToString() + "\n"; - output += "SimHandle: " + SimHandle.ToString() + "\n"; + { + string output = "-- SimulatorBlock --\n"; + output += Helpers.FieldToString(SimName, "SimName") + "\n"; + output += "AccessOK: " + AccessOK.ToString() + "\n"; + output += "SimHandle: " + SimHandle.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.UserSimLocationReply - public override PacketType Type { get { return PacketType.UserSimLocationReply; } } - /// SimulatorBlock block - public SimulatorBlockBlock SimulatorBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.UserSimLocationReply + public override PacketType Type { get { return PacketType.UserSimLocationReply; } } + /// SimulatorBlock block + public SimulatorBlockBlock SimulatorBlock; + + /// Default constructor public UserSimLocationReplyPacket() - { - Header = new LowHeader(); - Header.ID = 385; - Header.Reliable = true; - SimulatorBlock = new SimulatorBlockBlock(); + { + Header = new LowHeader(); + Header.ID = 385; + Header.Reliable = true; + SimulatorBlock = new SimulatorBlockBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public UserSimLocationReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - SimulatorBlock = new SimulatorBlockBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + SimulatorBlock = new SimulatorBlockBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public UserSimLocationReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - SimulatorBlock = new SimulatorBlockBlock(bytes, ref i); + { + Header = head; + SimulatorBlock = new SimulatorBlockBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += SimulatorBlock.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - SimulatorBlock.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += SimulatorBlock.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + SimulatorBlock.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- UserSimLocationReply ---\n"; - output += SimulatorBlock.ToString() + "\n"; + { + string output = "--- UserSimLocationReply ---\n"; + output += SimulatorBlock.ToString() + "\n"; return output; } - + } - - /// UserListReply packet + + /// UserListReply packet public class UserListReplyPacket : Packet - { - /// UserBlock block + { + /// UserBlock block public class UserBlockBlock - { - private byte[] _lastname; - /// LastName field + { + private byte[] _lastname; + /// LastName field public byte[] LastName - { - get { return _lastname; } + { + get { return _lastname; } set - { - if (value == null) { _lastname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _lastname = new byte[value.Length]; Array.Copy(value, _lastname, value.Length); } + { + if (value == null) { _lastname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _lastname = new byte[value.Length]; Array.Copy(value, _lastname, value.Length); } } - } - private byte[] _firstname; - /// FirstName field + } + private byte[] _firstname; + /// FirstName field public byte[] FirstName - { - get { return _firstname; } + { + get { return _firstname; } set - { - if (value == null) { _firstname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _firstname = new byte[value.Length]; Array.Copy(value, _firstname, value.Length); } + { + if (value == null) { _firstname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _firstname = new byte[value.Length]; Array.Copy(value, _firstname, value.Length); } } - } - /// Status field - public byte Status; - - /// Length of this block serialized in bytes + } + /// Status field + public byte Status; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 1; - if (LastName != null) { length += 1 + LastName.Length; } - if (FirstName != null) { length += 1 + FirstName.Length; } - return length; + { + int length = 1; + if (LastName != null) { length += 1 + LastName.Length; } + if (FirstName != null) { length += 1 + FirstName.Length; } + return length; } } - - /// Default constructor - public UserBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public UserBlockBlock() { } + /// Constructor for building the block from a byte array public UserBlockBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _lastname = new byte[length]; - Array.Copy(bytes, i, _lastname, 0, length); i += length; - length = (ushort)bytes[i++]; - _firstname = new byte[length]; - Array.Copy(bytes, i, _firstname, 0, length); i += length; - Status = (byte)bytes[i++]; + { + length = (ushort)bytes[i++]; + _lastname = new byte[length]; + Array.Copy(bytes, i, _lastname, 0, length); i += length; + length = (ushort)bytes[i++]; + _firstname = new byte[length]; + Array.Copy(bytes, i, _firstname, 0, length); i += length; + Status = (byte)bytes[i++]; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(LastName == null) { Console.WriteLine("Warning: LastName is null, in " + this.GetType()); } - bytes[i++] = (byte)LastName.Length; - Array.Copy(LastName, 0, bytes, i, LastName.Length); i += LastName.Length; - if(FirstName == null) { Console.WriteLine("Warning: FirstName is null, in " + this.GetType()); } - bytes[i++] = (byte)FirstName.Length; - Array.Copy(FirstName, 0, bytes, i, FirstName.Length); i += FirstName.Length; - bytes[i++] = Status; + { + if(LastName == null) { Console.WriteLine("Warning: LastName is null, in " + this.GetType()); } + bytes[i++] = (byte)LastName.Length; + Array.Copy(LastName, 0, bytes, i, LastName.Length); i += LastName.Length; + if(FirstName == null) { Console.WriteLine("Warning: FirstName is null, in " + this.GetType()); } + bytes[i++] = (byte)FirstName.Length; + Array.Copy(FirstName, 0, bytes, i, FirstName.Length); i += FirstName.Length; + bytes[i++] = Status; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- UserBlock --\n"; - output += Helpers.FieldToString(LastName, "LastName") + "\n"; - output += Helpers.FieldToString(FirstName, "FirstName") + "\n"; - output += "Status: " + Status.ToString() + "\n"; + { + string output = "-- UserBlock --\n"; + output += Helpers.FieldToString(LastName, "LastName") + "\n"; + output += Helpers.FieldToString(FirstName, "FirstName") + "\n"; + output += "Status: " + Status.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.UserListReply - public override PacketType Type { get { return PacketType.UserListReply; } } - /// UserBlock block - public UserBlockBlock[] UserBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.UserListReply + public override PacketType Type { get { return PacketType.UserListReply; } } + /// UserBlock block + public UserBlockBlock[] UserBlock; + + /// Default constructor public UserListReplyPacket() - { - Header = new LowHeader(); - Header.ID = 386; - Header.Reliable = true; - UserBlock = new UserBlockBlock[0]; + { + Header = new LowHeader(); + Header.ID = 386; + Header.Reliable = true; + UserBlock = new UserBlockBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public UserListReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - UserBlock = new UserBlockBlock[count]; - for (int j = 0; j < count; j++) - { UserBlock[j] = new UserBlockBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + UserBlock = new UserBlockBlock[count]; + for (int j = 0; j < count; j++) + { UserBlock[j] = new UserBlockBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public UserListReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - UserBlock = new UserBlockBlock[count]; - for (int j = 0; j < count; j++) - { UserBlock[j] = new UserBlockBlock(bytes, ref i); } + { + Header = head; + int count = (int)bytes[i++]; + UserBlock = new UserBlockBlock[count]; + for (int j = 0; j < count; j++) + { UserBlock[j] = new UserBlockBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; -; - length++; - for (int j = 0; j < UserBlock.Length; j++) { length += UserBlock[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)UserBlock.Length; - for (int j = 0; j < UserBlock.Length; j++) { UserBlock[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; +; + length++; + for (int j = 0; j < UserBlock.Length; j++) { length += UserBlock[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)UserBlock.Length; + for (int j = 0; j < UserBlock.Length; j++) { UserBlock[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- UserListReply ---\n"; + { + string output = "--- UserListReply ---\n"; for (int j = 0; j < UserBlock.Length; j++) - { + { output += UserBlock[j].ToString() + "\n"; - } + } return output; } - + } - - /// OnlineNotification packet + + /// OnlineNotification packet public class OnlineNotificationPacket : Packet - { - /// AgentBlock block + { + /// AgentBlock block public class AgentBlockBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentBlockBlock() { } + /// Constructor for building the block from a byte array public AgentBlockBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentBlock --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentBlock --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.OnlineNotification - public override PacketType Type { get { return PacketType.OnlineNotification; } } - /// AgentBlock block - public AgentBlockBlock[] AgentBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.OnlineNotification + public override PacketType Type { get { return PacketType.OnlineNotification; } } + /// AgentBlock block + public AgentBlockBlock[] AgentBlock; + + /// Default constructor public OnlineNotificationPacket() - { - Header = new LowHeader(); - Header.ID = 387; - Header.Reliable = true; - AgentBlock = new AgentBlockBlock[0]; + { + Header = new LowHeader(); + Header.ID = 387; + Header.Reliable = true; + AgentBlock = new AgentBlockBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public OnlineNotificationPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - AgentBlock = new AgentBlockBlock[count]; - for (int j = 0; j < count; j++) - { AgentBlock[j] = new AgentBlockBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + AgentBlock = new AgentBlockBlock[count]; + for (int j = 0; j < count; j++) + { AgentBlock[j] = new AgentBlockBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public OnlineNotificationPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - AgentBlock = new AgentBlockBlock[count]; - for (int j = 0; j < count; j++) - { AgentBlock[j] = new AgentBlockBlock(bytes, ref i); } + { + Header = head; + int count = (int)bytes[i++]; + AgentBlock = new AgentBlockBlock[count]; + for (int j = 0; j < count; j++) + { AgentBlock[j] = new AgentBlockBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; -; - length++; - for (int j = 0; j < AgentBlock.Length; j++) { length += AgentBlock[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)AgentBlock.Length; - for (int j = 0; j < AgentBlock.Length; j++) { AgentBlock[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; +; + length++; + for (int j = 0; j < AgentBlock.Length; j++) { length += AgentBlock[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)AgentBlock.Length; + for (int j = 0; j < AgentBlock.Length; j++) { AgentBlock[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- OnlineNotification ---\n"; + { + string output = "--- OnlineNotification ---\n"; for (int j = 0; j < AgentBlock.Length; j++) - { + { output += AgentBlock[j].ToString() + "\n"; - } + } return output; } - + } - - /// OfflineNotification packet + + /// OfflineNotification packet public class OfflineNotificationPacket : Packet - { - /// AgentBlock block + { + /// AgentBlock block public class AgentBlockBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentBlockBlock() { } + /// Constructor for building the block from a byte array public AgentBlockBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentBlock --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentBlock --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.OfflineNotification - public override PacketType Type { get { return PacketType.OfflineNotification; } } - /// AgentBlock block - public AgentBlockBlock[] AgentBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.OfflineNotification + public override PacketType Type { get { return PacketType.OfflineNotification; } } + /// AgentBlock block + public AgentBlockBlock[] AgentBlock; + + /// Default constructor public OfflineNotificationPacket() - { - Header = new LowHeader(); - Header.ID = 388; - Header.Reliable = true; - AgentBlock = new AgentBlockBlock[0]; + { + Header = new LowHeader(); + Header.ID = 388; + Header.Reliable = true; + AgentBlock = new AgentBlockBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public OfflineNotificationPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - AgentBlock = new AgentBlockBlock[count]; - for (int j = 0; j < count; j++) - { AgentBlock[j] = new AgentBlockBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + AgentBlock = new AgentBlockBlock[count]; + for (int j = 0; j < count; j++) + { AgentBlock[j] = new AgentBlockBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public OfflineNotificationPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - AgentBlock = new AgentBlockBlock[count]; - for (int j = 0; j < count; j++) - { AgentBlock[j] = new AgentBlockBlock(bytes, ref i); } + { + Header = head; + int count = (int)bytes[i++]; + AgentBlock = new AgentBlockBlock[count]; + for (int j = 0; j < count; j++) + { AgentBlock[j] = new AgentBlockBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; -; - length++; - for (int j = 0; j < AgentBlock.Length; j++) { length += AgentBlock[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)AgentBlock.Length; - for (int j = 0; j < AgentBlock.Length; j++) { AgentBlock[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; +; + length++; + for (int j = 0; j < AgentBlock.Length; j++) { length += AgentBlock[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)AgentBlock.Length; + for (int j = 0; j < AgentBlock.Length; j++) { AgentBlock[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- OfflineNotification ---\n"; + { + string output = "--- OfflineNotification ---\n"; for (int j = 0; j < AgentBlock.Length; j++) - { + { output += AgentBlock[j].ToString() + "\n"; - } + } return output; } - + } - - /// SetStartLocationRequest packet + + /// SetStartLocationRequest packet public class SetStartLocationRequestPacket : Packet - { - /// StartLocationData block + { + /// StartLocationData block public class StartLocationDataBlock - { - /// LocationPos field - public LLVector3 LocationPos; - private byte[] _simname; - /// SimName field + { + /// LocationPos field + public LLVector3 LocationPos; + private byte[] _simname; + /// SimName field public byte[] SimName - { - get { return _simname; } + { + get { return _simname; } set - { - if (value == null) { _simname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _simname = new byte[value.Length]; Array.Copy(value, _simname, value.Length); } + { + if (value == null) { _simname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _simname = new byte[value.Length]; Array.Copy(value, _simname, value.Length); } } - } - /// LocationID field - public uint LocationID; - /// LocationLookAt field - public LLVector3 LocationLookAt; - - /// Length of this block serialized in bytes + } + /// LocationID field + public uint LocationID; + /// LocationLookAt field + public LLVector3 LocationLookAt; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 28; - if (SimName != null) { length += 1 + SimName.Length; } - return length; + { + int length = 28; + if (SimName != null) { length += 1 + SimName.Length; } + return length; } } - - /// Default constructor - public StartLocationDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public StartLocationDataBlock() { } + /// Constructor for building the block from a byte array public StartLocationDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - LocationPos = new LLVector3(bytes, i); i += 12; - length = (ushort)bytes[i++]; - _simname = new byte[length]; - Array.Copy(bytes, i, _simname, 0, length); i += length; - LocationID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - LocationLookAt = new LLVector3(bytes, i); i += 12; + { + LocationPos = new LLVector3(bytes, i); i += 12; + length = (ushort)bytes[i++]; + _simname = new byte[length]; + Array.Copy(bytes, i, _simname, 0, length); i += length; + LocationID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + LocationLookAt = new LLVector3(bytes, i); i += 12; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(LocationPos == null) { Console.WriteLine("Warning: LocationPos is null, in " + this.GetType()); } - Array.Copy(LocationPos.GetBytes(), 0, bytes, i, 12); i += 12; - if(SimName == null) { Console.WriteLine("Warning: SimName is null, in " + this.GetType()); } - bytes[i++] = (byte)SimName.Length; - Array.Copy(SimName, 0, bytes, i, SimName.Length); i += SimName.Length; - bytes[i++] = (byte)(LocationID % 256); - bytes[i++] = (byte)((LocationID >> 8) % 256); - bytes[i++] = (byte)((LocationID >> 16) % 256); - bytes[i++] = (byte)((LocationID >> 24) % 256); - if(LocationLookAt == null) { Console.WriteLine("Warning: LocationLookAt is null, in " + this.GetType()); } - Array.Copy(LocationLookAt.GetBytes(), 0, bytes, i, 12); i += 12; + { + if(LocationPos == null) { Console.WriteLine("Warning: LocationPos is null, in " + this.GetType()); } + Array.Copy(LocationPos.GetBytes(), 0, bytes, i, 12); i += 12; + if(SimName == null) { Console.WriteLine("Warning: SimName is null, in " + this.GetType()); } + bytes[i++] = (byte)SimName.Length; + Array.Copy(SimName, 0, bytes, i, SimName.Length); i += SimName.Length; + bytes[i++] = (byte)(LocationID % 256); + bytes[i++] = (byte)((LocationID >> 8) % 256); + bytes[i++] = (byte)((LocationID >> 16) % 256); + bytes[i++] = (byte)((LocationID >> 24) % 256); + if(LocationLookAt == null) { Console.WriteLine("Warning: LocationLookAt is null, in " + this.GetType()); } + Array.Copy(LocationLookAt.GetBytes(), 0, bytes, i, 12); i += 12; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- StartLocationData --\n"; - output += "LocationPos: " + LocationPos.ToString() + "\n"; - output += Helpers.FieldToString(SimName, "SimName") + "\n"; - output += "LocationID: " + LocationID.ToString() + "\n"; - output += "LocationLookAt: " + LocationLookAt.ToString() + "\n"; + { + string output = "-- StartLocationData --\n"; + output += "LocationPos: " + LocationPos.ToString() + "\n"; + output += Helpers.FieldToString(SimName, "SimName") + "\n"; + output += "LocationID: " + LocationID.ToString() + "\n"; + output += "LocationLookAt: " + LocationLookAt.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.SetStartLocationRequest - public override PacketType Type { get { return PacketType.SetStartLocationRequest; } } - /// StartLocationData block - public StartLocationDataBlock StartLocationData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.SetStartLocationRequest + public override PacketType Type { get { return PacketType.SetStartLocationRequest; } } + /// StartLocationData block + public StartLocationDataBlock StartLocationData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public SetStartLocationRequestPacket() - { - Header = new LowHeader(); - Header.ID = 389; - Header.Reliable = true; - Header.Zerocoded = true; - StartLocationData = new StartLocationDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 389; + Header.Reliable = true; + Header.Zerocoded = true; + StartLocationData = new StartLocationDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public SetStartLocationRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - StartLocationData = new StartLocationDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + StartLocationData = new StartLocationDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public SetStartLocationRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - StartLocationData = new StartLocationDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + StartLocationData = new StartLocationDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += StartLocationData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - StartLocationData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += StartLocationData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + StartLocationData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- SetStartLocationRequest ---\n"; - output += StartLocationData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- SetStartLocationRequest ---\n"; + output += StartLocationData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// SetStartLocation packet + + /// SetStartLocation packet public class SetStartLocationPacket : Packet - { - /// StartLocationData block + { + /// StartLocationData block public class StartLocationDataBlock - { - /// LocationPos field - public LLVector3 LocationPos; - /// AgentID field - public LLUUID AgentID; - /// RegionID field - public LLUUID RegionID; - /// RegionHandle field - public ulong RegionHandle; - /// LocationID field - public uint LocationID; - /// LocationLookAt field - public LLVector3 LocationLookAt; - - /// Length of this block serialized in bytes + { + /// LocationPos field + public LLVector3 LocationPos; + /// AgentID field + public LLUUID AgentID; + /// RegionID field + public LLUUID RegionID; + /// RegionHandle field + public ulong RegionHandle; + /// LocationID field + public uint LocationID; + /// LocationLookAt field + public LLVector3 LocationLookAt; + + /// Length of this block serialized in bytes public int Length { get - { - return 68; + { + return 68; } } - - /// Default constructor - public StartLocationDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public StartLocationDataBlock() { } + /// Constructor for building the block from a byte array public StartLocationDataBlock(byte[] bytes, ref int i) - { + { try - { - LocationPos = new LLVector3(bytes, i); i += 12; - AgentID = new LLUUID(bytes, i); i += 16; - RegionID = new LLUUID(bytes, i); i += 16; - RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); - LocationID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - LocationLookAt = new LLVector3(bytes, i); i += 12; + { + LocationPos = new LLVector3(bytes, i); i += 12; + AgentID = new LLUUID(bytes, i); i += 16; + RegionID = new LLUUID(bytes, i); i += 16; + RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + LocationID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + LocationLookAt = new LLVector3(bytes, i); i += 12; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(LocationPos == null) { Console.WriteLine("Warning: LocationPos is null, in " + this.GetType()); } - Array.Copy(LocationPos.GetBytes(), 0, bytes, i, 12); i += 12; - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(RegionID == null) { Console.WriteLine("Warning: RegionID is null, in " + this.GetType()); } - Array.Copy(RegionID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(RegionHandle % 256); - bytes[i++] = (byte)((RegionHandle >> 8) % 256); - bytes[i++] = (byte)((RegionHandle >> 16) % 256); - bytes[i++] = (byte)((RegionHandle >> 24) % 256); - bytes[i++] = (byte)((RegionHandle >> 32) % 256); - bytes[i++] = (byte)((RegionHandle >> 40) % 256); - bytes[i++] = (byte)((RegionHandle >> 48) % 256); - bytes[i++] = (byte)((RegionHandle >> 56) % 256); - bytes[i++] = (byte)(LocationID % 256); - bytes[i++] = (byte)((LocationID >> 8) % 256); - bytes[i++] = (byte)((LocationID >> 16) % 256); - bytes[i++] = (byte)((LocationID >> 24) % 256); - if(LocationLookAt == null) { Console.WriteLine("Warning: LocationLookAt is null, in " + this.GetType()); } - Array.Copy(LocationLookAt.GetBytes(), 0, bytes, i, 12); i += 12; + { + if(LocationPos == null) { Console.WriteLine("Warning: LocationPos is null, in " + this.GetType()); } + Array.Copy(LocationPos.GetBytes(), 0, bytes, i, 12); i += 12; + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(RegionID == null) { Console.WriteLine("Warning: RegionID is null, in " + this.GetType()); } + Array.Copy(RegionID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(RegionHandle % 256); + bytes[i++] = (byte)((RegionHandle >> 8) % 256); + bytes[i++] = (byte)((RegionHandle >> 16) % 256); + bytes[i++] = (byte)((RegionHandle >> 24) % 256); + bytes[i++] = (byte)((RegionHandle >> 32) % 256); + bytes[i++] = (byte)((RegionHandle >> 40) % 256); + bytes[i++] = (byte)((RegionHandle >> 48) % 256); + bytes[i++] = (byte)((RegionHandle >> 56) % 256); + bytes[i++] = (byte)(LocationID % 256); + bytes[i++] = (byte)((LocationID >> 8) % 256); + bytes[i++] = (byte)((LocationID >> 16) % 256); + bytes[i++] = (byte)((LocationID >> 24) % 256); + if(LocationLookAt == null) { Console.WriteLine("Warning: LocationLookAt is null, in " + this.GetType()); } + Array.Copy(LocationLookAt.GetBytes(), 0, bytes, i, 12); i += 12; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- StartLocationData --\n"; - output += "LocationPos: " + LocationPos.ToString() + "\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "RegionID: " + RegionID.ToString() + "\n"; - output += "RegionHandle: " + RegionHandle.ToString() + "\n"; - output += "LocationID: " + LocationID.ToString() + "\n"; - output += "LocationLookAt: " + LocationLookAt.ToString() + "\n"; + { + string output = "-- StartLocationData --\n"; + output += "LocationPos: " + LocationPos.ToString() + "\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "RegionID: " + RegionID.ToString() + "\n"; + output += "RegionHandle: " + RegionHandle.ToString() + "\n"; + output += "LocationID: " + LocationID.ToString() + "\n"; + output += "LocationLookAt: " + LocationLookAt.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.SetStartLocation - public override PacketType Type { get { return PacketType.SetStartLocation; } } - /// StartLocationData block - public StartLocationDataBlock StartLocationData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.SetStartLocation + public override PacketType Type { get { return PacketType.SetStartLocation; } } + /// StartLocationData block + public StartLocationDataBlock StartLocationData; + + /// Default constructor public SetStartLocationPacket() - { - Header = new LowHeader(); - Header.ID = 390; - Header.Reliable = true; - Header.Zerocoded = true; - StartLocationData = new StartLocationDataBlock(); + { + Header = new LowHeader(); + Header.ID = 390; + Header.Reliable = true; + Header.Zerocoded = true; + StartLocationData = new StartLocationDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public SetStartLocationPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - StartLocationData = new StartLocationDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + StartLocationData = new StartLocationDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public SetStartLocationPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - StartLocationData = new StartLocationDataBlock(bytes, ref i); + { + Header = head; + StartLocationData = new StartLocationDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += StartLocationData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - StartLocationData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += StartLocationData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + StartLocationData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- SetStartLocation ---\n"; - output += StartLocationData.ToString() + "\n"; + { + string output = "--- SetStartLocation ---\n"; + output += StartLocationData.ToString() + "\n"; return output; } - + } - - /// UserLoginLocationRequest packet + + /// UserLoginLocationRequest packet public class UserLoginLocationRequestPacket : Packet - { - /// URLBlock block + { + /// URLBlock block public class URLBlockBlock - { - private byte[] _simname; - /// SimName field + { + private byte[] _simname; + /// SimName field public byte[] SimName - { - get { return _simname; } + { + get { return _simname; } set - { - if (value == null) { _simname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _simname = new byte[value.Length]; Array.Copy(value, _simname, value.Length); } + { + if (value == null) { _simname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _simname = new byte[value.Length]; Array.Copy(value, _simname, value.Length); } } - } - /// Pos field - public LLVector3 Pos; - - /// Length of this block serialized in bytes + } + /// Pos field + public LLVector3 Pos; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 12; - if (SimName != null) { length += 1 + SimName.Length; } - return length; + { + int length = 12; + if (SimName != null) { length += 1 + SimName.Length; } + return length; } } - - /// Default constructor - public URLBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public URLBlockBlock() { } + /// Constructor for building the block from a byte array public URLBlockBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _simname = new byte[length]; - Array.Copy(bytes, i, _simname, 0, length); i += length; - Pos = new LLVector3(bytes, i); i += 12; + { + length = (ushort)bytes[i++]; + _simname = new byte[length]; + Array.Copy(bytes, i, _simname, 0, length); i += length; + Pos = new LLVector3(bytes, i); i += 12; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(SimName == null) { Console.WriteLine("Warning: SimName is null, in " + this.GetType()); } - bytes[i++] = (byte)SimName.Length; - Array.Copy(SimName, 0, bytes, i, SimName.Length); i += SimName.Length; - if(Pos == null) { Console.WriteLine("Warning: Pos is null, in " + this.GetType()); } - Array.Copy(Pos.GetBytes(), 0, bytes, i, 12); i += 12; + { + if(SimName == null) { Console.WriteLine("Warning: SimName is null, in " + this.GetType()); } + bytes[i++] = (byte)SimName.Length; + Array.Copy(SimName, 0, bytes, i, SimName.Length); i += SimName.Length; + if(Pos == null) { Console.WriteLine("Warning: Pos is null, in " + this.GetType()); } + Array.Copy(Pos.GetBytes(), 0, bytes, i, 12); i += 12; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- URLBlock --\n"; - output += Helpers.FieldToString(SimName, "SimName") + "\n"; - output += "Pos: " + Pos.ToString() + "\n"; + { + string output = "-- URLBlock --\n"; + output += Helpers.FieldToString(SimName, "SimName") + "\n"; + output += "Pos: " + Pos.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// PositionBlock block + + /// PositionBlock block public class PositionBlockBlock - { - /// ViewerRegion field - public ulong ViewerRegion; - /// ViewerPosition field - public LLVector3 ViewerPosition; - - /// Length of this block serialized in bytes + { + /// ViewerRegion field + public ulong ViewerRegion; + /// ViewerPosition field + public LLVector3 ViewerPosition; + + /// Length of this block serialized in bytes public int Length { get - { - return 20; + { + return 20; } } - - /// Default constructor - public PositionBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public PositionBlockBlock() { } + /// Constructor for building the block from a byte array public PositionBlockBlock(byte[] bytes, ref int i) - { + { try - { - ViewerRegion = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); - ViewerPosition = new LLVector3(bytes, i); i += 12; + { + ViewerRegion = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + ViewerPosition = new LLVector3(bytes, i); i += 12; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(ViewerRegion % 256); - bytes[i++] = (byte)((ViewerRegion >> 8) % 256); - bytes[i++] = (byte)((ViewerRegion >> 16) % 256); - bytes[i++] = (byte)((ViewerRegion >> 24) % 256); - bytes[i++] = (byte)((ViewerRegion >> 32) % 256); - bytes[i++] = (byte)((ViewerRegion >> 40) % 256); - bytes[i++] = (byte)((ViewerRegion >> 48) % 256); - bytes[i++] = (byte)((ViewerRegion >> 56) % 256); - if(ViewerPosition == null) { Console.WriteLine("Warning: ViewerPosition is null, in " + this.GetType()); } - Array.Copy(ViewerPosition.GetBytes(), 0, bytes, i, 12); i += 12; + { + bytes[i++] = (byte)(ViewerRegion % 256); + bytes[i++] = (byte)((ViewerRegion >> 8) % 256); + bytes[i++] = (byte)((ViewerRegion >> 16) % 256); + bytes[i++] = (byte)((ViewerRegion >> 24) % 256); + bytes[i++] = (byte)((ViewerRegion >> 32) % 256); + bytes[i++] = (byte)((ViewerRegion >> 40) % 256); + bytes[i++] = (byte)((ViewerRegion >> 48) % 256); + bytes[i++] = (byte)((ViewerRegion >> 56) % 256); + if(ViewerPosition == null) { Console.WriteLine("Warning: ViewerPosition is null, in " + this.GetType()); } + Array.Copy(ViewerPosition.GetBytes(), 0, bytes, i, 12); i += 12; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- PositionBlock --\n"; - output += "ViewerRegion: " + ViewerRegion.ToString() + "\n"; - output += "ViewerPosition: " + ViewerPosition.ToString() + "\n"; + { + string output = "-- PositionBlock --\n"; + output += "ViewerRegion: " + ViewerRegion.ToString() + "\n"; + output += "ViewerPosition: " + ViewerPosition.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// UserBlock block + + /// UserBlock block public class UserBlockBlock - { - /// FirstLogin field - public bool FirstLogin; - /// TravelAccess field - public byte TravelAccess; - /// LimitedToEstate field - public uint LimitedToEstate; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// FirstLogin field + public bool FirstLogin; + /// TravelAccess field + public byte TravelAccess; + /// LimitedToEstate field + public uint LimitedToEstate; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 22; + { + return 22; } } - - /// Default constructor - public UserBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public UserBlockBlock() { } + /// Constructor for building the block from a byte array public UserBlockBlock(byte[] bytes, ref int i) - { + { try - { - FirstLogin = (bytes[i++] != 0) ? (bool)true : (bool)false; - TravelAccess = (byte)bytes[i++]; - LimitedToEstate = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - SessionID = new LLUUID(bytes, i); i += 16; + { + FirstLogin = (bytes[i++] != 0) ? (bool)true : (bool)false; + TravelAccess = (byte)bytes[i++]; + LimitedToEstate = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)((FirstLogin) ? 1 : 0); - bytes[i++] = TravelAccess; - bytes[i++] = (byte)(LimitedToEstate % 256); - bytes[i++] = (byte)((LimitedToEstate >> 8) % 256); - bytes[i++] = (byte)((LimitedToEstate >> 16) % 256); - bytes[i++] = (byte)((LimitedToEstate >> 24) % 256); - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + bytes[i++] = (byte)((FirstLogin) ? 1 : 0); + bytes[i++] = TravelAccess; + bytes[i++] = (byte)(LimitedToEstate % 256); + bytes[i++] = (byte)((LimitedToEstate >> 8) % 256); + bytes[i++] = (byte)((LimitedToEstate >> 16) % 256); + bytes[i++] = (byte)((LimitedToEstate >> 24) % 256); + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- UserBlock --\n"; - output += "FirstLogin: " + FirstLogin.ToString() + "\n"; - output += "TravelAccess: " + TravelAccess.ToString() + "\n"; - output += "LimitedToEstate: " + LimitedToEstate.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- UserBlock --\n"; + output += "FirstLogin: " + FirstLogin.ToString() + "\n"; + output += "TravelAccess: " + TravelAccess.ToString() + "\n"; + output += "LimitedToEstate: " + LimitedToEstate.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.UserLoginLocationRequest - public override PacketType Type { get { return PacketType.UserLoginLocationRequest; } } - /// URLBlock block - public URLBlockBlock URLBlock; - /// PositionBlock block - public PositionBlockBlock PositionBlock; - /// UserBlock block - public UserBlockBlock UserBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.UserLoginLocationRequest + public override PacketType Type { get { return PacketType.UserLoginLocationRequest; } } + /// URLBlock block + public URLBlockBlock URLBlock; + /// PositionBlock block + public PositionBlockBlock PositionBlock; + /// UserBlock block + public UserBlockBlock UserBlock; + + /// Default constructor public UserLoginLocationRequestPacket() - { - Header = new LowHeader(); - Header.ID = 391; - Header.Reliable = true; - Header.Zerocoded = true; - URLBlock = new URLBlockBlock(); - PositionBlock = new PositionBlockBlock(); - UserBlock = new UserBlockBlock(); + { + Header = new LowHeader(); + Header.ID = 391; + Header.Reliable = true; + Header.Zerocoded = true; + URLBlock = new URLBlockBlock(); + PositionBlock = new PositionBlockBlock(); + UserBlock = new UserBlockBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public UserLoginLocationRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - URLBlock = new URLBlockBlock(bytes, ref i); - PositionBlock = new PositionBlockBlock(bytes, ref i); - UserBlock = new UserBlockBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + URLBlock = new URLBlockBlock(bytes, ref i); + PositionBlock = new PositionBlockBlock(bytes, ref i); + UserBlock = new UserBlockBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public UserLoginLocationRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - URLBlock = new URLBlockBlock(bytes, ref i); - PositionBlock = new PositionBlockBlock(bytes, ref i); - UserBlock = new UserBlockBlock(bytes, ref i); + { + Header = head; + URLBlock = new URLBlockBlock(bytes, ref i); + PositionBlock = new PositionBlockBlock(bytes, ref i); + UserBlock = new UserBlockBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += URLBlock.Length; length += PositionBlock.Length; length += UserBlock.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - URLBlock.ToBytes(bytes, ref i); - PositionBlock.ToBytes(bytes, ref i); - UserBlock.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += URLBlock.Length; length += PositionBlock.Length; length += UserBlock.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + URLBlock.ToBytes(bytes, ref i); + PositionBlock.ToBytes(bytes, ref i); + UserBlock.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- UserLoginLocationRequest ---\n"; - output += URLBlock.ToString() + "\n"; - output += PositionBlock.ToString() + "\n"; - output += UserBlock.ToString() + "\n"; + { + string output = "--- UserLoginLocationRequest ---\n"; + output += URLBlock.ToString() + "\n"; + output += PositionBlock.ToString() + "\n"; + output += UserBlock.ToString() + "\n"; return output; } - + } - - /// SpaceLoginLocationReply packet + + /// SpaceLoginLocationReply packet public class SpaceLoginLocationReplyPacket : Packet - { - /// SimulatorBlock block + { + /// SimulatorBlock block public class SimulatorBlockBlock - { - /// IP field - public uint IP; - private byte[] _name; - /// Name field + { + /// IP field + public uint IP; + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - /// Port field - public ushort Port; - /// SimAccess field - public byte SimAccess; - /// CircuitCode field - public uint CircuitCode; - - /// Length of this block serialized in bytes + } + /// Port field + public ushort Port; + /// SimAccess field + public byte SimAccess; + /// CircuitCode field + public uint CircuitCode; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 11; - if (Name != null) { length += 1 + Name.Length; } - return length; + { + int length = 11; + if (Name != null) { length += 1 + Name.Length; } + return length; } } - - /// Default constructor - public SimulatorBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public SimulatorBlockBlock() { } + /// Constructor for building the block from a byte array public SimulatorBlockBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - IP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; - Port = (ushort)((bytes[i++] << 8) + bytes[i++]); - SimAccess = (byte)bytes[i++]; - CircuitCode = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + IP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; + Port = (ushort)((bytes[i++] << 8) + bytes[i++]); + SimAccess = (byte)bytes[i++]; + CircuitCode = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(IP % 256); - bytes[i++] = (byte)((IP >> 8) % 256); - bytes[i++] = (byte)((IP >> 16) % 256); - bytes[i++] = (byte)((IP >> 24) % 256); - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; - bytes[i++] = (byte)((Port >> 8) % 256); - bytes[i++] = (byte)(Port % 256); - bytes[i++] = SimAccess; - bytes[i++] = (byte)(CircuitCode % 256); - bytes[i++] = (byte)((CircuitCode >> 8) % 256); - bytes[i++] = (byte)((CircuitCode >> 16) % 256); - bytes[i++] = (byte)((CircuitCode >> 24) % 256); + { + bytes[i++] = (byte)(IP % 256); + bytes[i++] = (byte)((IP >> 8) % 256); + bytes[i++] = (byte)((IP >> 16) % 256); + bytes[i++] = (byte)((IP >> 24) % 256); + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + bytes[i++] = (byte)((Port >> 8) % 256); + bytes[i++] = (byte)(Port % 256); + bytes[i++] = SimAccess; + bytes[i++] = (byte)(CircuitCode % 256); + bytes[i++] = (byte)((CircuitCode >> 8) % 256); + bytes[i++] = (byte)((CircuitCode >> 16) % 256); + bytes[i++] = (byte)((CircuitCode >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- SimulatorBlock --\n"; - output += "IP: " + IP.ToString() + "\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; - output += "Port: " + Port.ToString() + "\n"; - output += "SimAccess: " + SimAccess.ToString() + "\n"; - output += "CircuitCode: " + CircuitCode.ToString() + "\n"; + { + string output = "-- SimulatorBlock --\n"; + output += "IP: " + IP.ToString() + "\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; + output += "Port: " + Port.ToString() + "\n"; + output += "SimAccess: " + SimAccess.ToString() + "\n"; + output += "CircuitCode: " + CircuitCode.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// UserBlock block + + /// UserBlock block public class UserBlockBlock - { - /// LocationPos field - public LLVector3 LocationPos; - /// SessionID field - public LLUUID SessionID; - /// LocationID field - public uint LocationID; - /// LocationLookAt field - public LLVector3 LocationLookAt; - - /// Length of this block serialized in bytes + { + /// LocationPos field + public LLVector3 LocationPos; + /// SessionID field + public LLUUID SessionID; + /// LocationID field + public uint LocationID; + /// LocationLookAt field + public LLVector3 LocationLookAt; + + /// Length of this block serialized in bytes public int Length { get - { - return 44; + { + return 44; } } - - /// Default constructor - public UserBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public UserBlockBlock() { } + /// Constructor for building the block from a byte array public UserBlockBlock(byte[] bytes, ref int i) - { + { try - { - LocationPos = new LLVector3(bytes, i); i += 12; - SessionID = new LLUUID(bytes, i); i += 16; - LocationID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - LocationLookAt = new LLVector3(bytes, i); i += 12; + { + LocationPos = new LLVector3(bytes, i); i += 12; + SessionID = new LLUUID(bytes, i); i += 16; + LocationID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + LocationLookAt = new LLVector3(bytes, i); i += 12; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(LocationPos == null) { Console.WriteLine("Warning: LocationPos is null, in " + this.GetType()); } - Array.Copy(LocationPos.GetBytes(), 0, bytes, i, 12); i += 12; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(LocationID % 256); - bytes[i++] = (byte)((LocationID >> 8) % 256); - bytes[i++] = (byte)((LocationID >> 16) % 256); - bytes[i++] = (byte)((LocationID >> 24) % 256); - if(LocationLookAt == null) { Console.WriteLine("Warning: LocationLookAt is null, in " + this.GetType()); } - Array.Copy(LocationLookAt.GetBytes(), 0, bytes, i, 12); i += 12; + { + if(LocationPos == null) { Console.WriteLine("Warning: LocationPos is null, in " + this.GetType()); } + Array.Copy(LocationPos.GetBytes(), 0, bytes, i, 12); i += 12; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(LocationID % 256); + bytes[i++] = (byte)((LocationID >> 8) % 256); + bytes[i++] = (byte)((LocationID >> 16) % 256); + bytes[i++] = (byte)((LocationID >> 24) % 256); + if(LocationLookAt == null) { Console.WriteLine("Warning: LocationLookAt is null, in " + this.GetType()); } + Array.Copy(LocationLookAt.GetBytes(), 0, bytes, i, 12); i += 12; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- UserBlock --\n"; - output += "LocationPos: " + LocationPos.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "LocationID: " + LocationID.ToString() + "\n"; - output += "LocationLookAt: " + LocationLookAt.ToString() + "\n"; + { + string output = "-- UserBlock --\n"; + output += "LocationPos: " + LocationPos.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "LocationID: " + LocationID.ToString() + "\n"; + output += "LocationLookAt: " + LocationLookAt.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// RegionInfo block + + /// RegionInfo block public class RegionInfoBlock - { - /// SecPerDay field - public uint SecPerDay; - /// MetersPerGrid field - public float MetersPerGrid; - /// UsecSinceStart field - public ulong UsecSinceStart; - /// SecPerYear field - public uint SecPerYear; - /// GridsPerEdge field - public uint GridsPerEdge; - /// Handle field - public ulong Handle; - /// SunAngVelocity field - public LLVector3 SunAngVelocity; - /// SunDirection field - public LLVector3 SunDirection; - - /// Length of this block serialized in bytes + { + /// SecPerDay field + public uint SecPerDay; + /// MetersPerGrid field + public float MetersPerGrid; + /// UsecSinceStart field + public ulong UsecSinceStart; + /// SecPerYear field + public uint SecPerYear; + /// GridsPerEdge field + public uint GridsPerEdge; + /// Handle field + public ulong Handle; + /// SunAngVelocity field + public LLVector3 SunAngVelocity; + /// SunDirection field + public LLVector3 SunDirection; + + /// Length of this block serialized in bytes public int Length { get - { - return 56; + { + return 56; } } - - /// Default constructor - public RegionInfoBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public RegionInfoBlock() { } + /// Constructor for building the block from a byte array public RegionInfoBlock(byte[] bytes, ref int i) - { + { try - { - SecPerDay = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - MetersPerGrid = BitConverter.ToSingle(bytes, i); i += 4; - UsecSinceStart = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); - SecPerYear = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - GridsPerEdge = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Handle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); - SunAngVelocity = new LLVector3(bytes, i); i += 12; - SunDirection = new LLVector3(bytes, i); i += 12; + { + SecPerDay = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + MetersPerGrid = BitConverter.ToSingle(bytes, i); i += 4; + UsecSinceStart = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + SecPerYear = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + GridsPerEdge = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Handle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + SunAngVelocity = new LLVector3(bytes, i); i += 12; + SunDirection = new LLVector3(bytes, i); i += 12; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; - bytes[i++] = (byte)(SecPerDay % 256); - bytes[i++] = (byte)((SecPerDay >> 8) % 256); - bytes[i++] = (byte)((SecPerDay >> 16) % 256); - bytes[i++] = (byte)((SecPerDay >> 24) % 256); + { + byte[] ba; + bytes[i++] = (byte)(SecPerDay % 256); + bytes[i++] = (byte)((SecPerDay >> 8) % 256); + bytes[i++] = (byte)((SecPerDay >> 16) % 256); + bytes[i++] = (byte)((SecPerDay >> 24) % 256); ba = BitConverter.GetBytes(MetersPerGrid); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - bytes[i++] = (byte)(UsecSinceStart % 256); - bytes[i++] = (byte)((UsecSinceStart >> 8) % 256); - bytes[i++] = (byte)((UsecSinceStart >> 16) % 256); - bytes[i++] = (byte)((UsecSinceStart >> 24) % 256); - bytes[i++] = (byte)((UsecSinceStart >> 32) % 256); - bytes[i++] = (byte)((UsecSinceStart >> 40) % 256); - bytes[i++] = (byte)((UsecSinceStart >> 48) % 256); - bytes[i++] = (byte)((UsecSinceStart >> 56) % 256); - bytes[i++] = (byte)(SecPerYear % 256); - bytes[i++] = (byte)((SecPerYear >> 8) % 256); - bytes[i++] = (byte)((SecPerYear >> 16) % 256); - bytes[i++] = (byte)((SecPerYear >> 24) % 256); - bytes[i++] = (byte)(GridsPerEdge % 256); - bytes[i++] = (byte)((GridsPerEdge >> 8) % 256); - bytes[i++] = (byte)((GridsPerEdge >> 16) % 256); - bytes[i++] = (byte)((GridsPerEdge >> 24) % 256); - bytes[i++] = (byte)(Handle % 256); - bytes[i++] = (byte)((Handle >> 8) % 256); - bytes[i++] = (byte)((Handle >> 16) % 256); - bytes[i++] = (byte)((Handle >> 24) % 256); - bytes[i++] = (byte)((Handle >> 32) % 256); - bytes[i++] = (byte)((Handle >> 40) % 256); - bytes[i++] = (byte)((Handle >> 48) % 256); - bytes[i++] = (byte)((Handle >> 56) % 256); - if(SunAngVelocity == null) { Console.WriteLine("Warning: SunAngVelocity is null, in " + this.GetType()); } - Array.Copy(SunAngVelocity.GetBytes(), 0, bytes, i, 12); i += 12; - if(SunDirection == null) { Console.WriteLine("Warning: SunDirection is null, in " + this.GetType()); } - Array.Copy(SunDirection.GetBytes(), 0, bytes, i, 12); i += 12; + Array.Copy(ba, 0, bytes, i, 4); i += 4; + bytes[i++] = (byte)(UsecSinceStart % 256); + bytes[i++] = (byte)((UsecSinceStart >> 8) % 256); + bytes[i++] = (byte)((UsecSinceStart >> 16) % 256); + bytes[i++] = (byte)((UsecSinceStart >> 24) % 256); + bytes[i++] = (byte)((UsecSinceStart >> 32) % 256); + bytes[i++] = (byte)((UsecSinceStart >> 40) % 256); + bytes[i++] = (byte)((UsecSinceStart >> 48) % 256); + bytes[i++] = (byte)((UsecSinceStart >> 56) % 256); + bytes[i++] = (byte)(SecPerYear % 256); + bytes[i++] = (byte)((SecPerYear >> 8) % 256); + bytes[i++] = (byte)((SecPerYear >> 16) % 256); + bytes[i++] = (byte)((SecPerYear >> 24) % 256); + bytes[i++] = (byte)(GridsPerEdge % 256); + bytes[i++] = (byte)((GridsPerEdge >> 8) % 256); + bytes[i++] = (byte)((GridsPerEdge >> 16) % 256); + bytes[i++] = (byte)((GridsPerEdge >> 24) % 256); + bytes[i++] = (byte)(Handle % 256); + bytes[i++] = (byte)((Handle >> 8) % 256); + bytes[i++] = (byte)((Handle >> 16) % 256); + bytes[i++] = (byte)((Handle >> 24) % 256); + bytes[i++] = (byte)((Handle >> 32) % 256); + bytes[i++] = (byte)((Handle >> 40) % 256); + bytes[i++] = (byte)((Handle >> 48) % 256); + bytes[i++] = (byte)((Handle >> 56) % 256); + if(SunAngVelocity == null) { Console.WriteLine("Warning: SunAngVelocity is null, in " + this.GetType()); } + Array.Copy(SunAngVelocity.GetBytes(), 0, bytes, i, 12); i += 12; + if(SunDirection == null) { Console.WriteLine("Warning: SunDirection is null, in " + this.GetType()); } + Array.Copy(SunDirection.GetBytes(), 0, bytes, i, 12); i += 12; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- RegionInfo --\n"; - output += "SecPerDay: " + SecPerDay.ToString() + "\n"; - output += "MetersPerGrid: " + MetersPerGrid.ToString() + "\n"; - output += "UsecSinceStart: " + UsecSinceStart.ToString() + "\n"; - output += "SecPerYear: " + SecPerYear.ToString() + "\n"; - output += "GridsPerEdge: " + GridsPerEdge.ToString() + "\n"; - output += "Handle: " + Handle.ToString() + "\n"; - output += "SunAngVelocity: " + SunAngVelocity.ToString() + "\n"; - output += "SunDirection: " + SunDirection.ToString() + "\n"; + { + string output = "-- RegionInfo --\n"; + output += "SecPerDay: " + SecPerDay.ToString() + "\n"; + output += "MetersPerGrid: " + MetersPerGrid.ToString() + "\n"; + output += "UsecSinceStart: " + UsecSinceStart.ToString() + "\n"; + output += "SecPerYear: " + SecPerYear.ToString() + "\n"; + output += "GridsPerEdge: " + GridsPerEdge.ToString() + "\n"; + output += "Handle: " + Handle.ToString() + "\n"; + output += "SunAngVelocity: " + SunAngVelocity.ToString() + "\n"; + output += "SunDirection: " + SunDirection.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.SpaceLoginLocationReply - public override PacketType Type { get { return PacketType.SpaceLoginLocationReply; } } - /// SimulatorBlock block - public SimulatorBlockBlock SimulatorBlock; - /// UserBlock block - public UserBlockBlock UserBlock; - /// RegionInfo block - public RegionInfoBlock RegionInfo; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.SpaceLoginLocationReply + public override PacketType Type { get { return PacketType.SpaceLoginLocationReply; } } + /// SimulatorBlock block + public SimulatorBlockBlock SimulatorBlock; + /// UserBlock block + public UserBlockBlock UserBlock; + /// RegionInfo block + public RegionInfoBlock RegionInfo; + + /// Default constructor public SpaceLoginLocationReplyPacket() - { - Header = new LowHeader(); - Header.ID = 392; - Header.Reliable = true; - Header.Zerocoded = true; - SimulatorBlock = new SimulatorBlockBlock(); - UserBlock = new UserBlockBlock(); - RegionInfo = new RegionInfoBlock(); + { + Header = new LowHeader(); + Header.ID = 392; + Header.Reliable = true; + Header.Zerocoded = true; + SimulatorBlock = new SimulatorBlockBlock(); + UserBlock = new UserBlockBlock(); + RegionInfo = new RegionInfoBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public SpaceLoginLocationReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - SimulatorBlock = new SimulatorBlockBlock(bytes, ref i); - UserBlock = new UserBlockBlock(bytes, ref i); - RegionInfo = new RegionInfoBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + SimulatorBlock = new SimulatorBlockBlock(bytes, ref i); + UserBlock = new UserBlockBlock(bytes, ref i); + RegionInfo = new RegionInfoBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public SpaceLoginLocationReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - SimulatorBlock = new SimulatorBlockBlock(bytes, ref i); - UserBlock = new UserBlockBlock(bytes, ref i); - RegionInfo = new RegionInfoBlock(bytes, ref i); + { + Header = head; + SimulatorBlock = new SimulatorBlockBlock(bytes, ref i); + UserBlock = new UserBlockBlock(bytes, ref i); + RegionInfo = new RegionInfoBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += SimulatorBlock.Length; length += UserBlock.Length; length += RegionInfo.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - SimulatorBlock.ToBytes(bytes, ref i); - UserBlock.ToBytes(bytes, ref i); - RegionInfo.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += SimulatorBlock.Length; length += UserBlock.Length; length += RegionInfo.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + SimulatorBlock.ToBytes(bytes, ref i); + UserBlock.ToBytes(bytes, ref i); + RegionInfo.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- SpaceLoginLocationReply ---\n"; - output += SimulatorBlock.ToString() + "\n"; - output += UserBlock.ToString() + "\n"; - output += RegionInfo.ToString() + "\n"; + { + string output = "--- SpaceLoginLocationReply ---\n"; + output += SimulatorBlock.ToString() + "\n"; + output += UserBlock.ToString() + "\n"; + output += RegionInfo.ToString() + "\n"; return output; } - + } - - /// NetTest packet + + /// NetTest packet public class NetTestPacket : Packet - { - /// NetBlock block + { + /// NetBlock block public class NetBlockBlock - { - /// Port field - public ushort Port; - - /// Length of this block serialized in bytes + { + /// Port field + public ushort Port; + + /// Length of this block serialized in bytes public int Length { get - { - return 2; + { + return 2; } } - - /// Default constructor - public NetBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public NetBlockBlock() { } + /// Constructor for building the block from a byte array public NetBlockBlock(byte[] bytes, ref int i) - { + { try - { - Port = (ushort)((bytes[i++] << 8) + bytes[i++]); + { + Port = (ushort)((bytes[i++] << 8) + bytes[i++]); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)((Port >> 8) % 256); - bytes[i++] = (byte)(Port % 256); + { + bytes[i++] = (byte)((Port >> 8) % 256); + bytes[i++] = (byte)(Port % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- NetBlock --\n"; - output += "Port: " + Port.ToString() + "\n"; + { + string output = "-- NetBlock --\n"; + output += "Port: " + Port.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.NetTest - public override PacketType Type { get { return PacketType.NetTest; } } - /// NetBlock block - public NetBlockBlock NetBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.NetTest + public override PacketType Type { get { return PacketType.NetTest; } } + /// NetBlock block + public NetBlockBlock NetBlock; + + /// Default constructor public NetTestPacket() - { - Header = new LowHeader(); - Header.ID = 393; - Header.Reliable = true; - NetBlock = new NetBlockBlock(); + { + Header = new LowHeader(); + Header.ID = 393; + Header.Reliable = true; + NetBlock = new NetBlockBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public NetTestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - NetBlock = new NetBlockBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + NetBlock = new NetBlockBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public NetTestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - NetBlock = new NetBlockBlock(bytes, ref i); + { + Header = head; + NetBlock = new NetBlockBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += NetBlock.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - NetBlock.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += NetBlock.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + NetBlock.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- NetTest ---\n"; - output += NetBlock.ToString() + "\n"; + { + string output = "--- NetTest ---\n"; + output += NetBlock.ToString() + "\n"; return output; } - + } - - /// SetCPURatio packet + + /// SetCPURatio packet public class SetCPURatioPacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - /// Ratio field - public byte Ratio; - - /// Length of this block serialized in bytes + { + /// Ratio field + public byte Ratio; + + /// Length of this block serialized in bytes public int Length { get - { - return 1; + { + return 1; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { + { try - { - Ratio = (byte)bytes[i++]; + { + Ratio = (byte)bytes[i++]; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = Ratio; + { + bytes[i++] = Ratio; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "Ratio: " + Ratio.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += "Ratio: " + Ratio.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.SetCPURatio - public override PacketType Type { get { return PacketType.SetCPURatio; } } - /// Data block - public DataBlock Data; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.SetCPURatio + public override PacketType Type { get { return PacketType.SetCPURatio; } } + /// Data block + public DataBlock Data; + + /// Default constructor public SetCPURatioPacket() - { - Header = new LowHeader(); - Header.ID = 394; - Header.Reliable = true; - Data = new DataBlock(); + { + Header = new LowHeader(); + Header.ID = 394; + Header.Reliable = true; + Data = new DataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public SetCPURatioPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Data = new DataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Data = new DataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public SetCPURatioPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Data = new DataBlock(bytes, ref i); + { + Header = head; + Data = new DataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Data.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Data.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Data.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Data.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- SetCPURatio ---\n"; - output += Data.ToString() + "\n"; + { + string output = "--- SetCPURatio ---\n"; + output += Data.ToString() + "\n"; return output; } - + } - - /// SimCrashed packet + + /// SimCrashed packet public class SimCrashedPacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - /// RegionX field - public uint RegionX; - /// RegionY field - public uint RegionY; - - /// Length of this block serialized in bytes + { + /// RegionX field + public uint RegionX; + /// RegionY field + public uint RegionY; + + /// Length of this block serialized in bytes public int Length { get - { - return 8; + { + return 8; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { + { try - { - RegionX = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - RegionY = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + RegionX = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + RegionY = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(RegionX % 256); - bytes[i++] = (byte)((RegionX >> 8) % 256); - bytes[i++] = (byte)((RegionX >> 16) % 256); - bytes[i++] = (byte)((RegionX >> 24) % 256); - bytes[i++] = (byte)(RegionY % 256); - bytes[i++] = (byte)((RegionY >> 8) % 256); - bytes[i++] = (byte)((RegionY >> 16) % 256); - bytes[i++] = (byte)((RegionY >> 24) % 256); + { + bytes[i++] = (byte)(RegionX % 256); + bytes[i++] = (byte)((RegionX >> 8) % 256); + bytes[i++] = (byte)((RegionX >> 16) % 256); + bytes[i++] = (byte)((RegionX >> 24) % 256); + bytes[i++] = (byte)(RegionY % 256); + bytes[i++] = (byte)((RegionY >> 8) % 256); + bytes[i++] = (byte)((RegionY >> 16) % 256); + bytes[i++] = (byte)((RegionY >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "RegionX: " + RegionX.ToString() + "\n"; - output += "RegionY: " + RegionY.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += "RegionX: " + RegionX.ToString() + "\n"; + output += "RegionY: " + RegionY.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// Users block + + /// Users block public class UsersBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public UsersBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public UsersBlock() { } + /// Constructor for building the block from a byte array public UsersBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Users --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- Users --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.SimCrashed - public override PacketType Type { get { return PacketType.SimCrashed; } } - /// Data block - public DataBlock Data; - /// Users block - public UsersBlock[] Users; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.SimCrashed + public override PacketType Type { get { return PacketType.SimCrashed; } } + /// Data block + public DataBlock Data; + /// Users block + public UsersBlock[] Users; + + /// Default constructor public SimCrashedPacket() - { - Header = new LowHeader(); - Header.ID = 395; - Header.Reliable = true; - Data = new DataBlock(); - Users = new UsersBlock[0]; + { + Header = new LowHeader(); + Header.ID = 395; + Header.Reliable = true; + Data = new DataBlock(); + Users = new UsersBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public SimCrashedPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Data = new DataBlock(bytes, ref i); - int count = (int)bytes[i++]; - Users = new UsersBlock[count]; - for (int j = 0; j < count; j++) - { Users[j] = new UsersBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Data = new DataBlock(bytes, ref i); + int count = (int)bytes[i++]; + Users = new UsersBlock[count]; + for (int j = 0; j < count; j++) + { Users[j] = new UsersBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public SimCrashedPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Data = new DataBlock(bytes, ref i); - int count = (int)bytes[i++]; - Users = new UsersBlock[count]; - for (int j = 0; j < count; j++) - { Users[j] = new UsersBlock(bytes, ref i); } + { + Header = head; + Data = new DataBlock(bytes, ref i); + int count = (int)bytes[i++]; + Users = new UsersBlock[count]; + for (int j = 0; j < count; j++) + { Users[j] = new UsersBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Data.Length;; - length++; - for (int j = 0; j < Users.Length; j++) { length += Users[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Data.ToBytes(bytes, ref i); - bytes[i++] = (byte)Users.Length; - for (int j = 0; j < Users.Length; j++) { Users[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Data.Length;; + length++; + for (int j = 0; j < Users.Length; j++) { length += Users[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Data.ToBytes(bytes, ref i); + bytes[i++] = (byte)Users.Length; + for (int j = 0; j < Users.Length; j++) { Users[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- SimCrashed ---\n"; - output += Data.ToString() + "\n"; + { + string output = "--- SimCrashed ---\n"; + output += Data.ToString() + "\n"; for (int j = 0; j < Users.Length; j++) - { + { output += Users[j].ToString() + "\n"; - } + } return output; } - + } - - /// SimulatorPauseState packet + + /// SimulatorPauseState packet public class SimulatorPauseStatePacket : Packet - { - /// PauseBlock block + { + /// PauseBlock block public class PauseBlockBlock - { - /// TasksPaused field - public uint TasksPaused; - /// SimPaused field - public uint SimPaused; - /// LayersPaused field - public uint LayersPaused; - - /// Length of this block serialized in bytes + { + /// TasksPaused field + public uint TasksPaused; + /// SimPaused field + public uint SimPaused; + /// LayersPaused field + public uint LayersPaused; + + /// Length of this block serialized in bytes public int Length { get - { - return 12; + { + return 12; } } - - /// Default constructor - public PauseBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public PauseBlockBlock() { } + /// Constructor for building the block from a byte array public PauseBlockBlock(byte[] bytes, ref int i) - { + { try - { - TasksPaused = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - SimPaused = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - LayersPaused = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + TasksPaused = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + SimPaused = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + LayersPaused = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(TasksPaused % 256); - bytes[i++] = (byte)((TasksPaused >> 8) % 256); - bytes[i++] = (byte)((TasksPaused >> 16) % 256); - bytes[i++] = (byte)((TasksPaused >> 24) % 256); - bytes[i++] = (byte)(SimPaused % 256); - bytes[i++] = (byte)((SimPaused >> 8) % 256); - bytes[i++] = (byte)((SimPaused >> 16) % 256); - bytes[i++] = (byte)((SimPaused >> 24) % 256); - bytes[i++] = (byte)(LayersPaused % 256); - bytes[i++] = (byte)((LayersPaused >> 8) % 256); - bytes[i++] = (byte)((LayersPaused >> 16) % 256); - bytes[i++] = (byte)((LayersPaused >> 24) % 256); + { + bytes[i++] = (byte)(TasksPaused % 256); + bytes[i++] = (byte)((TasksPaused >> 8) % 256); + bytes[i++] = (byte)((TasksPaused >> 16) % 256); + bytes[i++] = (byte)((TasksPaused >> 24) % 256); + bytes[i++] = (byte)(SimPaused % 256); + bytes[i++] = (byte)((SimPaused >> 8) % 256); + bytes[i++] = (byte)((SimPaused >> 16) % 256); + bytes[i++] = (byte)((SimPaused >> 24) % 256); + bytes[i++] = (byte)(LayersPaused % 256); + bytes[i++] = (byte)((LayersPaused >> 8) % 256); + bytes[i++] = (byte)((LayersPaused >> 16) % 256); + bytes[i++] = (byte)((LayersPaused >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- PauseBlock --\n"; - output += "TasksPaused: " + TasksPaused.ToString() + "\n"; - output += "SimPaused: " + SimPaused.ToString() + "\n"; - output += "LayersPaused: " + LayersPaused.ToString() + "\n"; + { + string output = "-- PauseBlock --\n"; + output += "TasksPaused: " + TasksPaused.ToString() + "\n"; + output += "SimPaused: " + SimPaused.ToString() + "\n"; + output += "LayersPaused: " + LayersPaused.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.SimulatorPauseState - public override PacketType Type { get { return PacketType.SimulatorPauseState; } } - /// PauseBlock block - public PauseBlockBlock PauseBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.SimulatorPauseState + public override PacketType Type { get { return PacketType.SimulatorPauseState; } } + /// PauseBlock block + public PauseBlockBlock PauseBlock; + + /// Default constructor public SimulatorPauseStatePacket() - { - Header = new LowHeader(); - Header.ID = 396; - Header.Reliable = true; - PauseBlock = new PauseBlockBlock(); + { + Header = new LowHeader(); + Header.ID = 396; + Header.Reliable = true; + PauseBlock = new PauseBlockBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public SimulatorPauseStatePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - PauseBlock = new PauseBlockBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + PauseBlock = new PauseBlockBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public SimulatorPauseStatePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - PauseBlock = new PauseBlockBlock(bytes, ref i); + { + Header = head; + PauseBlock = new PauseBlockBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += PauseBlock.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - PauseBlock.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += PauseBlock.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + PauseBlock.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- SimulatorPauseState ---\n"; - output += PauseBlock.ToString() + "\n"; + { + string output = "--- SimulatorPauseState ---\n"; + output += PauseBlock.ToString() + "\n"; return output; } - + } - - /// SimulatorThrottleSettings packet + + /// SimulatorThrottleSettings packet public class SimulatorThrottleSettingsPacket : Packet - { - /// Sender block + { + /// Sender block public class SenderBlock - { - /// ID field - public LLUUID ID; - - /// Length of this block serialized in bytes + { + /// ID field + public LLUUID ID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public SenderBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public SenderBlock() { } + /// Constructor for building the block from a byte array public SenderBlock(byte[] bytes, ref int i) - { + { try - { - ID = new LLUUID(bytes, i); i += 16; + { + ID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } - Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } + Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Sender --\n"; - output += "ID: " + ID.ToString() + "\n"; + { + string output = "-- Sender --\n"; + output += "ID: " + ID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// Throttle block + + /// Throttle block public class ThrottleBlock - { - private byte[] _throttles; - /// Throttles field + { + private byte[] _throttles; + /// Throttles field public byte[] Throttles - { - get { return _throttles; } + { + get { return _throttles; } set - { - if (value == null) { _throttles = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _throttles = new byte[value.Length]; Array.Copy(value, _throttles, value.Length); } + { + if (value == null) { _throttles = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _throttles = new byte[value.Length]; Array.Copy(value, _throttles, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 0; - if (Throttles != null) { length += 1 + Throttles.Length; } - return length; + { + int length = 0; + if (Throttles != null) { length += 1 + Throttles.Length; } + return length; } } - - /// Default constructor - public ThrottleBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ThrottleBlock() { } + /// Constructor for building the block from a byte array public ThrottleBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _throttles = new byte[length]; - Array.Copy(bytes, i, _throttles, 0, length); i += length; + { + length = (ushort)bytes[i++]; + _throttles = new byte[length]; + Array.Copy(bytes, i, _throttles, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(Throttles == null) { Console.WriteLine("Warning: Throttles is null, in " + this.GetType()); } - bytes[i++] = (byte)Throttles.Length; - Array.Copy(Throttles, 0, bytes, i, Throttles.Length); i += Throttles.Length; + { + if(Throttles == null) { Console.WriteLine("Warning: Throttles is null, in " + this.GetType()); } + bytes[i++] = (byte)Throttles.Length; + Array.Copy(Throttles, 0, bytes, i, Throttles.Length); i += Throttles.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Throttle --\n"; - output += Helpers.FieldToString(Throttles, "Throttles") + "\n"; + { + string output = "-- Throttle --\n"; + output += Helpers.FieldToString(Throttles, "Throttles") + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.SimulatorThrottleSettings - public override PacketType Type { get { return PacketType.SimulatorThrottleSettings; } } - /// Sender block - public SenderBlock Sender; - /// Throttle block - public ThrottleBlock Throttle; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.SimulatorThrottleSettings + public override PacketType Type { get { return PacketType.SimulatorThrottleSettings; } } + /// Sender block + public SenderBlock Sender; + /// Throttle block + public ThrottleBlock Throttle; + + /// Default constructor public SimulatorThrottleSettingsPacket() - { - Header = new LowHeader(); - Header.ID = 397; - Header.Reliable = true; - Sender = new SenderBlock(); - Throttle = new ThrottleBlock(); + { + Header = new LowHeader(); + Header.ID = 397; + Header.Reliable = true; + Sender = new SenderBlock(); + Throttle = new ThrottleBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public SimulatorThrottleSettingsPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Sender = new SenderBlock(bytes, ref i); - Throttle = new ThrottleBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Sender = new SenderBlock(bytes, ref i); + Throttle = new ThrottleBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public SimulatorThrottleSettingsPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Sender = new SenderBlock(bytes, ref i); - Throttle = new ThrottleBlock(bytes, ref i); + { + Header = head; + Sender = new SenderBlock(bytes, ref i); + Throttle = new ThrottleBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Sender.Length; length += Throttle.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Sender.ToBytes(bytes, ref i); - Throttle.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Sender.Length; length += Throttle.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Sender.ToBytes(bytes, ref i); + Throttle.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- SimulatorThrottleSettings ---\n"; - output += Sender.ToString() + "\n"; - output += Throttle.ToString() + "\n"; + { + string output = "--- SimulatorThrottleSettings ---\n"; + output += Sender.ToString() + "\n"; + output += Throttle.ToString() + "\n"; return output; } - + } - - /// NameValuePair packet + + /// NameValuePair packet public class NameValuePairPacket : Packet - { - /// NameValueData block + { + /// NameValueData block public class NameValueDataBlock - { - private byte[] _nvpair; - /// NVPair field + { + private byte[] _nvpair; + /// NVPair field public byte[] NVPair - { - get { return _nvpair; } + { + get { return _nvpair; } set - { - if (value == null) { _nvpair = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _nvpair = new byte[value.Length]; Array.Copy(value, _nvpair, value.Length); } + { + if (value == null) { _nvpair = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _nvpair = new byte[value.Length]; Array.Copy(value, _nvpair, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 0; - if (NVPair != null) { length += 2 + NVPair.Length; } - return length; + { + int length = 0; + if (NVPair != null) { length += 2 + NVPair.Length; } + return length; } } - - /// Default constructor - public NameValueDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public NameValueDataBlock() { } + /// Constructor for building the block from a byte array public NameValueDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _nvpair = new byte[length]; - Array.Copy(bytes, i, _nvpair, 0, length); i += length; + { + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _nvpair = new byte[length]; + Array.Copy(bytes, i, _nvpair, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(NVPair == null) { Console.WriteLine("Warning: NVPair is null, in " + this.GetType()); } - bytes[i++] = (byte)(NVPair.Length % 256); - bytes[i++] = (byte)((NVPair.Length >> 8) % 256); - Array.Copy(NVPair, 0, bytes, i, NVPair.Length); i += NVPair.Length; + { + if(NVPair == null) { Console.WriteLine("Warning: NVPair is null, in " + this.GetType()); } + bytes[i++] = (byte)(NVPair.Length % 256); + bytes[i++] = (byte)((NVPair.Length >> 8) % 256); + Array.Copy(NVPair, 0, bytes, i, NVPair.Length); i += NVPair.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- NameValueData --\n"; - output += Helpers.FieldToString(NVPair, "NVPair") + "\n"; + { + string output = "-- NameValueData --\n"; + output += Helpers.FieldToString(NVPair, "NVPair") + "\n"; output = output.Trim(); return output; - } + } } - - /// TaskData block + + /// TaskData block public class TaskDataBlock - { - /// ID field - public LLUUID ID; - - /// Length of this block serialized in bytes + { + /// ID field + public LLUUID ID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public TaskDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public TaskDataBlock() { } + /// Constructor for building the block from a byte array public TaskDataBlock(byte[] bytes, ref int i) - { + { try - { - ID = new LLUUID(bytes, i); i += 16; + { + ID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } - Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } + Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- TaskData --\n"; - output += "ID: " + ID.ToString() + "\n"; + { + string output = "-- TaskData --\n"; + output += "ID: " + ID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.NameValuePair - public override PacketType Type { get { return PacketType.NameValuePair; } } - /// NameValueData block - public NameValueDataBlock[] NameValueData; - /// TaskData block - public TaskDataBlock TaskData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.NameValuePair + public override PacketType Type { get { return PacketType.NameValuePair; } } + /// NameValueData block + public NameValueDataBlock[] NameValueData; + /// TaskData block + public TaskDataBlock TaskData; + + /// Default constructor public NameValuePairPacket() - { - Header = new LowHeader(); - Header.ID = 398; - Header.Reliable = true; - NameValueData = new NameValueDataBlock[0]; - TaskData = new TaskDataBlock(); + { + Header = new LowHeader(); + Header.ID = 398; + Header.Reliable = true; + NameValueData = new NameValueDataBlock[0]; + TaskData = new TaskDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public NameValuePairPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - NameValueData = new NameValueDataBlock[count]; - for (int j = 0; j < count; j++) - { NameValueData[j] = new NameValueDataBlock(bytes, ref i); } - TaskData = new TaskDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + NameValueData = new NameValueDataBlock[count]; + for (int j = 0; j < count; j++) + { NameValueData[j] = new NameValueDataBlock(bytes, ref i); } + TaskData = new TaskDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public NameValuePairPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - NameValueData = new NameValueDataBlock[count]; - for (int j = 0; j < count; j++) - { NameValueData[j] = new NameValueDataBlock(bytes, ref i); } - TaskData = new TaskDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + NameValueData = new NameValueDataBlock[count]; + for (int j = 0; j < count; j++) + { NameValueData[j] = new NameValueDataBlock(bytes, ref i); } + TaskData = new TaskDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += TaskData.Length;; - length++; - for (int j = 0; j < NameValueData.Length; j++) { length += NameValueData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)NameValueData.Length; - for (int j = 0; j < NameValueData.Length; j++) { NameValueData[j].ToBytes(bytes, ref i); } - TaskData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += TaskData.Length;; + length++; + for (int j = 0; j < NameValueData.Length; j++) { length += NameValueData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)NameValueData.Length; + for (int j = 0; j < NameValueData.Length; j++) { NameValueData[j].ToBytes(bytes, ref i); } + TaskData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- NameValuePair ---\n"; + { + string output = "--- NameValuePair ---\n"; for (int j = 0; j < NameValueData.Length; j++) - { + { output += NameValueData[j].ToString() + "\n"; - } - output += TaskData.ToString() + "\n"; + } + output += TaskData.ToString() + "\n"; return output; } - + } - - /// RemoveNameValuePair packet + + /// RemoveNameValuePair packet public class RemoveNameValuePairPacket : Packet - { - /// NameValueData block + { + /// NameValueData block public class NameValueDataBlock - { - private byte[] _nvpair; - /// NVPair field + { + private byte[] _nvpair; + /// NVPair field public byte[] NVPair - { - get { return _nvpair; } + { + get { return _nvpair; } set - { - if (value == null) { _nvpair = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _nvpair = new byte[value.Length]; Array.Copy(value, _nvpair, value.Length); } + { + if (value == null) { _nvpair = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _nvpair = new byte[value.Length]; Array.Copy(value, _nvpair, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 0; - if (NVPair != null) { length += 2 + NVPair.Length; } - return length; + { + int length = 0; + if (NVPair != null) { length += 2 + NVPair.Length; } + return length; } } - - /// Default constructor - public NameValueDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public NameValueDataBlock() { } + /// Constructor for building the block from a byte array public NameValueDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _nvpair = new byte[length]; - Array.Copy(bytes, i, _nvpair, 0, length); i += length; + { + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _nvpair = new byte[length]; + Array.Copy(bytes, i, _nvpair, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(NVPair == null) { Console.WriteLine("Warning: NVPair is null, in " + this.GetType()); } - bytes[i++] = (byte)(NVPair.Length % 256); - bytes[i++] = (byte)((NVPair.Length >> 8) % 256); - Array.Copy(NVPair, 0, bytes, i, NVPair.Length); i += NVPair.Length; + { + if(NVPair == null) { Console.WriteLine("Warning: NVPair is null, in " + this.GetType()); } + bytes[i++] = (byte)(NVPair.Length % 256); + bytes[i++] = (byte)((NVPair.Length >> 8) % 256); + Array.Copy(NVPair, 0, bytes, i, NVPair.Length); i += NVPair.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- NameValueData --\n"; - output += Helpers.FieldToString(NVPair, "NVPair") + "\n"; + { + string output = "-- NameValueData --\n"; + output += Helpers.FieldToString(NVPair, "NVPair") + "\n"; output = output.Trim(); return output; - } + } } - - /// TaskData block + + /// TaskData block public class TaskDataBlock - { - /// ID field - public LLUUID ID; - - /// Length of this block serialized in bytes + { + /// ID field + public LLUUID ID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public TaskDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public TaskDataBlock() { } + /// Constructor for building the block from a byte array public TaskDataBlock(byte[] bytes, ref int i) - { + { try - { - ID = new LLUUID(bytes, i); i += 16; + { + ID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } - Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } + Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- TaskData --\n"; - output += "ID: " + ID.ToString() + "\n"; + { + string output = "-- TaskData --\n"; + output += "ID: " + ID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.RemoveNameValuePair - public override PacketType Type { get { return PacketType.RemoveNameValuePair; } } - /// NameValueData block - public NameValueDataBlock[] NameValueData; - /// TaskData block - public TaskDataBlock TaskData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.RemoveNameValuePair + public override PacketType Type { get { return PacketType.RemoveNameValuePair; } } + /// NameValueData block + public NameValueDataBlock[] NameValueData; + /// TaskData block + public TaskDataBlock TaskData; + + /// Default constructor public RemoveNameValuePairPacket() - { - Header = new LowHeader(); - Header.ID = 399; - Header.Reliable = true; - NameValueData = new NameValueDataBlock[0]; - TaskData = new TaskDataBlock(); + { + Header = new LowHeader(); + Header.ID = 399; + Header.Reliable = true; + NameValueData = new NameValueDataBlock[0]; + TaskData = new TaskDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public RemoveNameValuePairPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - NameValueData = new NameValueDataBlock[count]; - for (int j = 0; j < count; j++) - { NameValueData[j] = new NameValueDataBlock(bytes, ref i); } - TaskData = new TaskDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + NameValueData = new NameValueDataBlock[count]; + for (int j = 0; j < count; j++) + { NameValueData[j] = new NameValueDataBlock(bytes, ref i); } + TaskData = new TaskDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public RemoveNameValuePairPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - NameValueData = new NameValueDataBlock[count]; - for (int j = 0; j < count; j++) - { NameValueData[j] = new NameValueDataBlock(bytes, ref i); } - TaskData = new TaskDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + NameValueData = new NameValueDataBlock[count]; + for (int j = 0; j < count; j++) + { NameValueData[j] = new NameValueDataBlock(bytes, ref i); } + TaskData = new TaskDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += TaskData.Length;; - length++; - for (int j = 0; j < NameValueData.Length; j++) { length += NameValueData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)NameValueData.Length; - for (int j = 0; j < NameValueData.Length; j++) { NameValueData[j].ToBytes(bytes, ref i); } - TaskData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += TaskData.Length;; + length++; + for (int j = 0; j < NameValueData.Length; j++) { length += NameValueData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)NameValueData.Length; + for (int j = 0; j < NameValueData.Length; j++) { NameValueData[j].ToBytes(bytes, ref i); } + TaskData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- RemoveNameValuePair ---\n"; + { + string output = "--- RemoveNameValuePair ---\n"; for (int j = 0; j < NameValueData.Length; j++) - { + { output += NameValueData[j].ToString() + "\n"; - } - output += TaskData.ToString() + "\n"; + } + output += TaskData.ToString() + "\n"; return output; } - + } - - /// GetNameValuePair packet + + /// GetNameValuePair packet public class GetNameValuePairPacket : Packet - { - /// NameValueName block + { + /// NameValueName block public class NameValueNameBlock - { - private byte[] _name; - /// Name field + { + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 0; - if (Name != null) { length += 2 + Name.Length; } - return length; + { + int length = 0; + if (Name != null) { length += 2 + Name.Length; } + return length; } } - - /// Default constructor - public NameValueNameBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public NameValueNameBlock() { } + /// Constructor for building the block from a byte array public NameValueNameBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; + { + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)(Name.Length % 256); - bytes[i++] = (byte)((Name.Length >> 8) % 256); - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + { + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)(Name.Length % 256); + bytes[i++] = (byte)((Name.Length >> 8) % 256); + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- NameValueName --\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; + { + string output = "-- NameValueName --\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; output = output.Trim(); return output; - } + } } - - /// TaskData block + + /// TaskData block public class TaskDataBlock - { - /// ID field - public LLUUID ID; - - /// Length of this block serialized in bytes + { + /// ID field + public LLUUID ID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public TaskDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public TaskDataBlock() { } + /// Constructor for building the block from a byte array public TaskDataBlock(byte[] bytes, ref int i) - { + { try - { - ID = new LLUUID(bytes, i); i += 16; + { + ID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } - Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } + Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- TaskData --\n"; - output += "ID: " + ID.ToString() + "\n"; + { + string output = "-- TaskData --\n"; + output += "ID: " + ID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.GetNameValuePair - public override PacketType Type { get { return PacketType.GetNameValuePair; } } - /// NameValueName block - public NameValueNameBlock[] NameValueName; - /// TaskData block - public TaskDataBlock TaskData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.GetNameValuePair + public override PacketType Type { get { return PacketType.GetNameValuePair; } } + /// NameValueName block + public NameValueNameBlock[] NameValueName; + /// TaskData block + public TaskDataBlock TaskData; + + /// Default constructor public GetNameValuePairPacket() - { - Header = new LowHeader(); - Header.ID = 400; - Header.Reliable = true; - NameValueName = new NameValueNameBlock[0]; - TaskData = new TaskDataBlock(); + { + Header = new LowHeader(); + Header.ID = 400; + Header.Reliable = true; + NameValueName = new NameValueNameBlock[0]; + TaskData = new TaskDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public GetNameValuePairPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - NameValueName = new NameValueNameBlock[count]; - for (int j = 0; j < count; j++) - { NameValueName[j] = new NameValueNameBlock(bytes, ref i); } - TaskData = new TaskDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + NameValueName = new NameValueNameBlock[count]; + for (int j = 0; j < count; j++) + { NameValueName[j] = new NameValueNameBlock(bytes, ref i); } + TaskData = new TaskDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public GetNameValuePairPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - NameValueName = new NameValueNameBlock[count]; - for (int j = 0; j < count; j++) - { NameValueName[j] = new NameValueNameBlock(bytes, ref i); } - TaskData = new TaskDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + NameValueName = new NameValueNameBlock[count]; + for (int j = 0; j < count; j++) + { NameValueName[j] = new NameValueNameBlock(bytes, ref i); } + TaskData = new TaskDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += TaskData.Length;; - length++; - for (int j = 0; j < NameValueName.Length; j++) { length += NameValueName[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)NameValueName.Length; - for (int j = 0; j < NameValueName.Length; j++) { NameValueName[j].ToBytes(bytes, ref i); } - TaskData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += TaskData.Length;; + length++; + for (int j = 0; j < NameValueName.Length; j++) { length += NameValueName[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)NameValueName.Length; + for (int j = 0; j < NameValueName.Length; j++) { NameValueName[j].ToBytes(bytes, ref i); } + TaskData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- GetNameValuePair ---\n"; + { + string output = "--- GetNameValuePair ---\n"; for (int j = 0; j < NameValueName.Length; j++) - { + { output += NameValueName[j].ToString() + "\n"; - } - output += TaskData.ToString() + "\n"; + } + output += TaskData.ToString() + "\n"; return output; } - + } - - /// UpdateAttachment packet + + /// UpdateAttachment packet public class UpdateAttachmentPacket : Packet - { - /// InventoryData block + { + /// InventoryData block public class InventoryDataBlock - { - /// GroupOwned field - public bool GroupOwned; - /// CRC field - public uint CRC; - /// CreationDate field - public int CreationDate; - /// SaleType field - public byte SaleType; - /// BaseMask field - public uint BaseMask; - private byte[] _name; - /// Name field + { + /// GroupOwned field + public bool GroupOwned; + /// CRC field + public uint CRC; + /// CreationDate field + public int CreationDate; + /// SaleType field + public byte SaleType; + /// BaseMask field + public uint BaseMask; + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - /// InvType field - public sbyte InvType; - /// Type field - public sbyte Type; - /// AssetID field - public LLUUID AssetID; - /// GroupID field - public LLUUID GroupID; - /// SalePrice field - public int SalePrice; - /// OwnerID field - public LLUUID OwnerID; - /// CreatorID field - public LLUUID CreatorID; - /// ItemID field - public LLUUID ItemID; - /// FolderID field - public LLUUID FolderID; - /// EveryoneMask field - public uint EveryoneMask; - private byte[] _description; - /// Description field + } + /// InvType field + public sbyte InvType; + /// Type field + public sbyte Type; + /// AssetID field + public LLUUID AssetID; + /// GroupID field + public LLUUID GroupID; + /// SalePrice field + public int SalePrice; + /// OwnerID field + public LLUUID OwnerID; + /// CreatorID field + public LLUUID CreatorID; + /// ItemID field + public LLUUID ItemID; + /// FolderID field + public LLUUID FolderID; + /// EveryoneMask field + public uint EveryoneMask; + private byte[] _description; + /// Description field public byte[] Description - { - get { return _description; } + { + get { return _description; } set - { - if (value == null) { _description = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } + { + if (value == null) { _description = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } } - } - /// Flags field - public uint Flags; - /// NextOwnerMask field - public uint NextOwnerMask; - /// GroupMask field - public uint GroupMask; - /// OwnerMask field - public uint OwnerMask; - - /// Length of this block serialized in bytes + } + /// Flags field + public uint Flags; + /// NextOwnerMask field + public uint NextOwnerMask; + /// GroupMask field + public uint GroupMask; + /// OwnerMask field + public uint OwnerMask; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 136; - if (Name != null) { length += 1 + Name.Length; } - if (Description != null) { length += 1 + Description.Length; } - return length; + { + int length = 136; + if (Name != null) { length += 1 + Name.Length; } + if (Description != null) { length += 1 + Description.Length; } + return length; } } - - /// Default constructor - public InventoryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public InventoryDataBlock() { } + /// Constructor for building the block from a byte array public InventoryDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - GroupOwned = (bytes[i++] != 0) ? (bool)true : (bool)false; - CRC = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - CreationDate = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - SaleType = (byte)bytes[i++]; - BaseMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; - InvType = (sbyte)bytes[i++]; - Type = (sbyte)bytes[i++]; - AssetID = new LLUUID(bytes, i); i += 16; - GroupID = new LLUUID(bytes, i); i += 16; - SalePrice = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - OwnerID = new LLUUID(bytes, i); i += 16; - CreatorID = new LLUUID(bytes, i); i += 16; - ItemID = new LLUUID(bytes, i); i += 16; - FolderID = new LLUUID(bytes, i); i += 16; - EveryoneMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _description = new byte[length]; - Array.Copy(bytes, i, _description, 0, length); i += length; - Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - NextOwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - GroupMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - OwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + GroupOwned = (bytes[i++] != 0) ? (bool)true : (bool)false; + CRC = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + CreationDate = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + SaleType = (byte)bytes[i++]; + BaseMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; + InvType = (sbyte)bytes[i++]; + Type = (sbyte)bytes[i++]; + AssetID = new LLUUID(bytes, i); i += 16; + GroupID = new LLUUID(bytes, i); i += 16; + SalePrice = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + OwnerID = new LLUUID(bytes, i); i += 16; + CreatorID = new LLUUID(bytes, i); i += 16; + ItemID = new LLUUID(bytes, i); i += 16; + FolderID = new LLUUID(bytes, i); i += 16; + EveryoneMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _description = new byte[length]; + Array.Copy(bytes, i, _description, 0, length); i += length; + Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + NextOwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + GroupMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + OwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)((GroupOwned) ? 1 : 0); - bytes[i++] = (byte)(CRC % 256); - bytes[i++] = (byte)((CRC >> 8) % 256); - bytes[i++] = (byte)((CRC >> 16) % 256); - bytes[i++] = (byte)((CRC >> 24) % 256); - bytes[i++] = (byte)(CreationDate % 256); - bytes[i++] = (byte)((CreationDate >> 8) % 256); - bytes[i++] = (byte)((CreationDate >> 16) % 256); - bytes[i++] = (byte)((CreationDate >> 24) % 256); - bytes[i++] = SaleType; - bytes[i++] = (byte)(BaseMask % 256); - bytes[i++] = (byte)((BaseMask >> 8) % 256); - bytes[i++] = (byte)((BaseMask >> 16) % 256); - bytes[i++] = (byte)((BaseMask >> 24) % 256); - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; - bytes[i++] = (byte)InvType; - bytes[i++] = (byte)Type; - if(AssetID == null) { Console.WriteLine("Warning: AssetID is null, in " + this.GetType()); } - Array.Copy(AssetID.GetBytes(), 0, bytes, i, 16); i += 16; - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(SalePrice % 256); - bytes[i++] = (byte)((SalePrice >> 8) % 256); - bytes[i++] = (byte)((SalePrice >> 16) % 256); - bytes[i++] = (byte)((SalePrice >> 24) % 256); - if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } - Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; - if(CreatorID == null) { Console.WriteLine("Warning: CreatorID is null, in " + this.GetType()); } - Array.Copy(CreatorID.GetBytes(), 0, bytes, i, 16); i += 16; - if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } - Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; - if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } - Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(EveryoneMask % 256); - bytes[i++] = (byte)((EveryoneMask >> 8) % 256); - bytes[i++] = (byte)((EveryoneMask >> 16) % 256); - bytes[i++] = (byte)((EveryoneMask >> 24) % 256); - if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } - bytes[i++] = (byte)Description.Length; - Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; - bytes[i++] = (byte)(Flags % 256); - bytes[i++] = (byte)((Flags >> 8) % 256); - bytes[i++] = (byte)((Flags >> 16) % 256); - bytes[i++] = (byte)((Flags >> 24) % 256); - bytes[i++] = (byte)(NextOwnerMask % 256); - bytes[i++] = (byte)((NextOwnerMask >> 8) % 256); - bytes[i++] = (byte)((NextOwnerMask >> 16) % 256); - bytes[i++] = (byte)((NextOwnerMask >> 24) % 256); - bytes[i++] = (byte)(GroupMask % 256); - bytes[i++] = (byte)((GroupMask >> 8) % 256); - bytes[i++] = (byte)((GroupMask >> 16) % 256); - bytes[i++] = (byte)((GroupMask >> 24) % 256); - bytes[i++] = (byte)(OwnerMask % 256); - bytes[i++] = (byte)((OwnerMask >> 8) % 256); - bytes[i++] = (byte)((OwnerMask >> 16) % 256); - bytes[i++] = (byte)((OwnerMask >> 24) % 256); + { + bytes[i++] = (byte)((GroupOwned) ? 1 : 0); + bytes[i++] = (byte)(CRC % 256); + bytes[i++] = (byte)((CRC >> 8) % 256); + bytes[i++] = (byte)((CRC >> 16) % 256); + bytes[i++] = (byte)((CRC >> 24) % 256); + bytes[i++] = (byte)(CreationDate % 256); + bytes[i++] = (byte)((CreationDate >> 8) % 256); + bytes[i++] = (byte)((CreationDate >> 16) % 256); + bytes[i++] = (byte)((CreationDate >> 24) % 256); + bytes[i++] = SaleType; + bytes[i++] = (byte)(BaseMask % 256); + bytes[i++] = (byte)((BaseMask >> 8) % 256); + bytes[i++] = (byte)((BaseMask >> 16) % 256); + bytes[i++] = (byte)((BaseMask >> 24) % 256); + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + bytes[i++] = (byte)InvType; + bytes[i++] = (byte)Type; + if(AssetID == null) { Console.WriteLine("Warning: AssetID is null, in " + this.GetType()); } + Array.Copy(AssetID.GetBytes(), 0, bytes, i, 16); i += 16; + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(SalePrice % 256); + bytes[i++] = (byte)((SalePrice >> 8) % 256); + bytes[i++] = (byte)((SalePrice >> 16) % 256); + bytes[i++] = (byte)((SalePrice >> 24) % 256); + if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } + Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; + if(CreatorID == null) { Console.WriteLine("Warning: CreatorID is null, in " + this.GetType()); } + Array.Copy(CreatorID.GetBytes(), 0, bytes, i, 16); i += 16; + if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } + Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; + if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } + Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(EveryoneMask % 256); + bytes[i++] = (byte)((EveryoneMask >> 8) % 256); + bytes[i++] = (byte)((EveryoneMask >> 16) % 256); + bytes[i++] = (byte)((EveryoneMask >> 24) % 256); + if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } + bytes[i++] = (byte)Description.Length; + Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; + bytes[i++] = (byte)(Flags % 256); + bytes[i++] = (byte)((Flags >> 8) % 256); + bytes[i++] = (byte)((Flags >> 16) % 256); + bytes[i++] = (byte)((Flags >> 24) % 256); + bytes[i++] = (byte)(NextOwnerMask % 256); + bytes[i++] = (byte)((NextOwnerMask >> 8) % 256); + bytes[i++] = (byte)((NextOwnerMask >> 16) % 256); + bytes[i++] = (byte)((NextOwnerMask >> 24) % 256); + bytes[i++] = (byte)(GroupMask % 256); + bytes[i++] = (byte)((GroupMask >> 8) % 256); + bytes[i++] = (byte)((GroupMask >> 16) % 256); + bytes[i++] = (byte)((GroupMask >> 24) % 256); + bytes[i++] = (byte)(OwnerMask % 256); + bytes[i++] = (byte)((OwnerMask >> 8) % 256); + bytes[i++] = (byte)((OwnerMask >> 16) % 256); + bytes[i++] = (byte)((OwnerMask >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- InventoryData --\n"; - output += "GroupOwned: " + GroupOwned.ToString() + "\n"; - output += "CRC: " + CRC.ToString() + "\n"; - output += "CreationDate: " + CreationDate.ToString() + "\n"; - output += "SaleType: " + SaleType.ToString() + "\n"; - output += "BaseMask: " + BaseMask.ToString() + "\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; - output += "InvType: " + InvType.ToString() + "\n"; - output += "Type: " + Type.ToString() + "\n"; - output += "AssetID: " + AssetID.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; - output += "SalePrice: " + SalePrice.ToString() + "\n"; - output += "OwnerID: " + OwnerID.ToString() + "\n"; - output += "CreatorID: " + CreatorID.ToString() + "\n"; - output += "ItemID: " + ItemID.ToString() + "\n"; - output += "FolderID: " + FolderID.ToString() + "\n"; - output += "EveryoneMask: " + EveryoneMask.ToString() + "\n"; - output += Helpers.FieldToString(Description, "Description") + "\n"; - output += "Flags: " + Flags.ToString() + "\n"; - output += "NextOwnerMask: " + NextOwnerMask.ToString() + "\n"; - output += "GroupMask: " + GroupMask.ToString() + "\n"; - output += "OwnerMask: " + OwnerMask.ToString() + "\n"; + { + string output = "-- InventoryData --\n"; + output += "GroupOwned: " + GroupOwned.ToString() + "\n"; + output += "CRC: " + CRC.ToString() + "\n"; + output += "CreationDate: " + CreationDate.ToString() + "\n"; + output += "SaleType: " + SaleType.ToString() + "\n"; + output += "BaseMask: " + BaseMask.ToString() + "\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; + output += "InvType: " + InvType.ToString() + "\n"; + output += "Type: " + Type.ToString() + "\n"; + output += "AssetID: " + AssetID.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; + output += "SalePrice: " + SalePrice.ToString() + "\n"; + output += "OwnerID: " + OwnerID.ToString() + "\n"; + output += "CreatorID: " + CreatorID.ToString() + "\n"; + output += "ItemID: " + ItemID.ToString() + "\n"; + output += "FolderID: " + FolderID.ToString() + "\n"; + output += "EveryoneMask: " + EveryoneMask.ToString() + "\n"; + output += Helpers.FieldToString(Description, "Description") + "\n"; + output += "Flags: " + Flags.ToString() + "\n"; + output += "NextOwnerMask: " + NextOwnerMask.ToString() + "\n"; + output += "GroupMask: " + GroupMask.ToString() + "\n"; + output += "OwnerMask: " + OwnerMask.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// OperationData block + + /// OperationData block public class OperationDataBlock - { - /// AddItem field - public bool AddItem; - /// UseExistingAsset field - public bool UseExistingAsset; - - /// Length of this block serialized in bytes + { + /// AddItem field + public bool AddItem; + /// UseExistingAsset field + public bool UseExistingAsset; + + /// Length of this block serialized in bytes public int Length { get - { - return 2; + { + return 2; } } - - /// Default constructor - public OperationDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public OperationDataBlock() { } + /// Constructor for building the block from a byte array public OperationDataBlock(byte[] bytes, ref int i) - { + { try - { - AddItem = (bytes[i++] != 0) ? (bool)true : (bool)false; - UseExistingAsset = (bytes[i++] != 0) ? (bool)true : (bool)false; + { + AddItem = (bytes[i++] != 0) ? (bool)true : (bool)false; + UseExistingAsset = (bytes[i++] != 0) ? (bool)true : (bool)false; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)((AddItem) ? 1 : 0); - bytes[i++] = (byte)((UseExistingAsset) ? 1 : 0); + { + bytes[i++] = (byte)((AddItem) ? 1 : 0); + bytes[i++] = (byte)((UseExistingAsset) ? 1 : 0); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- OperationData --\n"; - output += "AddItem: " + AddItem.ToString() + "\n"; - output += "UseExistingAsset: " + UseExistingAsset.ToString() + "\n"; + { + string output = "-- OperationData --\n"; + output += "AddItem: " + AddItem.ToString() + "\n"; + output += "UseExistingAsset: " + UseExistingAsset.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AttachmentBlock block + + /// AttachmentBlock block public class AttachmentBlockBlock - { - /// AttachmentPoint field - public byte AttachmentPoint; - - /// Length of this block serialized in bytes + { + /// AttachmentPoint field + public byte AttachmentPoint; + + /// Length of this block serialized in bytes public int Length { get - { - return 1; + { + return 1; } } - - /// Default constructor - public AttachmentBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AttachmentBlockBlock() { } + /// Constructor for building the block from a byte array public AttachmentBlockBlock(byte[] bytes, ref int i) - { + { try - { - AttachmentPoint = (byte)bytes[i++]; + { + AttachmentPoint = (byte)bytes[i++]; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = AttachmentPoint; + { + bytes[i++] = AttachmentPoint; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AttachmentBlock --\n"; - output += "AttachmentPoint: " + AttachmentPoint.ToString() + "\n"; + { + string output = "-- AttachmentBlock --\n"; + output += "AttachmentPoint: " + AttachmentPoint.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.UpdateAttachment - public override PacketType Type { get { return PacketType.UpdateAttachment; } } - /// InventoryData block - public InventoryDataBlock InventoryData; - /// AgentData block - public AgentDataBlock AgentData; - /// OperationData block - public OperationDataBlock OperationData; - /// AttachmentBlock block - public AttachmentBlockBlock AttachmentBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.UpdateAttachment + public override PacketType Type { get { return PacketType.UpdateAttachment; } } + /// InventoryData block + public InventoryDataBlock InventoryData; + /// AgentData block + public AgentDataBlock AgentData; + /// OperationData block + public OperationDataBlock OperationData; + /// AttachmentBlock block + public AttachmentBlockBlock AttachmentBlock; + + /// Default constructor public UpdateAttachmentPacket() - { - Header = new LowHeader(); - Header.ID = 401; - Header.Reliable = true; - Header.Zerocoded = true; - InventoryData = new InventoryDataBlock(); - AgentData = new AgentDataBlock(); - OperationData = new OperationDataBlock(); - AttachmentBlock = new AttachmentBlockBlock(); + { + Header = new LowHeader(); + Header.ID = 401; + Header.Reliable = true; + Header.Zerocoded = true; + InventoryData = new InventoryDataBlock(); + AgentData = new AgentDataBlock(); + OperationData = new OperationDataBlock(); + AttachmentBlock = new AttachmentBlockBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public UpdateAttachmentPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - InventoryData = new InventoryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); - OperationData = new OperationDataBlock(bytes, ref i); - AttachmentBlock = new AttachmentBlockBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + InventoryData = new InventoryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); + OperationData = new OperationDataBlock(bytes, ref i); + AttachmentBlock = new AttachmentBlockBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public UpdateAttachmentPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - InventoryData = new InventoryDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); - OperationData = new OperationDataBlock(bytes, ref i); - AttachmentBlock = new AttachmentBlockBlock(bytes, ref i); + { + Header = head; + InventoryData = new InventoryDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); + OperationData = new OperationDataBlock(bytes, ref i); + AttachmentBlock = new AttachmentBlockBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += InventoryData.Length; length += AgentData.Length; length += OperationData.Length; length += AttachmentBlock.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - InventoryData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - OperationData.ToBytes(bytes, ref i); - AttachmentBlock.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += InventoryData.Length; length += AgentData.Length; length += OperationData.Length; length += AttachmentBlock.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + InventoryData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + OperationData.ToBytes(bytes, ref i); + AttachmentBlock.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- UpdateAttachment ---\n"; - output += InventoryData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; - output += OperationData.ToString() + "\n"; - output += AttachmentBlock.ToString() + "\n"; + { + string output = "--- UpdateAttachment ---\n"; + output += InventoryData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; + output += OperationData.ToString() + "\n"; + output += AttachmentBlock.ToString() + "\n"; return output; } - + } - - /// RemoveAttachment packet + + /// RemoveAttachment packet public class RemoveAttachmentPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AttachmentBlock block + + /// AttachmentBlock block public class AttachmentBlockBlock - { - /// AttachmentPoint field - public byte AttachmentPoint; - /// ItemID field - public LLUUID ItemID; - - /// Length of this block serialized in bytes + { + /// AttachmentPoint field + public byte AttachmentPoint; + /// ItemID field + public LLUUID ItemID; + + /// Length of this block serialized in bytes public int Length { get - { - return 17; + { + return 17; } } - - /// Default constructor - public AttachmentBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AttachmentBlockBlock() { } + /// Constructor for building the block from a byte array public AttachmentBlockBlock(byte[] bytes, ref int i) - { + { try - { - AttachmentPoint = (byte)bytes[i++]; - ItemID = new LLUUID(bytes, i); i += 16; + { + AttachmentPoint = (byte)bytes[i++]; + ItemID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = AttachmentPoint; - if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } - Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; + { + bytes[i++] = AttachmentPoint; + if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } + Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AttachmentBlock --\n"; - output += "AttachmentPoint: " + AttachmentPoint.ToString() + "\n"; - output += "ItemID: " + ItemID.ToString() + "\n"; + { + string output = "-- AttachmentBlock --\n"; + output += "AttachmentPoint: " + AttachmentPoint.ToString() + "\n"; + output += "ItemID: " + ItemID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.RemoveAttachment - public override PacketType Type { get { return PacketType.RemoveAttachment; } } - /// AgentData block - public AgentDataBlock AgentData; - /// AttachmentBlock block - public AttachmentBlockBlock AttachmentBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.RemoveAttachment + public override PacketType Type { get { return PacketType.RemoveAttachment; } } + /// AgentData block + public AgentDataBlock AgentData; + /// AttachmentBlock block + public AttachmentBlockBlock AttachmentBlock; + + /// Default constructor public RemoveAttachmentPacket() - { - Header = new LowHeader(); - Header.ID = 402; - Header.Reliable = true; - AgentData = new AgentDataBlock(); - AttachmentBlock = new AttachmentBlockBlock(); + { + Header = new LowHeader(); + Header.ID = 402; + Header.Reliable = true; + AgentData = new AgentDataBlock(); + AttachmentBlock = new AttachmentBlockBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public RemoveAttachmentPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); - AttachmentBlock = new AttachmentBlockBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); + AttachmentBlock = new AttachmentBlockBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public RemoveAttachmentPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); - AttachmentBlock = new AttachmentBlockBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); + AttachmentBlock = new AttachmentBlockBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length; length += AttachmentBlock.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - AttachmentBlock.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length; length += AttachmentBlock.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + AttachmentBlock.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- RemoveAttachment ---\n"; - output += AgentData.ToString() + "\n"; - output += AttachmentBlock.ToString() + "\n"; + { + string output = "--- RemoveAttachment ---\n"; + output += AgentData.ToString() + "\n"; + output += AttachmentBlock.ToString() + "\n"; return output; } - + } - - /// AssetUploadRequest packet + + /// AssetUploadRequest packet public class AssetUploadRequestPacket : Packet - { - /// AssetBlock block + { + /// AssetBlock block public class AssetBlockBlock - { - /// Type field - public sbyte Type; - /// Tempfile field - public bool Tempfile; - private byte[] _assetdata; - /// AssetData field + { + /// Type field + public sbyte Type; + /// Tempfile field + public bool Tempfile; + private byte[] _assetdata; + /// AssetData field public byte[] AssetData - { - get { return _assetdata; } + { + get { return _assetdata; } set - { - if (value == null) { _assetdata = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _assetdata = new byte[value.Length]; Array.Copy(value, _assetdata, value.Length); } + { + if (value == null) { _assetdata = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _assetdata = new byte[value.Length]; Array.Copy(value, _assetdata, value.Length); } } - } - /// TransactionID field - public LLUUID TransactionID; - /// StoreLocal field - public bool StoreLocal; - - /// Length of this block serialized in bytes + } + /// TransactionID field + public LLUUID TransactionID; + /// StoreLocal field + public bool StoreLocal; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 19; - if (AssetData != null) { length += 2 + AssetData.Length; } - return length; + { + int length = 19; + if (AssetData != null) { length += 2 + AssetData.Length; } + return length; } } - - /// Default constructor - public AssetBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AssetBlockBlock() { } + /// Constructor for building the block from a byte array public AssetBlockBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - Type = (sbyte)bytes[i++]; - Tempfile = (bytes[i++] != 0) ? (bool)true : (bool)false; - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _assetdata = new byte[length]; - Array.Copy(bytes, i, _assetdata, 0, length); i += length; - TransactionID = new LLUUID(bytes, i); i += 16; - StoreLocal = (bytes[i++] != 0) ? (bool)true : (bool)false; + { + Type = (sbyte)bytes[i++]; + Tempfile = (bytes[i++] != 0) ? (bool)true : (bool)false; + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _assetdata = new byte[length]; + Array.Copy(bytes, i, _assetdata, 0, length); i += length; + TransactionID = new LLUUID(bytes, i); i += 16; + StoreLocal = (bytes[i++] != 0) ? (bool)true : (bool)false; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)Type; - bytes[i++] = (byte)((Tempfile) ? 1 : 0); - if(AssetData == null) { Console.WriteLine("Warning: AssetData is null, in " + this.GetType()); } - bytes[i++] = (byte)(AssetData.Length % 256); - bytes[i++] = (byte)((AssetData.Length >> 8) % 256); - Array.Copy(AssetData, 0, bytes, i, AssetData.Length); i += AssetData.Length; - if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } - Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((StoreLocal) ? 1 : 0); + { + bytes[i++] = (byte)Type; + bytes[i++] = (byte)((Tempfile) ? 1 : 0); + if(AssetData == null) { Console.WriteLine("Warning: AssetData is null, in " + this.GetType()); } + bytes[i++] = (byte)(AssetData.Length % 256); + bytes[i++] = (byte)((AssetData.Length >> 8) % 256); + Array.Copy(AssetData, 0, bytes, i, AssetData.Length); i += AssetData.Length; + if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } + Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((StoreLocal) ? 1 : 0); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AssetBlock --\n"; - output += "Type: " + Type.ToString() + "\n"; - output += "Tempfile: " + Tempfile.ToString() + "\n"; - output += Helpers.FieldToString(AssetData, "AssetData") + "\n"; - output += "TransactionID: " + TransactionID.ToString() + "\n"; - output += "StoreLocal: " + StoreLocal.ToString() + "\n"; + { + string output = "-- AssetBlock --\n"; + output += "Type: " + Type.ToString() + "\n"; + output += "Tempfile: " + Tempfile.ToString() + "\n"; + output += Helpers.FieldToString(AssetData, "AssetData") + "\n"; + output += "TransactionID: " + TransactionID.ToString() + "\n"; + output += "StoreLocal: " + StoreLocal.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AssetUploadRequest - public override PacketType Type { get { return PacketType.AssetUploadRequest; } } - /// AssetBlock block - public AssetBlockBlock AssetBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AssetUploadRequest + public override PacketType Type { get { return PacketType.AssetUploadRequest; } } + /// AssetBlock block + public AssetBlockBlock AssetBlock; + + /// Default constructor public AssetUploadRequestPacket() - { - Header = new LowHeader(); - Header.ID = 403; - Header.Reliable = true; - AssetBlock = new AssetBlockBlock(); + { + Header = new LowHeader(); + Header.ID = 403; + Header.Reliable = true; + AssetBlock = new AssetBlockBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AssetUploadRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AssetBlock = new AssetBlockBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AssetBlock = new AssetBlockBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AssetUploadRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AssetBlock = new AssetBlockBlock(bytes, ref i); + { + Header = head; + AssetBlock = new AssetBlockBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AssetBlock.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AssetBlock.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AssetBlock.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AssetBlock.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AssetUploadRequest ---\n"; - output += AssetBlock.ToString() + "\n"; + { + string output = "--- AssetUploadRequest ---\n"; + output += AssetBlock.ToString() + "\n"; return output; } - + } - - /// AssetUploadComplete packet + + /// AssetUploadComplete packet public class AssetUploadCompletePacket : Packet - { - /// AssetBlock block + { + /// AssetBlock block public class AssetBlockBlock - { - /// UUID field - public LLUUID UUID; - /// Success field - public bool Success; - /// Type field - public sbyte Type; - - /// Length of this block serialized in bytes + { + /// UUID field + public LLUUID UUID; + /// Success field + public bool Success; + /// Type field + public sbyte Type; + + /// Length of this block serialized in bytes public int Length { get - { - return 18; + { + return 18; } } - - /// Default constructor - public AssetBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AssetBlockBlock() { } + /// Constructor for building the block from a byte array public AssetBlockBlock(byte[] bytes, ref int i) - { + { try - { - UUID = new LLUUID(bytes, i); i += 16; - Success = (bytes[i++] != 0) ? (bool)true : (bool)false; - Type = (sbyte)bytes[i++]; + { + UUID = new LLUUID(bytes, i); i += 16; + Success = (bytes[i++] != 0) ? (bool)true : (bool)false; + Type = (sbyte)bytes[i++]; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(UUID == null) { Console.WriteLine("Warning: UUID is null, in " + this.GetType()); } - Array.Copy(UUID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((Success) ? 1 : 0); - bytes[i++] = (byte)Type; + { + if(UUID == null) { Console.WriteLine("Warning: UUID is null, in " + this.GetType()); } + Array.Copy(UUID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((Success) ? 1 : 0); + bytes[i++] = (byte)Type; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AssetBlock --\n"; - output += "UUID: " + UUID.ToString() + "\n"; - output += "Success: " + Success.ToString() + "\n"; - output += "Type: " + Type.ToString() + "\n"; + { + string output = "-- AssetBlock --\n"; + output += "UUID: " + UUID.ToString() + "\n"; + output += "Success: " + Success.ToString() + "\n"; + output += "Type: " + Type.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AssetUploadComplete - public override PacketType Type { get { return PacketType.AssetUploadComplete; } } - /// AssetBlock block - public AssetBlockBlock AssetBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AssetUploadComplete + public override PacketType Type { get { return PacketType.AssetUploadComplete; } } + /// AssetBlock block + public AssetBlockBlock AssetBlock; + + /// Default constructor public AssetUploadCompletePacket() - { - Header = new LowHeader(); - Header.ID = 404; - Header.Reliable = true; - AssetBlock = new AssetBlockBlock(); + { + Header = new LowHeader(); + Header.ID = 404; + Header.Reliable = true; + AssetBlock = new AssetBlockBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AssetUploadCompletePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AssetBlock = new AssetBlockBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AssetBlock = new AssetBlockBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AssetUploadCompletePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AssetBlock = new AssetBlockBlock(bytes, ref i); + { + Header = head; + AssetBlock = new AssetBlockBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AssetBlock.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AssetBlock.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AssetBlock.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AssetBlock.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AssetUploadComplete ---\n"; - output += AssetBlock.ToString() + "\n"; + { + string output = "--- AssetUploadComplete ---\n"; + output += AssetBlock.ToString() + "\n"; return output; } - + } - - /// ReputationAgentAssign packet + + /// ReputationAgentAssign packet public class ReputationAgentAssignPacket : Packet - { - /// DataBlock block + { + /// DataBlock block public class DataBlockBlock - { - /// RateeID field - public LLUUID RateeID; - /// RatorID field - public LLUUID RatorID; - /// Appearance field - public float Appearance; - /// Behavior field - public float Behavior; - /// Building field - public float Building; - - /// Length of this block serialized in bytes + { + /// RateeID field + public LLUUID RateeID; + /// RatorID field + public LLUUID RatorID; + /// Appearance field + public float Appearance; + /// Behavior field + public float Behavior; + /// Building field + public float Building; + + /// Length of this block serialized in bytes public int Length { get - { - return 44; + { + return 44; } } - - /// Default constructor - public DataBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlockBlock() { } + /// Constructor for building the block from a byte array public DataBlockBlock(byte[] bytes, ref int i) - { + { try - { - RateeID = new LLUUID(bytes, i); i += 16; - RatorID = new LLUUID(bytes, i); i += 16; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - Appearance = BitConverter.ToSingle(bytes, i); i += 4; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - Behavior = BitConverter.ToSingle(bytes, i); i += 4; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - Building = BitConverter.ToSingle(bytes, i); i += 4; + { + RateeID = new LLUUID(bytes, i); i += 16; + RatorID = new LLUUID(bytes, i); i += 16; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + Appearance = BitConverter.ToSingle(bytes, i); i += 4; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + Behavior = BitConverter.ToSingle(bytes, i); i += 4; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + Building = BitConverter.ToSingle(bytes, i); i += 4; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; - if(RateeID == null) { Console.WriteLine("Warning: RateeID is null, in " + this.GetType()); } - Array.Copy(RateeID.GetBytes(), 0, bytes, i, 16); i += 16; - if(RatorID == null) { Console.WriteLine("Warning: RatorID is null, in " + this.GetType()); } - Array.Copy(RatorID.GetBytes(), 0, bytes, i, 16); i += 16; + { + byte[] ba; + if(RateeID == null) { Console.WriteLine("Warning: RateeID is null, in " + this.GetType()); } + Array.Copy(RateeID.GetBytes(), 0, bytes, i, 16); i += 16; + if(RatorID == null) { Console.WriteLine("Warning: RatorID is null, in " + this.GetType()); } + Array.Copy(RatorID.GetBytes(), 0, bytes, i, 16); i += 16; ba = BitConverter.GetBytes(Appearance); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; ba = BitConverter.GetBytes(Behavior); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; ba = BitConverter.GetBytes(Building); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- DataBlock --\n"; - output += "RateeID: " + RateeID.ToString() + "\n"; - output += "RatorID: " + RatorID.ToString() + "\n"; - output += "Appearance: " + Appearance.ToString() + "\n"; - output += "Behavior: " + Behavior.ToString() + "\n"; - output += "Building: " + Building.ToString() + "\n"; + { + string output = "-- DataBlock --\n"; + output += "RateeID: " + RateeID.ToString() + "\n"; + output += "RatorID: " + RatorID.ToString() + "\n"; + output += "Appearance: " + Appearance.ToString() + "\n"; + output += "Behavior: " + Behavior.ToString() + "\n"; + output += "Building: " + Building.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ReputationAgentAssign - public override PacketType Type { get { return PacketType.ReputationAgentAssign; } } - /// DataBlock block - public DataBlockBlock DataBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ReputationAgentAssign + public override PacketType Type { get { return PacketType.ReputationAgentAssign; } } + /// DataBlock block + public DataBlockBlock DataBlock; + + /// Default constructor public ReputationAgentAssignPacket() - { - Header = new LowHeader(); - Header.ID = 405; - Header.Reliable = true; - DataBlock = new DataBlockBlock(); + { + Header = new LowHeader(); + Header.ID = 405; + Header.Reliable = true; + DataBlock = new DataBlockBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ReputationAgentAssignPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - DataBlock = new DataBlockBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + DataBlock = new DataBlockBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ReputationAgentAssignPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - DataBlock = new DataBlockBlock(bytes, ref i); + { + Header = head; + DataBlock = new DataBlockBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += DataBlock.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - DataBlock.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += DataBlock.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + DataBlock.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ReputationAgentAssign ---\n"; - output += DataBlock.ToString() + "\n"; + { + string output = "--- ReputationAgentAssign ---\n"; + output += DataBlock.ToString() + "\n"; return output; } - + } - - /// ReputationIndividualRequest packet + + /// ReputationIndividualRequest packet public class ReputationIndividualRequestPacket : Packet - { - /// ReputationData block + { + /// ReputationData block public class ReputationDataBlock - { - /// ToID field - public LLUUID ToID; - /// FromID field - public LLUUID FromID; - - /// Length of this block serialized in bytes + { + /// ToID field + public LLUUID ToID; + /// FromID field + public LLUUID FromID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public ReputationDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ReputationDataBlock() { } + /// Constructor for building the block from a byte array public ReputationDataBlock(byte[] bytes, ref int i) - { + { try - { - ToID = new LLUUID(bytes, i); i += 16; - FromID = new LLUUID(bytes, i); i += 16; + { + ToID = new LLUUID(bytes, i); i += 16; + FromID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ToID == null) { Console.WriteLine("Warning: ToID is null, in " + this.GetType()); } - Array.Copy(ToID.GetBytes(), 0, bytes, i, 16); i += 16; - if(FromID == null) { Console.WriteLine("Warning: FromID is null, in " + this.GetType()); } - Array.Copy(FromID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(ToID == null) { Console.WriteLine("Warning: ToID is null, in " + this.GetType()); } + Array.Copy(ToID.GetBytes(), 0, bytes, i, 16); i += 16; + if(FromID == null) { Console.WriteLine("Warning: FromID is null, in " + this.GetType()); } + Array.Copy(FromID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ReputationData --\n"; - output += "ToID: " + ToID.ToString() + "\n"; - output += "FromID: " + FromID.ToString() + "\n"; + { + string output = "-- ReputationData --\n"; + output += "ToID: " + ToID.ToString() + "\n"; + output += "FromID: " + FromID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ReputationIndividualRequest - public override PacketType Type { get { return PacketType.ReputationIndividualRequest; } } - /// ReputationData block - public ReputationDataBlock ReputationData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ReputationIndividualRequest + public override PacketType Type { get { return PacketType.ReputationIndividualRequest; } } + /// ReputationData block + public ReputationDataBlock ReputationData; + + /// Default constructor public ReputationIndividualRequestPacket() - { - Header = new LowHeader(); - Header.ID = 406; - Header.Reliable = true; - ReputationData = new ReputationDataBlock(); + { + Header = new LowHeader(); + Header.ID = 406; + Header.Reliable = true; + ReputationData = new ReputationDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ReputationIndividualRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - ReputationData = new ReputationDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + ReputationData = new ReputationDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ReputationIndividualRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - ReputationData = new ReputationDataBlock(bytes, ref i); + { + Header = head; + ReputationData = new ReputationDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += ReputationData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - ReputationData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += ReputationData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + ReputationData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ReputationIndividualRequest ---\n"; - output += ReputationData.ToString() + "\n"; + { + string output = "--- ReputationIndividualRequest ---\n"; + output += ReputationData.ToString() + "\n"; return output; } - + } - - /// ReputationIndividualReply packet + + /// ReputationIndividualReply packet public class ReputationIndividualReplyPacket : Packet - { - /// ReputationData block + { + /// ReputationData block public class ReputationDataBlock - { - /// Appearance field - public float Appearance; - /// ToID field - public LLUUID ToID; - /// Behavior field - public float Behavior; - /// FromID field - public LLUUID FromID; - /// Building field - public float Building; - - /// Length of this block serialized in bytes + { + /// Appearance field + public float Appearance; + /// ToID field + public LLUUID ToID; + /// Behavior field + public float Behavior; + /// FromID field + public LLUUID FromID; + /// Building field + public float Building; + + /// Length of this block serialized in bytes public int Length { get - { - return 44; + { + return 44; } } - - /// Default constructor - public ReputationDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ReputationDataBlock() { } + /// Constructor for building the block from a byte array public ReputationDataBlock(byte[] bytes, ref int i) - { + { try - { - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - Appearance = BitConverter.ToSingle(bytes, i); i += 4; - ToID = new LLUUID(bytes, i); i += 16; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - Behavior = BitConverter.ToSingle(bytes, i); i += 4; - FromID = new LLUUID(bytes, i); i += 16; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - Building = BitConverter.ToSingle(bytes, i); i += 4; + { + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + Appearance = BitConverter.ToSingle(bytes, i); i += 4; + ToID = new LLUUID(bytes, i); i += 16; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + Behavior = BitConverter.ToSingle(bytes, i); i += 4; + FromID = new LLUUID(bytes, i); i += 16; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + Building = BitConverter.ToSingle(bytes, i); i += 4; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; + { + byte[] ba; ba = BitConverter.GetBytes(Appearance); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - if(ToID == null) { Console.WriteLine("Warning: ToID is null, in " + this.GetType()); } - Array.Copy(ToID.GetBytes(), 0, bytes, i, 16); i += 16; + Array.Copy(ba, 0, bytes, i, 4); i += 4; + if(ToID == null) { Console.WriteLine("Warning: ToID is null, in " + this.GetType()); } + Array.Copy(ToID.GetBytes(), 0, bytes, i, 16); i += 16; ba = BitConverter.GetBytes(Behavior); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - if(FromID == null) { Console.WriteLine("Warning: FromID is null, in " + this.GetType()); } - Array.Copy(FromID.GetBytes(), 0, bytes, i, 16); i += 16; + Array.Copy(ba, 0, bytes, i, 4); i += 4; + if(FromID == null) { Console.WriteLine("Warning: FromID is null, in " + this.GetType()); } + Array.Copy(FromID.GetBytes(), 0, bytes, i, 16); i += 16; ba = BitConverter.GetBytes(Building); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ReputationData --\n"; - output += "Appearance: " + Appearance.ToString() + "\n"; - output += "ToID: " + ToID.ToString() + "\n"; - output += "Behavior: " + Behavior.ToString() + "\n"; - output += "FromID: " + FromID.ToString() + "\n"; - output += "Building: " + Building.ToString() + "\n"; + { + string output = "-- ReputationData --\n"; + output += "Appearance: " + Appearance.ToString() + "\n"; + output += "ToID: " + ToID.ToString() + "\n"; + output += "Behavior: " + Behavior.ToString() + "\n"; + output += "FromID: " + FromID.ToString() + "\n"; + output += "Building: " + Building.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ReputationIndividualReply - public override PacketType Type { get { return PacketType.ReputationIndividualReply; } } - /// ReputationData block - public ReputationDataBlock ReputationData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ReputationIndividualReply + public override PacketType Type { get { return PacketType.ReputationIndividualReply; } } + /// ReputationData block + public ReputationDataBlock ReputationData; + + /// Default constructor public ReputationIndividualReplyPacket() - { - Header = new LowHeader(); - Header.ID = 407; - Header.Reliable = true; - ReputationData = new ReputationDataBlock(); + { + Header = new LowHeader(); + Header.ID = 407; + Header.Reliable = true; + ReputationData = new ReputationDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ReputationIndividualReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - ReputationData = new ReputationDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + ReputationData = new ReputationDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ReputationIndividualReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - ReputationData = new ReputationDataBlock(bytes, ref i); + { + Header = head; + ReputationData = new ReputationDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += ReputationData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - ReputationData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += ReputationData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + ReputationData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ReputationIndividualReply ---\n"; - output += ReputationData.ToString() + "\n"; + { + string output = "--- ReputationIndividualReply ---\n"; + output += ReputationData.ToString() + "\n"; return output; } - + } - - /// EmailMessageRequest packet + + /// EmailMessageRequest packet public class EmailMessageRequestPacket : Packet - { - /// DataBlock block + { + /// DataBlock block public class DataBlockBlock - { - /// ObjectID field - public LLUUID ObjectID; - private byte[] _subject; - /// Subject field + { + /// ObjectID field + public LLUUID ObjectID; + private byte[] _subject; + /// Subject field public byte[] Subject - { - get { return _subject; } + { + get { return _subject; } set - { - if (value == null) { _subject = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _subject = new byte[value.Length]; Array.Copy(value, _subject, value.Length); } + { + if (value == null) { _subject = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _subject = new byte[value.Length]; Array.Copy(value, _subject, value.Length); } } - } - private byte[] _fromaddress; - /// FromAddress field + } + private byte[] _fromaddress; + /// FromAddress field public byte[] FromAddress - { - get { return _fromaddress; } + { + get { return _fromaddress; } set - { - if (value == null) { _fromaddress = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _fromaddress = new byte[value.Length]; Array.Copy(value, _fromaddress, value.Length); } + { + if (value == null) { _fromaddress = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _fromaddress = new byte[value.Length]; Array.Copy(value, _fromaddress, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 16; - if (Subject != null) { length += 1 + Subject.Length; } - if (FromAddress != null) { length += 1 + FromAddress.Length; } - return length; + { + int length = 16; + if (Subject != null) { length += 1 + Subject.Length; } + if (FromAddress != null) { length += 1 + FromAddress.Length; } + return length; } } - - /// Default constructor - public DataBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlockBlock() { } + /// Constructor for building the block from a byte array public DataBlockBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - ObjectID = new LLUUID(bytes, i); i += 16; - length = (ushort)bytes[i++]; - _subject = new byte[length]; - Array.Copy(bytes, i, _subject, 0, length); i += length; - length = (ushort)bytes[i++]; - _fromaddress = new byte[length]; - Array.Copy(bytes, i, _fromaddress, 0, length); i += length; + { + ObjectID = new LLUUID(bytes, i); i += 16; + length = (ushort)bytes[i++]; + _subject = new byte[length]; + Array.Copy(bytes, i, _subject, 0, length); i += length; + length = (ushort)bytes[i++]; + _fromaddress = new byte[length]; + Array.Copy(bytes, i, _fromaddress, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } - Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; - if(Subject == null) { Console.WriteLine("Warning: Subject is null, in " + this.GetType()); } - bytes[i++] = (byte)Subject.Length; - Array.Copy(Subject, 0, bytes, i, Subject.Length); i += Subject.Length; - if(FromAddress == null) { Console.WriteLine("Warning: FromAddress is null, in " + this.GetType()); } - bytes[i++] = (byte)FromAddress.Length; - Array.Copy(FromAddress, 0, bytes, i, FromAddress.Length); i += FromAddress.Length; + { + if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } + Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; + if(Subject == null) { Console.WriteLine("Warning: Subject is null, in " + this.GetType()); } + bytes[i++] = (byte)Subject.Length; + Array.Copy(Subject, 0, bytes, i, Subject.Length); i += Subject.Length; + if(FromAddress == null) { Console.WriteLine("Warning: FromAddress is null, in " + this.GetType()); } + bytes[i++] = (byte)FromAddress.Length; + Array.Copy(FromAddress, 0, bytes, i, FromAddress.Length); i += FromAddress.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- DataBlock --\n"; - output += "ObjectID: " + ObjectID.ToString() + "\n"; - output += Helpers.FieldToString(Subject, "Subject") + "\n"; - output += Helpers.FieldToString(FromAddress, "FromAddress") + "\n"; + { + string output = "-- DataBlock --\n"; + output += "ObjectID: " + ObjectID.ToString() + "\n"; + output += Helpers.FieldToString(Subject, "Subject") + "\n"; + output += Helpers.FieldToString(FromAddress, "FromAddress") + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.EmailMessageRequest - public override PacketType Type { get { return PacketType.EmailMessageRequest; } } - /// DataBlock block - public DataBlockBlock DataBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.EmailMessageRequest + public override PacketType Type { get { return PacketType.EmailMessageRequest; } } + /// DataBlock block + public DataBlockBlock DataBlock; + + /// Default constructor public EmailMessageRequestPacket() - { - Header = new LowHeader(); - Header.ID = 408; - Header.Reliable = true; - DataBlock = new DataBlockBlock(); + { + Header = new LowHeader(); + Header.ID = 408; + Header.Reliable = true; + DataBlock = new DataBlockBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public EmailMessageRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - DataBlock = new DataBlockBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + DataBlock = new DataBlockBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public EmailMessageRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - DataBlock = new DataBlockBlock(bytes, ref i); + { + Header = head; + DataBlock = new DataBlockBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += DataBlock.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - DataBlock.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += DataBlock.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + DataBlock.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- EmailMessageRequest ---\n"; - output += DataBlock.ToString() + "\n"; + { + string output = "--- EmailMessageRequest ---\n"; + output += DataBlock.ToString() + "\n"; return output; } - + } - - /// EmailMessageReply packet + + /// EmailMessageReply packet public class EmailMessageReplyPacket : Packet - { - /// DataBlock block + { + /// DataBlock block public class DataBlockBlock - { - /// ObjectID field - public LLUUID ObjectID; - private byte[] _data; - /// Data field + { + /// ObjectID field + public LLUUID ObjectID; + private byte[] _data; + /// Data field public byte[] Data - { - get { return _data; } + { + get { return _data; } set - { - if (value == null) { _data = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _data = new byte[value.Length]; Array.Copy(value, _data, value.Length); } + { + if (value == null) { _data = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _data = new byte[value.Length]; Array.Copy(value, _data, value.Length); } } - } - private byte[] _subject; - /// Subject field + } + private byte[] _subject; + /// Subject field public byte[] Subject - { - get { return _subject; } + { + get { return _subject; } set - { - if (value == null) { _subject = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _subject = new byte[value.Length]; Array.Copy(value, _subject, value.Length); } + { + if (value == null) { _subject = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _subject = new byte[value.Length]; Array.Copy(value, _subject, value.Length); } } - } - /// Time field - public uint Time; - private byte[] _fromaddress; - /// FromAddress field + } + /// Time field + public uint Time; + private byte[] _fromaddress; + /// FromAddress field public byte[] FromAddress - { - get { return _fromaddress; } + { + get { return _fromaddress; } set - { - if (value == null) { _fromaddress = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _fromaddress = new byte[value.Length]; Array.Copy(value, _fromaddress, value.Length); } + { + if (value == null) { _fromaddress = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _fromaddress = new byte[value.Length]; Array.Copy(value, _fromaddress, value.Length); } } - } - /// More field - public uint More; - private byte[] _mailfilter; - /// MailFilter field + } + /// More field + public uint More; + private byte[] _mailfilter; + /// MailFilter field public byte[] MailFilter - { - get { return _mailfilter; } + { + get { return _mailfilter; } set - { - if (value == null) { _mailfilter = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _mailfilter = new byte[value.Length]; Array.Copy(value, _mailfilter, value.Length); } + { + if (value == null) { _mailfilter = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _mailfilter = new byte[value.Length]; Array.Copy(value, _mailfilter, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 24; - if (Data != null) { length += 2 + Data.Length; } - if (Subject != null) { length += 1 + Subject.Length; } - if (FromAddress != null) { length += 1 + FromAddress.Length; } - if (MailFilter != null) { length += 1 + MailFilter.Length; } - return length; + { + int length = 24; + if (Data != null) { length += 2 + Data.Length; } + if (Subject != null) { length += 1 + Subject.Length; } + if (FromAddress != null) { length += 1 + FromAddress.Length; } + if (MailFilter != null) { length += 1 + MailFilter.Length; } + return length; } } - - /// Default constructor - public DataBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlockBlock() { } + /// Constructor for building the block from a byte array public DataBlockBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - ObjectID = new LLUUID(bytes, i); i += 16; - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _data = new byte[length]; - Array.Copy(bytes, i, _data, 0, length); i += length; - length = (ushort)bytes[i++]; - _subject = new byte[length]; - Array.Copy(bytes, i, _subject, 0, length); i += length; - Time = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _fromaddress = new byte[length]; - Array.Copy(bytes, i, _fromaddress, 0, length); i += length; - More = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _mailfilter = new byte[length]; - Array.Copy(bytes, i, _mailfilter, 0, length); i += length; + { + ObjectID = new LLUUID(bytes, i); i += 16; + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _data = new byte[length]; + Array.Copy(bytes, i, _data, 0, length); i += length; + length = (ushort)bytes[i++]; + _subject = new byte[length]; + Array.Copy(bytes, i, _subject, 0, length); i += length; + Time = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _fromaddress = new byte[length]; + Array.Copy(bytes, i, _fromaddress, 0, length); i += length; + More = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _mailfilter = new byte[length]; + Array.Copy(bytes, i, _mailfilter, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } - Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; - if(Data == null) { Console.WriteLine("Warning: Data is null, in " + this.GetType()); } - bytes[i++] = (byte)(Data.Length % 256); - bytes[i++] = (byte)((Data.Length >> 8) % 256); - Array.Copy(Data, 0, bytes, i, Data.Length); i += Data.Length; - if(Subject == null) { Console.WriteLine("Warning: Subject is null, in " + this.GetType()); } - bytes[i++] = (byte)Subject.Length; - Array.Copy(Subject, 0, bytes, i, Subject.Length); i += Subject.Length; - bytes[i++] = (byte)(Time % 256); - bytes[i++] = (byte)((Time >> 8) % 256); - bytes[i++] = (byte)((Time >> 16) % 256); - bytes[i++] = (byte)((Time >> 24) % 256); - if(FromAddress == null) { Console.WriteLine("Warning: FromAddress is null, in " + this.GetType()); } - bytes[i++] = (byte)FromAddress.Length; - Array.Copy(FromAddress, 0, bytes, i, FromAddress.Length); i += FromAddress.Length; - bytes[i++] = (byte)(More % 256); - bytes[i++] = (byte)((More >> 8) % 256); - bytes[i++] = (byte)((More >> 16) % 256); - bytes[i++] = (byte)((More >> 24) % 256); - if(MailFilter == null) { Console.WriteLine("Warning: MailFilter is null, in " + this.GetType()); } - bytes[i++] = (byte)MailFilter.Length; - Array.Copy(MailFilter, 0, bytes, i, MailFilter.Length); i += MailFilter.Length; + { + if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } + Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; + if(Data == null) { Console.WriteLine("Warning: Data is null, in " + this.GetType()); } + bytes[i++] = (byte)(Data.Length % 256); + bytes[i++] = (byte)((Data.Length >> 8) % 256); + Array.Copy(Data, 0, bytes, i, Data.Length); i += Data.Length; + if(Subject == null) { Console.WriteLine("Warning: Subject is null, in " + this.GetType()); } + bytes[i++] = (byte)Subject.Length; + Array.Copy(Subject, 0, bytes, i, Subject.Length); i += Subject.Length; + bytes[i++] = (byte)(Time % 256); + bytes[i++] = (byte)((Time >> 8) % 256); + bytes[i++] = (byte)((Time >> 16) % 256); + bytes[i++] = (byte)((Time >> 24) % 256); + if(FromAddress == null) { Console.WriteLine("Warning: FromAddress is null, in " + this.GetType()); } + bytes[i++] = (byte)FromAddress.Length; + Array.Copy(FromAddress, 0, bytes, i, FromAddress.Length); i += FromAddress.Length; + bytes[i++] = (byte)(More % 256); + bytes[i++] = (byte)((More >> 8) % 256); + bytes[i++] = (byte)((More >> 16) % 256); + bytes[i++] = (byte)((More >> 24) % 256); + if(MailFilter == null) { Console.WriteLine("Warning: MailFilter is null, in " + this.GetType()); } + bytes[i++] = (byte)MailFilter.Length; + Array.Copy(MailFilter, 0, bytes, i, MailFilter.Length); i += MailFilter.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- DataBlock --\n"; - output += "ObjectID: " + ObjectID.ToString() + "\n"; - output += Helpers.FieldToString(Data, "Data") + "\n"; - output += Helpers.FieldToString(Subject, "Subject") + "\n"; - output += "Time: " + Time.ToString() + "\n"; - output += Helpers.FieldToString(FromAddress, "FromAddress") + "\n"; - output += "More: " + More.ToString() + "\n"; - output += Helpers.FieldToString(MailFilter, "MailFilter") + "\n"; + { + string output = "-- DataBlock --\n"; + output += "ObjectID: " + ObjectID.ToString() + "\n"; + output += Helpers.FieldToString(Data, "Data") + "\n"; + output += Helpers.FieldToString(Subject, "Subject") + "\n"; + output += "Time: " + Time.ToString() + "\n"; + output += Helpers.FieldToString(FromAddress, "FromAddress") + "\n"; + output += "More: " + More.ToString() + "\n"; + output += Helpers.FieldToString(MailFilter, "MailFilter") + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.EmailMessageReply - public override PacketType Type { get { return PacketType.EmailMessageReply; } } - /// DataBlock block - public DataBlockBlock DataBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.EmailMessageReply + public override PacketType Type { get { return PacketType.EmailMessageReply; } } + /// DataBlock block + public DataBlockBlock DataBlock; + + /// Default constructor public EmailMessageReplyPacket() - { - Header = new LowHeader(); - Header.ID = 409; - Header.Reliable = true; - DataBlock = new DataBlockBlock(); + { + Header = new LowHeader(); + Header.ID = 409; + Header.Reliable = true; + DataBlock = new DataBlockBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public EmailMessageReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - DataBlock = new DataBlockBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + DataBlock = new DataBlockBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public EmailMessageReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - DataBlock = new DataBlockBlock(bytes, ref i); + { + Header = head; + DataBlock = new DataBlockBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += DataBlock.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - DataBlock.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += DataBlock.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + DataBlock.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- EmailMessageReply ---\n"; - output += DataBlock.ToString() + "\n"; + { + string output = "--- EmailMessageReply ---\n"; + output += DataBlock.ToString() + "\n"; return output; } - + } - - /// ScriptDataRequest packet + + /// ScriptDataRequest packet public class ScriptDataRequestPacket : Packet - { - /// DataBlock block + { + /// DataBlock block public class DataBlockBlock - { - /// RequestType field - public sbyte RequestType; - private byte[] _request; - /// Request field + { + /// RequestType field + public sbyte RequestType; + private byte[] _request; + /// Request field public byte[] Request - { - get { return _request; } + { + get { return _request; } set - { - if (value == null) { _request = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _request = new byte[value.Length]; Array.Copy(value, _request, value.Length); } + { + if (value == null) { _request = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _request = new byte[value.Length]; Array.Copy(value, _request, value.Length); } } - } - /// Hash field - public ulong Hash; - - /// Length of this block serialized in bytes + } + /// Hash field + public ulong Hash; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 9; - if (Request != null) { length += 2 + Request.Length; } - return length; + { + int length = 9; + if (Request != null) { length += 2 + Request.Length; } + return length; } } - - /// Default constructor - public DataBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlockBlock() { } + /// Constructor for building the block from a byte array public DataBlockBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - RequestType = (sbyte)bytes[i++]; - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _request = new byte[length]; - Array.Copy(bytes, i, _request, 0, length); i += length; - Hash = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + { + RequestType = (sbyte)bytes[i++]; + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _request = new byte[length]; + Array.Copy(bytes, i, _request, 0, length); i += length; + Hash = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)RequestType; - if(Request == null) { Console.WriteLine("Warning: Request is null, in " + this.GetType()); } - bytes[i++] = (byte)(Request.Length % 256); - bytes[i++] = (byte)((Request.Length >> 8) % 256); - Array.Copy(Request, 0, bytes, i, Request.Length); i += Request.Length; - bytes[i++] = (byte)(Hash % 256); - bytes[i++] = (byte)((Hash >> 8) % 256); - bytes[i++] = (byte)((Hash >> 16) % 256); - bytes[i++] = (byte)((Hash >> 24) % 256); - bytes[i++] = (byte)((Hash >> 32) % 256); - bytes[i++] = (byte)((Hash >> 40) % 256); - bytes[i++] = (byte)((Hash >> 48) % 256); - bytes[i++] = (byte)((Hash >> 56) % 256); + { + bytes[i++] = (byte)RequestType; + if(Request == null) { Console.WriteLine("Warning: Request is null, in " + this.GetType()); } + bytes[i++] = (byte)(Request.Length % 256); + bytes[i++] = (byte)((Request.Length >> 8) % 256); + Array.Copy(Request, 0, bytes, i, Request.Length); i += Request.Length; + bytes[i++] = (byte)(Hash % 256); + bytes[i++] = (byte)((Hash >> 8) % 256); + bytes[i++] = (byte)((Hash >> 16) % 256); + bytes[i++] = (byte)((Hash >> 24) % 256); + bytes[i++] = (byte)((Hash >> 32) % 256); + bytes[i++] = (byte)((Hash >> 40) % 256); + bytes[i++] = (byte)((Hash >> 48) % 256); + bytes[i++] = (byte)((Hash >> 56) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- DataBlock --\n"; - output += "RequestType: " + RequestType.ToString() + "\n"; - output += Helpers.FieldToString(Request, "Request") + "\n"; - output += "Hash: " + Hash.ToString() + "\n"; + { + string output = "-- DataBlock --\n"; + output += "RequestType: " + RequestType.ToString() + "\n"; + output += Helpers.FieldToString(Request, "Request") + "\n"; + output += "Hash: " + Hash.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ScriptDataRequest - public override PacketType Type { get { return PacketType.ScriptDataRequest; } } - /// DataBlock block - public DataBlockBlock[] DataBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ScriptDataRequest + public override PacketType Type { get { return PacketType.ScriptDataRequest; } } + /// DataBlock block + public DataBlockBlock[] DataBlock; + + /// Default constructor public ScriptDataRequestPacket() - { - Header = new LowHeader(); - Header.ID = 410; - Header.Reliable = true; - DataBlock = new DataBlockBlock[0]; + { + Header = new LowHeader(); + Header.ID = 410; + Header.Reliable = true; + DataBlock = new DataBlockBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ScriptDataRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - DataBlock = new DataBlockBlock[count]; - for (int j = 0; j < count; j++) - { DataBlock[j] = new DataBlockBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + DataBlock = new DataBlockBlock[count]; + for (int j = 0; j < count; j++) + { DataBlock[j] = new DataBlockBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ScriptDataRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - DataBlock = new DataBlockBlock[count]; - for (int j = 0; j < count; j++) - { DataBlock[j] = new DataBlockBlock(bytes, ref i); } + { + Header = head; + int count = (int)bytes[i++]; + DataBlock = new DataBlockBlock[count]; + for (int j = 0; j < count; j++) + { DataBlock[j] = new DataBlockBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; -; - length++; - for (int j = 0; j < DataBlock.Length; j++) { length += DataBlock[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)DataBlock.Length; - for (int j = 0; j < DataBlock.Length; j++) { DataBlock[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; +; + length++; + for (int j = 0; j < DataBlock.Length; j++) { length += DataBlock[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)DataBlock.Length; + for (int j = 0; j < DataBlock.Length; j++) { DataBlock[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ScriptDataRequest ---\n"; + { + string output = "--- ScriptDataRequest ---\n"; for (int j = 0; j < DataBlock.Length; j++) - { + { output += DataBlock[j].ToString() + "\n"; - } + } return output; } - + } - - /// ScriptDataReply packet + + /// ScriptDataReply packet public class ScriptDataReplyPacket : Packet - { - /// DataBlock block + { + /// DataBlock block public class DataBlockBlock - { - /// Hash field - public ulong Hash; - private byte[] _reply; - /// Reply field + { + /// Hash field + public ulong Hash; + private byte[] _reply; + /// Reply field public byte[] Reply - { - get { return _reply; } + { + get { return _reply; } set - { - if (value == null) { _reply = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _reply = new byte[value.Length]; Array.Copy(value, _reply, value.Length); } + { + if (value == null) { _reply = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _reply = new byte[value.Length]; Array.Copy(value, _reply, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 8; - if (Reply != null) { length += 2 + Reply.Length; } - return length; + { + int length = 8; + if (Reply != null) { length += 2 + Reply.Length; } + return length; } } - - /// Default constructor - public DataBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlockBlock() { } + /// Constructor for building the block from a byte array public DataBlockBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - Hash = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _reply = new byte[length]; - Array.Copy(bytes, i, _reply, 0, length); i += length; + { + Hash = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _reply = new byte[length]; + Array.Copy(bytes, i, _reply, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(Hash % 256); - bytes[i++] = (byte)((Hash >> 8) % 256); - bytes[i++] = (byte)((Hash >> 16) % 256); - bytes[i++] = (byte)((Hash >> 24) % 256); - bytes[i++] = (byte)((Hash >> 32) % 256); - bytes[i++] = (byte)((Hash >> 40) % 256); - bytes[i++] = (byte)((Hash >> 48) % 256); - bytes[i++] = (byte)((Hash >> 56) % 256); - if(Reply == null) { Console.WriteLine("Warning: Reply is null, in " + this.GetType()); } - bytes[i++] = (byte)(Reply.Length % 256); - bytes[i++] = (byte)((Reply.Length >> 8) % 256); - Array.Copy(Reply, 0, bytes, i, Reply.Length); i += Reply.Length; + { + bytes[i++] = (byte)(Hash % 256); + bytes[i++] = (byte)((Hash >> 8) % 256); + bytes[i++] = (byte)((Hash >> 16) % 256); + bytes[i++] = (byte)((Hash >> 24) % 256); + bytes[i++] = (byte)((Hash >> 32) % 256); + bytes[i++] = (byte)((Hash >> 40) % 256); + bytes[i++] = (byte)((Hash >> 48) % 256); + bytes[i++] = (byte)((Hash >> 56) % 256); + if(Reply == null) { Console.WriteLine("Warning: Reply is null, in " + this.GetType()); } + bytes[i++] = (byte)(Reply.Length % 256); + bytes[i++] = (byte)((Reply.Length >> 8) % 256); + Array.Copy(Reply, 0, bytes, i, Reply.Length); i += Reply.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- DataBlock --\n"; - output += "Hash: " + Hash.ToString() + "\n"; - output += Helpers.FieldToString(Reply, "Reply") + "\n"; + { + string output = "-- DataBlock --\n"; + output += "Hash: " + Hash.ToString() + "\n"; + output += Helpers.FieldToString(Reply, "Reply") + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ScriptDataReply - public override PacketType Type { get { return PacketType.ScriptDataReply; } } - /// DataBlock block - public DataBlockBlock[] DataBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ScriptDataReply + public override PacketType Type { get { return PacketType.ScriptDataReply; } } + /// DataBlock block + public DataBlockBlock[] DataBlock; + + /// Default constructor public ScriptDataReplyPacket() - { - Header = new LowHeader(); - Header.ID = 411; - Header.Reliable = true; - DataBlock = new DataBlockBlock[0]; + { + Header = new LowHeader(); + Header.ID = 411; + Header.Reliable = true; + DataBlock = new DataBlockBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ScriptDataReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - DataBlock = new DataBlockBlock[count]; - for (int j = 0; j < count; j++) - { DataBlock[j] = new DataBlockBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + DataBlock = new DataBlockBlock[count]; + for (int j = 0; j < count; j++) + { DataBlock[j] = new DataBlockBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ScriptDataReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - DataBlock = new DataBlockBlock[count]; - for (int j = 0; j < count; j++) - { DataBlock[j] = new DataBlockBlock(bytes, ref i); } + { + Header = head; + int count = (int)bytes[i++]; + DataBlock = new DataBlockBlock[count]; + for (int j = 0; j < count; j++) + { DataBlock[j] = new DataBlockBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; -; - length++; - for (int j = 0; j < DataBlock.Length; j++) { length += DataBlock[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)DataBlock.Length; - for (int j = 0; j < DataBlock.Length; j++) { DataBlock[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; +; + length++; + for (int j = 0; j < DataBlock.Length; j++) { length += DataBlock[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)DataBlock.Length; + for (int j = 0; j < DataBlock.Length; j++) { DataBlock[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ScriptDataReply ---\n"; + { + string output = "--- ScriptDataReply ---\n"; for (int j = 0; j < DataBlock.Length; j++) - { + { output += DataBlock[j].ToString() + "\n"; - } + } return output; } - + } - - /// CreateGroupRequest packet + + /// CreateGroupRequest packet public class CreateGroupRequestPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// GroupData block + + /// GroupData block public class GroupDataBlock - { - /// AllowPublish field - public bool AllowPublish; - private byte[] _charter; - /// Charter field + { + /// AllowPublish field + public bool AllowPublish; + private byte[] _charter; + /// Charter field public byte[] Charter - { - get { return _charter; } + { + get { return _charter; } set - { - if (value == null) { _charter = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _charter = new byte[value.Length]; Array.Copy(value, _charter, value.Length); } + { + if (value == null) { _charter = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _charter = new byte[value.Length]; Array.Copy(value, _charter, value.Length); } } - } - /// ShowInList field - public bool ShowInList; - private byte[] _name; - /// Name field + } + /// ShowInList field + public bool ShowInList; + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - /// InsigniaID field - public LLUUID InsigniaID; - /// MembershipFee field - public int MembershipFee; - /// MaturePublish field - public bool MaturePublish; - /// OpenEnrollment field - public bool OpenEnrollment; - - /// Length of this block serialized in bytes + } + /// InsigniaID field + public LLUUID InsigniaID; + /// MembershipFee field + public int MembershipFee; + /// MaturePublish field + public bool MaturePublish; + /// OpenEnrollment field + public bool OpenEnrollment; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 24; - if (Charter != null) { length += 2 + Charter.Length; } - if (Name != null) { length += 1 + Name.Length; } - return length; + { + int length = 24; + if (Charter != null) { length += 2 + Charter.Length; } + if (Name != null) { length += 1 + Name.Length; } + return length; } } - - /// Default constructor - public GroupDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public GroupDataBlock() { } + /// Constructor for building the block from a byte array public GroupDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - AllowPublish = (bytes[i++] != 0) ? (bool)true : (bool)false; - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _charter = new byte[length]; - Array.Copy(bytes, i, _charter, 0, length); i += length; - ShowInList = (bytes[i++] != 0) ? (bool)true : (bool)false; - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; - InsigniaID = new LLUUID(bytes, i); i += 16; - MembershipFee = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - MaturePublish = (bytes[i++] != 0) ? (bool)true : (bool)false; - OpenEnrollment = (bytes[i++] != 0) ? (bool)true : (bool)false; + { + AllowPublish = (bytes[i++] != 0) ? (bool)true : (bool)false; + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _charter = new byte[length]; + Array.Copy(bytes, i, _charter, 0, length); i += length; + ShowInList = (bytes[i++] != 0) ? (bool)true : (bool)false; + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; + InsigniaID = new LLUUID(bytes, i); i += 16; + MembershipFee = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + MaturePublish = (bytes[i++] != 0) ? (bool)true : (bool)false; + OpenEnrollment = (bytes[i++] != 0) ? (bool)true : (bool)false; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)((AllowPublish) ? 1 : 0); - if(Charter == null) { Console.WriteLine("Warning: Charter is null, in " + this.GetType()); } - bytes[i++] = (byte)(Charter.Length % 256); - bytes[i++] = (byte)((Charter.Length >> 8) % 256); - Array.Copy(Charter, 0, bytes, i, Charter.Length); i += Charter.Length; - bytes[i++] = (byte)((ShowInList) ? 1 : 0); - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; - if(InsigniaID == null) { Console.WriteLine("Warning: InsigniaID is null, in " + this.GetType()); } - Array.Copy(InsigniaID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(MembershipFee % 256); - bytes[i++] = (byte)((MembershipFee >> 8) % 256); - bytes[i++] = (byte)((MembershipFee >> 16) % 256); - bytes[i++] = (byte)((MembershipFee >> 24) % 256); - bytes[i++] = (byte)((MaturePublish) ? 1 : 0); - bytes[i++] = (byte)((OpenEnrollment) ? 1 : 0); + { + bytes[i++] = (byte)((AllowPublish) ? 1 : 0); + if(Charter == null) { Console.WriteLine("Warning: Charter is null, in " + this.GetType()); } + bytes[i++] = (byte)(Charter.Length % 256); + bytes[i++] = (byte)((Charter.Length >> 8) % 256); + Array.Copy(Charter, 0, bytes, i, Charter.Length); i += Charter.Length; + bytes[i++] = (byte)((ShowInList) ? 1 : 0); + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + if(InsigniaID == null) { Console.WriteLine("Warning: InsigniaID is null, in " + this.GetType()); } + Array.Copy(InsigniaID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(MembershipFee % 256); + bytes[i++] = (byte)((MembershipFee >> 8) % 256); + bytes[i++] = (byte)((MembershipFee >> 16) % 256); + bytes[i++] = (byte)((MembershipFee >> 24) % 256); + bytes[i++] = (byte)((MaturePublish) ? 1 : 0); + bytes[i++] = (byte)((OpenEnrollment) ? 1 : 0); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- GroupData --\n"; - output += "AllowPublish: " + AllowPublish.ToString() + "\n"; - output += Helpers.FieldToString(Charter, "Charter") + "\n"; - output += "ShowInList: " + ShowInList.ToString() + "\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; - output += "InsigniaID: " + InsigniaID.ToString() + "\n"; - output += "MembershipFee: " + MembershipFee.ToString() + "\n"; - output += "MaturePublish: " + MaturePublish.ToString() + "\n"; - output += "OpenEnrollment: " + OpenEnrollment.ToString() + "\n"; + { + string output = "-- GroupData --\n"; + output += "AllowPublish: " + AllowPublish.ToString() + "\n"; + output += Helpers.FieldToString(Charter, "Charter") + "\n"; + output += "ShowInList: " + ShowInList.ToString() + "\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; + output += "InsigniaID: " + InsigniaID.ToString() + "\n"; + output += "MembershipFee: " + MembershipFee.ToString() + "\n"; + output += "MaturePublish: " + MaturePublish.ToString() + "\n"; + output += "OpenEnrollment: " + OpenEnrollment.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.CreateGroupRequest - public override PacketType Type { get { return PacketType.CreateGroupRequest; } } - /// AgentData block - public AgentDataBlock AgentData; - /// GroupData block - public GroupDataBlock GroupData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.CreateGroupRequest + public override PacketType Type { get { return PacketType.CreateGroupRequest; } } + /// AgentData block + public AgentDataBlock AgentData; + /// GroupData block + public GroupDataBlock GroupData; + + /// Default constructor public CreateGroupRequestPacket() - { - Header = new LowHeader(); - Header.ID = 412; - Header.Reliable = true; - Header.Zerocoded = true; - AgentData = new AgentDataBlock(); - GroupData = new GroupDataBlock(); + { + Header = new LowHeader(); + Header.ID = 412; + Header.Reliable = true; + Header.Zerocoded = true; + AgentData = new AgentDataBlock(); + GroupData = new GroupDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public CreateGroupRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); - GroupData = new GroupDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); + GroupData = new GroupDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public CreateGroupRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); - GroupData = new GroupDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); + GroupData = new GroupDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length; length += GroupData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - GroupData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length; length += GroupData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + GroupData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- CreateGroupRequest ---\n"; - output += AgentData.ToString() + "\n"; - output += GroupData.ToString() + "\n"; + { + string output = "--- CreateGroupRequest ---\n"; + output += AgentData.ToString() + "\n"; + output += GroupData.ToString() + "\n"; return output; } - + } - - /// CreateGroupReply packet + + /// CreateGroupReply packet public class CreateGroupReplyPacket : Packet - { - /// ReplyData block + { + /// ReplyData block public class ReplyDataBlock - { - private byte[] _message; - /// Message field + { + private byte[] _message; + /// Message field public byte[] Message - { - get { return _message; } + { + get { return _message; } set - { - if (value == null) { _message = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _message = new byte[value.Length]; Array.Copy(value, _message, value.Length); } + { + if (value == null) { _message = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _message = new byte[value.Length]; Array.Copy(value, _message, value.Length); } } - } - /// Success field - public bool Success; - /// GroupID field - public LLUUID GroupID; - - /// Length of this block serialized in bytes + } + /// Success field + public bool Success; + /// GroupID field + public LLUUID GroupID; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 17; - if (Message != null) { length += 1 + Message.Length; } - return length; + { + int length = 17; + if (Message != null) { length += 1 + Message.Length; } + return length; } } - - /// Default constructor - public ReplyDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ReplyDataBlock() { } + /// Constructor for building the block from a byte array public ReplyDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _message = new byte[length]; - Array.Copy(bytes, i, _message, 0, length); i += length; - Success = (bytes[i++] != 0) ? (bool)true : (bool)false; - GroupID = new LLUUID(bytes, i); i += 16; + { + length = (ushort)bytes[i++]; + _message = new byte[length]; + Array.Copy(bytes, i, _message, 0, length); i += length; + Success = (bytes[i++] != 0) ? (bool)true : (bool)false; + GroupID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(Message == null) { Console.WriteLine("Warning: Message is null, in " + this.GetType()); } - bytes[i++] = (byte)Message.Length; - Array.Copy(Message, 0, bytes, i, Message.Length); i += Message.Length; - bytes[i++] = (byte)((Success) ? 1 : 0); - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(Message == null) { Console.WriteLine("Warning: Message is null, in " + this.GetType()); } + bytes[i++] = (byte)Message.Length; + Array.Copy(Message, 0, bytes, i, Message.Length); i += Message.Length; + bytes[i++] = (byte)((Success) ? 1 : 0); + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ReplyData --\n"; - output += Helpers.FieldToString(Message, "Message") + "\n"; - output += "Success: " + Success.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; + { + string output = "-- ReplyData --\n"; + output += Helpers.FieldToString(Message, "Message") + "\n"; + output += "Success: " + Success.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.CreateGroupReply - public override PacketType Type { get { return PacketType.CreateGroupReply; } } - /// ReplyData block - public ReplyDataBlock ReplyData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.CreateGroupReply + public override PacketType Type { get { return PacketType.CreateGroupReply; } } + /// ReplyData block + public ReplyDataBlock ReplyData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public CreateGroupReplyPacket() - { - Header = new LowHeader(); - Header.ID = 413; - Header.Reliable = true; - ReplyData = new ReplyDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 413; + Header.Reliable = true; + ReplyData = new ReplyDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public CreateGroupReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - ReplyData = new ReplyDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + ReplyData = new ReplyDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public CreateGroupReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - ReplyData = new ReplyDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + ReplyData = new ReplyDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += ReplyData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - ReplyData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += ReplyData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + ReplyData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- CreateGroupReply ---\n"; - output += ReplyData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- CreateGroupReply ---\n"; + output += ReplyData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// UpdateGroupInfo packet + + /// UpdateGroupInfo packet public class UpdateGroupInfoPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// GroupData block + + /// GroupData block public class GroupDataBlock - { - /// AllowPublish field - public bool AllowPublish; - private byte[] _charter; - /// Charter field + { + /// AllowPublish field + public bool AllowPublish; + private byte[] _charter; + /// Charter field public byte[] Charter - { - get { return _charter; } + { + get { return _charter; } set - { - if (value == null) { _charter = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _charter = new byte[value.Length]; Array.Copy(value, _charter, value.Length); } + { + if (value == null) { _charter = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _charter = new byte[value.Length]; Array.Copy(value, _charter, value.Length); } } - } - /// ShowInList field - public bool ShowInList; - /// InsigniaID field - public LLUUID InsigniaID; - /// GroupID field - public LLUUID GroupID; - /// MembershipFee field - public int MembershipFee; - /// MaturePublish field - public bool MaturePublish; - /// OpenEnrollment field - public bool OpenEnrollment; - - /// Length of this block serialized in bytes + } + /// ShowInList field + public bool ShowInList; + /// InsigniaID field + public LLUUID InsigniaID; + /// GroupID field + public LLUUID GroupID; + /// MembershipFee field + public int MembershipFee; + /// MaturePublish field + public bool MaturePublish; + /// OpenEnrollment field + public bool OpenEnrollment; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 40; - if (Charter != null) { length += 2 + Charter.Length; } - return length; + { + int length = 40; + if (Charter != null) { length += 2 + Charter.Length; } + return length; } } - - /// Default constructor - public GroupDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public GroupDataBlock() { } + /// Constructor for building the block from a byte array public GroupDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - AllowPublish = (bytes[i++] != 0) ? (bool)true : (bool)false; - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _charter = new byte[length]; - Array.Copy(bytes, i, _charter, 0, length); i += length; - ShowInList = (bytes[i++] != 0) ? (bool)true : (bool)false; - InsigniaID = new LLUUID(bytes, i); i += 16; - GroupID = new LLUUID(bytes, i); i += 16; - MembershipFee = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - MaturePublish = (bytes[i++] != 0) ? (bool)true : (bool)false; - OpenEnrollment = (bytes[i++] != 0) ? (bool)true : (bool)false; + { + AllowPublish = (bytes[i++] != 0) ? (bool)true : (bool)false; + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _charter = new byte[length]; + Array.Copy(bytes, i, _charter, 0, length); i += length; + ShowInList = (bytes[i++] != 0) ? (bool)true : (bool)false; + InsigniaID = new LLUUID(bytes, i); i += 16; + GroupID = new LLUUID(bytes, i); i += 16; + MembershipFee = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + MaturePublish = (bytes[i++] != 0) ? (bool)true : (bool)false; + OpenEnrollment = (bytes[i++] != 0) ? (bool)true : (bool)false; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)((AllowPublish) ? 1 : 0); - if(Charter == null) { Console.WriteLine("Warning: Charter is null, in " + this.GetType()); } - bytes[i++] = (byte)(Charter.Length % 256); - bytes[i++] = (byte)((Charter.Length >> 8) % 256); - Array.Copy(Charter, 0, bytes, i, Charter.Length); i += Charter.Length; - bytes[i++] = (byte)((ShowInList) ? 1 : 0); - if(InsigniaID == null) { Console.WriteLine("Warning: InsigniaID is null, in " + this.GetType()); } - Array.Copy(InsigniaID.GetBytes(), 0, bytes, i, 16); i += 16; - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(MembershipFee % 256); - bytes[i++] = (byte)((MembershipFee >> 8) % 256); - bytes[i++] = (byte)((MembershipFee >> 16) % 256); - bytes[i++] = (byte)((MembershipFee >> 24) % 256); - bytes[i++] = (byte)((MaturePublish) ? 1 : 0); - bytes[i++] = (byte)((OpenEnrollment) ? 1 : 0); + { + bytes[i++] = (byte)((AllowPublish) ? 1 : 0); + if(Charter == null) { Console.WriteLine("Warning: Charter is null, in " + this.GetType()); } + bytes[i++] = (byte)(Charter.Length % 256); + bytes[i++] = (byte)((Charter.Length >> 8) % 256); + Array.Copy(Charter, 0, bytes, i, Charter.Length); i += Charter.Length; + bytes[i++] = (byte)((ShowInList) ? 1 : 0); + if(InsigniaID == null) { Console.WriteLine("Warning: InsigniaID is null, in " + this.GetType()); } + Array.Copy(InsigniaID.GetBytes(), 0, bytes, i, 16); i += 16; + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(MembershipFee % 256); + bytes[i++] = (byte)((MembershipFee >> 8) % 256); + bytes[i++] = (byte)((MembershipFee >> 16) % 256); + bytes[i++] = (byte)((MembershipFee >> 24) % 256); + bytes[i++] = (byte)((MaturePublish) ? 1 : 0); + bytes[i++] = (byte)((OpenEnrollment) ? 1 : 0); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- GroupData --\n"; - output += "AllowPublish: " + AllowPublish.ToString() + "\n"; - output += Helpers.FieldToString(Charter, "Charter") + "\n"; - output += "ShowInList: " + ShowInList.ToString() + "\n"; - output += "InsigniaID: " + InsigniaID.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; - output += "MembershipFee: " + MembershipFee.ToString() + "\n"; - output += "MaturePublish: " + MaturePublish.ToString() + "\n"; - output += "OpenEnrollment: " + OpenEnrollment.ToString() + "\n"; + { + string output = "-- GroupData --\n"; + output += "AllowPublish: " + AllowPublish.ToString() + "\n"; + output += Helpers.FieldToString(Charter, "Charter") + "\n"; + output += "ShowInList: " + ShowInList.ToString() + "\n"; + output += "InsigniaID: " + InsigniaID.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; + output += "MembershipFee: " + MembershipFee.ToString() + "\n"; + output += "MaturePublish: " + MaturePublish.ToString() + "\n"; + output += "OpenEnrollment: " + OpenEnrollment.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.UpdateGroupInfo - public override PacketType Type { get { return PacketType.UpdateGroupInfo; } } - /// AgentData block - public AgentDataBlock AgentData; - /// GroupData block - public GroupDataBlock GroupData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.UpdateGroupInfo + public override PacketType Type { get { return PacketType.UpdateGroupInfo; } } + /// AgentData block + public AgentDataBlock AgentData; + /// GroupData block + public GroupDataBlock GroupData; + + /// Default constructor public UpdateGroupInfoPacket() - { - Header = new LowHeader(); - Header.ID = 414; - Header.Reliable = true; - Header.Zerocoded = true; - AgentData = new AgentDataBlock(); - GroupData = new GroupDataBlock(); + { + Header = new LowHeader(); + Header.ID = 414; + Header.Reliable = true; + Header.Zerocoded = true; + AgentData = new AgentDataBlock(); + GroupData = new GroupDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public UpdateGroupInfoPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); - GroupData = new GroupDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); + GroupData = new GroupDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public UpdateGroupInfoPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); - GroupData = new GroupDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); + GroupData = new GroupDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length; length += GroupData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - GroupData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length; length += GroupData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + GroupData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- UpdateGroupInfo ---\n"; - output += AgentData.ToString() + "\n"; - output += GroupData.ToString() + "\n"; + { + string output = "--- UpdateGroupInfo ---\n"; + output += AgentData.ToString() + "\n"; + output += GroupData.ToString() + "\n"; return output; } - + } - - /// GroupRoleChanges packet + + /// GroupRoleChanges packet public class GroupRoleChangesPacket : Packet - { - /// RoleChange block + { + /// RoleChange block public class RoleChangeBlock - { - /// MemberID field - public LLUUID MemberID; - /// Change field - public uint Change; - /// RoleID field - public LLUUID RoleID; - - /// Length of this block serialized in bytes + { + /// MemberID field + public LLUUID MemberID; + /// Change field + public uint Change; + /// RoleID field + public LLUUID RoleID; + + /// Length of this block serialized in bytes public int Length { get - { - return 36; + { + return 36; } } - - /// Default constructor - public RoleChangeBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public RoleChangeBlock() { } + /// Constructor for building the block from a byte array public RoleChangeBlock(byte[] bytes, ref int i) - { + { try - { - MemberID = new LLUUID(bytes, i); i += 16; - Change = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - RoleID = new LLUUID(bytes, i); i += 16; + { + MemberID = new LLUUID(bytes, i); i += 16; + Change = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + RoleID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(MemberID == null) { Console.WriteLine("Warning: MemberID is null, in " + this.GetType()); } - Array.Copy(MemberID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(Change % 256); - bytes[i++] = (byte)((Change >> 8) % 256); - bytes[i++] = (byte)((Change >> 16) % 256); - bytes[i++] = (byte)((Change >> 24) % 256); - if(RoleID == null) { Console.WriteLine("Warning: RoleID is null, in " + this.GetType()); } - Array.Copy(RoleID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(MemberID == null) { Console.WriteLine("Warning: MemberID is null, in " + this.GetType()); } + Array.Copy(MemberID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(Change % 256); + bytes[i++] = (byte)((Change >> 8) % 256); + bytes[i++] = (byte)((Change >> 16) % 256); + bytes[i++] = (byte)((Change >> 24) % 256); + if(RoleID == null) { Console.WriteLine("Warning: RoleID is null, in " + this.GetType()); } + Array.Copy(RoleID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- RoleChange --\n"; - output += "MemberID: " + MemberID.ToString() + "\n"; - output += "Change: " + Change.ToString() + "\n"; - output += "RoleID: " + RoleID.ToString() + "\n"; + { + string output = "-- RoleChange --\n"; + output += "MemberID: " + MemberID.ToString() + "\n"; + output += "Change: " + Change.ToString() + "\n"; + output += "RoleID: " + RoleID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - /// GroupID field - public LLUUID GroupID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + /// GroupID field + public LLUUID GroupID; + + /// Length of this block serialized in bytes public int Length { get - { - return 48; + { + return 48; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; - GroupID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; + GroupID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.GroupRoleChanges - public override PacketType Type { get { return PacketType.GroupRoleChanges; } } - /// RoleChange block - public RoleChangeBlock[] RoleChange; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.GroupRoleChanges + public override PacketType Type { get { return PacketType.GroupRoleChanges; } } + /// RoleChange block + public RoleChangeBlock[] RoleChange; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public GroupRoleChangesPacket() - { - Header = new LowHeader(); - Header.ID = 415; - Header.Reliable = true; - RoleChange = new RoleChangeBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 415; + Header.Reliable = true; + RoleChange = new RoleChangeBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public GroupRoleChangesPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - RoleChange = new RoleChangeBlock[count]; - for (int j = 0; j < count; j++) - { RoleChange[j] = new RoleChangeBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + RoleChange = new RoleChangeBlock[count]; + for (int j = 0; j < count; j++) + { RoleChange[j] = new RoleChangeBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public GroupRoleChangesPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - RoleChange = new RoleChangeBlock[count]; - for (int j = 0; j < count; j++) - { RoleChange[j] = new RoleChangeBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + RoleChange = new RoleChangeBlock[count]; + for (int j = 0; j < count; j++) + { RoleChange[j] = new RoleChangeBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < RoleChange.Length; j++) { length += RoleChange[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)RoleChange.Length; - for (int j = 0; j < RoleChange.Length; j++) { RoleChange[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < RoleChange.Length; j++) { length += RoleChange[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)RoleChange.Length; + for (int j = 0; j < RoleChange.Length; j++) { RoleChange[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- GroupRoleChanges ---\n"; + { + string output = "--- GroupRoleChanges ---\n"; for (int j = 0; j < RoleChange.Length; j++) - { + { output += RoleChange[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// JoinGroupRequest packet + + /// JoinGroupRequest packet public class JoinGroupRequestPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// GroupData block + + /// GroupData block public class GroupDataBlock - { - /// GroupID field - public LLUUID GroupID; - - /// Length of this block serialized in bytes + { + /// GroupID field + public LLUUID GroupID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public GroupDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public GroupDataBlock() { } + /// Constructor for building the block from a byte array public GroupDataBlock(byte[] bytes, ref int i) - { + { try - { - GroupID = new LLUUID(bytes, i); i += 16; + { + GroupID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- GroupData --\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; + { + string output = "-- GroupData --\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.JoinGroupRequest - public override PacketType Type { get { return PacketType.JoinGroupRequest; } } - /// AgentData block - public AgentDataBlock AgentData; - /// GroupData block - public GroupDataBlock GroupData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.JoinGroupRequest + public override PacketType Type { get { return PacketType.JoinGroupRequest; } } + /// AgentData block + public AgentDataBlock AgentData; + /// GroupData block + public GroupDataBlock GroupData; + + /// Default constructor public JoinGroupRequestPacket() - { - Header = new LowHeader(); - Header.ID = 416; - Header.Reliable = true; - Header.Zerocoded = true; - AgentData = new AgentDataBlock(); - GroupData = new GroupDataBlock(); + { + Header = new LowHeader(); + Header.ID = 416; + Header.Reliable = true; + Header.Zerocoded = true; + AgentData = new AgentDataBlock(); + GroupData = new GroupDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public JoinGroupRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); - GroupData = new GroupDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); + GroupData = new GroupDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public JoinGroupRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); - GroupData = new GroupDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); + GroupData = new GroupDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length; length += GroupData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - GroupData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length; length += GroupData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + GroupData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- JoinGroupRequest ---\n"; - output += AgentData.ToString() + "\n"; - output += GroupData.ToString() + "\n"; + { + string output = "--- JoinGroupRequest ---\n"; + output += AgentData.ToString() + "\n"; + output += GroupData.ToString() + "\n"; return output; } - + } - - /// JoinGroupReply packet + + /// JoinGroupReply packet public class JoinGroupReplyPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// GroupData block + + /// GroupData block public class GroupDataBlock - { - /// Success field - public bool Success; - /// GroupID field - public LLUUID GroupID; - - /// Length of this block serialized in bytes + { + /// Success field + public bool Success; + /// GroupID field + public LLUUID GroupID; + + /// Length of this block serialized in bytes public int Length { get - { - return 17; + { + return 17; } } - - /// Default constructor - public GroupDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public GroupDataBlock() { } + /// Constructor for building the block from a byte array public GroupDataBlock(byte[] bytes, ref int i) - { + { try - { - Success = (bytes[i++] != 0) ? (bool)true : (bool)false; - GroupID = new LLUUID(bytes, i); i += 16; + { + Success = (bytes[i++] != 0) ? (bool)true : (bool)false; + GroupID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)((Success) ? 1 : 0); - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + { + bytes[i++] = (byte)((Success) ? 1 : 0); + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- GroupData --\n"; - output += "Success: " + Success.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; + { + string output = "-- GroupData --\n"; + output += "Success: " + Success.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.JoinGroupReply - public override PacketType Type { get { return PacketType.JoinGroupReply; } } - /// AgentData block - public AgentDataBlock AgentData; - /// GroupData block - public GroupDataBlock GroupData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.JoinGroupReply + public override PacketType Type { get { return PacketType.JoinGroupReply; } } + /// AgentData block + public AgentDataBlock AgentData; + /// GroupData block + public GroupDataBlock GroupData; + + /// Default constructor public JoinGroupReplyPacket() - { - Header = new LowHeader(); - Header.ID = 417; - Header.Reliable = true; - AgentData = new AgentDataBlock(); - GroupData = new GroupDataBlock(); + { + Header = new LowHeader(); + Header.ID = 417; + Header.Reliable = true; + AgentData = new AgentDataBlock(); + GroupData = new GroupDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public JoinGroupReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); - GroupData = new GroupDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); + GroupData = new GroupDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public JoinGroupReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); - GroupData = new GroupDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); + GroupData = new GroupDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length; length += GroupData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - GroupData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length; length += GroupData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + GroupData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- JoinGroupReply ---\n"; - output += AgentData.ToString() + "\n"; - output += GroupData.ToString() + "\n"; + { + string output = "--- JoinGroupReply ---\n"; + output += AgentData.ToString() + "\n"; + output += GroupData.ToString() + "\n"; return output; } - + } - - /// EjectGroupMemberRequest packet + + /// EjectGroupMemberRequest packet public class EjectGroupMemberRequestPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// EjectData block + + /// EjectData block public class EjectDataBlock - { - /// EjecteeID field - public LLUUID EjecteeID; - - /// Length of this block serialized in bytes + { + /// EjecteeID field + public LLUUID EjecteeID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public EjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public EjectDataBlock() { } + /// Constructor for building the block from a byte array public EjectDataBlock(byte[] bytes, ref int i) - { + { try - { - EjecteeID = new LLUUID(bytes, i); i += 16; + { + EjecteeID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(EjecteeID == null) { Console.WriteLine("Warning: EjecteeID is null, in " + this.GetType()); } - Array.Copy(EjecteeID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(EjecteeID == null) { Console.WriteLine("Warning: EjecteeID is null, in " + this.GetType()); } + Array.Copy(EjecteeID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- EjectData --\n"; - output += "EjecteeID: " + EjecteeID.ToString() + "\n"; + { + string output = "-- EjectData --\n"; + output += "EjecteeID: " + EjecteeID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// GroupData block + + /// GroupData block public class GroupDataBlock - { - /// GroupID field - public LLUUID GroupID; - - /// Length of this block serialized in bytes + { + /// GroupID field + public LLUUID GroupID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public GroupDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public GroupDataBlock() { } + /// Constructor for building the block from a byte array public GroupDataBlock(byte[] bytes, ref int i) - { + { try - { - GroupID = new LLUUID(bytes, i); i += 16; + { + GroupID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- GroupData --\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; + { + string output = "-- GroupData --\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.EjectGroupMemberRequest - public override PacketType Type { get { return PacketType.EjectGroupMemberRequest; } } - /// AgentData block - public AgentDataBlock AgentData; - /// EjectData block - public EjectDataBlock[] EjectData; - /// GroupData block - public GroupDataBlock GroupData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.EjectGroupMemberRequest + public override PacketType Type { get { return PacketType.EjectGroupMemberRequest; } } + /// AgentData block + public AgentDataBlock AgentData; + /// EjectData block + public EjectDataBlock[] EjectData; + /// GroupData block + public GroupDataBlock GroupData; + + /// Default constructor public EjectGroupMemberRequestPacket() - { - Header = new LowHeader(); - Header.ID = 418; - Header.Reliable = true; - AgentData = new AgentDataBlock(); - EjectData = new EjectDataBlock[0]; - GroupData = new GroupDataBlock(); + { + Header = new LowHeader(); + Header.ID = 418; + Header.Reliable = true; + AgentData = new AgentDataBlock(); + EjectData = new EjectDataBlock[0]; + GroupData = new GroupDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public EjectGroupMemberRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); - int count = (int)bytes[i++]; - EjectData = new EjectDataBlock[count]; - for (int j = 0; j < count; j++) - { EjectData[j] = new EjectDataBlock(bytes, ref i); } - GroupData = new GroupDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); + int count = (int)bytes[i++]; + EjectData = new EjectDataBlock[count]; + for (int j = 0; j < count; j++) + { EjectData[j] = new EjectDataBlock(bytes, ref i); } + GroupData = new GroupDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public EjectGroupMemberRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); - int count = (int)bytes[i++]; - EjectData = new EjectDataBlock[count]; - for (int j = 0; j < count; j++) - { EjectData[j] = new EjectDataBlock(bytes, ref i); } - GroupData = new GroupDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); + int count = (int)bytes[i++]; + EjectData = new EjectDataBlock[count]; + for (int j = 0; j < count; j++) + { EjectData[j] = new EjectDataBlock(bytes, ref i); } + GroupData = new GroupDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length; length += GroupData.Length;; - length++; - for (int j = 0; j < EjectData.Length; j++) { length += EjectData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - bytes[i++] = (byte)EjectData.Length; - for (int j = 0; j < EjectData.Length; j++) { EjectData[j].ToBytes(bytes, ref i); } - GroupData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length; length += GroupData.Length;; + length++; + for (int j = 0; j < EjectData.Length; j++) { length += EjectData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + bytes[i++] = (byte)EjectData.Length; + for (int j = 0; j < EjectData.Length; j++) { EjectData[j].ToBytes(bytes, ref i); } + GroupData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- EjectGroupMemberRequest ---\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- EjectGroupMemberRequest ---\n"; + output += AgentData.ToString() + "\n"; for (int j = 0; j < EjectData.Length; j++) - { + { output += EjectData[j].ToString() + "\n"; - } - output += GroupData.ToString() + "\n"; + } + output += GroupData.ToString() + "\n"; return output; } - + } - - /// EjectGroupMemberReply packet + + /// EjectGroupMemberReply packet public class EjectGroupMemberReplyPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// EjectData block + + /// EjectData block public class EjectDataBlock - { - /// Success field - public bool Success; - - /// Length of this block serialized in bytes + { + /// Success field + public bool Success; + + /// Length of this block serialized in bytes public int Length { get - { - return 1; + { + return 1; } } - - /// Default constructor - public EjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public EjectDataBlock() { } + /// Constructor for building the block from a byte array public EjectDataBlock(byte[] bytes, ref int i) - { + { try - { - Success = (bytes[i++] != 0) ? (bool)true : (bool)false; + { + Success = (bytes[i++] != 0) ? (bool)true : (bool)false; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)((Success) ? 1 : 0); + { + bytes[i++] = (byte)((Success) ? 1 : 0); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- EjectData --\n"; - output += "Success: " + Success.ToString() + "\n"; + { + string output = "-- EjectData --\n"; + output += "Success: " + Success.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// GroupData block + + /// GroupData block public class GroupDataBlock - { - /// GroupID field - public LLUUID GroupID; - - /// Length of this block serialized in bytes + { + /// GroupID field + public LLUUID GroupID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public GroupDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public GroupDataBlock() { } + /// Constructor for building the block from a byte array public GroupDataBlock(byte[] bytes, ref int i) - { + { try - { - GroupID = new LLUUID(bytes, i); i += 16; + { + GroupID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- GroupData --\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; + { + string output = "-- GroupData --\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.EjectGroupMemberReply - public override PacketType Type { get { return PacketType.EjectGroupMemberReply; } } - /// AgentData block - public AgentDataBlock AgentData; - /// EjectData block - public EjectDataBlock EjectData; - /// GroupData block - public GroupDataBlock GroupData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.EjectGroupMemberReply + public override PacketType Type { get { return PacketType.EjectGroupMemberReply; } } + /// AgentData block + public AgentDataBlock AgentData; + /// EjectData block + public EjectDataBlock EjectData; + /// GroupData block + public GroupDataBlock GroupData; + + /// Default constructor public EjectGroupMemberReplyPacket() - { - Header = new LowHeader(); - Header.ID = 419; - Header.Reliable = true; - AgentData = new AgentDataBlock(); - EjectData = new EjectDataBlock(); - GroupData = new GroupDataBlock(); + { + Header = new LowHeader(); + Header.ID = 419; + Header.Reliable = true; + AgentData = new AgentDataBlock(); + EjectData = new EjectDataBlock(); + GroupData = new GroupDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public EjectGroupMemberReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); - EjectData = new EjectDataBlock(bytes, ref i); - GroupData = new GroupDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); + EjectData = new EjectDataBlock(bytes, ref i); + GroupData = new GroupDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public EjectGroupMemberReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); - EjectData = new EjectDataBlock(bytes, ref i); - GroupData = new GroupDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); + EjectData = new EjectDataBlock(bytes, ref i); + GroupData = new GroupDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length; length += EjectData.Length; length += GroupData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - EjectData.ToBytes(bytes, ref i); - GroupData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length; length += EjectData.Length; length += GroupData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + EjectData.ToBytes(bytes, ref i); + GroupData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- EjectGroupMemberReply ---\n"; - output += AgentData.ToString() + "\n"; - output += EjectData.ToString() + "\n"; - output += GroupData.ToString() + "\n"; + { + string output = "--- EjectGroupMemberReply ---\n"; + output += AgentData.ToString() + "\n"; + output += EjectData.ToString() + "\n"; + output += GroupData.ToString() + "\n"; return output; } - + } - - /// LeaveGroupRequest packet + + /// LeaveGroupRequest packet public class LeaveGroupRequestPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// GroupData block + + /// GroupData block public class GroupDataBlock - { - /// GroupID field - public LLUUID GroupID; - - /// Length of this block serialized in bytes + { + /// GroupID field + public LLUUID GroupID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public GroupDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public GroupDataBlock() { } + /// Constructor for building the block from a byte array public GroupDataBlock(byte[] bytes, ref int i) - { + { try - { - GroupID = new LLUUID(bytes, i); i += 16; + { + GroupID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- GroupData --\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; + { + string output = "-- GroupData --\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.LeaveGroupRequest - public override PacketType Type { get { return PacketType.LeaveGroupRequest; } } - /// AgentData block - public AgentDataBlock AgentData; - /// GroupData block - public GroupDataBlock GroupData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.LeaveGroupRequest + public override PacketType Type { get { return PacketType.LeaveGroupRequest; } } + /// AgentData block + public AgentDataBlock AgentData; + /// GroupData block + public GroupDataBlock GroupData; + + /// Default constructor public LeaveGroupRequestPacket() - { - Header = new LowHeader(); - Header.ID = 420; - Header.Reliable = true; - AgentData = new AgentDataBlock(); - GroupData = new GroupDataBlock(); + { + Header = new LowHeader(); + Header.ID = 420; + Header.Reliable = true; + AgentData = new AgentDataBlock(); + GroupData = new GroupDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public LeaveGroupRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); - GroupData = new GroupDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); + GroupData = new GroupDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public LeaveGroupRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); - GroupData = new GroupDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); + GroupData = new GroupDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length; length += GroupData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - GroupData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length; length += GroupData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + GroupData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- LeaveGroupRequest ---\n"; - output += AgentData.ToString() + "\n"; - output += GroupData.ToString() + "\n"; + { + string output = "--- LeaveGroupRequest ---\n"; + output += AgentData.ToString() + "\n"; + output += GroupData.ToString() + "\n"; return output; } - + } - - /// LeaveGroupReply packet + + /// LeaveGroupReply packet public class LeaveGroupReplyPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// GroupData block + + /// GroupData block public class GroupDataBlock - { - /// Success field - public bool Success; - /// GroupID field - public LLUUID GroupID; - - /// Length of this block serialized in bytes + { + /// Success field + public bool Success; + /// GroupID field + public LLUUID GroupID; + + /// Length of this block serialized in bytes public int Length { get - { - return 17; + { + return 17; } } - - /// Default constructor - public GroupDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public GroupDataBlock() { } + /// Constructor for building the block from a byte array public GroupDataBlock(byte[] bytes, ref int i) - { + { try - { - Success = (bytes[i++] != 0) ? (bool)true : (bool)false; - GroupID = new LLUUID(bytes, i); i += 16; + { + Success = (bytes[i++] != 0) ? (bool)true : (bool)false; + GroupID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)((Success) ? 1 : 0); - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + { + bytes[i++] = (byte)((Success) ? 1 : 0); + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- GroupData --\n"; - output += "Success: " + Success.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; + { + string output = "-- GroupData --\n"; + output += "Success: " + Success.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.LeaveGroupReply - public override PacketType Type { get { return PacketType.LeaveGroupReply; } } - /// AgentData block - public AgentDataBlock AgentData; - /// GroupData block - public GroupDataBlock GroupData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.LeaveGroupReply + public override PacketType Type { get { return PacketType.LeaveGroupReply; } } + /// AgentData block + public AgentDataBlock AgentData; + /// GroupData block + public GroupDataBlock GroupData; + + /// Default constructor public LeaveGroupReplyPacket() - { - Header = new LowHeader(); - Header.ID = 421; - Header.Reliable = true; - AgentData = new AgentDataBlock(); - GroupData = new GroupDataBlock(); + { + Header = new LowHeader(); + Header.ID = 421; + Header.Reliable = true; + AgentData = new AgentDataBlock(); + GroupData = new GroupDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public LeaveGroupReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); - GroupData = new GroupDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); + GroupData = new GroupDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public LeaveGroupReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); - GroupData = new GroupDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); + GroupData = new GroupDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length; length += GroupData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - GroupData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length; length += GroupData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + GroupData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- LeaveGroupReply ---\n"; - output += AgentData.ToString() + "\n"; - output += GroupData.ToString() + "\n"; + { + string output = "--- LeaveGroupReply ---\n"; + output += AgentData.ToString() + "\n"; + output += GroupData.ToString() + "\n"; return output; } - + } - - /// InviteGroupRequest packet + + /// InviteGroupRequest packet public class InviteGroupRequestPacket : Packet - { - /// InviteData block + { + /// InviteData block public class InviteDataBlock - { - /// RoleID field - public LLUUID RoleID; - /// InviteeID field - public LLUUID InviteeID; - - /// Length of this block serialized in bytes + { + /// RoleID field + public LLUUID RoleID; + /// InviteeID field + public LLUUID InviteeID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public InviteDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public InviteDataBlock() { } + /// Constructor for building the block from a byte array public InviteDataBlock(byte[] bytes, ref int i) - { + { try - { - RoleID = new LLUUID(bytes, i); i += 16; - InviteeID = new LLUUID(bytes, i); i += 16; + { + RoleID = new LLUUID(bytes, i); i += 16; + InviteeID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(RoleID == null) { Console.WriteLine("Warning: RoleID is null, in " + this.GetType()); } - Array.Copy(RoleID.GetBytes(), 0, bytes, i, 16); i += 16; - if(InviteeID == null) { Console.WriteLine("Warning: InviteeID is null, in " + this.GetType()); } - Array.Copy(InviteeID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(RoleID == null) { Console.WriteLine("Warning: RoleID is null, in " + this.GetType()); } + Array.Copy(RoleID.GetBytes(), 0, bytes, i, 16); i += 16; + if(InviteeID == null) { Console.WriteLine("Warning: InviteeID is null, in " + this.GetType()); } + Array.Copy(InviteeID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- InviteData --\n"; - output += "RoleID: " + RoleID.ToString() + "\n"; - output += "InviteeID: " + InviteeID.ToString() + "\n"; + { + string output = "-- InviteData --\n"; + output += "RoleID: " + RoleID.ToString() + "\n"; + output += "InviteeID: " + InviteeID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// GroupData block + + /// GroupData block public class GroupDataBlock - { - /// GroupID field - public LLUUID GroupID; - - /// Length of this block serialized in bytes + { + /// GroupID field + public LLUUID GroupID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public GroupDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public GroupDataBlock() { } + /// Constructor for building the block from a byte array public GroupDataBlock(byte[] bytes, ref int i) - { + { try - { - GroupID = new LLUUID(bytes, i); i += 16; + { + GroupID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- GroupData --\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; + { + string output = "-- GroupData --\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.InviteGroupRequest - public override PacketType Type { get { return PacketType.InviteGroupRequest; } } - /// InviteData block - public InviteDataBlock[] InviteData; - /// AgentData block - public AgentDataBlock AgentData; - /// GroupData block - public GroupDataBlock GroupData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.InviteGroupRequest + public override PacketType Type { get { return PacketType.InviteGroupRequest; } } + /// InviteData block + public InviteDataBlock[] InviteData; + /// AgentData block + public AgentDataBlock AgentData; + /// GroupData block + public GroupDataBlock GroupData; + + /// Default constructor public InviteGroupRequestPacket() - { - Header = new LowHeader(); - Header.ID = 422; - Header.Reliable = true; - InviteData = new InviteDataBlock[0]; - AgentData = new AgentDataBlock(); - GroupData = new GroupDataBlock(); + { + Header = new LowHeader(); + Header.ID = 422; + Header.Reliable = true; + InviteData = new InviteDataBlock[0]; + AgentData = new AgentDataBlock(); + GroupData = new GroupDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public InviteGroupRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - InviteData = new InviteDataBlock[count]; - for (int j = 0; j < count; j++) - { InviteData[j] = new InviteDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); - GroupData = new GroupDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + InviteData = new InviteDataBlock[count]; + for (int j = 0; j < count; j++) + { InviteData[j] = new InviteDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); + GroupData = new GroupDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public InviteGroupRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - InviteData = new InviteDataBlock[count]; - for (int j = 0; j < count; j++) - { InviteData[j] = new InviteDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); - GroupData = new GroupDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + InviteData = new InviteDataBlock[count]; + for (int j = 0; j < count; j++) + { InviteData[j] = new InviteDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); + GroupData = new GroupDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length; length += GroupData.Length;; - length++; - for (int j = 0; j < InviteData.Length; j++) { length += InviteData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)InviteData.Length; - for (int j = 0; j < InviteData.Length; j++) { InviteData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - GroupData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length; length += GroupData.Length;; + length++; + for (int j = 0; j < InviteData.Length; j++) { length += InviteData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)InviteData.Length; + for (int j = 0; j < InviteData.Length; j++) { InviteData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + GroupData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- InviteGroupRequest ---\n"; + { + string output = "--- InviteGroupRequest ---\n"; for (int j = 0; j < InviteData.Length; j++) - { + { output += InviteData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; - output += GroupData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; + output += GroupData.ToString() + "\n"; return output; } - + } - - /// InviteGroupResponse packet + + /// InviteGroupResponse packet public class InviteGroupResponsePacket : Packet - { - /// InviteData block + { + /// InviteData block public class InviteDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// GroupID field - public LLUUID GroupID; - /// MembershipFee field - public int MembershipFee; - /// RoleID field - public LLUUID RoleID; - /// InviteeID field - public LLUUID InviteeID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// GroupID field + public LLUUID GroupID; + /// MembershipFee field + public int MembershipFee; + /// RoleID field + public LLUUID RoleID; + /// InviteeID field + public LLUUID InviteeID; + + /// Length of this block serialized in bytes public int Length { get - { - return 68; + { + return 68; } } - - /// Default constructor - public InviteDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public InviteDataBlock() { } + /// Constructor for building the block from a byte array public InviteDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - GroupID = new LLUUID(bytes, i); i += 16; - MembershipFee = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - RoleID = new LLUUID(bytes, i); i += 16; - InviteeID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + GroupID = new LLUUID(bytes, i); i += 16; + MembershipFee = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + RoleID = new LLUUID(bytes, i); i += 16; + InviteeID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(MembershipFee % 256); - bytes[i++] = (byte)((MembershipFee >> 8) % 256); - bytes[i++] = (byte)((MembershipFee >> 16) % 256); - bytes[i++] = (byte)((MembershipFee >> 24) % 256); - if(RoleID == null) { Console.WriteLine("Warning: RoleID is null, in " + this.GetType()); } - Array.Copy(RoleID.GetBytes(), 0, bytes, i, 16); i += 16; - if(InviteeID == null) { Console.WriteLine("Warning: InviteeID is null, in " + this.GetType()); } - Array.Copy(InviteeID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(MembershipFee % 256); + bytes[i++] = (byte)((MembershipFee >> 8) % 256); + bytes[i++] = (byte)((MembershipFee >> 16) % 256); + bytes[i++] = (byte)((MembershipFee >> 24) % 256); + if(RoleID == null) { Console.WriteLine("Warning: RoleID is null, in " + this.GetType()); } + Array.Copy(RoleID.GetBytes(), 0, bytes, i, 16); i += 16; + if(InviteeID == null) { Console.WriteLine("Warning: InviteeID is null, in " + this.GetType()); } + Array.Copy(InviteeID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- InviteData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; - output += "MembershipFee: " + MembershipFee.ToString() + "\n"; - output += "RoleID: " + RoleID.ToString() + "\n"; - output += "InviteeID: " + InviteeID.ToString() + "\n"; + { + string output = "-- InviteData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; + output += "MembershipFee: " + MembershipFee.ToString() + "\n"; + output += "RoleID: " + RoleID.ToString() + "\n"; + output += "InviteeID: " + InviteeID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.InviteGroupResponse - public override PacketType Type { get { return PacketType.InviteGroupResponse; } } - /// InviteData block - public InviteDataBlock InviteData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.InviteGroupResponse + public override PacketType Type { get { return PacketType.InviteGroupResponse; } } + /// InviteData block + public InviteDataBlock InviteData; + + /// Default constructor public InviteGroupResponsePacket() - { - Header = new LowHeader(); - Header.ID = 423; - Header.Reliable = true; - InviteData = new InviteDataBlock(); + { + Header = new LowHeader(); + Header.ID = 423; + Header.Reliable = true; + InviteData = new InviteDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public InviteGroupResponsePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - InviteData = new InviteDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + InviteData = new InviteDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public InviteGroupResponsePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - InviteData = new InviteDataBlock(bytes, ref i); + { + Header = head; + InviteData = new InviteDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += InviteData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - InviteData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += InviteData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + InviteData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- InviteGroupResponse ---\n"; - output += InviteData.ToString() + "\n"; + { + string output = "--- InviteGroupResponse ---\n"; + output += InviteData.ToString() + "\n"; return output; } - + } - - /// GroupProfileRequest packet + + /// GroupProfileRequest packet public class GroupProfileRequestPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// GroupData block + + /// GroupData block public class GroupDataBlock - { - /// GroupID field - public LLUUID GroupID; - - /// Length of this block serialized in bytes + { + /// GroupID field + public LLUUID GroupID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public GroupDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public GroupDataBlock() { } + /// Constructor for building the block from a byte array public GroupDataBlock(byte[] bytes, ref int i) - { + { try - { - GroupID = new LLUUID(bytes, i); i += 16; + { + GroupID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- GroupData --\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; + { + string output = "-- GroupData --\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.GroupProfileRequest - public override PacketType Type { get { return PacketType.GroupProfileRequest; } } - /// AgentData block - public AgentDataBlock AgentData; - /// GroupData block - public GroupDataBlock GroupData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.GroupProfileRequest + public override PacketType Type { get { return PacketType.GroupProfileRequest; } } + /// AgentData block + public AgentDataBlock AgentData; + /// GroupData block + public GroupDataBlock GroupData; + + /// Default constructor public GroupProfileRequestPacket() - { - Header = new LowHeader(); - Header.ID = 424; - Header.Reliable = true; - AgentData = new AgentDataBlock(); - GroupData = new GroupDataBlock(); + { + Header = new LowHeader(); + Header.ID = 424; + Header.Reliable = true; + AgentData = new AgentDataBlock(); + GroupData = new GroupDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public GroupProfileRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); - GroupData = new GroupDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); + GroupData = new GroupDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public GroupProfileRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); - GroupData = new GroupDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); + GroupData = new GroupDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length; length += GroupData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - GroupData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length; length += GroupData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + GroupData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- GroupProfileRequest ---\n"; - output += AgentData.ToString() + "\n"; - output += GroupData.ToString() + "\n"; + { + string output = "--- GroupProfileRequest ---\n"; + output += AgentData.ToString() + "\n"; + output += GroupData.ToString() + "\n"; return output; } - + } - - /// GroupProfileReply packet + + /// GroupProfileReply packet public class GroupProfileReplyPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// GroupData block + + /// GroupData block public class GroupDataBlock - { - /// OwnerRole field - public LLUUID OwnerRole; - /// AllowPublish field - public bool AllowPublish; - private byte[] _charter; - /// Charter field + { + /// OwnerRole field + public LLUUID OwnerRole; + /// AllowPublish field + public bool AllowPublish; + private byte[] _charter; + /// Charter field public byte[] Charter - { - get { return _charter; } + { + get { return _charter; } set - { - if (value == null) { _charter = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _charter = new byte[value.Length]; Array.Copy(value, _charter, value.Length); } + { + if (value == null) { _charter = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _charter = new byte[value.Length]; Array.Copy(value, _charter, value.Length); } } - } - /// GroupMembershipCount field - public int GroupMembershipCount; - /// ShowInList field - public bool ShowInList; - private byte[] _name; - /// Name field + } + /// GroupMembershipCount field + public int GroupMembershipCount; + /// ShowInList field + public bool ShowInList; + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - private byte[] _membertitle; - /// MemberTitle field + } + private byte[] _membertitle; + /// MemberTitle field public byte[] MemberTitle - { - get { return _membertitle; } + { + get { return _membertitle; } set - { - if (value == null) { _membertitle = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _membertitle = new byte[value.Length]; Array.Copy(value, _membertitle, value.Length); } + { + if (value == null) { _membertitle = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _membertitle = new byte[value.Length]; Array.Copy(value, _membertitle, value.Length); } } - } - /// InsigniaID field - public LLUUID InsigniaID; - /// GroupRolesCount field - public int GroupRolesCount; - /// GroupID field - public LLUUID GroupID; - /// MembershipFee field - public int MembershipFee; - /// MaturePublish field - public bool MaturePublish; - /// PowersMask field - public ulong PowersMask; - /// Money field - public int Money; - /// FounderID field - public LLUUID FounderID; - /// OpenEnrollment field - public bool OpenEnrollment; - - /// Length of this block serialized in bytes + } + /// InsigniaID field + public LLUUID InsigniaID; + /// GroupRolesCount field + public int GroupRolesCount; + /// GroupID field + public LLUUID GroupID; + /// MembershipFee field + public int MembershipFee; + /// MaturePublish field + public bool MaturePublish; + /// PowersMask field + public ulong PowersMask; + /// Money field + public int Money; + /// FounderID field + public LLUUID FounderID; + /// OpenEnrollment field + public bool OpenEnrollment; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 92; - if (Charter != null) { length += 2 + Charter.Length; } - if (Name != null) { length += 1 + Name.Length; } - if (MemberTitle != null) { length += 1 + MemberTitle.Length; } - return length; + { + int length = 92; + if (Charter != null) { length += 2 + Charter.Length; } + if (Name != null) { length += 1 + Name.Length; } + if (MemberTitle != null) { length += 1 + MemberTitle.Length; } + return length; } } - - /// Default constructor - public GroupDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public GroupDataBlock() { } + /// Constructor for building the block from a byte array public GroupDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - OwnerRole = new LLUUID(bytes, i); i += 16; - AllowPublish = (bytes[i++] != 0) ? (bool)true : (bool)false; - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _charter = new byte[length]; - Array.Copy(bytes, i, _charter, 0, length); i += length; - GroupMembershipCount = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - ShowInList = (bytes[i++] != 0) ? (bool)true : (bool)false; - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; - length = (ushort)bytes[i++]; - _membertitle = new byte[length]; - Array.Copy(bytes, i, _membertitle, 0, length); i += length; - InsigniaID = new LLUUID(bytes, i); i += 16; - GroupRolesCount = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - GroupID = new LLUUID(bytes, i); i += 16; - MembershipFee = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - MaturePublish = (bytes[i++] != 0) ? (bool)true : (bool)false; - PowersMask = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); - Money = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - FounderID = new LLUUID(bytes, i); i += 16; - OpenEnrollment = (bytes[i++] != 0) ? (bool)true : (bool)false; + { + OwnerRole = new LLUUID(bytes, i); i += 16; + AllowPublish = (bytes[i++] != 0) ? (bool)true : (bool)false; + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _charter = new byte[length]; + Array.Copy(bytes, i, _charter, 0, length); i += length; + GroupMembershipCount = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + ShowInList = (bytes[i++] != 0) ? (bool)true : (bool)false; + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; + length = (ushort)bytes[i++]; + _membertitle = new byte[length]; + Array.Copy(bytes, i, _membertitle, 0, length); i += length; + InsigniaID = new LLUUID(bytes, i); i += 16; + GroupRolesCount = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + GroupID = new LLUUID(bytes, i); i += 16; + MembershipFee = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + MaturePublish = (bytes[i++] != 0) ? (bool)true : (bool)false; + PowersMask = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + Money = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + FounderID = new LLUUID(bytes, i); i += 16; + OpenEnrollment = (bytes[i++] != 0) ? (bool)true : (bool)false; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(OwnerRole == null) { Console.WriteLine("Warning: OwnerRole is null, in " + this.GetType()); } - Array.Copy(OwnerRole.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((AllowPublish) ? 1 : 0); - if(Charter == null) { Console.WriteLine("Warning: Charter is null, in " + this.GetType()); } - bytes[i++] = (byte)(Charter.Length % 256); - bytes[i++] = (byte)((Charter.Length >> 8) % 256); - Array.Copy(Charter, 0, bytes, i, Charter.Length); i += Charter.Length; - bytes[i++] = (byte)(GroupMembershipCount % 256); - bytes[i++] = (byte)((GroupMembershipCount >> 8) % 256); - bytes[i++] = (byte)((GroupMembershipCount >> 16) % 256); - bytes[i++] = (byte)((GroupMembershipCount >> 24) % 256); - bytes[i++] = (byte)((ShowInList) ? 1 : 0); - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; - if(MemberTitle == null) { Console.WriteLine("Warning: MemberTitle is null, in " + this.GetType()); } - bytes[i++] = (byte)MemberTitle.Length; - Array.Copy(MemberTitle, 0, bytes, i, MemberTitle.Length); i += MemberTitle.Length; - if(InsigniaID == null) { Console.WriteLine("Warning: InsigniaID is null, in " + this.GetType()); } - Array.Copy(InsigniaID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(GroupRolesCount % 256); - bytes[i++] = (byte)((GroupRolesCount >> 8) % 256); - bytes[i++] = (byte)((GroupRolesCount >> 16) % 256); - bytes[i++] = (byte)((GroupRolesCount >> 24) % 256); - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(MembershipFee % 256); - bytes[i++] = (byte)((MembershipFee >> 8) % 256); - bytes[i++] = (byte)((MembershipFee >> 16) % 256); - bytes[i++] = (byte)((MembershipFee >> 24) % 256); - bytes[i++] = (byte)((MaturePublish) ? 1 : 0); - bytes[i++] = (byte)(PowersMask % 256); - bytes[i++] = (byte)((PowersMask >> 8) % 256); - bytes[i++] = (byte)((PowersMask >> 16) % 256); - bytes[i++] = (byte)((PowersMask >> 24) % 256); - bytes[i++] = (byte)((PowersMask >> 32) % 256); - bytes[i++] = (byte)((PowersMask >> 40) % 256); - bytes[i++] = (byte)((PowersMask >> 48) % 256); - bytes[i++] = (byte)((PowersMask >> 56) % 256); - bytes[i++] = (byte)(Money % 256); - bytes[i++] = (byte)((Money >> 8) % 256); - bytes[i++] = (byte)((Money >> 16) % 256); - bytes[i++] = (byte)((Money >> 24) % 256); - if(FounderID == null) { Console.WriteLine("Warning: FounderID is null, in " + this.GetType()); } - Array.Copy(FounderID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((OpenEnrollment) ? 1 : 0); + { + if(OwnerRole == null) { Console.WriteLine("Warning: OwnerRole is null, in " + this.GetType()); } + Array.Copy(OwnerRole.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((AllowPublish) ? 1 : 0); + if(Charter == null) { Console.WriteLine("Warning: Charter is null, in " + this.GetType()); } + bytes[i++] = (byte)(Charter.Length % 256); + bytes[i++] = (byte)((Charter.Length >> 8) % 256); + Array.Copy(Charter, 0, bytes, i, Charter.Length); i += Charter.Length; + bytes[i++] = (byte)(GroupMembershipCount % 256); + bytes[i++] = (byte)((GroupMembershipCount >> 8) % 256); + bytes[i++] = (byte)((GroupMembershipCount >> 16) % 256); + bytes[i++] = (byte)((GroupMembershipCount >> 24) % 256); + bytes[i++] = (byte)((ShowInList) ? 1 : 0); + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + if(MemberTitle == null) { Console.WriteLine("Warning: MemberTitle is null, in " + this.GetType()); } + bytes[i++] = (byte)MemberTitle.Length; + Array.Copy(MemberTitle, 0, bytes, i, MemberTitle.Length); i += MemberTitle.Length; + if(InsigniaID == null) { Console.WriteLine("Warning: InsigniaID is null, in " + this.GetType()); } + Array.Copy(InsigniaID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(GroupRolesCount % 256); + bytes[i++] = (byte)((GroupRolesCount >> 8) % 256); + bytes[i++] = (byte)((GroupRolesCount >> 16) % 256); + bytes[i++] = (byte)((GroupRolesCount >> 24) % 256); + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(MembershipFee % 256); + bytes[i++] = (byte)((MembershipFee >> 8) % 256); + bytes[i++] = (byte)((MembershipFee >> 16) % 256); + bytes[i++] = (byte)((MembershipFee >> 24) % 256); + bytes[i++] = (byte)((MaturePublish) ? 1 : 0); + bytes[i++] = (byte)(PowersMask % 256); + bytes[i++] = (byte)((PowersMask >> 8) % 256); + bytes[i++] = (byte)((PowersMask >> 16) % 256); + bytes[i++] = (byte)((PowersMask >> 24) % 256); + bytes[i++] = (byte)((PowersMask >> 32) % 256); + bytes[i++] = (byte)((PowersMask >> 40) % 256); + bytes[i++] = (byte)((PowersMask >> 48) % 256); + bytes[i++] = (byte)((PowersMask >> 56) % 256); + bytes[i++] = (byte)(Money % 256); + bytes[i++] = (byte)((Money >> 8) % 256); + bytes[i++] = (byte)((Money >> 16) % 256); + bytes[i++] = (byte)((Money >> 24) % 256); + if(FounderID == null) { Console.WriteLine("Warning: FounderID is null, in " + this.GetType()); } + Array.Copy(FounderID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((OpenEnrollment) ? 1 : 0); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- GroupData --\n"; - output += "OwnerRole: " + OwnerRole.ToString() + "\n"; - output += "AllowPublish: " + AllowPublish.ToString() + "\n"; - output += Helpers.FieldToString(Charter, "Charter") + "\n"; - output += "GroupMembershipCount: " + GroupMembershipCount.ToString() + "\n"; - output += "ShowInList: " + ShowInList.ToString() + "\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; - output += Helpers.FieldToString(MemberTitle, "MemberTitle") + "\n"; - output += "InsigniaID: " + InsigniaID.ToString() + "\n"; - output += "GroupRolesCount: " + GroupRolesCount.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; - output += "MembershipFee: " + MembershipFee.ToString() + "\n"; - output += "MaturePublish: " + MaturePublish.ToString() + "\n"; - output += "PowersMask: " + PowersMask.ToString() + "\n"; - output += "Money: " + Money.ToString() + "\n"; - output += "FounderID: " + FounderID.ToString() + "\n"; - output += "OpenEnrollment: " + OpenEnrollment.ToString() + "\n"; + { + string output = "-- GroupData --\n"; + output += "OwnerRole: " + OwnerRole.ToString() + "\n"; + output += "AllowPublish: " + AllowPublish.ToString() + "\n"; + output += Helpers.FieldToString(Charter, "Charter") + "\n"; + output += "GroupMembershipCount: " + GroupMembershipCount.ToString() + "\n"; + output += "ShowInList: " + ShowInList.ToString() + "\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; + output += Helpers.FieldToString(MemberTitle, "MemberTitle") + "\n"; + output += "InsigniaID: " + InsigniaID.ToString() + "\n"; + output += "GroupRolesCount: " + GroupRolesCount.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; + output += "MembershipFee: " + MembershipFee.ToString() + "\n"; + output += "MaturePublish: " + MaturePublish.ToString() + "\n"; + output += "PowersMask: " + PowersMask.ToString() + "\n"; + output += "Money: " + Money.ToString() + "\n"; + output += "FounderID: " + FounderID.ToString() + "\n"; + output += "OpenEnrollment: " + OpenEnrollment.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.GroupProfileReply - public override PacketType Type { get { return PacketType.GroupProfileReply; } } - /// AgentData block - public AgentDataBlock AgentData; - /// GroupData block - public GroupDataBlock GroupData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.GroupProfileReply + public override PacketType Type { get { return PacketType.GroupProfileReply; } } + /// AgentData block + public AgentDataBlock AgentData; + /// GroupData block + public GroupDataBlock GroupData; + + /// Default constructor public GroupProfileReplyPacket() - { - Header = new LowHeader(); - Header.ID = 425; - Header.Reliable = true; - Header.Zerocoded = true; - AgentData = new AgentDataBlock(); - GroupData = new GroupDataBlock(); + { + Header = new LowHeader(); + Header.ID = 425; + Header.Reliable = true; + Header.Zerocoded = true; + AgentData = new AgentDataBlock(); + GroupData = new GroupDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public GroupProfileReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); - GroupData = new GroupDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); + GroupData = new GroupDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public GroupProfileReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); - GroupData = new GroupDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); + GroupData = new GroupDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length; length += GroupData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - GroupData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length; length += GroupData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + GroupData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- GroupProfileReply ---\n"; - output += AgentData.ToString() + "\n"; - output += GroupData.ToString() + "\n"; + { + string output = "--- GroupProfileReply ---\n"; + output += AgentData.ToString() + "\n"; + output += GroupData.ToString() + "\n"; return output; } - + } - - /// GroupAccountSummaryRequest packet + + /// GroupAccountSummaryRequest packet public class GroupAccountSummaryRequestPacket : Packet - { - /// MoneyData block + { + /// MoneyData block public class MoneyDataBlock - { - /// RequestID field - public LLUUID RequestID; - /// IntervalDays field - public int IntervalDays; - /// CurrentInterval field - public int CurrentInterval; - - /// Length of this block serialized in bytes + { + /// RequestID field + public LLUUID RequestID; + /// IntervalDays field + public int IntervalDays; + /// CurrentInterval field + public int CurrentInterval; + + /// Length of this block serialized in bytes public int Length { get - { - return 24; + { + return 24; } } - - /// Default constructor - public MoneyDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public MoneyDataBlock() { } + /// Constructor for building the block from a byte array public MoneyDataBlock(byte[] bytes, ref int i) - { + { try - { - RequestID = new LLUUID(bytes, i); i += 16; - IntervalDays = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - CurrentInterval = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + RequestID = new LLUUID(bytes, i); i += 16; + IntervalDays = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + CurrentInterval = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(RequestID == null) { Console.WriteLine("Warning: RequestID is null, in " + this.GetType()); } - Array.Copy(RequestID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(IntervalDays % 256); - bytes[i++] = (byte)((IntervalDays >> 8) % 256); - bytes[i++] = (byte)((IntervalDays >> 16) % 256); - bytes[i++] = (byte)((IntervalDays >> 24) % 256); - bytes[i++] = (byte)(CurrentInterval % 256); - bytes[i++] = (byte)((CurrentInterval >> 8) % 256); - bytes[i++] = (byte)((CurrentInterval >> 16) % 256); - bytes[i++] = (byte)((CurrentInterval >> 24) % 256); + { + if(RequestID == null) { Console.WriteLine("Warning: RequestID is null, in " + this.GetType()); } + Array.Copy(RequestID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(IntervalDays % 256); + bytes[i++] = (byte)((IntervalDays >> 8) % 256); + bytes[i++] = (byte)((IntervalDays >> 16) % 256); + bytes[i++] = (byte)((IntervalDays >> 24) % 256); + bytes[i++] = (byte)(CurrentInterval % 256); + bytes[i++] = (byte)((CurrentInterval >> 8) % 256); + bytes[i++] = (byte)((CurrentInterval >> 16) % 256); + bytes[i++] = (byte)((CurrentInterval >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- MoneyData --\n"; - output += "RequestID: " + RequestID.ToString() + "\n"; - output += "IntervalDays: " + IntervalDays.ToString() + "\n"; - output += "CurrentInterval: " + CurrentInterval.ToString() + "\n"; + { + string output = "-- MoneyData --\n"; + output += "RequestID: " + RequestID.ToString() + "\n"; + output += "IntervalDays: " + IntervalDays.ToString() + "\n"; + output += "CurrentInterval: " + CurrentInterval.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - /// GroupID field - public LLUUID GroupID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + /// GroupID field + public LLUUID GroupID; + + /// Length of this block serialized in bytes public int Length { get - { - return 48; + { + return 48; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; - GroupID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; + GroupID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.GroupAccountSummaryRequest - public override PacketType Type { get { return PacketType.GroupAccountSummaryRequest; } } - /// MoneyData block - public MoneyDataBlock MoneyData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.GroupAccountSummaryRequest + public override PacketType Type { get { return PacketType.GroupAccountSummaryRequest; } } + /// MoneyData block + public MoneyDataBlock MoneyData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public GroupAccountSummaryRequestPacket() - { - Header = new LowHeader(); - Header.ID = 426; - Header.Reliable = true; - Header.Zerocoded = true; - MoneyData = new MoneyDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 426; + Header.Reliable = true; + Header.Zerocoded = true; + MoneyData = new MoneyDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public GroupAccountSummaryRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - MoneyData = new MoneyDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + MoneyData = new MoneyDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public GroupAccountSummaryRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - MoneyData = new MoneyDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + MoneyData = new MoneyDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += MoneyData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - MoneyData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += MoneyData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + MoneyData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- GroupAccountSummaryRequest ---\n"; - output += MoneyData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- GroupAccountSummaryRequest ---\n"; + output += MoneyData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// GroupAccountSummaryReply packet + + /// GroupAccountSummaryReply packet public class GroupAccountSummaryReplyPacket : Packet - { - /// MoneyData block + { + /// MoneyData block public class MoneyDataBlock - { - /// ParcelDirFeeCurrent field - public int ParcelDirFeeCurrent; - private byte[] _taxdate; - /// TaxDate field + { + /// ParcelDirFeeCurrent field + public int ParcelDirFeeCurrent; + private byte[] _taxdate; + /// TaxDate field public byte[] TaxDate - { - get { return _taxdate; } + { + get { return _taxdate; } set - { - if (value == null) { _taxdate = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _taxdate = new byte[value.Length]; Array.Copy(value, _taxdate, value.Length); } + { + if (value == null) { _taxdate = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _taxdate = new byte[value.Length]; Array.Copy(value, _taxdate, value.Length); } } - } - /// Balance field - public int Balance; - /// ParcelDirFeeEstimate field - public int ParcelDirFeeEstimate; - /// RequestID field - public LLUUID RequestID; - /// ObjectTaxCurrent field - public int ObjectTaxCurrent; - /// LightTaxCurrent field - public int LightTaxCurrent; - /// LandTaxCurrent field - public int LandTaxCurrent; - /// GroupTaxCurrent field - public int GroupTaxCurrent; - /// TotalDebits field - public int TotalDebits; - /// IntervalDays field - public int IntervalDays; - /// ObjectTaxEstimate field - public int ObjectTaxEstimate; - /// LightTaxEstimate field - public int LightTaxEstimate; - /// LandTaxEstimate field - public int LandTaxEstimate; - /// GroupTaxEstimate field - public int GroupTaxEstimate; - private byte[] _lasttaxdate; - /// LastTaxDate field + } + /// Balance field + public int Balance; + /// ParcelDirFeeEstimate field + public int ParcelDirFeeEstimate; + /// RequestID field + public LLUUID RequestID; + /// ObjectTaxCurrent field + public int ObjectTaxCurrent; + /// LightTaxCurrent field + public int LightTaxCurrent; + /// LandTaxCurrent field + public int LandTaxCurrent; + /// GroupTaxCurrent field + public int GroupTaxCurrent; + /// TotalDebits field + public int TotalDebits; + /// IntervalDays field + public int IntervalDays; + /// ObjectTaxEstimate field + public int ObjectTaxEstimate; + /// LightTaxEstimate field + public int LightTaxEstimate; + /// LandTaxEstimate field + public int LandTaxEstimate; + /// GroupTaxEstimate field + public int GroupTaxEstimate; + private byte[] _lasttaxdate; + /// LastTaxDate field public byte[] LastTaxDate - { - get { return _lasttaxdate; } + { + get { return _lasttaxdate; } set - { - if (value == null) { _lasttaxdate = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _lasttaxdate = new byte[value.Length]; Array.Copy(value, _lasttaxdate, value.Length); } + { + if (value == null) { _lasttaxdate = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _lasttaxdate = new byte[value.Length]; Array.Copy(value, _lasttaxdate, value.Length); } } - } - /// NonExemptMembers field - public int NonExemptMembers; - private byte[] _startdate; - /// StartDate field + } + /// NonExemptMembers field + public int NonExemptMembers; + private byte[] _startdate; + /// StartDate field public byte[] StartDate - { - get { return _startdate; } + { + get { return _startdate; } set - { - if (value == null) { _startdate = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _startdate = new byte[value.Length]; Array.Copy(value, _startdate, value.Length); } + { + if (value == null) { _startdate = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _startdate = new byte[value.Length]; Array.Copy(value, _startdate, value.Length); } } - } - /// TotalCredits field - public int TotalCredits; - /// CurrentInterval field - public int CurrentInterval; - - /// Length of this block serialized in bytes + } + /// TotalCredits field + public int TotalCredits; + /// CurrentInterval field + public int CurrentInterval; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 80; - if (TaxDate != null) { length += 1 + TaxDate.Length; } - if (LastTaxDate != null) { length += 1 + LastTaxDate.Length; } - if (StartDate != null) { length += 1 + StartDate.Length; } - return length; + { + int length = 80; + if (TaxDate != null) { length += 1 + TaxDate.Length; } + if (LastTaxDate != null) { length += 1 + LastTaxDate.Length; } + if (StartDate != null) { length += 1 + StartDate.Length; } + return length; } } - - /// Default constructor - public MoneyDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public MoneyDataBlock() { } + /// Constructor for building the block from a byte array public MoneyDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - ParcelDirFeeCurrent = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _taxdate = new byte[length]; - Array.Copy(bytes, i, _taxdate, 0, length); i += length; - Balance = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - ParcelDirFeeEstimate = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - RequestID = new LLUUID(bytes, i); i += 16; - ObjectTaxCurrent = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - LightTaxCurrent = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - LandTaxCurrent = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - GroupTaxCurrent = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - TotalDebits = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - IntervalDays = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - ObjectTaxEstimate = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - LightTaxEstimate = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - LandTaxEstimate = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - GroupTaxEstimate = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _lasttaxdate = new byte[length]; - Array.Copy(bytes, i, _lasttaxdate, 0, length); i += length; - NonExemptMembers = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _startdate = new byte[length]; - Array.Copy(bytes, i, _startdate, 0, length); i += length; - TotalCredits = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - CurrentInterval = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + ParcelDirFeeCurrent = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _taxdate = new byte[length]; + Array.Copy(bytes, i, _taxdate, 0, length); i += length; + Balance = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + ParcelDirFeeEstimate = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + RequestID = new LLUUID(bytes, i); i += 16; + ObjectTaxCurrent = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + LightTaxCurrent = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + LandTaxCurrent = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + GroupTaxCurrent = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + TotalDebits = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + IntervalDays = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + ObjectTaxEstimate = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + LightTaxEstimate = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + LandTaxEstimate = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + GroupTaxEstimate = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _lasttaxdate = new byte[length]; + Array.Copy(bytes, i, _lasttaxdate, 0, length); i += length; + NonExemptMembers = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _startdate = new byte[length]; + Array.Copy(bytes, i, _startdate, 0, length); i += length; + TotalCredits = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + CurrentInterval = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(ParcelDirFeeCurrent % 256); - bytes[i++] = (byte)((ParcelDirFeeCurrent >> 8) % 256); - bytes[i++] = (byte)((ParcelDirFeeCurrent >> 16) % 256); - bytes[i++] = (byte)((ParcelDirFeeCurrent >> 24) % 256); - if(TaxDate == null) { Console.WriteLine("Warning: TaxDate is null, in " + this.GetType()); } - bytes[i++] = (byte)TaxDate.Length; - Array.Copy(TaxDate, 0, bytes, i, TaxDate.Length); i += TaxDate.Length; - bytes[i++] = (byte)(Balance % 256); - bytes[i++] = (byte)((Balance >> 8) % 256); - bytes[i++] = (byte)((Balance >> 16) % 256); - bytes[i++] = (byte)((Balance >> 24) % 256); - bytes[i++] = (byte)(ParcelDirFeeEstimate % 256); - bytes[i++] = (byte)((ParcelDirFeeEstimate >> 8) % 256); - bytes[i++] = (byte)((ParcelDirFeeEstimate >> 16) % 256); - bytes[i++] = (byte)((ParcelDirFeeEstimate >> 24) % 256); - if(RequestID == null) { Console.WriteLine("Warning: RequestID is null, in " + this.GetType()); } - Array.Copy(RequestID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(ObjectTaxCurrent % 256); - bytes[i++] = (byte)((ObjectTaxCurrent >> 8) % 256); - bytes[i++] = (byte)((ObjectTaxCurrent >> 16) % 256); - bytes[i++] = (byte)((ObjectTaxCurrent >> 24) % 256); - bytes[i++] = (byte)(LightTaxCurrent % 256); - bytes[i++] = (byte)((LightTaxCurrent >> 8) % 256); - bytes[i++] = (byte)((LightTaxCurrent >> 16) % 256); - bytes[i++] = (byte)((LightTaxCurrent >> 24) % 256); - bytes[i++] = (byte)(LandTaxCurrent % 256); - bytes[i++] = (byte)((LandTaxCurrent >> 8) % 256); - bytes[i++] = (byte)((LandTaxCurrent >> 16) % 256); - bytes[i++] = (byte)((LandTaxCurrent >> 24) % 256); - bytes[i++] = (byte)(GroupTaxCurrent % 256); - bytes[i++] = (byte)((GroupTaxCurrent >> 8) % 256); - bytes[i++] = (byte)((GroupTaxCurrent >> 16) % 256); - bytes[i++] = (byte)((GroupTaxCurrent >> 24) % 256); - bytes[i++] = (byte)(TotalDebits % 256); - bytes[i++] = (byte)((TotalDebits >> 8) % 256); - bytes[i++] = (byte)((TotalDebits >> 16) % 256); - bytes[i++] = (byte)((TotalDebits >> 24) % 256); - bytes[i++] = (byte)(IntervalDays % 256); - bytes[i++] = (byte)((IntervalDays >> 8) % 256); - bytes[i++] = (byte)((IntervalDays >> 16) % 256); - bytes[i++] = (byte)((IntervalDays >> 24) % 256); - bytes[i++] = (byte)(ObjectTaxEstimate % 256); - bytes[i++] = (byte)((ObjectTaxEstimate >> 8) % 256); - bytes[i++] = (byte)((ObjectTaxEstimate >> 16) % 256); - bytes[i++] = (byte)((ObjectTaxEstimate >> 24) % 256); - bytes[i++] = (byte)(LightTaxEstimate % 256); - bytes[i++] = (byte)((LightTaxEstimate >> 8) % 256); - bytes[i++] = (byte)((LightTaxEstimate >> 16) % 256); - bytes[i++] = (byte)((LightTaxEstimate >> 24) % 256); - bytes[i++] = (byte)(LandTaxEstimate % 256); - bytes[i++] = (byte)((LandTaxEstimate >> 8) % 256); - bytes[i++] = (byte)((LandTaxEstimate >> 16) % 256); - bytes[i++] = (byte)((LandTaxEstimate >> 24) % 256); - bytes[i++] = (byte)(GroupTaxEstimate % 256); - bytes[i++] = (byte)((GroupTaxEstimate >> 8) % 256); - bytes[i++] = (byte)((GroupTaxEstimate >> 16) % 256); - bytes[i++] = (byte)((GroupTaxEstimate >> 24) % 256); - if(LastTaxDate == null) { Console.WriteLine("Warning: LastTaxDate is null, in " + this.GetType()); } - bytes[i++] = (byte)LastTaxDate.Length; - Array.Copy(LastTaxDate, 0, bytes, i, LastTaxDate.Length); i += LastTaxDate.Length; - bytes[i++] = (byte)(NonExemptMembers % 256); - bytes[i++] = (byte)((NonExemptMembers >> 8) % 256); - bytes[i++] = (byte)((NonExemptMembers >> 16) % 256); - bytes[i++] = (byte)((NonExemptMembers >> 24) % 256); - if(StartDate == null) { Console.WriteLine("Warning: StartDate is null, in " + this.GetType()); } - bytes[i++] = (byte)StartDate.Length; - Array.Copy(StartDate, 0, bytes, i, StartDate.Length); i += StartDate.Length; - bytes[i++] = (byte)(TotalCredits % 256); - bytes[i++] = (byte)((TotalCredits >> 8) % 256); - bytes[i++] = (byte)((TotalCredits >> 16) % 256); - bytes[i++] = (byte)((TotalCredits >> 24) % 256); - bytes[i++] = (byte)(CurrentInterval % 256); - bytes[i++] = (byte)((CurrentInterval >> 8) % 256); - bytes[i++] = (byte)((CurrentInterval >> 16) % 256); - bytes[i++] = (byte)((CurrentInterval >> 24) % 256); + { + bytes[i++] = (byte)(ParcelDirFeeCurrent % 256); + bytes[i++] = (byte)((ParcelDirFeeCurrent >> 8) % 256); + bytes[i++] = (byte)((ParcelDirFeeCurrent >> 16) % 256); + bytes[i++] = (byte)((ParcelDirFeeCurrent >> 24) % 256); + if(TaxDate == null) { Console.WriteLine("Warning: TaxDate is null, in " + this.GetType()); } + bytes[i++] = (byte)TaxDate.Length; + Array.Copy(TaxDate, 0, bytes, i, TaxDate.Length); i += TaxDate.Length; + bytes[i++] = (byte)(Balance % 256); + bytes[i++] = (byte)((Balance >> 8) % 256); + bytes[i++] = (byte)((Balance >> 16) % 256); + bytes[i++] = (byte)((Balance >> 24) % 256); + bytes[i++] = (byte)(ParcelDirFeeEstimate % 256); + bytes[i++] = (byte)((ParcelDirFeeEstimate >> 8) % 256); + bytes[i++] = (byte)((ParcelDirFeeEstimate >> 16) % 256); + bytes[i++] = (byte)((ParcelDirFeeEstimate >> 24) % 256); + if(RequestID == null) { Console.WriteLine("Warning: RequestID is null, in " + this.GetType()); } + Array.Copy(RequestID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(ObjectTaxCurrent % 256); + bytes[i++] = (byte)((ObjectTaxCurrent >> 8) % 256); + bytes[i++] = (byte)((ObjectTaxCurrent >> 16) % 256); + bytes[i++] = (byte)((ObjectTaxCurrent >> 24) % 256); + bytes[i++] = (byte)(LightTaxCurrent % 256); + bytes[i++] = (byte)((LightTaxCurrent >> 8) % 256); + bytes[i++] = (byte)((LightTaxCurrent >> 16) % 256); + bytes[i++] = (byte)((LightTaxCurrent >> 24) % 256); + bytes[i++] = (byte)(LandTaxCurrent % 256); + bytes[i++] = (byte)((LandTaxCurrent >> 8) % 256); + bytes[i++] = (byte)((LandTaxCurrent >> 16) % 256); + bytes[i++] = (byte)((LandTaxCurrent >> 24) % 256); + bytes[i++] = (byte)(GroupTaxCurrent % 256); + bytes[i++] = (byte)((GroupTaxCurrent >> 8) % 256); + bytes[i++] = (byte)((GroupTaxCurrent >> 16) % 256); + bytes[i++] = (byte)((GroupTaxCurrent >> 24) % 256); + bytes[i++] = (byte)(TotalDebits % 256); + bytes[i++] = (byte)((TotalDebits >> 8) % 256); + bytes[i++] = (byte)((TotalDebits >> 16) % 256); + bytes[i++] = (byte)((TotalDebits >> 24) % 256); + bytes[i++] = (byte)(IntervalDays % 256); + bytes[i++] = (byte)((IntervalDays >> 8) % 256); + bytes[i++] = (byte)((IntervalDays >> 16) % 256); + bytes[i++] = (byte)((IntervalDays >> 24) % 256); + bytes[i++] = (byte)(ObjectTaxEstimate % 256); + bytes[i++] = (byte)((ObjectTaxEstimate >> 8) % 256); + bytes[i++] = (byte)((ObjectTaxEstimate >> 16) % 256); + bytes[i++] = (byte)((ObjectTaxEstimate >> 24) % 256); + bytes[i++] = (byte)(LightTaxEstimate % 256); + bytes[i++] = (byte)((LightTaxEstimate >> 8) % 256); + bytes[i++] = (byte)((LightTaxEstimate >> 16) % 256); + bytes[i++] = (byte)((LightTaxEstimate >> 24) % 256); + bytes[i++] = (byte)(LandTaxEstimate % 256); + bytes[i++] = (byte)((LandTaxEstimate >> 8) % 256); + bytes[i++] = (byte)((LandTaxEstimate >> 16) % 256); + bytes[i++] = (byte)((LandTaxEstimate >> 24) % 256); + bytes[i++] = (byte)(GroupTaxEstimate % 256); + bytes[i++] = (byte)((GroupTaxEstimate >> 8) % 256); + bytes[i++] = (byte)((GroupTaxEstimate >> 16) % 256); + bytes[i++] = (byte)((GroupTaxEstimate >> 24) % 256); + if(LastTaxDate == null) { Console.WriteLine("Warning: LastTaxDate is null, in " + this.GetType()); } + bytes[i++] = (byte)LastTaxDate.Length; + Array.Copy(LastTaxDate, 0, bytes, i, LastTaxDate.Length); i += LastTaxDate.Length; + bytes[i++] = (byte)(NonExemptMembers % 256); + bytes[i++] = (byte)((NonExemptMembers >> 8) % 256); + bytes[i++] = (byte)((NonExemptMembers >> 16) % 256); + bytes[i++] = (byte)((NonExemptMembers >> 24) % 256); + if(StartDate == null) { Console.WriteLine("Warning: StartDate is null, in " + this.GetType()); } + bytes[i++] = (byte)StartDate.Length; + Array.Copy(StartDate, 0, bytes, i, StartDate.Length); i += StartDate.Length; + bytes[i++] = (byte)(TotalCredits % 256); + bytes[i++] = (byte)((TotalCredits >> 8) % 256); + bytes[i++] = (byte)((TotalCredits >> 16) % 256); + bytes[i++] = (byte)((TotalCredits >> 24) % 256); + bytes[i++] = (byte)(CurrentInterval % 256); + bytes[i++] = (byte)((CurrentInterval >> 8) % 256); + bytes[i++] = (byte)((CurrentInterval >> 16) % 256); + bytes[i++] = (byte)((CurrentInterval >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- MoneyData --\n"; - output += "ParcelDirFeeCurrent: " + ParcelDirFeeCurrent.ToString() + "\n"; - output += Helpers.FieldToString(TaxDate, "TaxDate") + "\n"; - output += "Balance: " + Balance.ToString() + "\n"; - output += "ParcelDirFeeEstimate: " + ParcelDirFeeEstimate.ToString() + "\n"; - output += "RequestID: " + RequestID.ToString() + "\n"; - output += "ObjectTaxCurrent: " + ObjectTaxCurrent.ToString() + "\n"; - output += "LightTaxCurrent: " + LightTaxCurrent.ToString() + "\n"; - output += "LandTaxCurrent: " + LandTaxCurrent.ToString() + "\n"; - output += "GroupTaxCurrent: " + GroupTaxCurrent.ToString() + "\n"; - output += "TotalDebits: " + TotalDebits.ToString() + "\n"; - output += "IntervalDays: " + IntervalDays.ToString() + "\n"; - output += "ObjectTaxEstimate: " + ObjectTaxEstimate.ToString() + "\n"; - output += "LightTaxEstimate: " + LightTaxEstimate.ToString() + "\n"; - output += "LandTaxEstimate: " + LandTaxEstimate.ToString() + "\n"; - output += "GroupTaxEstimate: " + GroupTaxEstimate.ToString() + "\n"; - output += Helpers.FieldToString(LastTaxDate, "LastTaxDate") + "\n"; - output += "NonExemptMembers: " + NonExemptMembers.ToString() + "\n"; - output += Helpers.FieldToString(StartDate, "StartDate") + "\n"; - output += "TotalCredits: " + TotalCredits.ToString() + "\n"; - output += "CurrentInterval: " + CurrentInterval.ToString() + "\n"; + { + string output = "-- MoneyData --\n"; + output += "ParcelDirFeeCurrent: " + ParcelDirFeeCurrent.ToString() + "\n"; + output += Helpers.FieldToString(TaxDate, "TaxDate") + "\n"; + output += "Balance: " + Balance.ToString() + "\n"; + output += "ParcelDirFeeEstimate: " + ParcelDirFeeEstimate.ToString() + "\n"; + output += "RequestID: " + RequestID.ToString() + "\n"; + output += "ObjectTaxCurrent: " + ObjectTaxCurrent.ToString() + "\n"; + output += "LightTaxCurrent: " + LightTaxCurrent.ToString() + "\n"; + output += "LandTaxCurrent: " + LandTaxCurrent.ToString() + "\n"; + output += "GroupTaxCurrent: " + GroupTaxCurrent.ToString() + "\n"; + output += "TotalDebits: " + TotalDebits.ToString() + "\n"; + output += "IntervalDays: " + IntervalDays.ToString() + "\n"; + output += "ObjectTaxEstimate: " + ObjectTaxEstimate.ToString() + "\n"; + output += "LightTaxEstimate: " + LightTaxEstimate.ToString() + "\n"; + output += "LandTaxEstimate: " + LandTaxEstimate.ToString() + "\n"; + output += "GroupTaxEstimate: " + GroupTaxEstimate.ToString() + "\n"; + output += Helpers.FieldToString(LastTaxDate, "LastTaxDate") + "\n"; + output += "NonExemptMembers: " + NonExemptMembers.ToString() + "\n"; + output += Helpers.FieldToString(StartDate, "StartDate") + "\n"; + output += "TotalCredits: " + TotalCredits.ToString() + "\n"; + output += "CurrentInterval: " + CurrentInterval.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// GroupID field - public LLUUID GroupID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// GroupID field + public LLUUID GroupID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - GroupID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + GroupID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.GroupAccountSummaryReply - public override PacketType Type { get { return PacketType.GroupAccountSummaryReply; } } - /// MoneyData block - public MoneyDataBlock MoneyData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.GroupAccountSummaryReply + public override PacketType Type { get { return PacketType.GroupAccountSummaryReply; } } + /// MoneyData block + public MoneyDataBlock MoneyData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public GroupAccountSummaryReplyPacket() - { - Header = new LowHeader(); - Header.ID = 427; - Header.Reliable = true; - Header.Zerocoded = true; - MoneyData = new MoneyDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 427; + Header.Reliable = true; + Header.Zerocoded = true; + MoneyData = new MoneyDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public GroupAccountSummaryReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - MoneyData = new MoneyDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + MoneyData = new MoneyDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public GroupAccountSummaryReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - MoneyData = new MoneyDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + MoneyData = new MoneyDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += MoneyData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - MoneyData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += MoneyData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + MoneyData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- GroupAccountSummaryReply ---\n"; - output += MoneyData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- GroupAccountSummaryReply ---\n"; + output += MoneyData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// GroupAccountDetailsRequest packet + + /// GroupAccountDetailsRequest packet public class GroupAccountDetailsRequestPacket : Packet - { - /// MoneyData block + { + /// MoneyData block public class MoneyDataBlock - { - /// RequestID field - public LLUUID RequestID; - /// IntervalDays field - public int IntervalDays; - /// CurrentInterval field - public int CurrentInterval; - - /// Length of this block serialized in bytes + { + /// RequestID field + public LLUUID RequestID; + /// IntervalDays field + public int IntervalDays; + /// CurrentInterval field + public int CurrentInterval; + + /// Length of this block serialized in bytes public int Length { get - { - return 24; + { + return 24; } } - - /// Default constructor - public MoneyDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public MoneyDataBlock() { } + /// Constructor for building the block from a byte array public MoneyDataBlock(byte[] bytes, ref int i) - { + { try - { - RequestID = new LLUUID(bytes, i); i += 16; - IntervalDays = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - CurrentInterval = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + RequestID = new LLUUID(bytes, i); i += 16; + IntervalDays = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + CurrentInterval = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(RequestID == null) { Console.WriteLine("Warning: RequestID is null, in " + this.GetType()); } - Array.Copy(RequestID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(IntervalDays % 256); - bytes[i++] = (byte)((IntervalDays >> 8) % 256); - bytes[i++] = (byte)((IntervalDays >> 16) % 256); - bytes[i++] = (byte)((IntervalDays >> 24) % 256); - bytes[i++] = (byte)(CurrentInterval % 256); - bytes[i++] = (byte)((CurrentInterval >> 8) % 256); - bytes[i++] = (byte)((CurrentInterval >> 16) % 256); - bytes[i++] = (byte)((CurrentInterval >> 24) % 256); + { + if(RequestID == null) { Console.WriteLine("Warning: RequestID is null, in " + this.GetType()); } + Array.Copy(RequestID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(IntervalDays % 256); + bytes[i++] = (byte)((IntervalDays >> 8) % 256); + bytes[i++] = (byte)((IntervalDays >> 16) % 256); + bytes[i++] = (byte)((IntervalDays >> 24) % 256); + bytes[i++] = (byte)(CurrentInterval % 256); + bytes[i++] = (byte)((CurrentInterval >> 8) % 256); + bytes[i++] = (byte)((CurrentInterval >> 16) % 256); + bytes[i++] = (byte)((CurrentInterval >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- MoneyData --\n"; - output += "RequestID: " + RequestID.ToString() + "\n"; - output += "IntervalDays: " + IntervalDays.ToString() + "\n"; - output += "CurrentInterval: " + CurrentInterval.ToString() + "\n"; + { + string output = "-- MoneyData --\n"; + output += "RequestID: " + RequestID.ToString() + "\n"; + output += "IntervalDays: " + IntervalDays.ToString() + "\n"; + output += "CurrentInterval: " + CurrentInterval.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - /// GroupID field - public LLUUID GroupID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + /// GroupID field + public LLUUID GroupID; + + /// Length of this block serialized in bytes public int Length { get - { - return 48; + { + return 48; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; - GroupID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; + GroupID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.GroupAccountDetailsRequest - public override PacketType Type { get { return PacketType.GroupAccountDetailsRequest; } } - /// MoneyData block - public MoneyDataBlock MoneyData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.GroupAccountDetailsRequest + public override PacketType Type { get { return PacketType.GroupAccountDetailsRequest; } } + /// MoneyData block + public MoneyDataBlock MoneyData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public GroupAccountDetailsRequestPacket() - { - Header = new LowHeader(); - Header.ID = 428; - Header.Reliable = true; - Header.Zerocoded = true; - MoneyData = new MoneyDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 428; + Header.Reliable = true; + Header.Zerocoded = true; + MoneyData = new MoneyDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public GroupAccountDetailsRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - MoneyData = new MoneyDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + MoneyData = new MoneyDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public GroupAccountDetailsRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - MoneyData = new MoneyDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + MoneyData = new MoneyDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += MoneyData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - MoneyData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += MoneyData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + MoneyData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- GroupAccountDetailsRequest ---\n"; - output += MoneyData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- GroupAccountDetailsRequest ---\n"; + output += MoneyData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// GroupAccountDetailsReply packet + + /// GroupAccountDetailsReply packet public class GroupAccountDetailsReplyPacket : Packet - { - /// MoneyData block + { + /// MoneyData block public class MoneyDataBlock - { - /// RequestID field - public LLUUID RequestID; - /// IntervalDays field - public int IntervalDays; - private byte[] _startdate; - /// StartDate field + { + /// RequestID field + public LLUUID RequestID; + /// IntervalDays field + public int IntervalDays; + private byte[] _startdate; + /// StartDate field public byte[] StartDate - { - get { return _startdate; } + { + get { return _startdate; } set - { - if (value == null) { _startdate = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _startdate = new byte[value.Length]; Array.Copy(value, _startdate, value.Length); } + { + if (value == null) { _startdate = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _startdate = new byte[value.Length]; Array.Copy(value, _startdate, value.Length); } } - } - /// CurrentInterval field - public int CurrentInterval; - - /// Length of this block serialized in bytes + } + /// CurrentInterval field + public int CurrentInterval; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 24; - if (StartDate != null) { length += 1 + StartDate.Length; } - return length; + { + int length = 24; + if (StartDate != null) { length += 1 + StartDate.Length; } + return length; } } - - /// Default constructor - public MoneyDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public MoneyDataBlock() { } + /// Constructor for building the block from a byte array public MoneyDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - RequestID = new LLUUID(bytes, i); i += 16; - IntervalDays = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _startdate = new byte[length]; - Array.Copy(bytes, i, _startdate, 0, length); i += length; - CurrentInterval = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + RequestID = new LLUUID(bytes, i); i += 16; + IntervalDays = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _startdate = new byte[length]; + Array.Copy(bytes, i, _startdate, 0, length); i += length; + CurrentInterval = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(RequestID == null) { Console.WriteLine("Warning: RequestID is null, in " + this.GetType()); } - Array.Copy(RequestID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(IntervalDays % 256); - bytes[i++] = (byte)((IntervalDays >> 8) % 256); - bytes[i++] = (byte)((IntervalDays >> 16) % 256); - bytes[i++] = (byte)((IntervalDays >> 24) % 256); - if(StartDate == null) { Console.WriteLine("Warning: StartDate is null, in " + this.GetType()); } - bytes[i++] = (byte)StartDate.Length; - Array.Copy(StartDate, 0, bytes, i, StartDate.Length); i += StartDate.Length; - bytes[i++] = (byte)(CurrentInterval % 256); - bytes[i++] = (byte)((CurrentInterval >> 8) % 256); - bytes[i++] = (byte)((CurrentInterval >> 16) % 256); - bytes[i++] = (byte)((CurrentInterval >> 24) % 256); + { + if(RequestID == null) { Console.WriteLine("Warning: RequestID is null, in " + this.GetType()); } + Array.Copy(RequestID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(IntervalDays % 256); + bytes[i++] = (byte)((IntervalDays >> 8) % 256); + bytes[i++] = (byte)((IntervalDays >> 16) % 256); + bytes[i++] = (byte)((IntervalDays >> 24) % 256); + if(StartDate == null) { Console.WriteLine("Warning: StartDate is null, in " + this.GetType()); } + bytes[i++] = (byte)StartDate.Length; + Array.Copy(StartDate, 0, bytes, i, StartDate.Length); i += StartDate.Length; + bytes[i++] = (byte)(CurrentInterval % 256); + bytes[i++] = (byte)((CurrentInterval >> 8) % 256); + bytes[i++] = (byte)((CurrentInterval >> 16) % 256); + bytes[i++] = (byte)((CurrentInterval >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- MoneyData --\n"; - output += "RequestID: " + RequestID.ToString() + "\n"; - output += "IntervalDays: " + IntervalDays.ToString() + "\n"; - output += Helpers.FieldToString(StartDate, "StartDate") + "\n"; - output += "CurrentInterval: " + CurrentInterval.ToString() + "\n"; + { + string output = "-- MoneyData --\n"; + output += "RequestID: " + RequestID.ToString() + "\n"; + output += "IntervalDays: " + IntervalDays.ToString() + "\n"; + output += Helpers.FieldToString(StartDate, "StartDate") + "\n"; + output += "CurrentInterval: " + CurrentInterval.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// HistoryData block + + /// HistoryData block public class HistoryDataBlock - { - /// Amount field - public int Amount; - private byte[] _description; - /// Description field + { + /// Amount field + public int Amount; + private byte[] _description; + /// Description field public byte[] Description - { - get { return _description; } + { + get { return _description; } set - { - if (value == null) { _description = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } + { + if (value == null) { _description = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 4; - if (Description != null) { length += 1 + Description.Length; } - return length; + { + int length = 4; + if (Description != null) { length += 1 + Description.Length; } + return length; } } - - /// Default constructor - public HistoryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public HistoryDataBlock() { } + /// Constructor for building the block from a byte array public HistoryDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - Amount = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _description = new byte[length]; - Array.Copy(bytes, i, _description, 0, length); i += length; + { + Amount = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _description = new byte[length]; + Array.Copy(bytes, i, _description, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(Amount % 256); - bytes[i++] = (byte)((Amount >> 8) % 256); - bytes[i++] = (byte)((Amount >> 16) % 256); - bytes[i++] = (byte)((Amount >> 24) % 256); - if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } - bytes[i++] = (byte)Description.Length; - Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; + { + bytes[i++] = (byte)(Amount % 256); + bytes[i++] = (byte)((Amount >> 8) % 256); + bytes[i++] = (byte)((Amount >> 16) % 256); + bytes[i++] = (byte)((Amount >> 24) % 256); + if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } + bytes[i++] = (byte)Description.Length; + Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- HistoryData --\n"; - output += "Amount: " + Amount.ToString() + "\n"; - output += Helpers.FieldToString(Description, "Description") + "\n"; + { + string output = "-- HistoryData --\n"; + output += "Amount: " + Amount.ToString() + "\n"; + output += Helpers.FieldToString(Description, "Description") + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// GroupID field - public LLUUID GroupID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// GroupID field + public LLUUID GroupID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - GroupID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + GroupID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.GroupAccountDetailsReply - public override PacketType Type { get { return PacketType.GroupAccountDetailsReply; } } - /// MoneyData block - public MoneyDataBlock MoneyData; - /// HistoryData block - public HistoryDataBlock[] HistoryData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.GroupAccountDetailsReply + public override PacketType Type { get { return PacketType.GroupAccountDetailsReply; } } + /// MoneyData block + public MoneyDataBlock MoneyData; + /// HistoryData block + public HistoryDataBlock[] HistoryData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public GroupAccountDetailsReplyPacket() - { - Header = new LowHeader(); - Header.ID = 429; - Header.Reliable = true; - Header.Zerocoded = true; - MoneyData = new MoneyDataBlock(); - HistoryData = new HistoryDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 429; + Header.Reliable = true; + Header.Zerocoded = true; + MoneyData = new MoneyDataBlock(); + HistoryData = new HistoryDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public GroupAccountDetailsReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - MoneyData = new MoneyDataBlock(bytes, ref i); - int count = (int)bytes[i++]; - HistoryData = new HistoryDataBlock[count]; - for (int j = 0; j < count; j++) - { HistoryData[j] = new HistoryDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + MoneyData = new MoneyDataBlock(bytes, ref i); + int count = (int)bytes[i++]; + HistoryData = new HistoryDataBlock[count]; + for (int j = 0; j < count; j++) + { HistoryData[j] = new HistoryDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public GroupAccountDetailsReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - MoneyData = new MoneyDataBlock(bytes, ref i); - int count = (int)bytes[i++]; - HistoryData = new HistoryDataBlock[count]; - for (int j = 0; j < count; j++) - { HistoryData[j] = new HistoryDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + MoneyData = new MoneyDataBlock(bytes, ref i); + int count = (int)bytes[i++]; + HistoryData = new HistoryDataBlock[count]; + for (int j = 0; j < count; j++) + { HistoryData[j] = new HistoryDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += MoneyData.Length; length += AgentData.Length;; - length++; - for (int j = 0; j < HistoryData.Length; j++) { length += HistoryData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - MoneyData.ToBytes(bytes, ref i); - bytes[i++] = (byte)HistoryData.Length; - for (int j = 0; j < HistoryData.Length; j++) { HistoryData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += MoneyData.Length; length += AgentData.Length;; + length++; + for (int j = 0; j < HistoryData.Length; j++) { length += HistoryData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + MoneyData.ToBytes(bytes, ref i); + bytes[i++] = (byte)HistoryData.Length; + for (int j = 0; j < HistoryData.Length; j++) { HistoryData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- GroupAccountDetailsReply ---\n"; - output += MoneyData.ToString() + "\n"; + { + string output = "--- GroupAccountDetailsReply ---\n"; + output += MoneyData.ToString() + "\n"; for (int j = 0; j < HistoryData.Length; j++) - { + { output += HistoryData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// GroupAccountTransactionsRequest packet + + /// GroupAccountTransactionsRequest packet public class GroupAccountTransactionsRequestPacket : Packet - { - /// MoneyData block + { + /// MoneyData block public class MoneyDataBlock - { - /// RequestID field - public LLUUID RequestID; - /// IntervalDays field - public int IntervalDays; - /// CurrentInterval field - public int CurrentInterval; - - /// Length of this block serialized in bytes + { + /// RequestID field + public LLUUID RequestID; + /// IntervalDays field + public int IntervalDays; + /// CurrentInterval field + public int CurrentInterval; + + /// Length of this block serialized in bytes public int Length { get - { - return 24; + { + return 24; } } - - /// Default constructor - public MoneyDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public MoneyDataBlock() { } + /// Constructor for building the block from a byte array public MoneyDataBlock(byte[] bytes, ref int i) - { + { try - { - RequestID = new LLUUID(bytes, i); i += 16; - IntervalDays = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - CurrentInterval = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + RequestID = new LLUUID(bytes, i); i += 16; + IntervalDays = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + CurrentInterval = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(RequestID == null) { Console.WriteLine("Warning: RequestID is null, in " + this.GetType()); } - Array.Copy(RequestID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(IntervalDays % 256); - bytes[i++] = (byte)((IntervalDays >> 8) % 256); - bytes[i++] = (byte)((IntervalDays >> 16) % 256); - bytes[i++] = (byte)((IntervalDays >> 24) % 256); - bytes[i++] = (byte)(CurrentInterval % 256); - bytes[i++] = (byte)((CurrentInterval >> 8) % 256); - bytes[i++] = (byte)((CurrentInterval >> 16) % 256); - bytes[i++] = (byte)((CurrentInterval >> 24) % 256); + { + if(RequestID == null) { Console.WriteLine("Warning: RequestID is null, in " + this.GetType()); } + Array.Copy(RequestID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(IntervalDays % 256); + bytes[i++] = (byte)((IntervalDays >> 8) % 256); + bytes[i++] = (byte)((IntervalDays >> 16) % 256); + bytes[i++] = (byte)((IntervalDays >> 24) % 256); + bytes[i++] = (byte)(CurrentInterval % 256); + bytes[i++] = (byte)((CurrentInterval >> 8) % 256); + bytes[i++] = (byte)((CurrentInterval >> 16) % 256); + bytes[i++] = (byte)((CurrentInterval >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- MoneyData --\n"; - output += "RequestID: " + RequestID.ToString() + "\n"; - output += "IntervalDays: " + IntervalDays.ToString() + "\n"; - output += "CurrentInterval: " + CurrentInterval.ToString() + "\n"; + { + string output = "-- MoneyData --\n"; + output += "RequestID: " + RequestID.ToString() + "\n"; + output += "IntervalDays: " + IntervalDays.ToString() + "\n"; + output += "CurrentInterval: " + CurrentInterval.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - /// GroupID field - public LLUUID GroupID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + /// GroupID field + public LLUUID GroupID; + + /// Length of this block serialized in bytes public int Length { get - { - return 48; + { + return 48; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; - GroupID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; + GroupID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.GroupAccountTransactionsRequest - public override PacketType Type { get { return PacketType.GroupAccountTransactionsRequest; } } - /// MoneyData block - public MoneyDataBlock MoneyData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.GroupAccountTransactionsRequest + public override PacketType Type { get { return PacketType.GroupAccountTransactionsRequest; } } + /// MoneyData block + public MoneyDataBlock MoneyData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public GroupAccountTransactionsRequestPacket() - { - Header = new LowHeader(); - Header.ID = 430; - Header.Reliable = true; - Header.Zerocoded = true; - MoneyData = new MoneyDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 430; + Header.Reliable = true; + Header.Zerocoded = true; + MoneyData = new MoneyDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public GroupAccountTransactionsRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - MoneyData = new MoneyDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + MoneyData = new MoneyDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public GroupAccountTransactionsRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - MoneyData = new MoneyDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + MoneyData = new MoneyDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += MoneyData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - MoneyData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += MoneyData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + MoneyData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- GroupAccountTransactionsRequest ---\n"; - output += MoneyData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- GroupAccountTransactionsRequest ---\n"; + output += MoneyData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// GroupAccountTransactionsReply packet + + /// GroupAccountTransactionsReply packet public class GroupAccountTransactionsReplyPacket : Packet - { - /// MoneyData block + { + /// MoneyData block public class MoneyDataBlock - { - /// RequestID field - public LLUUID RequestID; - /// IntervalDays field - public int IntervalDays; - private byte[] _startdate; - /// StartDate field + { + /// RequestID field + public LLUUID RequestID; + /// IntervalDays field + public int IntervalDays; + private byte[] _startdate; + /// StartDate field public byte[] StartDate - { - get { return _startdate; } + { + get { return _startdate; } set - { - if (value == null) { _startdate = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _startdate = new byte[value.Length]; Array.Copy(value, _startdate, value.Length); } + { + if (value == null) { _startdate = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _startdate = new byte[value.Length]; Array.Copy(value, _startdate, value.Length); } } - } - /// CurrentInterval field - public int CurrentInterval; - - /// Length of this block serialized in bytes + } + /// CurrentInterval field + public int CurrentInterval; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 24; - if (StartDate != null) { length += 1 + StartDate.Length; } - return length; + { + int length = 24; + if (StartDate != null) { length += 1 + StartDate.Length; } + return length; } } - - /// Default constructor - public MoneyDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public MoneyDataBlock() { } + /// Constructor for building the block from a byte array public MoneyDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - RequestID = new LLUUID(bytes, i); i += 16; - IntervalDays = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _startdate = new byte[length]; - Array.Copy(bytes, i, _startdate, 0, length); i += length; - CurrentInterval = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + RequestID = new LLUUID(bytes, i); i += 16; + IntervalDays = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _startdate = new byte[length]; + Array.Copy(bytes, i, _startdate, 0, length); i += length; + CurrentInterval = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(RequestID == null) { Console.WriteLine("Warning: RequestID is null, in " + this.GetType()); } - Array.Copy(RequestID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(IntervalDays % 256); - bytes[i++] = (byte)((IntervalDays >> 8) % 256); - bytes[i++] = (byte)((IntervalDays >> 16) % 256); - bytes[i++] = (byte)((IntervalDays >> 24) % 256); - if(StartDate == null) { Console.WriteLine("Warning: StartDate is null, in " + this.GetType()); } - bytes[i++] = (byte)StartDate.Length; - Array.Copy(StartDate, 0, bytes, i, StartDate.Length); i += StartDate.Length; - bytes[i++] = (byte)(CurrentInterval % 256); - bytes[i++] = (byte)((CurrentInterval >> 8) % 256); - bytes[i++] = (byte)((CurrentInterval >> 16) % 256); - bytes[i++] = (byte)((CurrentInterval >> 24) % 256); + { + if(RequestID == null) { Console.WriteLine("Warning: RequestID is null, in " + this.GetType()); } + Array.Copy(RequestID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(IntervalDays % 256); + bytes[i++] = (byte)((IntervalDays >> 8) % 256); + bytes[i++] = (byte)((IntervalDays >> 16) % 256); + bytes[i++] = (byte)((IntervalDays >> 24) % 256); + if(StartDate == null) { Console.WriteLine("Warning: StartDate is null, in " + this.GetType()); } + bytes[i++] = (byte)StartDate.Length; + Array.Copy(StartDate, 0, bytes, i, StartDate.Length); i += StartDate.Length; + bytes[i++] = (byte)(CurrentInterval % 256); + bytes[i++] = (byte)((CurrentInterval >> 8) % 256); + bytes[i++] = (byte)((CurrentInterval >> 16) % 256); + bytes[i++] = (byte)((CurrentInterval >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- MoneyData --\n"; - output += "RequestID: " + RequestID.ToString() + "\n"; - output += "IntervalDays: " + IntervalDays.ToString() + "\n"; - output += Helpers.FieldToString(StartDate, "StartDate") + "\n"; - output += "CurrentInterval: " + CurrentInterval.ToString() + "\n"; + { + string output = "-- MoneyData --\n"; + output += "RequestID: " + RequestID.ToString() + "\n"; + output += "IntervalDays: " + IntervalDays.ToString() + "\n"; + output += Helpers.FieldToString(StartDate, "StartDate") + "\n"; + output += "CurrentInterval: " + CurrentInterval.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// HistoryData block + + /// HistoryData block public class HistoryDataBlock - { - private byte[] _time; - /// Time field + { + private byte[] _time; + /// Time field public byte[] Time - { - get { return _time; } + { + get { return _time; } set - { - if (value == null) { _time = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _time = new byte[value.Length]; Array.Copy(value, _time, value.Length); } + { + if (value == null) { _time = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _time = new byte[value.Length]; Array.Copy(value, _time, value.Length); } } - } - private byte[] _item; - /// Item field + } + private byte[] _item; + /// Item field public byte[] Item - { - get { return _item; } + { + get { return _item; } set - { - if (value == null) { _item = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _item = new byte[value.Length]; Array.Copy(value, _item, value.Length); } + { + if (value == null) { _item = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _item = new byte[value.Length]; Array.Copy(value, _item, value.Length); } } - } - private byte[] _user; - /// User field + } + private byte[] _user; + /// User field public byte[] User - { - get { return _user; } + { + get { return _user; } set - { - if (value == null) { _user = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _user = new byte[value.Length]; Array.Copy(value, _user, value.Length); } + { + if (value == null) { _user = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _user = new byte[value.Length]; Array.Copy(value, _user, value.Length); } } - } - /// Type field - public int Type; - /// Amount field - public int Amount; - - /// Length of this block serialized in bytes + } + /// Type field + public int Type; + /// Amount field + public int Amount; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 8; - if (Time != null) { length += 1 + Time.Length; } - if (Item != null) { length += 1 + Item.Length; } - if (User != null) { length += 1 + User.Length; } - return length; + { + int length = 8; + if (Time != null) { length += 1 + Time.Length; } + if (Item != null) { length += 1 + Item.Length; } + if (User != null) { length += 1 + User.Length; } + return length; } } - - /// Default constructor - public HistoryDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public HistoryDataBlock() { } + /// Constructor for building the block from a byte array public HistoryDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _time = new byte[length]; - Array.Copy(bytes, i, _time, 0, length); i += length; - length = (ushort)bytes[i++]; - _item = new byte[length]; - Array.Copy(bytes, i, _item, 0, length); i += length; - length = (ushort)bytes[i++]; - _user = new byte[length]; - Array.Copy(bytes, i, _user, 0, length); i += length; - Type = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Amount = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + length = (ushort)bytes[i++]; + _time = new byte[length]; + Array.Copy(bytes, i, _time, 0, length); i += length; + length = (ushort)bytes[i++]; + _item = new byte[length]; + Array.Copy(bytes, i, _item, 0, length); i += length; + length = (ushort)bytes[i++]; + _user = new byte[length]; + Array.Copy(bytes, i, _user, 0, length); i += length; + Type = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Amount = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(Time == null) { Console.WriteLine("Warning: Time is null, in " + this.GetType()); } - bytes[i++] = (byte)Time.Length; - Array.Copy(Time, 0, bytes, i, Time.Length); i += Time.Length; - if(Item == null) { Console.WriteLine("Warning: Item is null, in " + this.GetType()); } - bytes[i++] = (byte)Item.Length; - Array.Copy(Item, 0, bytes, i, Item.Length); i += Item.Length; - if(User == null) { Console.WriteLine("Warning: User is null, in " + this.GetType()); } - bytes[i++] = (byte)User.Length; - Array.Copy(User, 0, bytes, i, User.Length); i += User.Length; - bytes[i++] = (byte)(Type % 256); - bytes[i++] = (byte)((Type >> 8) % 256); - bytes[i++] = (byte)((Type >> 16) % 256); - bytes[i++] = (byte)((Type >> 24) % 256); - bytes[i++] = (byte)(Amount % 256); - bytes[i++] = (byte)((Amount >> 8) % 256); - bytes[i++] = (byte)((Amount >> 16) % 256); - bytes[i++] = (byte)((Amount >> 24) % 256); + { + if(Time == null) { Console.WriteLine("Warning: Time is null, in " + this.GetType()); } + bytes[i++] = (byte)Time.Length; + Array.Copy(Time, 0, bytes, i, Time.Length); i += Time.Length; + if(Item == null) { Console.WriteLine("Warning: Item is null, in " + this.GetType()); } + bytes[i++] = (byte)Item.Length; + Array.Copy(Item, 0, bytes, i, Item.Length); i += Item.Length; + if(User == null) { Console.WriteLine("Warning: User is null, in " + this.GetType()); } + bytes[i++] = (byte)User.Length; + Array.Copy(User, 0, bytes, i, User.Length); i += User.Length; + bytes[i++] = (byte)(Type % 256); + bytes[i++] = (byte)((Type >> 8) % 256); + bytes[i++] = (byte)((Type >> 16) % 256); + bytes[i++] = (byte)((Type >> 24) % 256); + bytes[i++] = (byte)(Amount % 256); + bytes[i++] = (byte)((Amount >> 8) % 256); + bytes[i++] = (byte)((Amount >> 16) % 256); + bytes[i++] = (byte)((Amount >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- HistoryData --\n"; - output += Helpers.FieldToString(Time, "Time") + "\n"; - output += Helpers.FieldToString(Item, "Item") + "\n"; - output += Helpers.FieldToString(User, "User") + "\n"; - output += "Type: " + Type.ToString() + "\n"; - output += "Amount: " + Amount.ToString() + "\n"; + { + string output = "-- HistoryData --\n"; + output += Helpers.FieldToString(Time, "Time") + "\n"; + output += Helpers.FieldToString(Item, "Item") + "\n"; + output += Helpers.FieldToString(User, "User") + "\n"; + output += "Type: " + Type.ToString() + "\n"; + output += "Amount: " + Amount.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// GroupID field - public LLUUID GroupID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// GroupID field + public LLUUID GroupID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - GroupID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + GroupID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.GroupAccountTransactionsReply - public override PacketType Type { get { return PacketType.GroupAccountTransactionsReply; } } - /// MoneyData block - public MoneyDataBlock MoneyData; - /// HistoryData block - public HistoryDataBlock[] HistoryData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.GroupAccountTransactionsReply + public override PacketType Type { get { return PacketType.GroupAccountTransactionsReply; } } + /// MoneyData block + public MoneyDataBlock MoneyData; + /// HistoryData block + public HistoryDataBlock[] HistoryData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public GroupAccountTransactionsReplyPacket() - { - Header = new LowHeader(); - Header.ID = 431; - Header.Reliable = true; - Header.Zerocoded = true; - MoneyData = new MoneyDataBlock(); - HistoryData = new HistoryDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 431; + Header.Reliable = true; + Header.Zerocoded = true; + MoneyData = new MoneyDataBlock(); + HistoryData = new HistoryDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public GroupAccountTransactionsReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - MoneyData = new MoneyDataBlock(bytes, ref i); - int count = (int)bytes[i++]; - HistoryData = new HistoryDataBlock[count]; - for (int j = 0; j < count; j++) - { HistoryData[j] = new HistoryDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + MoneyData = new MoneyDataBlock(bytes, ref i); + int count = (int)bytes[i++]; + HistoryData = new HistoryDataBlock[count]; + for (int j = 0; j < count; j++) + { HistoryData[j] = new HistoryDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public GroupAccountTransactionsReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - MoneyData = new MoneyDataBlock(bytes, ref i); - int count = (int)bytes[i++]; - HistoryData = new HistoryDataBlock[count]; - for (int j = 0; j < count; j++) - { HistoryData[j] = new HistoryDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + MoneyData = new MoneyDataBlock(bytes, ref i); + int count = (int)bytes[i++]; + HistoryData = new HistoryDataBlock[count]; + for (int j = 0; j < count; j++) + { HistoryData[j] = new HistoryDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += MoneyData.Length; length += AgentData.Length;; - length++; - for (int j = 0; j < HistoryData.Length; j++) { length += HistoryData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - MoneyData.ToBytes(bytes, ref i); - bytes[i++] = (byte)HistoryData.Length; - for (int j = 0; j < HistoryData.Length; j++) { HistoryData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += MoneyData.Length; length += AgentData.Length;; + length++; + for (int j = 0; j < HistoryData.Length; j++) { length += HistoryData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + MoneyData.ToBytes(bytes, ref i); + bytes[i++] = (byte)HistoryData.Length; + for (int j = 0; j < HistoryData.Length; j++) { HistoryData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- GroupAccountTransactionsReply ---\n"; - output += MoneyData.ToString() + "\n"; + { + string output = "--- GroupAccountTransactionsReply ---\n"; + output += MoneyData.ToString() + "\n"; for (int j = 0; j < HistoryData.Length; j++) - { + { output += HistoryData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// GroupActiveProposalsRequest packet + + /// GroupActiveProposalsRequest packet public class GroupActiveProposalsRequestPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// TransactionData block + + /// TransactionData block public class TransactionDataBlock - { - /// TransactionID field - public LLUUID TransactionID; - - /// Length of this block serialized in bytes + { + /// TransactionID field + public LLUUID TransactionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public TransactionDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public TransactionDataBlock() { } + /// Constructor for building the block from a byte array public TransactionDataBlock(byte[] bytes, ref int i) - { + { try - { - TransactionID = new LLUUID(bytes, i); i += 16; + { + TransactionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } - Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } + Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- TransactionData --\n"; - output += "TransactionID: " + TransactionID.ToString() + "\n"; + { + string output = "-- TransactionData --\n"; + output += "TransactionID: " + TransactionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// GroupData block + + /// GroupData block public class GroupDataBlock - { - /// GroupID field - public LLUUID GroupID; - - /// Length of this block serialized in bytes + { + /// GroupID field + public LLUUID GroupID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public GroupDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public GroupDataBlock() { } + /// Constructor for building the block from a byte array public GroupDataBlock(byte[] bytes, ref int i) - { + { try - { - GroupID = new LLUUID(bytes, i); i += 16; + { + GroupID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- GroupData --\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; + { + string output = "-- GroupData --\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.GroupActiveProposalsRequest - public override PacketType Type { get { return PacketType.GroupActiveProposalsRequest; } } - /// AgentData block - public AgentDataBlock AgentData; - /// TransactionData block - public TransactionDataBlock TransactionData; - /// GroupData block - public GroupDataBlock GroupData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.GroupActiveProposalsRequest + public override PacketType Type { get { return PacketType.GroupActiveProposalsRequest; } } + /// AgentData block + public AgentDataBlock AgentData; + /// TransactionData block + public TransactionDataBlock TransactionData; + /// GroupData block + public GroupDataBlock GroupData; + + /// Default constructor public GroupActiveProposalsRequestPacket() - { - Header = new LowHeader(); - Header.ID = 432; - Header.Reliable = true; - AgentData = new AgentDataBlock(); - TransactionData = new TransactionDataBlock(); - GroupData = new GroupDataBlock(); + { + Header = new LowHeader(); + Header.ID = 432; + Header.Reliable = true; + AgentData = new AgentDataBlock(); + TransactionData = new TransactionDataBlock(); + GroupData = new GroupDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public GroupActiveProposalsRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); - TransactionData = new TransactionDataBlock(bytes, ref i); - GroupData = new GroupDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); + TransactionData = new TransactionDataBlock(bytes, ref i); + GroupData = new GroupDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public GroupActiveProposalsRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); - TransactionData = new TransactionDataBlock(bytes, ref i); - GroupData = new GroupDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); + TransactionData = new TransactionDataBlock(bytes, ref i); + GroupData = new GroupDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length; length += TransactionData.Length; length += GroupData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - TransactionData.ToBytes(bytes, ref i); - GroupData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length; length += TransactionData.Length; length += GroupData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + TransactionData.ToBytes(bytes, ref i); + GroupData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- GroupActiveProposalsRequest ---\n"; - output += AgentData.ToString() + "\n"; - output += TransactionData.ToString() + "\n"; - output += GroupData.ToString() + "\n"; + { + string output = "--- GroupActiveProposalsRequest ---\n"; + output += AgentData.ToString() + "\n"; + output += TransactionData.ToString() + "\n"; + output += GroupData.ToString() + "\n"; return output; } - + } - - /// GroupActiveProposalItemReply packet + + /// GroupActiveProposalItemReply packet public class GroupActiveProposalItemReplyPacket : Packet - { - /// ProposalData block + { + /// ProposalData block public class ProposalDataBlock - { - private byte[] _startdatetime; - /// StartDateTime field + { + private byte[] _startdatetime; + /// StartDateTime field public byte[] StartDateTime - { - get { return _startdatetime; } + { + get { return _startdatetime; } set - { - if (value == null) { _startdatetime = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _startdatetime = new byte[value.Length]; Array.Copy(value, _startdatetime, value.Length); } + { + if (value == null) { _startdatetime = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _startdatetime = new byte[value.Length]; Array.Copy(value, _startdatetime, value.Length); } } - } - private byte[] _proposaltext; - /// ProposalText field + } + private byte[] _proposaltext; + /// ProposalText field public byte[] ProposalText - { - get { return _proposaltext; } + { + get { return _proposaltext; } set - { - if (value == null) { _proposaltext = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _proposaltext = new byte[value.Length]; Array.Copy(value, _proposaltext, value.Length); } + { + if (value == null) { _proposaltext = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _proposaltext = new byte[value.Length]; Array.Copy(value, _proposaltext, value.Length); } } - } - /// Majority field - public float Majority; - private byte[] _tersedateid; - /// TerseDateID field + } + /// Majority field + public float Majority; + private byte[] _tersedateid; + /// TerseDateID field public byte[] TerseDateID - { - get { return _tersedateid; } + { + get { return _tersedateid; } set - { - if (value == null) { _tersedateid = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _tersedateid = new byte[value.Length]; Array.Copy(value, _tersedateid, value.Length); } + { + if (value == null) { _tersedateid = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _tersedateid = new byte[value.Length]; Array.Copy(value, _tersedateid, value.Length); } } - } - private byte[] _enddatetime; - /// EndDateTime field + } + private byte[] _enddatetime; + /// EndDateTime field public byte[] EndDateTime - { - get { return _enddatetime; } + { + get { return _enddatetime; } set - { - if (value == null) { _enddatetime = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _enddatetime = new byte[value.Length]; Array.Copy(value, _enddatetime, value.Length); } + { + if (value == null) { _enddatetime = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _enddatetime = new byte[value.Length]; Array.Copy(value, _enddatetime, value.Length); } } - } - /// VoteID field - public LLUUID VoteID; - /// AlreadyVoted field - public bool AlreadyVoted; - private byte[] _votecast; - /// VoteCast field + } + /// VoteID field + public LLUUID VoteID; + /// AlreadyVoted field + public bool AlreadyVoted; + private byte[] _votecast; + /// VoteCast field public byte[] VoteCast - { - get { return _votecast; } + { + get { return _votecast; } set - { - if (value == null) { _votecast = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _votecast = new byte[value.Length]; Array.Copy(value, _votecast, value.Length); } + { + if (value == null) { _votecast = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _votecast = new byte[value.Length]; Array.Copy(value, _votecast, value.Length); } } - } - /// Quorum field - public int Quorum; - /// VoteInitiator field - public LLUUID VoteInitiator; - - /// Length of this block serialized in bytes + } + /// Quorum field + public int Quorum; + /// VoteInitiator field + public LLUUID VoteInitiator; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 41; - if (StartDateTime != null) { length += 1 + StartDateTime.Length; } - if (ProposalText != null) { length += 1 + ProposalText.Length; } - if (TerseDateID != null) { length += 1 + TerseDateID.Length; } - if (EndDateTime != null) { length += 1 + EndDateTime.Length; } - if (VoteCast != null) { length += 1 + VoteCast.Length; } - return length; + { + int length = 41; + if (StartDateTime != null) { length += 1 + StartDateTime.Length; } + if (ProposalText != null) { length += 1 + ProposalText.Length; } + if (TerseDateID != null) { length += 1 + TerseDateID.Length; } + if (EndDateTime != null) { length += 1 + EndDateTime.Length; } + if (VoteCast != null) { length += 1 + VoteCast.Length; } + return length; } } - - /// Default constructor - public ProposalDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ProposalDataBlock() { } + /// Constructor for building the block from a byte array public ProposalDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _startdatetime = new byte[length]; - Array.Copy(bytes, i, _startdatetime, 0, length); i += length; - length = (ushort)bytes[i++]; - _proposaltext = new byte[length]; - Array.Copy(bytes, i, _proposaltext, 0, length); i += length; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - Majority = BitConverter.ToSingle(bytes, i); i += 4; - length = (ushort)bytes[i++]; - _tersedateid = new byte[length]; - Array.Copy(bytes, i, _tersedateid, 0, length); i += length; - length = (ushort)bytes[i++]; - _enddatetime = new byte[length]; - Array.Copy(bytes, i, _enddatetime, 0, length); i += length; - VoteID = new LLUUID(bytes, i); i += 16; - AlreadyVoted = (bytes[i++] != 0) ? (bool)true : (bool)false; - length = (ushort)bytes[i++]; - _votecast = new byte[length]; - Array.Copy(bytes, i, _votecast, 0, length); i += length; - Quorum = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - VoteInitiator = new LLUUID(bytes, i); i += 16; + { + length = (ushort)bytes[i++]; + _startdatetime = new byte[length]; + Array.Copy(bytes, i, _startdatetime, 0, length); i += length; + length = (ushort)bytes[i++]; + _proposaltext = new byte[length]; + Array.Copy(bytes, i, _proposaltext, 0, length); i += length; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + Majority = BitConverter.ToSingle(bytes, i); i += 4; + length = (ushort)bytes[i++]; + _tersedateid = new byte[length]; + Array.Copy(bytes, i, _tersedateid, 0, length); i += length; + length = (ushort)bytes[i++]; + _enddatetime = new byte[length]; + Array.Copy(bytes, i, _enddatetime, 0, length); i += length; + VoteID = new LLUUID(bytes, i); i += 16; + AlreadyVoted = (bytes[i++] != 0) ? (bool)true : (bool)false; + length = (ushort)bytes[i++]; + _votecast = new byte[length]; + Array.Copy(bytes, i, _votecast, 0, length); i += length; + Quorum = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + VoteInitiator = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; - if(StartDateTime == null) { Console.WriteLine("Warning: StartDateTime is null, in " + this.GetType()); } - bytes[i++] = (byte)StartDateTime.Length; - Array.Copy(StartDateTime, 0, bytes, i, StartDateTime.Length); i += StartDateTime.Length; - if(ProposalText == null) { Console.WriteLine("Warning: ProposalText is null, in " + this.GetType()); } - bytes[i++] = (byte)ProposalText.Length; - Array.Copy(ProposalText, 0, bytes, i, ProposalText.Length); i += ProposalText.Length; + { + byte[] ba; + if(StartDateTime == null) { Console.WriteLine("Warning: StartDateTime is null, in " + this.GetType()); } + bytes[i++] = (byte)StartDateTime.Length; + Array.Copy(StartDateTime, 0, bytes, i, StartDateTime.Length); i += StartDateTime.Length; + if(ProposalText == null) { Console.WriteLine("Warning: ProposalText is null, in " + this.GetType()); } + bytes[i++] = (byte)ProposalText.Length; + Array.Copy(ProposalText, 0, bytes, i, ProposalText.Length); i += ProposalText.Length; ba = BitConverter.GetBytes(Majority); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - if(TerseDateID == null) { Console.WriteLine("Warning: TerseDateID is null, in " + this.GetType()); } - bytes[i++] = (byte)TerseDateID.Length; - Array.Copy(TerseDateID, 0, bytes, i, TerseDateID.Length); i += TerseDateID.Length; - if(EndDateTime == null) { Console.WriteLine("Warning: EndDateTime is null, in " + this.GetType()); } - bytes[i++] = (byte)EndDateTime.Length; - Array.Copy(EndDateTime, 0, bytes, i, EndDateTime.Length); i += EndDateTime.Length; - if(VoteID == null) { Console.WriteLine("Warning: VoteID is null, in " + this.GetType()); } - Array.Copy(VoteID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((AlreadyVoted) ? 1 : 0); - if(VoteCast == null) { Console.WriteLine("Warning: VoteCast is null, in " + this.GetType()); } - bytes[i++] = (byte)VoteCast.Length; - Array.Copy(VoteCast, 0, bytes, i, VoteCast.Length); i += VoteCast.Length; - bytes[i++] = (byte)(Quorum % 256); - bytes[i++] = (byte)((Quorum >> 8) % 256); - bytes[i++] = (byte)((Quorum >> 16) % 256); - bytes[i++] = (byte)((Quorum >> 24) % 256); - if(VoteInitiator == null) { Console.WriteLine("Warning: VoteInitiator is null, in " + this.GetType()); } - Array.Copy(VoteInitiator.GetBytes(), 0, bytes, i, 16); i += 16; + Array.Copy(ba, 0, bytes, i, 4); i += 4; + if(TerseDateID == null) { Console.WriteLine("Warning: TerseDateID is null, in " + this.GetType()); } + bytes[i++] = (byte)TerseDateID.Length; + Array.Copy(TerseDateID, 0, bytes, i, TerseDateID.Length); i += TerseDateID.Length; + if(EndDateTime == null) { Console.WriteLine("Warning: EndDateTime is null, in " + this.GetType()); } + bytes[i++] = (byte)EndDateTime.Length; + Array.Copy(EndDateTime, 0, bytes, i, EndDateTime.Length); i += EndDateTime.Length; + if(VoteID == null) { Console.WriteLine("Warning: VoteID is null, in " + this.GetType()); } + Array.Copy(VoteID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((AlreadyVoted) ? 1 : 0); + if(VoteCast == null) { Console.WriteLine("Warning: VoteCast is null, in " + this.GetType()); } + bytes[i++] = (byte)VoteCast.Length; + Array.Copy(VoteCast, 0, bytes, i, VoteCast.Length); i += VoteCast.Length; + bytes[i++] = (byte)(Quorum % 256); + bytes[i++] = (byte)((Quorum >> 8) % 256); + bytes[i++] = (byte)((Quorum >> 16) % 256); + bytes[i++] = (byte)((Quorum >> 24) % 256); + if(VoteInitiator == null) { Console.WriteLine("Warning: VoteInitiator is null, in " + this.GetType()); } + Array.Copy(VoteInitiator.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ProposalData --\n"; - output += Helpers.FieldToString(StartDateTime, "StartDateTime") + "\n"; - output += Helpers.FieldToString(ProposalText, "ProposalText") + "\n"; - output += "Majority: " + Majority.ToString() + "\n"; - output += Helpers.FieldToString(TerseDateID, "TerseDateID") + "\n"; - output += Helpers.FieldToString(EndDateTime, "EndDateTime") + "\n"; - output += "VoteID: " + VoteID.ToString() + "\n"; - output += "AlreadyVoted: " + AlreadyVoted.ToString() + "\n"; - output += Helpers.FieldToString(VoteCast, "VoteCast") + "\n"; - output += "Quorum: " + Quorum.ToString() + "\n"; - output += "VoteInitiator: " + VoteInitiator.ToString() + "\n"; + { + string output = "-- ProposalData --\n"; + output += Helpers.FieldToString(StartDateTime, "StartDateTime") + "\n"; + output += Helpers.FieldToString(ProposalText, "ProposalText") + "\n"; + output += "Majority: " + Majority.ToString() + "\n"; + output += Helpers.FieldToString(TerseDateID, "TerseDateID") + "\n"; + output += Helpers.FieldToString(EndDateTime, "EndDateTime") + "\n"; + output += "VoteID: " + VoteID.ToString() + "\n"; + output += "AlreadyVoted: " + AlreadyVoted.ToString() + "\n"; + output += Helpers.FieldToString(VoteCast, "VoteCast") + "\n"; + output += "Quorum: " + Quorum.ToString() + "\n"; + output += "VoteInitiator: " + VoteInitiator.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// GroupID field - public LLUUID GroupID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// GroupID field + public LLUUID GroupID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - GroupID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + GroupID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// TransactionData block + + /// TransactionData block public class TransactionDataBlock - { - /// TotalNumItems field - public uint TotalNumItems; - /// TransactionID field - public LLUUID TransactionID; - - /// Length of this block serialized in bytes + { + /// TotalNumItems field + public uint TotalNumItems; + /// TransactionID field + public LLUUID TransactionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 20; + { + return 20; } } - - /// Default constructor - public TransactionDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public TransactionDataBlock() { } + /// Constructor for building the block from a byte array public TransactionDataBlock(byte[] bytes, ref int i) - { + { try - { - TotalNumItems = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - TransactionID = new LLUUID(bytes, i); i += 16; + { + TotalNumItems = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + TransactionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(TotalNumItems % 256); - bytes[i++] = (byte)((TotalNumItems >> 8) % 256); - bytes[i++] = (byte)((TotalNumItems >> 16) % 256); - bytes[i++] = (byte)((TotalNumItems >> 24) % 256); - if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } - Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + bytes[i++] = (byte)(TotalNumItems % 256); + bytes[i++] = (byte)((TotalNumItems >> 8) % 256); + bytes[i++] = (byte)((TotalNumItems >> 16) % 256); + bytes[i++] = (byte)((TotalNumItems >> 24) % 256); + if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } + Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- TransactionData --\n"; - output += "TotalNumItems: " + TotalNumItems.ToString() + "\n"; - output += "TransactionID: " + TransactionID.ToString() + "\n"; + { + string output = "-- TransactionData --\n"; + output += "TotalNumItems: " + TotalNumItems.ToString() + "\n"; + output += "TransactionID: " + TransactionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.GroupActiveProposalItemReply - public override PacketType Type { get { return PacketType.GroupActiveProposalItemReply; } } - /// ProposalData block - public ProposalDataBlock[] ProposalData; - /// AgentData block - public AgentDataBlock AgentData; - /// TransactionData block - public TransactionDataBlock TransactionData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.GroupActiveProposalItemReply + public override PacketType Type { get { return PacketType.GroupActiveProposalItemReply; } } + /// ProposalData block + public ProposalDataBlock[] ProposalData; + /// AgentData block + public AgentDataBlock AgentData; + /// TransactionData block + public TransactionDataBlock TransactionData; + + /// Default constructor public GroupActiveProposalItemReplyPacket() - { - Header = new LowHeader(); - Header.ID = 433; - Header.Reliable = true; - Header.Zerocoded = true; - ProposalData = new ProposalDataBlock[0]; - AgentData = new AgentDataBlock(); - TransactionData = new TransactionDataBlock(); + { + Header = new LowHeader(); + Header.ID = 433; + Header.Reliable = true; + Header.Zerocoded = true; + ProposalData = new ProposalDataBlock[0]; + AgentData = new AgentDataBlock(); + TransactionData = new TransactionDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public GroupActiveProposalItemReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ProposalData = new ProposalDataBlock[count]; - for (int j = 0; j < count; j++) - { ProposalData[j] = new ProposalDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); - TransactionData = new TransactionDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ProposalData = new ProposalDataBlock[count]; + for (int j = 0; j < count; j++) + { ProposalData[j] = new ProposalDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); + TransactionData = new TransactionDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public GroupActiveProposalItemReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ProposalData = new ProposalDataBlock[count]; - for (int j = 0; j < count; j++) - { ProposalData[j] = new ProposalDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); - TransactionData = new TransactionDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + ProposalData = new ProposalDataBlock[count]; + for (int j = 0; j < count; j++) + { ProposalData[j] = new ProposalDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); + TransactionData = new TransactionDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length; length += TransactionData.Length;; - length++; - for (int j = 0; j < ProposalData.Length; j++) { length += ProposalData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ProposalData.Length; - for (int j = 0; j < ProposalData.Length; j++) { ProposalData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - TransactionData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length; length += TransactionData.Length;; + length++; + for (int j = 0; j < ProposalData.Length; j++) { length += ProposalData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ProposalData.Length; + for (int j = 0; j < ProposalData.Length; j++) { ProposalData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + TransactionData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- GroupActiveProposalItemReply ---\n"; + { + string output = "--- GroupActiveProposalItemReply ---\n"; for (int j = 0; j < ProposalData.Length; j++) - { + { output += ProposalData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; - output += TransactionData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; + output += TransactionData.ToString() + "\n"; return output; } - + } - - /// GroupVoteHistoryRequest packet + + /// GroupVoteHistoryRequest packet public class GroupVoteHistoryRequestPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// TransactionData block + + /// TransactionData block public class TransactionDataBlock - { - /// TransactionID field - public LLUUID TransactionID; - - /// Length of this block serialized in bytes + { + /// TransactionID field + public LLUUID TransactionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public TransactionDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public TransactionDataBlock() { } + /// Constructor for building the block from a byte array public TransactionDataBlock(byte[] bytes, ref int i) - { + { try - { - TransactionID = new LLUUID(bytes, i); i += 16; + { + TransactionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } - Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } + Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- TransactionData --\n"; - output += "TransactionID: " + TransactionID.ToString() + "\n"; + { + string output = "-- TransactionData --\n"; + output += "TransactionID: " + TransactionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// GroupData block + + /// GroupData block public class GroupDataBlock - { - /// GroupID field - public LLUUID GroupID; - - /// Length of this block serialized in bytes + { + /// GroupID field + public LLUUID GroupID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public GroupDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public GroupDataBlock() { } + /// Constructor for building the block from a byte array public GroupDataBlock(byte[] bytes, ref int i) - { + { try - { - GroupID = new LLUUID(bytes, i); i += 16; + { + GroupID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- GroupData --\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; + { + string output = "-- GroupData --\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.GroupVoteHistoryRequest - public override PacketType Type { get { return PacketType.GroupVoteHistoryRequest; } } - /// AgentData block - public AgentDataBlock AgentData; - /// TransactionData block - public TransactionDataBlock TransactionData; - /// GroupData block - public GroupDataBlock GroupData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.GroupVoteHistoryRequest + public override PacketType Type { get { return PacketType.GroupVoteHistoryRequest; } } + /// AgentData block + public AgentDataBlock AgentData; + /// TransactionData block + public TransactionDataBlock TransactionData; + /// GroupData block + public GroupDataBlock GroupData; + + /// Default constructor public GroupVoteHistoryRequestPacket() - { - Header = new LowHeader(); - Header.ID = 434; - Header.Reliable = true; - AgentData = new AgentDataBlock(); - TransactionData = new TransactionDataBlock(); - GroupData = new GroupDataBlock(); + { + Header = new LowHeader(); + Header.ID = 434; + Header.Reliable = true; + AgentData = new AgentDataBlock(); + TransactionData = new TransactionDataBlock(); + GroupData = new GroupDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public GroupVoteHistoryRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); - TransactionData = new TransactionDataBlock(bytes, ref i); - GroupData = new GroupDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); + TransactionData = new TransactionDataBlock(bytes, ref i); + GroupData = new GroupDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public GroupVoteHistoryRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); - TransactionData = new TransactionDataBlock(bytes, ref i); - GroupData = new GroupDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); + TransactionData = new TransactionDataBlock(bytes, ref i); + GroupData = new GroupDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length; length += TransactionData.Length; length += GroupData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - TransactionData.ToBytes(bytes, ref i); - GroupData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length; length += TransactionData.Length; length += GroupData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + TransactionData.ToBytes(bytes, ref i); + GroupData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- GroupVoteHistoryRequest ---\n"; - output += AgentData.ToString() + "\n"; - output += TransactionData.ToString() + "\n"; - output += GroupData.ToString() + "\n"; + { + string output = "--- GroupVoteHistoryRequest ---\n"; + output += AgentData.ToString() + "\n"; + output += TransactionData.ToString() + "\n"; + output += GroupData.ToString() + "\n"; return output; } - + } - - /// GroupVoteHistoryItemReply packet + + /// GroupVoteHistoryItemReply packet public class GroupVoteHistoryItemReplyPacket : Packet - { - /// HistoryItemData block + { + /// HistoryItemData block public class HistoryItemDataBlock - { - private byte[] _startdatetime; - /// StartDateTime field + { + private byte[] _startdatetime; + /// StartDateTime field public byte[] StartDateTime - { - get { return _startdatetime; } + { + get { return _startdatetime; } set - { - if (value == null) { _startdatetime = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _startdatetime = new byte[value.Length]; Array.Copy(value, _startdatetime, value.Length); } + { + if (value == null) { _startdatetime = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _startdatetime = new byte[value.Length]; Array.Copy(value, _startdatetime, value.Length); } } - } - private byte[] _voteresult; - /// VoteResult field + } + private byte[] _voteresult; + /// VoteResult field public byte[] VoteResult - { - get { return _voteresult; } + { + get { return _voteresult; } set - { - if (value == null) { _voteresult = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _voteresult = new byte[value.Length]; Array.Copy(value, _voteresult, value.Length); } + { + if (value == null) { _voteresult = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _voteresult = new byte[value.Length]; Array.Copy(value, _voteresult, value.Length); } } - } - private byte[] _proposaltext; - /// ProposalText field + } + private byte[] _proposaltext; + /// ProposalText field public byte[] ProposalText - { - get { return _proposaltext; } + { + get { return _proposaltext; } set - { - if (value == null) { _proposaltext = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _proposaltext = new byte[value.Length]; Array.Copy(value, _proposaltext, value.Length); } + { + if (value == null) { _proposaltext = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _proposaltext = new byte[value.Length]; Array.Copy(value, _proposaltext, value.Length); } } - } - /// Majority field - public float Majority; - private byte[] _tersedateid; - /// TerseDateID field + } + /// Majority field + public float Majority; + private byte[] _tersedateid; + /// TerseDateID field public byte[] TerseDateID - { - get { return _tersedateid; } + { + get { return _tersedateid; } set - { - if (value == null) { _tersedateid = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _tersedateid = new byte[value.Length]; Array.Copy(value, _tersedateid, value.Length); } + { + if (value == null) { _tersedateid = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _tersedateid = new byte[value.Length]; Array.Copy(value, _tersedateid, value.Length); } } - } - private byte[] _enddatetime; - /// EndDateTime field + } + private byte[] _enddatetime; + /// EndDateTime field public byte[] EndDateTime - { - get { return _enddatetime; } + { + get { return _enddatetime; } set - { - if (value == null) { _enddatetime = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _enddatetime = new byte[value.Length]; Array.Copy(value, _enddatetime, value.Length); } + { + if (value == null) { _enddatetime = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _enddatetime = new byte[value.Length]; Array.Copy(value, _enddatetime, value.Length); } } - } - /// VoteID field - public LLUUID VoteID; - /// Quorum field - public int Quorum; - private byte[] _votetype; - /// VoteType field + } + /// VoteID field + public LLUUID VoteID; + /// Quorum field + public int Quorum; + private byte[] _votetype; + /// VoteType field public byte[] VoteType - { - get { return _votetype; } + { + get { return _votetype; } set - { - if (value == null) { _votetype = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _votetype = new byte[value.Length]; Array.Copy(value, _votetype, value.Length); } + { + if (value == null) { _votetype = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _votetype = new byte[value.Length]; Array.Copy(value, _votetype, value.Length); } } - } - /// VoteInitiator field - public LLUUID VoteInitiator; - - /// Length of this block serialized in bytes + } + /// VoteInitiator field + public LLUUID VoteInitiator; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 40; - if (StartDateTime != null) { length += 1 + StartDateTime.Length; } - if (VoteResult != null) { length += 1 + VoteResult.Length; } - if (ProposalText != null) { length += 2 + ProposalText.Length; } - if (TerseDateID != null) { length += 1 + TerseDateID.Length; } - if (EndDateTime != null) { length += 1 + EndDateTime.Length; } - if (VoteType != null) { length += 1 + VoteType.Length; } - return length; + { + int length = 40; + if (StartDateTime != null) { length += 1 + StartDateTime.Length; } + if (VoteResult != null) { length += 1 + VoteResult.Length; } + if (ProposalText != null) { length += 2 + ProposalText.Length; } + if (TerseDateID != null) { length += 1 + TerseDateID.Length; } + if (EndDateTime != null) { length += 1 + EndDateTime.Length; } + if (VoteType != null) { length += 1 + VoteType.Length; } + return length; } } - - /// Default constructor - public HistoryItemDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public HistoryItemDataBlock() { } + /// Constructor for building the block from a byte array public HistoryItemDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _startdatetime = new byte[length]; - Array.Copy(bytes, i, _startdatetime, 0, length); i += length; - length = (ushort)bytes[i++]; - _voteresult = new byte[length]; - Array.Copy(bytes, i, _voteresult, 0, length); i += length; - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _proposaltext = new byte[length]; - Array.Copy(bytes, i, _proposaltext, 0, length); i += length; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - Majority = BitConverter.ToSingle(bytes, i); i += 4; - length = (ushort)bytes[i++]; - _tersedateid = new byte[length]; - Array.Copy(bytes, i, _tersedateid, 0, length); i += length; - length = (ushort)bytes[i++]; - _enddatetime = new byte[length]; - Array.Copy(bytes, i, _enddatetime, 0, length); i += length; - VoteID = new LLUUID(bytes, i); i += 16; - Quorum = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _votetype = new byte[length]; - Array.Copy(bytes, i, _votetype, 0, length); i += length; - VoteInitiator = new LLUUID(bytes, i); i += 16; + { + length = (ushort)bytes[i++]; + _startdatetime = new byte[length]; + Array.Copy(bytes, i, _startdatetime, 0, length); i += length; + length = (ushort)bytes[i++]; + _voteresult = new byte[length]; + Array.Copy(bytes, i, _voteresult, 0, length); i += length; + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _proposaltext = new byte[length]; + Array.Copy(bytes, i, _proposaltext, 0, length); i += length; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + Majority = BitConverter.ToSingle(bytes, i); i += 4; + length = (ushort)bytes[i++]; + _tersedateid = new byte[length]; + Array.Copy(bytes, i, _tersedateid, 0, length); i += length; + length = (ushort)bytes[i++]; + _enddatetime = new byte[length]; + Array.Copy(bytes, i, _enddatetime, 0, length); i += length; + VoteID = new LLUUID(bytes, i); i += 16; + Quorum = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _votetype = new byte[length]; + Array.Copy(bytes, i, _votetype, 0, length); i += length; + VoteInitiator = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; - if(StartDateTime == null) { Console.WriteLine("Warning: StartDateTime is null, in " + this.GetType()); } - bytes[i++] = (byte)StartDateTime.Length; - Array.Copy(StartDateTime, 0, bytes, i, StartDateTime.Length); i += StartDateTime.Length; - if(VoteResult == null) { Console.WriteLine("Warning: VoteResult is null, in " + this.GetType()); } - bytes[i++] = (byte)VoteResult.Length; - Array.Copy(VoteResult, 0, bytes, i, VoteResult.Length); i += VoteResult.Length; - if(ProposalText == null) { Console.WriteLine("Warning: ProposalText is null, in " + this.GetType()); } - bytes[i++] = (byte)(ProposalText.Length % 256); - bytes[i++] = (byte)((ProposalText.Length >> 8) % 256); - Array.Copy(ProposalText, 0, bytes, i, ProposalText.Length); i += ProposalText.Length; + { + byte[] ba; + if(StartDateTime == null) { Console.WriteLine("Warning: StartDateTime is null, in " + this.GetType()); } + bytes[i++] = (byte)StartDateTime.Length; + Array.Copy(StartDateTime, 0, bytes, i, StartDateTime.Length); i += StartDateTime.Length; + if(VoteResult == null) { Console.WriteLine("Warning: VoteResult is null, in " + this.GetType()); } + bytes[i++] = (byte)VoteResult.Length; + Array.Copy(VoteResult, 0, bytes, i, VoteResult.Length); i += VoteResult.Length; + if(ProposalText == null) { Console.WriteLine("Warning: ProposalText is null, in " + this.GetType()); } + bytes[i++] = (byte)(ProposalText.Length % 256); + bytes[i++] = (byte)((ProposalText.Length >> 8) % 256); + Array.Copy(ProposalText, 0, bytes, i, ProposalText.Length); i += ProposalText.Length; ba = BitConverter.GetBytes(Majority); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - if(TerseDateID == null) { Console.WriteLine("Warning: TerseDateID is null, in " + this.GetType()); } - bytes[i++] = (byte)TerseDateID.Length; - Array.Copy(TerseDateID, 0, bytes, i, TerseDateID.Length); i += TerseDateID.Length; - if(EndDateTime == null) { Console.WriteLine("Warning: EndDateTime is null, in " + this.GetType()); } - bytes[i++] = (byte)EndDateTime.Length; - Array.Copy(EndDateTime, 0, bytes, i, EndDateTime.Length); i += EndDateTime.Length; - if(VoteID == null) { Console.WriteLine("Warning: VoteID is null, in " + this.GetType()); } - Array.Copy(VoteID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(Quorum % 256); - bytes[i++] = (byte)((Quorum >> 8) % 256); - bytes[i++] = (byte)((Quorum >> 16) % 256); - bytes[i++] = (byte)((Quorum >> 24) % 256); - if(VoteType == null) { Console.WriteLine("Warning: VoteType is null, in " + this.GetType()); } - bytes[i++] = (byte)VoteType.Length; - Array.Copy(VoteType, 0, bytes, i, VoteType.Length); i += VoteType.Length; - if(VoteInitiator == null) { Console.WriteLine("Warning: VoteInitiator is null, in " + this.GetType()); } - Array.Copy(VoteInitiator.GetBytes(), 0, bytes, i, 16); i += 16; + Array.Copy(ba, 0, bytes, i, 4); i += 4; + if(TerseDateID == null) { Console.WriteLine("Warning: TerseDateID is null, in " + this.GetType()); } + bytes[i++] = (byte)TerseDateID.Length; + Array.Copy(TerseDateID, 0, bytes, i, TerseDateID.Length); i += TerseDateID.Length; + if(EndDateTime == null) { Console.WriteLine("Warning: EndDateTime is null, in " + this.GetType()); } + bytes[i++] = (byte)EndDateTime.Length; + Array.Copy(EndDateTime, 0, bytes, i, EndDateTime.Length); i += EndDateTime.Length; + if(VoteID == null) { Console.WriteLine("Warning: VoteID is null, in " + this.GetType()); } + Array.Copy(VoteID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(Quorum % 256); + bytes[i++] = (byte)((Quorum >> 8) % 256); + bytes[i++] = (byte)((Quorum >> 16) % 256); + bytes[i++] = (byte)((Quorum >> 24) % 256); + if(VoteType == null) { Console.WriteLine("Warning: VoteType is null, in " + this.GetType()); } + bytes[i++] = (byte)VoteType.Length; + Array.Copy(VoteType, 0, bytes, i, VoteType.Length); i += VoteType.Length; + if(VoteInitiator == null) { Console.WriteLine("Warning: VoteInitiator is null, in " + this.GetType()); } + Array.Copy(VoteInitiator.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- HistoryItemData --\n"; - output += Helpers.FieldToString(StartDateTime, "StartDateTime") + "\n"; - output += Helpers.FieldToString(VoteResult, "VoteResult") + "\n"; - output += Helpers.FieldToString(ProposalText, "ProposalText") + "\n"; - output += "Majority: " + Majority.ToString() + "\n"; - output += Helpers.FieldToString(TerseDateID, "TerseDateID") + "\n"; - output += Helpers.FieldToString(EndDateTime, "EndDateTime") + "\n"; - output += "VoteID: " + VoteID.ToString() + "\n"; - output += "Quorum: " + Quorum.ToString() + "\n"; - output += Helpers.FieldToString(VoteType, "VoteType") + "\n"; - output += "VoteInitiator: " + VoteInitiator.ToString() + "\n"; + { + string output = "-- HistoryItemData --\n"; + output += Helpers.FieldToString(StartDateTime, "StartDateTime") + "\n"; + output += Helpers.FieldToString(VoteResult, "VoteResult") + "\n"; + output += Helpers.FieldToString(ProposalText, "ProposalText") + "\n"; + output += "Majority: " + Majority.ToString() + "\n"; + output += Helpers.FieldToString(TerseDateID, "TerseDateID") + "\n"; + output += Helpers.FieldToString(EndDateTime, "EndDateTime") + "\n"; + output += "VoteID: " + VoteID.ToString() + "\n"; + output += "Quorum: " + Quorum.ToString() + "\n"; + output += Helpers.FieldToString(VoteType, "VoteType") + "\n"; + output += "VoteInitiator: " + VoteInitiator.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// VoteItem block + + /// VoteItem block public class VoteItemBlock - { - /// CandidateID field - public LLUUID CandidateID; - private byte[] _votecast; - /// VoteCast field + { + /// CandidateID field + public LLUUID CandidateID; + private byte[] _votecast; + /// VoteCast field public byte[] VoteCast - { - get { return _votecast; } + { + get { return _votecast; } set - { - if (value == null) { _votecast = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _votecast = new byte[value.Length]; Array.Copy(value, _votecast, value.Length); } + { + if (value == null) { _votecast = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _votecast = new byte[value.Length]; Array.Copy(value, _votecast, value.Length); } } - } - /// NumVotes field - public int NumVotes; - - /// Length of this block serialized in bytes + } + /// NumVotes field + public int NumVotes; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 20; - if (VoteCast != null) { length += 1 + VoteCast.Length; } - return length; + { + int length = 20; + if (VoteCast != null) { length += 1 + VoteCast.Length; } + return length; } } - - /// Default constructor - public VoteItemBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public VoteItemBlock() { } + /// Constructor for building the block from a byte array public VoteItemBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - CandidateID = new LLUUID(bytes, i); i += 16; - length = (ushort)bytes[i++]; - _votecast = new byte[length]; - Array.Copy(bytes, i, _votecast, 0, length); i += length; - NumVotes = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + CandidateID = new LLUUID(bytes, i); i += 16; + length = (ushort)bytes[i++]; + _votecast = new byte[length]; + Array.Copy(bytes, i, _votecast, 0, length); i += length; + NumVotes = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(CandidateID == null) { Console.WriteLine("Warning: CandidateID is null, in " + this.GetType()); } - Array.Copy(CandidateID.GetBytes(), 0, bytes, i, 16); i += 16; - if(VoteCast == null) { Console.WriteLine("Warning: VoteCast is null, in " + this.GetType()); } - bytes[i++] = (byte)VoteCast.Length; - Array.Copy(VoteCast, 0, bytes, i, VoteCast.Length); i += VoteCast.Length; - bytes[i++] = (byte)(NumVotes % 256); - bytes[i++] = (byte)((NumVotes >> 8) % 256); - bytes[i++] = (byte)((NumVotes >> 16) % 256); - bytes[i++] = (byte)((NumVotes >> 24) % 256); + { + if(CandidateID == null) { Console.WriteLine("Warning: CandidateID is null, in " + this.GetType()); } + Array.Copy(CandidateID.GetBytes(), 0, bytes, i, 16); i += 16; + if(VoteCast == null) { Console.WriteLine("Warning: VoteCast is null, in " + this.GetType()); } + bytes[i++] = (byte)VoteCast.Length; + Array.Copy(VoteCast, 0, bytes, i, VoteCast.Length); i += VoteCast.Length; + bytes[i++] = (byte)(NumVotes % 256); + bytes[i++] = (byte)((NumVotes >> 8) % 256); + bytes[i++] = (byte)((NumVotes >> 16) % 256); + bytes[i++] = (byte)((NumVotes >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- VoteItem --\n"; - output += "CandidateID: " + CandidateID.ToString() + "\n"; - output += Helpers.FieldToString(VoteCast, "VoteCast") + "\n"; - output += "NumVotes: " + NumVotes.ToString() + "\n"; + { + string output = "-- VoteItem --\n"; + output += "CandidateID: " + CandidateID.ToString() + "\n"; + output += Helpers.FieldToString(VoteCast, "VoteCast") + "\n"; + output += "NumVotes: " + NumVotes.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// GroupID field - public LLUUID GroupID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// GroupID field + public LLUUID GroupID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - GroupID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + GroupID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// TransactionData block + + /// TransactionData block public class TransactionDataBlock - { - /// TotalNumItems field - public uint TotalNumItems; - /// TransactionID field - public LLUUID TransactionID; - - /// Length of this block serialized in bytes + { + /// TotalNumItems field + public uint TotalNumItems; + /// TransactionID field + public LLUUID TransactionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 20; + { + return 20; } } - - /// Default constructor - public TransactionDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public TransactionDataBlock() { } + /// Constructor for building the block from a byte array public TransactionDataBlock(byte[] bytes, ref int i) - { + { try - { - TotalNumItems = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - TransactionID = new LLUUID(bytes, i); i += 16; + { + TotalNumItems = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + TransactionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(TotalNumItems % 256); - bytes[i++] = (byte)((TotalNumItems >> 8) % 256); - bytes[i++] = (byte)((TotalNumItems >> 16) % 256); - bytes[i++] = (byte)((TotalNumItems >> 24) % 256); - if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } - Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + bytes[i++] = (byte)(TotalNumItems % 256); + bytes[i++] = (byte)((TotalNumItems >> 8) % 256); + bytes[i++] = (byte)((TotalNumItems >> 16) % 256); + bytes[i++] = (byte)((TotalNumItems >> 24) % 256); + if(TransactionID == null) { Console.WriteLine("Warning: TransactionID is null, in " + this.GetType()); } + Array.Copy(TransactionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- TransactionData --\n"; - output += "TotalNumItems: " + TotalNumItems.ToString() + "\n"; - output += "TransactionID: " + TransactionID.ToString() + "\n"; + { + string output = "-- TransactionData --\n"; + output += "TotalNumItems: " + TotalNumItems.ToString() + "\n"; + output += "TransactionID: " + TransactionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.GroupVoteHistoryItemReply - public override PacketType Type { get { return PacketType.GroupVoteHistoryItemReply; } } - /// HistoryItemData block - public HistoryItemDataBlock HistoryItemData; - /// VoteItem block - public VoteItemBlock[] VoteItem; - /// AgentData block - public AgentDataBlock AgentData; - /// TransactionData block - public TransactionDataBlock TransactionData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.GroupVoteHistoryItemReply + public override PacketType Type { get { return PacketType.GroupVoteHistoryItemReply; } } + /// HistoryItemData block + public HistoryItemDataBlock HistoryItemData; + /// VoteItem block + public VoteItemBlock[] VoteItem; + /// AgentData block + public AgentDataBlock AgentData; + /// TransactionData block + public TransactionDataBlock TransactionData; + + /// Default constructor public GroupVoteHistoryItemReplyPacket() - { - Header = new LowHeader(); - Header.ID = 435; - Header.Reliable = true; - Header.Zerocoded = true; - HistoryItemData = new HistoryItemDataBlock(); - VoteItem = new VoteItemBlock[0]; - AgentData = new AgentDataBlock(); - TransactionData = new TransactionDataBlock(); + { + Header = new LowHeader(); + Header.ID = 435; + Header.Reliable = true; + Header.Zerocoded = true; + HistoryItemData = new HistoryItemDataBlock(); + VoteItem = new VoteItemBlock[0]; + AgentData = new AgentDataBlock(); + TransactionData = new TransactionDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public GroupVoteHistoryItemReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - HistoryItemData = new HistoryItemDataBlock(bytes, ref i); - int count = (int)bytes[i++]; - VoteItem = new VoteItemBlock[count]; - for (int j = 0; j < count; j++) - { VoteItem[j] = new VoteItemBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); - TransactionData = new TransactionDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + HistoryItemData = new HistoryItemDataBlock(bytes, ref i); + int count = (int)bytes[i++]; + VoteItem = new VoteItemBlock[count]; + for (int j = 0; j < count; j++) + { VoteItem[j] = new VoteItemBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); + TransactionData = new TransactionDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public GroupVoteHistoryItemReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - HistoryItemData = new HistoryItemDataBlock(bytes, ref i); - int count = (int)bytes[i++]; - VoteItem = new VoteItemBlock[count]; - for (int j = 0; j < count; j++) - { VoteItem[j] = new VoteItemBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); - TransactionData = new TransactionDataBlock(bytes, ref i); + { + Header = head; + HistoryItemData = new HistoryItemDataBlock(bytes, ref i); + int count = (int)bytes[i++]; + VoteItem = new VoteItemBlock[count]; + for (int j = 0; j < count; j++) + { VoteItem[j] = new VoteItemBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); + TransactionData = new TransactionDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += HistoryItemData.Length; length += AgentData.Length; length += TransactionData.Length;; - length++; - for (int j = 0; j < VoteItem.Length; j++) { length += VoteItem[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - HistoryItemData.ToBytes(bytes, ref i); - bytes[i++] = (byte)VoteItem.Length; - for (int j = 0; j < VoteItem.Length; j++) { VoteItem[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - TransactionData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += HistoryItemData.Length; length += AgentData.Length; length += TransactionData.Length;; + length++; + for (int j = 0; j < VoteItem.Length; j++) { length += VoteItem[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + HistoryItemData.ToBytes(bytes, ref i); + bytes[i++] = (byte)VoteItem.Length; + for (int j = 0; j < VoteItem.Length; j++) { VoteItem[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + TransactionData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- GroupVoteHistoryItemReply ---\n"; - output += HistoryItemData.ToString() + "\n"; + { + string output = "--- GroupVoteHistoryItemReply ---\n"; + output += HistoryItemData.ToString() + "\n"; for (int j = 0; j < VoteItem.Length; j++) - { + { output += VoteItem[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; - output += TransactionData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; + output += TransactionData.ToString() + "\n"; return output; } - + } - - /// StartGroupProposal packet + + /// StartGroupProposal packet public class StartGroupProposalPacket : Packet - { - /// ProposalData block + { + /// ProposalData block public class ProposalDataBlock - { - /// Duration field - public int Duration; - private byte[] _proposaltext; - /// ProposalText field + { + /// Duration field + public int Duration; + private byte[] _proposaltext; + /// ProposalText field public byte[] ProposalText - { - get { return _proposaltext; } + { + get { return _proposaltext; } set - { - if (value == null) { _proposaltext = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _proposaltext = new byte[value.Length]; Array.Copy(value, _proposaltext, value.Length); } + { + if (value == null) { _proposaltext = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _proposaltext = new byte[value.Length]; Array.Copy(value, _proposaltext, value.Length); } } - } - /// Majority field - public float Majority; - /// GroupID field - public LLUUID GroupID; - /// Quorum field - public int Quorum; - - /// Length of this block serialized in bytes + } + /// Majority field + public float Majority; + /// GroupID field + public LLUUID GroupID; + /// Quorum field + public int Quorum; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 28; - if (ProposalText != null) { length += 1 + ProposalText.Length; } - return length; + { + int length = 28; + if (ProposalText != null) { length += 1 + ProposalText.Length; } + return length; } } - - /// Default constructor - public ProposalDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ProposalDataBlock() { } + /// Constructor for building the block from a byte array public ProposalDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - Duration = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _proposaltext = new byte[length]; - Array.Copy(bytes, i, _proposaltext, 0, length); i += length; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - Majority = BitConverter.ToSingle(bytes, i); i += 4; - GroupID = new LLUUID(bytes, i); i += 16; - Quorum = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + Duration = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _proposaltext = new byte[length]; + Array.Copy(bytes, i, _proposaltext, 0, length); i += length; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + Majority = BitConverter.ToSingle(bytes, i); i += 4; + GroupID = new LLUUID(bytes, i); i += 16; + Quorum = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; - bytes[i++] = (byte)(Duration % 256); - bytes[i++] = (byte)((Duration >> 8) % 256); - bytes[i++] = (byte)((Duration >> 16) % 256); - bytes[i++] = (byte)((Duration >> 24) % 256); - if(ProposalText == null) { Console.WriteLine("Warning: ProposalText is null, in " + this.GetType()); } - bytes[i++] = (byte)ProposalText.Length; - Array.Copy(ProposalText, 0, bytes, i, ProposalText.Length); i += ProposalText.Length; + { + byte[] ba; + bytes[i++] = (byte)(Duration % 256); + bytes[i++] = (byte)((Duration >> 8) % 256); + bytes[i++] = (byte)((Duration >> 16) % 256); + bytes[i++] = (byte)((Duration >> 24) % 256); + if(ProposalText == null) { Console.WriteLine("Warning: ProposalText is null, in " + this.GetType()); } + bytes[i++] = (byte)ProposalText.Length; + Array.Copy(ProposalText, 0, bytes, i, ProposalText.Length); i += ProposalText.Length; ba = BitConverter.GetBytes(Majority); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(Quorum % 256); - bytes[i++] = (byte)((Quorum >> 8) % 256); - bytes[i++] = (byte)((Quorum >> 16) % 256); - bytes[i++] = (byte)((Quorum >> 24) % 256); + Array.Copy(ba, 0, bytes, i, 4); i += 4; + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(Quorum % 256); + bytes[i++] = (byte)((Quorum >> 8) % 256); + bytes[i++] = (byte)((Quorum >> 16) % 256); + bytes[i++] = (byte)((Quorum >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ProposalData --\n"; - output += "Duration: " + Duration.ToString() + "\n"; - output += Helpers.FieldToString(ProposalText, "ProposalText") + "\n"; - output += "Majority: " + Majority.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; - output += "Quorum: " + Quorum.ToString() + "\n"; + { + string output = "-- ProposalData --\n"; + output += "Duration: " + Duration.ToString() + "\n"; + output += Helpers.FieldToString(ProposalText, "ProposalText") + "\n"; + output += "Majority: " + Majority.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; + output += "Quorum: " + Quorum.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.StartGroupProposal - public override PacketType Type { get { return PacketType.StartGroupProposal; } } - /// ProposalData block - public ProposalDataBlock ProposalData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.StartGroupProposal + public override PacketType Type { get { return PacketType.StartGroupProposal; } } + /// ProposalData block + public ProposalDataBlock ProposalData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public StartGroupProposalPacket() - { - Header = new LowHeader(); - Header.ID = 436; - Header.Reliable = true; - Header.Zerocoded = true; - ProposalData = new ProposalDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 436; + Header.Reliable = true; + Header.Zerocoded = true; + ProposalData = new ProposalDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public StartGroupProposalPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - ProposalData = new ProposalDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + ProposalData = new ProposalDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public StartGroupProposalPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - ProposalData = new ProposalDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + ProposalData = new ProposalDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += ProposalData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - ProposalData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += ProposalData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + ProposalData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- StartGroupProposal ---\n"; - output += ProposalData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- StartGroupProposal ---\n"; + output += ProposalData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// GroupProposalBallot packet + + /// GroupProposalBallot packet public class GroupProposalBallotPacket : Packet - { - /// ProposalData block + { + /// ProposalData block public class ProposalDataBlock - { - /// ProposalID field - public LLUUID ProposalID; - /// GroupID field - public LLUUID GroupID; - private byte[] _votecast; - /// VoteCast field + { + /// ProposalID field + public LLUUID ProposalID; + /// GroupID field + public LLUUID GroupID; + private byte[] _votecast; + /// VoteCast field public byte[] VoteCast - { - get { return _votecast; } + { + get { return _votecast; } set - { - if (value == null) { _votecast = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _votecast = new byte[value.Length]; Array.Copy(value, _votecast, value.Length); } + { + if (value == null) { _votecast = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _votecast = new byte[value.Length]; Array.Copy(value, _votecast, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 32; - if (VoteCast != null) { length += 1 + VoteCast.Length; } - return length; + { + int length = 32; + if (VoteCast != null) { length += 1 + VoteCast.Length; } + return length; } } - - /// Default constructor - public ProposalDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ProposalDataBlock() { } + /// Constructor for building the block from a byte array public ProposalDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - ProposalID = new LLUUID(bytes, i); i += 16; - GroupID = new LLUUID(bytes, i); i += 16; - length = (ushort)bytes[i++]; - _votecast = new byte[length]; - Array.Copy(bytes, i, _votecast, 0, length); i += length; + { + ProposalID = new LLUUID(bytes, i); i += 16; + GroupID = new LLUUID(bytes, i); i += 16; + length = (ushort)bytes[i++]; + _votecast = new byte[length]; + Array.Copy(bytes, i, _votecast, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ProposalID == null) { Console.WriteLine("Warning: ProposalID is null, in " + this.GetType()); } - Array.Copy(ProposalID.GetBytes(), 0, bytes, i, 16); i += 16; - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; - if(VoteCast == null) { Console.WriteLine("Warning: VoteCast is null, in " + this.GetType()); } - bytes[i++] = (byte)VoteCast.Length; - Array.Copy(VoteCast, 0, bytes, i, VoteCast.Length); i += VoteCast.Length; + { + if(ProposalID == null) { Console.WriteLine("Warning: ProposalID is null, in " + this.GetType()); } + Array.Copy(ProposalID.GetBytes(), 0, bytes, i, 16); i += 16; + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + if(VoteCast == null) { Console.WriteLine("Warning: VoteCast is null, in " + this.GetType()); } + bytes[i++] = (byte)VoteCast.Length; + Array.Copy(VoteCast, 0, bytes, i, VoteCast.Length); i += VoteCast.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ProposalData --\n"; - output += "ProposalID: " + ProposalID.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; - output += Helpers.FieldToString(VoteCast, "VoteCast") + "\n"; + { + string output = "-- ProposalData --\n"; + output += "ProposalID: " + ProposalID.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; + output += Helpers.FieldToString(VoteCast, "VoteCast") + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.GroupProposalBallot - public override PacketType Type { get { return PacketType.GroupProposalBallot; } } - /// ProposalData block - public ProposalDataBlock ProposalData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.GroupProposalBallot + public override PacketType Type { get { return PacketType.GroupProposalBallot; } } + /// ProposalData block + public ProposalDataBlock ProposalData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public GroupProposalBallotPacket() - { - Header = new LowHeader(); - Header.ID = 437; - Header.Reliable = true; - ProposalData = new ProposalDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 437; + Header.Reliable = true; + ProposalData = new ProposalDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public GroupProposalBallotPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - ProposalData = new ProposalDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + ProposalData = new ProposalDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public GroupProposalBallotPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - ProposalData = new ProposalDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + ProposalData = new ProposalDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += ProposalData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - ProposalData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += ProposalData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + ProposalData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- GroupProposalBallot ---\n"; - output += ProposalData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- GroupProposalBallot ---\n"; + output += ProposalData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// TallyVotes packet + + /// TallyVotes packet public class TallyVotesPacket : Packet - { - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.TallyVotes - public override PacketType Type { get { return PacketType.TallyVotes; } } - - /// Default constructor + { + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.TallyVotes + public override PacketType Type { get { return PacketType.TallyVotes; } } + + /// Default constructor public TallyVotesPacket() - { - Header = new LowHeader(); - Header.ID = 438; - Header.Reliable = true; + { + Header = new LowHeader(); + Header.ID = 438; + Header.Reliable = true; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public TallyVotesPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public TallyVotesPacket(Header head, byte[] bytes, ref int i) - { - Header = head; + { + Header = head; } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; -; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; +; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- TallyVotes ---\n"; + { + string output = "--- TallyVotes ---\n"; return output; } - + } - - /// GroupMembersRequest packet + + /// GroupMembersRequest packet public class GroupMembersRequestPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// GroupData block + + /// GroupData block public class GroupDataBlock - { - /// RequestID field - public LLUUID RequestID; - /// GroupID field - public LLUUID GroupID; - - /// Length of this block serialized in bytes + { + /// RequestID field + public LLUUID RequestID; + /// GroupID field + public LLUUID GroupID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public GroupDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public GroupDataBlock() { } + /// Constructor for building the block from a byte array public GroupDataBlock(byte[] bytes, ref int i) - { + { try - { - RequestID = new LLUUID(bytes, i); i += 16; - GroupID = new LLUUID(bytes, i); i += 16; + { + RequestID = new LLUUID(bytes, i); i += 16; + GroupID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(RequestID == null) { Console.WriteLine("Warning: RequestID is null, in " + this.GetType()); } - Array.Copy(RequestID.GetBytes(), 0, bytes, i, 16); i += 16; - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(RequestID == null) { Console.WriteLine("Warning: RequestID is null, in " + this.GetType()); } + Array.Copy(RequestID.GetBytes(), 0, bytes, i, 16); i += 16; + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- GroupData --\n"; - output += "RequestID: " + RequestID.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; + { + string output = "-- GroupData --\n"; + output += "RequestID: " + RequestID.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.GroupMembersRequest - public override PacketType Type { get { return PacketType.GroupMembersRequest; } } - /// AgentData block - public AgentDataBlock AgentData; - /// GroupData block - public GroupDataBlock GroupData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.GroupMembersRequest + public override PacketType Type { get { return PacketType.GroupMembersRequest; } } + /// AgentData block + public AgentDataBlock AgentData; + /// GroupData block + public GroupDataBlock GroupData; + + /// Default constructor public GroupMembersRequestPacket() - { - Header = new LowHeader(); - Header.ID = 439; - Header.Reliable = true; - AgentData = new AgentDataBlock(); - GroupData = new GroupDataBlock(); + { + Header = new LowHeader(); + Header.ID = 439; + Header.Reliable = true; + AgentData = new AgentDataBlock(); + GroupData = new GroupDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public GroupMembersRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); - GroupData = new GroupDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); + GroupData = new GroupDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public GroupMembersRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); - GroupData = new GroupDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); + GroupData = new GroupDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length; length += GroupData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - GroupData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length; length += GroupData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + GroupData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- GroupMembersRequest ---\n"; - output += AgentData.ToString() + "\n"; - output += GroupData.ToString() + "\n"; + { + string output = "--- GroupMembersRequest ---\n"; + output += AgentData.ToString() + "\n"; + output += GroupData.ToString() + "\n"; return output; } - + } - - /// GroupMembersReply packet + + /// GroupMembersReply packet public class GroupMembersReplyPacket : Packet - { - /// MemberData block + { + /// MemberData block public class MemberDataBlock - { - private byte[] _onlinestatus; - /// OnlineStatus field + { + private byte[] _onlinestatus; + /// OnlineStatus field public byte[] OnlineStatus - { - get { return _onlinestatus; } + { + get { return _onlinestatus; } set - { - if (value == null) { _onlinestatus = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _onlinestatus = new byte[value.Length]; Array.Copy(value, _onlinestatus, value.Length); } + { + if (value == null) { _onlinestatus = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _onlinestatus = new byte[value.Length]; Array.Copy(value, _onlinestatus, value.Length); } } - } - /// AgentID field - public LLUUID AgentID; - /// Contribution field - public int Contribution; - /// IsOwner field - public bool IsOwner; - private byte[] _title; - /// Title field + } + /// AgentID field + public LLUUID AgentID; + /// Contribution field + public int Contribution; + /// IsOwner field + public bool IsOwner; + private byte[] _title; + /// Title field public byte[] Title - { - get { return _title; } + { + get { return _title; } set - { - if (value == null) { _title = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _title = new byte[value.Length]; Array.Copy(value, _title, value.Length); } + { + if (value == null) { _title = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _title = new byte[value.Length]; Array.Copy(value, _title, value.Length); } } - } - /// AgentPowers field - public ulong AgentPowers; - - /// Length of this block serialized in bytes + } + /// AgentPowers field + public ulong AgentPowers; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 29; - if (OnlineStatus != null) { length += 1 + OnlineStatus.Length; } - if (Title != null) { length += 1 + Title.Length; } - return length; + { + int length = 29; + if (OnlineStatus != null) { length += 1 + OnlineStatus.Length; } + if (Title != null) { length += 1 + Title.Length; } + return length; } } - - /// Default constructor - public MemberDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public MemberDataBlock() { } + /// Constructor for building the block from a byte array public MemberDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _onlinestatus = new byte[length]; - Array.Copy(bytes, i, _onlinestatus, 0, length); i += length; - AgentID = new LLUUID(bytes, i); i += 16; - Contribution = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - IsOwner = (bytes[i++] != 0) ? (bool)true : (bool)false; - length = (ushort)bytes[i++]; - _title = new byte[length]; - Array.Copy(bytes, i, _title, 0, length); i += length; - AgentPowers = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + { + length = (ushort)bytes[i++]; + _onlinestatus = new byte[length]; + Array.Copy(bytes, i, _onlinestatus, 0, length); i += length; + AgentID = new LLUUID(bytes, i); i += 16; + Contribution = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + IsOwner = (bytes[i++] != 0) ? (bool)true : (bool)false; + length = (ushort)bytes[i++]; + _title = new byte[length]; + Array.Copy(bytes, i, _title, 0, length); i += length; + AgentPowers = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(OnlineStatus == null) { Console.WriteLine("Warning: OnlineStatus is null, in " + this.GetType()); } - bytes[i++] = (byte)OnlineStatus.Length; - Array.Copy(OnlineStatus, 0, bytes, i, OnlineStatus.Length); i += OnlineStatus.Length; - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(Contribution % 256); - bytes[i++] = (byte)((Contribution >> 8) % 256); - bytes[i++] = (byte)((Contribution >> 16) % 256); - bytes[i++] = (byte)((Contribution >> 24) % 256); - bytes[i++] = (byte)((IsOwner) ? 1 : 0); - if(Title == null) { Console.WriteLine("Warning: Title is null, in " + this.GetType()); } - bytes[i++] = (byte)Title.Length; - Array.Copy(Title, 0, bytes, i, Title.Length); i += Title.Length; - bytes[i++] = (byte)(AgentPowers % 256); - bytes[i++] = (byte)((AgentPowers >> 8) % 256); - bytes[i++] = (byte)((AgentPowers >> 16) % 256); - bytes[i++] = (byte)((AgentPowers >> 24) % 256); - bytes[i++] = (byte)((AgentPowers >> 32) % 256); - bytes[i++] = (byte)((AgentPowers >> 40) % 256); - bytes[i++] = (byte)((AgentPowers >> 48) % 256); - bytes[i++] = (byte)((AgentPowers >> 56) % 256); + { + if(OnlineStatus == null) { Console.WriteLine("Warning: OnlineStatus is null, in " + this.GetType()); } + bytes[i++] = (byte)OnlineStatus.Length; + Array.Copy(OnlineStatus, 0, bytes, i, OnlineStatus.Length); i += OnlineStatus.Length; + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(Contribution % 256); + bytes[i++] = (byte)((Contribution >> 8) % 256); + bytes[i++] = (byte)((Contribution >> 16) % 256); + bytes[i++] = (byte)((Contribution >> 24) % 256); + bytes[i++] = (byte)((IsOwner) ? 1 : 0); + if(Title == null) { Console.WriteLine("Warning: Title is null, in " + this.GetType()); } + bytes[i++] = (byte)Title.Length; + Array.Copy(Title, 0, bytes, i, Title.Length); i += Title.Length; + bytes[i++] = (byte)(AgentPowers % 256); + bytes[i++] = (byte)((AgentPowers >> 8) % 256); + bytes[i++] = (byte)((AgentPowers >> 16) % 256); + bytes[i++] = (byte)((AgentPowers >> 24) % 256); + bytes[i++] = (byte)((AgentPowers >> 32) % 256); + bytes[i++] = (byte)((AgentPowers >> 40) % 256); + bytes[i++] = (byte)((AgentPowers >> 48) % 256); + bytes[i++] = (byte)((AgentPowers >> 56) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- MemberData --\n"; - output += Helpers.FieldToString(OnlineStatus, "OnlineStatus") + "\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "Contribution: " + Contribution.ToString() + "\n"; - output += "IsOwner: " + IsOwner.ToString() + "\n"; - output += Helpers.FieldToString(Title, "Title") + "\n"; - output += "AgentPowers: " + AgentPowers.ToString() + "\n"; + { + string output = "-- MemberData --\n"; + output += Helpers.FieldToString(OnlineStatus, "OnlineStatus") + "\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "Contribution: " + Contribution.ToString() + "\n"; + output += "IsOwner: " + IsOwner.ToString() + "\n"; + output += Helpers.FieldToString(Title, "Title") + "\n"; + output += "AgentPowers: " + AgentPowers.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// GroupData block + + /// GroupData block public class GroupDataBlock - { - /// RequestID field - public LLUUID RequestID; - /// MemberCount field - public int MemberCount; - /// GroupID field - public LLUUID GroupID; - - /// Length of this block serialized in bytes + { + /// RequestID field + public LLUUID RequestID; + /// MemberCount field + public int MemberCount; + /// GroupID field + public LLUUID GroupID; + + /// Length of this block serialized in bytes public int Length { get - { - return 36; + { + return 36; } } - - /// Default constructor - public GroupDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public GroupDataBlock() { } + /// Constructor for building the block from a byte array public GroupDataBlock(byte[] bytes, ref int i) - { + { try - { - RequestID = new LLUUID(bytes, i); i += 16; - MemberCount = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - GroupID = new LLUUID(bytes, i); i += 16; + { + RequestID = new LLUUID(bytes, i); i += 16; + MemberCount = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + GroupID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(RequestID == null) { Console.WriteLine("Warning: RequestID is null, in " + this.GetType()); } - Array.Copy(RequestID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(MemberCount % 256); - bytes[i++] = (byte)((MemberCount >> 8) % 256); - bytes[i++] = (byte)((MemberCount >> 16) % 256); - bytes[i++] = (byte)((MemberCount >> 24) % 256); - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(RequestID == null) { Console.WriteLine("Warning: RequestID is null, in " + this.GetType()); } + Array.Copy(RequestID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(MemberCount % 256); + bytes[i++] = (byte)((MemberCount >> 8) % 256); + bytes[i++] = (byte)((MemberCount >> 16) % 256); + bytes[i++] = (byte)((MemberCount >> 24) % 256); + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- GroupData --\n"; - output += "RequestID: " + RequestID.ToString() + "\n"; - output += "MemberCount: " + MemberCount.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; + { + string output = "-- GroupData --\n"; + output += "RequestID: " + RequestID.ToString() + "\n"; + output += "MemberCount: " + MemberCount.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.GroupMembersReply - public override PacketType Type { get { return PacketType.GroupMembersReply; } } - /// MemberData block - public MemberDataBlock[] MemberData; - /// AgentData block - public AgentDataBlock AgentData; - /// GroupData block - public GroupDataBlock GroupData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.GroupMembersReply + public override PacketType Type { get { return PacketType.GroupMembersReply; } } + /// MemberData block + public MemberDataBlock[] MemberData; + /// AgentData block + public AgentDataBlock AgentData; + /// GroupData block + public GroupDataBlock GroupData; + + /// Default constructor public GroupMembersReplyPacket() - { - Header = new LowHeader(); - Header.ID = 440; - Header.Reliable = true; - Header.Zerocoded = true; - MemberData = new MemberDataBlock[0]; - AgentData = new AgentDataBlock(); - GroupData = new GroupDataBlock(); + { + Header = new LowHeader(); + Header.ID = 440; + Header.Reliable = true; + Header.Zerocoded = true; + MemberData = new MemberDataBlock[0]; + AgentData = new AgentDataBlock(); + GroupData = new GroupDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public GroupMembersReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - MemberData = new MemberDataBlock[count]; - for (int j = 0; j < count; j++) - { MemberData[j] = new MemberDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); - GroupData = new GroupDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + MemberData = new MemberDataBlock[count]; + for (int j = 0; j < count; j++) + { MemberData[j] = new MemberDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); + GroupData = new GroupDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public GroupMembersReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - MemberData = new MemberDataBlock[count]; - for (int j = 0; j < count; j++) - { MemberData[j] = new MemberDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); - GroupData = new GroupDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + MemberData = new MemberDataBlock[count]; + for (int j = 0; j < count; j++) + { MemberData[j] = new MemberDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); + GroupData = new GroupDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length; length += GroupData.Length;; - length++; - for (int j = 0; j < MemberData.Length; j++) { length += MemberData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)MemberData.Length; - for (int j = 0; j < MemberData.Length; j++) { MemberData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - GroupData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length; length += GroupData.Length;; + length++; + for (int j = 0; j < MemberData.Length; j++) { length += MemberData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)MemberData.Length; + for (int j = 0; j < MemberData.Length; j++) { MemberData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + GroupData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- GroupMembersReply ---\n"; + { + string output = "--- GroupMembersReply ---\n"; for (int j = 0; j < MemberData.Length; j++) - { + { output += MemberData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; - output += GroupData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; + output += GroupData.ToString() + "\n"; return output; } - + } - - /// ActivateGroup packet + + /// ActivateGroup packet public class ActivateGroupPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - /// GroupID field - public LLUUID GroupID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + /// GroupID field + public LLUUID GroupID; + + /// Length of this block serialized in bytes public int Length { get - { - return 48; + { + return 48; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; - GroupID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; + GroupID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ActivateGroup - public override PacketType Type { get { return PacketType.ActivateGroup; } } - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ActivateGroup + public override PacketType Type { get { return PacketType.ActivateGroup; } } + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ActivateGroupPacket() - { - Header = new LowHeader(); - Header.ID = 441; - Header.Reliable = true; - Header.Zerocoded = true; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 441; + Header.Reliable = true; + Header.Zerocoded = true; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ActivateGroupPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ActivateGroupPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ActivateGroup ---\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- ActivateGroup ---\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// SetGroupContribution packet + + /// SetGroupContribution packet public class SetGroupContributionPacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - /// Contribution field - public int Contribution; - /// GroupID field - public LLUUID GroupID; - - /// Length of this block serialized in bytes + { + /// Contribution field + public int Contribution; + /// GroupID field + public LLUUID GroupID; + + /// Length of this block serialized in bytes public int Length { get - { - return 20; + { + return 20; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { + { try - { - Contribution = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - GroupID = new LLUUID(bytes, i); i += 16; + { + Contribution = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + GroupID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(Contribution % 256); - bytes[i++] = (byte)((Contribution >> 8) % 256); - bytes[i++] = (byte)((Contribution >> 16) % 256); - bytes[i++] = (byte)((Contribution >> 24) % 256); - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + { + bytes[i++] = (byte)(Contribution % 256); + bytes[i++] = (byte)((Contribution >> 8) % 256); + bytes[i++] = (byte)((Contribution >> 16) % 256); + bytes[i++] = (byte)((Contribution >> 24) % 256); + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "Contribution: " + Contribution.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += "Contribution: " + Contribution.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.SetGroupContribution - public override PacketType Type { get { return PacketType.SetGroupContribution; } } - /// Data block - public DataBlock Data; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.SetGroupContribution + public override PacketType Type { get { return PacketType.SetGroupContribution; } } + /// Data block + public DataBlock Data; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public SetGroupContributionPacket() - { - Header = new LowHeader(); - Header.ID = 442; - Header.Reliable = true; - Data = new DataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 442; + Header.Reliable = true; + Data = new DataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public SetGroupContributionPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public SetGroupContributionPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Data.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Data.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Data.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Data.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- SetGroupContribution ---\n"; - output += Data.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- SetGroupContribution ---\n"; + output += Data.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// SetGroupAcceptNotices packet + + /// SetGroupAcceptNotices packet public class SetGroupAcceptNoticesPacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - /// GroupID field - public LLUUID GroupID; - /// AcceptNotices field - public bool AcceptNotices; - - /// Length of this block serialized in bytes + { + /// GroupID field + public LLUUID GroupID; + /// AcceptNotices field + public bool AcceptNotices; + + /// Length of this block serialized in bytes public int Length { get - { - return 17; + { + return 17; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { + { try - { - GroupID = new LLUUID(bytes, i); i += 16; - AcceptNotices = (bytes[i++] != 0) ? (bool)true : (bool)false; + { + GroupID = new LLUUID(bytes, i); i += 16; + AcceptNotices = (bytes[i++] != 0) ? (bool)true : (bool)false; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((AcceptNotices) ? 1 : 0); + { + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((AcceptNotices) ? 1 : 0); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; - output += "AcceptNotices: " + AcceptNotices.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; + output += "AcceptNotices: " + AcceptNotices.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.SetGroupAcceptNotices - public override PacketType Type { get { return PacketType.SetGroupAcceptNotices; } } - /// Data block - public DataBlock Data; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.SetGroupAcceptNotices + public override PacketType Type { get { return PacketType.SetGroupAcceptNotices; } } + /// Data block + public DataBlock Data; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public SetGroupAcceptNoticesPacket() - { - Header = new LowHeader(); - Header.ID = 443; - Header.Reliable = true; - Data = new DataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 443; + Header.Reliable = true; + Data = new DataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public SetGroupAcceptNoticesPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public SetGroupAcceptNoticesPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += Data.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Data.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += Data.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Data.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- SetGroupAcceptNotices ---\n"; - output += Data.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- SetGroupAcceptNotices ---\n"; + output += Data.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// GroupRoleDataRequest packet + + /// GroupRoleDataRequest packet public class GroupRoleDataRequestPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// GroupData block + + /// GroupData block public class GroupDataBlock - { - /// RequestID field - public LLUUID RequestID; - /// GroupID field - public LLUUID GroupID; - - /// Length of this block serialized in bytes + { + /// RequestID field + public LLUUID RequestID; + /// GroupID field + public LLUUID GroupID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public GroupDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public GroupDataBlock() { } + /// Constructor for building the block from a byte array public GroupDataBlock(byte[] bytes, ref int i) - { + { try - { - RequestID = new LLUUID(bytes, i); i += 16; - GroupID = new LLUUID(bytes, i); i += 16; + { + RequestID = new LLUUID(bytes, i); i += 16; + GroupID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(RequestID == null) { Console.WriteLine("Warning: RequestID is null, in " + this.GetType()); } - Array.Copy(RequestID.GetBytes(), 0, bytes, i, 16); i += 16; - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(RequestID == null) { Console.WriteLine("Warning: RequestID is null, in " + this.GetType()); } + Array.Copy(RequestID.GetBytes(), 0, bytes, i, 16); i += 16; + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- GroupData --\n"; - output += "RequestID: " + RequestID.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; + { + string output = "-- GroupData --\n"; + output += "RequestID: " + RequestID.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.GroupRoleDataRequest - public override PacketType Type { get { return PacketType.GroupRoleDataRequest; } } - /// AgentData block - public AgentDataBlock AgentData; - /// GroupData block - public GroupDataBlock GroupData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.GroupRoleDataRequest + public override PacketType Type { get { return PacketType.GroupRoleDataRequest; } } + /// AgentData block + public AgentDataBlock AgentData; + /// GroupData block + public GroupDataBlock GroupData; + + /// Default constructor public GroupRoleDataRequestPacket() - { - Header = new LowHeader(); - Header.ID = 444; - Header.Reliable = true; - AgentData = new AgentDataBlock(); - GroupData = new GroupDataBlock(); + { + Header = new LowHeader(); + Header.ID = 444; + Header.Reliable = true; + AgentData = new AgentDataBlock(); + GroupData = new GroupDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public GroupRoleDataRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); - GroupData = new GroupDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); + GroupData = new GroupDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public GroupRoleDataRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); - GroupData = new GroupDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); + GroupData = new GroupDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length; length += GroupData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - GroupData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length; length += GroupData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + GroupData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- GroupRoleDataRequest ---\n"; - output += AgentData.ToString() + "\n"; - output += GroupData.ToString() + "\n"; + { + string output = "--- GroupRoleDataRequest ---\n"; + output += AgentData.ToString() + "\n"; + output += GroupData.ToString() + "\n"; return output; } - + } - - /// GroupRoleDataReply packet + + /// GroupRoleDataReply packet public class GroupRoleDataReplyPacket : Packet - { - /// RoleData block + { + /// RoleData block public class RoleDataBlock - { - /// Members field - public uint Members; - private byte[] _name; - /// Name field + { + /// Members field + public uint Members; + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - /// RoleID field - public LLUUID RoleID; - /// Powers field - public ulong Powers; - private byte[] _description; - /// Description field + } + /// RoleID field + public LLUUID RoleID; + /// Powers field + public ulong Powers; + private byte[] _description; + /// Description field public byte[] Description - { - get { return _description; } + { + get { return _description; } set - { - if (value == null) { _description = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } + { + if (value == null) { _description = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } } - } - private byte[] _title; - /// Title field + } + private byte[] _title; + /// Title field public byte[] Title - { - get { return _title; } + { + get { return _title; } set - { - if (value == null) { _title = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _title = new byte[value.Length]; Array.Copy(value, _title, value.Length); } + { + if (value == null) { _title = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _title = new byte[value.Length]; Array.Copy(value, _title, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 28; - if (Name != null) { length += 1 + Name.Length; } - if (Description != null) { length += 1 + Description.Length; } - if (Title != null) { length += 1 + Title.Length; } - return length; + { + int length = 28; + if (Name != null) { length += 1 + Name.Length; } + if (Description != null) { length += 1 + Description.Length; } + if (Title != null) { length += 1 + Title.Length; } + return length; } } - - /// Default constructor - public RoleDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public RoleDataBlock() { } + /// Constructor for building the block from a byte array public RoleDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - Members = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; - RoleID = new LLUUID(bytes, i); i += 16; - Powers = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); - length = (ushort)bytes[i++]; - _description = new byte[length]; - Array.Copy(bytes, i, _description, 0, length); i += length; - length = (ushort)bytes[i++]; - _title = new byte[length]; - Array.Copy(bytes, i, _title, 0, length); i += length; + { + Members = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; + RoleID = new LLUUID(bytes, i); i += 16; + Powers = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + length = (ushort)bytes[i++]; + _description = new byte[length]; + Array.Copy(bytes, i, _description, 0, length); i += length; + length = (ushort)bytes[i++]; + _title = new byte[length]; + Array.Copy(bytes, i, _title, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(Members % 256); - bytes[i++] = (byte)((Members >> 8) % 256); - bytes[i++] = (byte)((Members >> 16) % 256); - bytes[i++] = (byte)((Members >> 24) % 256); - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; - if(RoleID == null) { Console.WriteLine("Warning: RoleID is null, in " + this.GetType()); } - Array.Copy(RoleID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(Powers % 256); - bytes[i++] = (byte)((Powers >> 8) % 256); - bytes[i++] = (byte)((Powers >> 16) % 256); - bytes[i++] = (byte)((Powers >> 24) % 256); - bytes[i++] = (byte)((Powers >> 32) % 256); - bytes[i++] = (byte)((Powers >> 40) % 256); - bytes[i++] = (byte)((Powers >> 48) % 256); - bytes[i++] = (byte)((Powers >> 56) % 256); - if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } - bytes[i++] = (byte)Description.Length; - Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; - if(Title == null) { Console.WriteLine("Warning: Title is null, in " + this.GetType()); } - bytes[i++] = (byte)Title.Length; - Array.Copy(Title, 0, bytes, i, Title.Length); i += Title.Length; + { + bytes[i++] = (byte)(Members % 256); + bytes[i++] = (byte)((Members >> 8) % 256); + bytes[i++] = (byte)((Members >> 16) % 256); + bytes[i++] = (byte)((Members >> 24) % 256); + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + if(RoleID == null) { Console.WriteLine("Warning: RoleID is null, in " + this.GetType()); } + Array.Copy(RoleID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(Powers % 256); + bytes[i++] = (byte)((Powers >> 8) % 256); + bytes[i++] = (byte)((Powers >> 16) % 256); + bytes[i++] = (byte)((Powers >> 24) % 256); + bytes[i++] = (byte)((Powers >> 32) % 256); + bytes[i++] = (byte)((Powers >> 40) % 256); + bytes[i++] = (byte)((Powers >> 48) % 256); + bytes[i++] = (byte)((Powers >> 56) % 256); + if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } + bytes[i++] = (byte)Description.Length; + Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; + if(Title == null) { Console.WriteLine("Warning: Title is null, in " + this.GetType()); } + bytes[i++] = (byte)Title.Length; + Array.Copy(Title, 0, bytes, i, Title.Length); i += Title.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- RoleData --\n"; - output += "Members: " + Members.ToString() + "\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; - output += "RoleID: " + RoleID.ToString() + "\n"; - output += "Powers: " + Powers.ToString() + "\n"; - output += Helpers.FieldToString(Description, "Description") + "\n"; - output += Helpers.FieldToString(Title, "Title") + "\n"; + { + string output = "-- RoleData --\n"; + output += "Members: " + Members.ToString() + "\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; + output += "RoleID: " + RoleID.ToString() + "\n"; + output += "Powers: " + Powers.ToString() + "\n"; + output += Helpers.FieldToString(Description, "Description") + "\n"; + output += Helpers.FieldToString(Title, "Title") + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// GroupData block + + /// GroupData block public class GroupDataBlock - { - /// RoleCount field - public int RoleCount; - /// RequestID field - public LLUUID RequestID; - /// GroupID field - public LLUUID GroupID; - - /// Length of this block serialized in bytes + { + /// RoleCount field + public int RoleCount; + /// RequestID field + public LLUUID RequestID; + /// GroupID field + public LLUUID GroupID; + + /// Length of this block serialized in bytes public int Length { get - { - return 36; + { + return 36; } } - - /// Default constructor - public GroupDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public GroupDataBlock() { } + /// Constructor for building the block from a byte array public GroupDataBlock(byte[] bytes, ref int i) - { + { try - { - RoleCount = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - RequestID = new LLUUID(bytes, i); i += 16; - GroupID = new LLUUID(bytes, i); i += 16; + { + RoleCount = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + RequestID = new LLUUID(bytes, i); i += 16; + GroupID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(RoleCount % 256); - bytes[i++] = (byte)((RoleCount >> 8) % 256); - bytes[i++] = (byte)((RoleCount >> 16) % 256); - bytes[i++] = (byte)((RoleCount >> 24) % 256); - if(RequestID == null) { Console.WriteLine("Warning: RequestID is null, in " + this.GetType()); } - Array.Copy(RequestID.GetBytes(), 0, bytes, i, 16); i += 16; - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + { + bytes[i++] = (byte)(RoleCount % 256); + bytes[i++] = (byte)((RoleCount >> 8) % 256); + bytes[i++] = (byte)((RoleCount >> 16) % 256); + bytes[i++] = (byte)((RoleCount >> 24) % 256); + if(RequestID == null) { Console.WriteLine("Warning: RequestID is null, in " + this.GetType()); } + Array.Copy(RequestID.GetBytes(), 0, bytes, i, 16); i += 16; + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- GroupData --\n"; - output += "RoleCount: " + RoleCount.ToString() + "\n"; - output += "RequestID: " + RequestID.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; + { + string output = "-- GroupData --\n"; + output += "RoleCount: " + RoleCount.ToString() + "\n"; + output += "RequestID: " + RequestID.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.GroupRoleDataReply - public override PacketType Type { get { return PacketType.GroupRoleDataReply; } } - /// RoleData block - public RoleDataBlock[] RoleData; - /// AgentData block - public AgentDataBlock AgentData; - /// GroupData block - public GroupDataBlock GroupData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.GroupRoleDataReply + public override PacketType Type { get { return PacketType.GroupRoleDataReply; } } + /// RoleData block + public RoleDataBlock[] RoleData; + /// AgentData block + public AgentDataBlock AgentData; + /// GroupData block + public GroupDataBlock GroupData; + + /// Default constructor public GroupRoleDataReplyPacket() - { - Header = new LowHeader(); - Header.ID = 445; - Header.Reliable = true; - RoleData = new RoleDataBlock[0]; - AgentData = new AgentDataBlock(); - GroupData = new GroupDataBlock(); + { + Header = new LowHeader(); + Header.ID = 445; + Header.Reliable = true; + RoleData = new RoleDataBlock[0]; + AgentData = new AgentDataBlock(); + GroupData = new GroupDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public GroupRoleDataReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - RoleData = new RoleDataBlock[count]; - for (int j = 0; j < count; j++) - { RoleData[j] = new RoleDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); - GroupData = new GroupDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + RoleData = new RoleDataBlock[count]; + for (int j = 0; j < count; j++) + { RoleData[j] = new RoleDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); + GroupData = new GroupDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public GroupRoleDataReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - RoleData = new RoleDataBlock[count]; - for (int j = 0; j < count; j++) - { RoleData[j] = new RoleDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); - GroupData = new GroupDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + RoleData = new RoleDataBlock[count]; + for (int j = 0; j < count; j++) + { RoleData[j] = new RoleDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); + GroupData = new GroupDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length; length += GroupData.Length;; - length++; - for (int j = 0; j < RoleData.Length; j++) { length += RoleData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)RoleData.Length; - for (int j = 0; j < RoleData.Length; j++) { RoleData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - GroupData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length; length += GroupData.Length;; + length++; + for (int j = 0; j < RoleData.Length; j++) { length += RoleData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)RoleData.Length; + for (int j = 0; j < RoleData.Length; j++) { RoleData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + GroupData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- GroupRoleDataReply ---\n"; + { + string output = "--- GroupRoleDataReply ---\n"; for (int j = 0; j < RoleData.Length; j++) - { + { output += RoleData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; - output += GroupData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; + output += GroupData.ToString() + "\n"; return output; } - + } - - /// GroupRoleMembersRequest packet + + /// GroupRoleMembersRequest packet public class GroupRoleMembersRequestPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// GroupData block + + /// GroupData block public class GroupDataBlock - { - /// RequestID field - public LLUUID RequestID; - /// GroupID field - public LLUUID GroupID; - - /// Length of this block serialized in bytes + { + /// RequestID field + public LLUUID RequestID; + /// GroupID field + public LLUUID GroupID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public GroupDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public GroupDataBlock() { } + /// Constructor for building the block from a byte array public GroupDataBlock(byte[] bytes, ref int i) - { + { try - { - RequestID = new LLUUID(bytes, i); i += 16; - GroupID = new LLUUID(bytes, i); i += 16; + { + RequestID = new LLUUID(bytes, i); i += 16; + GroupID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(RequestID == null) { Console.WriteLine("Warning: RequestID is null, in " + this.GetType()); } - Array.Copy(RequestID.GetBytes(), 0, bytes, i, 16); i += 16; - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(RequestID == null) { Console.WriteLine("Warning: RequestID is null, in " + this.GetType()); } + Array.Copy(RequestID.GetBytes(), 0, bytes, i, 16); i += 16; + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- GroupData --\n"; - output += "RequestID: " + RequestID.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; + { + string output = "-- GroupData --\n"; + output += "RequestID: " + RequestID.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.GroupRoleMembersRequest - public override PacketType Type { get { return PacketType.GroupRoleMembersRequest; } } - /// AgentData block - public AgentDataBlock AgentData; - /// GroupData block - public GroupDataBlock GroupData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.GroupRoleMembersRequest + public override PacketType Type { get { return PacketType.GroupRoleMembersRequest; } } + /// AgentData block + public AgentDataBlock AgentData; + /// GroupData block + public GroupDataBlock GroupData; + + /// Default constructor public GroupRoleMembersRequestPacket() - { - Header = new LowHeader(); - Header.ID = 446; - Header.Reliable = true; - AgentData = new AgentDataBlock(); - GroupData = new GroupDataBlock(); + { + Header = new LowHeader(); + Header.ID = 446; + Header.Reliable = true; + AgentData = new AgentDataBlock(); + GroupData = new GroupDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public GroupRoleMembersRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); - GroupData = new GroupDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); + GroupData = new GroupDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public GroupRoleMembersRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); - GroupData = new GroupDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); + GroupData = new GroupDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length; length += GroupData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - GroupData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length; length += GroupData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + GroupData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- GroupRoleMembersRequest ---\n"; - output += AgentData.ToString() + "\n"; - output += GroupData.ToString() + "\n"; + { + string output = "--- GroupRoleMembersRequest ---\n"; + output += AgentData.ToString() + "\n"; + output += GroupData.ToString() + "\n"; return output; } - + } - - /// GroupRoleMembersReply packet + + /// GroupRoleMembersReply packet public class GroupRoleMembersReplyPacket : Packet - { - /// MemberData block + { + /// MemberData block public class MemberDataBlock - { - /// MemberID field - public LLUUID MemberID; - /// RoleID field - public LLUUID RoleID; - - /// Length of this block serialized in bytes + { + /// MemberID field + public LLUUID MemberID; + /// RoleID field + public LLUUID RoleID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public MemberDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public MemberDataBlock() { } + /// Constructor for building the block from a byte array public MemberDataBlock(byte[] bytes, ref int i) - { + { try - { - MemberID = new LLUUID(bytes, i); i += 16; - RoleID = new LLUUID(bytes, i); i += 16; + { + MemberID = new LLUUID(bytes, i); i += 16; + RoleID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(MemberID == null) { Console.WriteLine("Warning: MemberID is null, in " + this.GetType()); } - Array.Copy(MemberID.GetBytes(), 0, bytes, i, 16); i += 16; - if(RoleID == null) { Console.WriteLine("Warning: RoleID is null, in " + this.GetType()); } - Array.Copy(RoleID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(MemberID == null) { Console.WriteLine("Warning: MemberID is null, in " + this.GetType()); } + Array.Copy(MemberID.GetBytes(), 0, bytes, i, 16); i += 16; + if(RoleID == null) { Console.WriteLine("Warning: RoleID is null, in " + this.GetType()); } + Array.Copy(RoleID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- MemberData --\n"; - output += "MemberID: " + MemberID.ToString() + "\n"; - output += "RoleID: " + RoleID.ToString() + "\n"; + { + string output = "-- MemberData --\n"; + output += "MemberID: " + MemberID.ToString() + "\n"; + output += "RoleID: " + RoleID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// TotalPairs field - public uint TotalPairs; - /// RequestID field - public LLUUID RequestID; - /// GroupID field - public LLUUID GroupID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// TotalPairs field + public uint TotalPairs; + /// RequestID field + public LLUUID RequestID; + /// GroupID field + public LLUUID GroupID; + + /// Length of this block serialized in bytes public int Length { get - { - return 52; + { + return 52; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - TotalPairs = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - RequestID = new LLUUID(bytes, i); i += 16; - GroupID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + TotalPairs = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + RequestID = new LLUUID(bytes, i); i += 16; + GroupID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(TotalPairs % 256); - bytes[i++] = (byte)((TotalPairs >> 8) % 256); - bytes[i++] = (byte)((TotalPairs >> 16) % 256); - bytes[i++] = (byte)((TotalPairs >> 24) % 256); - if(RequestID == null) { Console.WriteLine("Warning: RequestID is null, in " + this.GetType()); } - Array.Copy(RequestID.GetBytes(), 0, bytes, i, 16); i += 16; - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(TotalPairs % 256); + bytes[i++] = (byte)((TotalPairs >> 8) % 256); + bytes[i++] = (byte)((TotalPairs >> 16) % 256); + bytes[i++] = (byte)((TotalPairs >> 24) % 256); + if(RequestID == null) { Console.WriteLine("Warning: RequestID is null, in " + this.GetType()); } + Array.Copy(RequestID.GetBytes(), 0, bytes, i, 16); i += 16; + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "TotalPairs: " + TotalPairs.ToString() + "\n"; - output += "RequestID: " + RequestID.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "TotalPairs: " + TotalPairs.ToString() + "\n"; + output += "RequestID: " + RequestID.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.GroupRoleMembersReply - public override PacketType Type { get { return PacketType.GroupRoleMembersReply; } } - /// MemberData block - public MemberDataBlock[] MemberData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.GroupRoleMembersReply + public override PacketType Type { get { return PacketType.GroupRoleMembersReply; } } + /// MemberData block + public MemberDataBlock[] MemberData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public GroupRoleMembersReplyPacket() - { - Header = new LowHeader(); - Header.ID = 447; - Header.Reliable = true; - MemberData = new MemberDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 447; + Header.Reliable = true; + MemberData = new MemberDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public GroupRoleMembersReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - MemberData = new MemberDataBlock[count]; - for (int j = 0; j < count; j++) - { MemberData[j] = new MemberDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + MemberData = new MemberDataBlock[count]; + for (int j = 0; j < count; j++) + { MemberData[j] = new MemberDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public GroupRoleMembersReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - MemberData = new MemberDataBlock[count]; - for (int j = 0; j < count; j++) - { MemberData[j] = new MemberDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + MemberData = new MemberDataBlock[count]; + for (int j = 0; j < count; j++) + { MemberData[j] = new MemberDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < MemberData.Length; j++) { length += MemberData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)MemberData.Length; - for (int j = 0; j < MemberData.Length; j++) { MemberData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < MemberData.Length; j++) { length += MemberData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)MemberData.Length; + for (int j = 0; j < MemberData.Length; j++) { MemberData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- GroupRoleMembersReply ---\n"; + { + string output = "--- GroupRoleMembersReply ---\n"; for (int j = 0; j < MemberData.Length; j++) - { + { output += MemberData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// GroupTitlesRequest packet + + /// GroupTitlesRequest packet public class GroupTitlesRequestPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// RequestID field - public LLUUID RequestID; - /// SessionID field - public LLUUID SessionID; - /// GroupID field - public LLUUID GroupID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// RequestID field + public LLUUID RequestID; + /// SessionID field + public LLUUID SessionID; + /// GroupID field + public LLUUID GroupID; + + /// Length of this block serialized in bytes public int Length { get - { - return 64; + { + return 64; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - RequestID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; - GroupID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + RequestID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; + GroupID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(RequestID == null) { Console.WriteLine("Warning: RequestID is null, in " + this.GetType()); } - Array.Copy(RequestID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(RequestID == null) { Console.WriteLine("Warning: RequestID is null, in " + this.GetType()); } + Array.Copy(RequestID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "RequestID: " + RequestID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "RequestID: " + RequestID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.GroupTitlesRequest - public override PacketType Type { get { return PacketType.GroupTitlesRequest; } } - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.GroupTitlesRequest + public override PacketType Type { get { return PacketType.GroupTitlesRequest; } } + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public GroupTitlesRequestPacket() - { - Header = new LowHeader(); - Header.ID = 448; - Header.Reliable = true; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 448; + Header.Reliable = true; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public GroupTitlesRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public GroupTitlesRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- GroupTitlesRequest ---\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- GroupTitlesRequest ---\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// GroupTitlesReply packet + + /// GroupTitlesReply packet public class GroupTitlesReplyPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// RequestID field - public LLUUID RequestID; - /// GroupID field - public LLUUID GroupID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// RequestID field + public LLUUID RequestID; + /// GroupID field + public LLUUID GroupID; + + /// Length of this block serialized in bytes public int Length { get - { - return 48; + { + return 48; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - RequestID = new LLUUID(bytes, i); i += 16; - GroupID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + RequestID = new LLUUID(bytes, i); i += 16; + GroupID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(RequestID == null) { Console.WriteLine("Warning: RequestID is null, in " + this.GetType()); } - Array.Copy(RequestID.GetBytes(), 0, bytes, i, 16); i += 16; - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(RequestID == null) { Console.WriteLine("Warning: RequestID is null, in " + this.GetType()); } + Array.Copy(RequestID.GetBytes(), 0, bytes, i, 16); i += 16; + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "RequestID: " + RequestID.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "RequestID: " + RequestID.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// GroupData block + + /// GroupData block public class GroupDataBlock - { - /// Selected field - public bool Selected; - /// RoleID field - public LLUUID RoleID; - private byte[] _title; - /// Title field + { + /// Selected field + public bool Selected; + /// RoleID field + public LLUUID RoleID; + private byte[] _title; + /// Title field public byte[] Title - { - get { return _title; } + { + get { return _title; } set - { - if (value == null) { _title = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _title = new byte[value.Length]; Array.Copy(value, _title, value.Length); } + { + if (value == null) { _title = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _title = new byte[value.Length]; Array.Copy(value, _title, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 17; - if (Title != null) { length += 1 + Title.Length; } - return length; + { + int length = 17; + if (Title != null) { length += 1 + Title.Length; } + return length; } } - - /// Default constructor - public GroupDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public GroupDataBlock() { } + /// Constructor for building the block from a byte array public GroupDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - Selected = (bytes[i++] != 0) ? (bool)true : (bool)false; - RoleID = new LLUUID(bytes, i); i += 16; - length = (ushort)bytes[i++]; - _title = new byte[length]; - Array.Copy(bytes, i, _title, 0, length); i += length; + { + Selected = (bytes[i++] != 0) ? (bool)true : (bool)false; + RoleID = new LLUUID(bytes, i); i += 16; + length = (ushort)bytes[i++]; + _title = new byte[length]; + Array.Copy(bytes, i, _title, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)((Selected) ? 1 : 0); - if(RoleID == null) { Console.WriteLine("Warning: RoleID is null, in " + this.GetType()); } - Array.Copy(RoleID.GetBytes(), 0, bytes, i, 16); i += 16; - if(Title == null) { Console.WriteLine("Warning: Title is null, in " + this.GetType()); } - bytes[i++] = (byte)Title.Length; - Array.Copy(Title, 0, bytes, i, Title.Length); i += Title.Length; + { + bytes[i++] = (byte)((Selected) ? 1 : 0); + if(RoleID == null) { Console.WriteLine("Warning: RoleID is null, in " + this.GetType()); } + Array.Copy(RoleID.GetBytes(), 0, bytes, i, 16); i += 16; + if(Title == null) { Console.WriteLine("Warning: Title is null, in " + this.GetType()); } + bytes[i++] = (byte)Title.Length; + Array.Copy(Title, 0, bytes, i, Title.Length); i += Title.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- GroupData --\n"; - output += "Selected: " + Selected.ToString() + "\n"; - output += "RoleID: " + RoleID.ToString() + "\n"; - output += Helpers.FieldToString(Title, "Title") + "\n"; + { + string output = "-- GroupData --\n"; + output += "Selected: " + Selected.ToString() + "\n"; + output += "RoleID: " + RoleID.ToString() + "\n"; + output += Helpers.FieldToString(Title, "Title") + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.GroupTitlesReply - public override PacketType Type { get { return PacketType.GroupTitlesReply; } } - /// AgentData block - public AgentDataBlock AgentData; - /// GroupData block - public GroupDataBlock[] GroupData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.GroupTitlesReply + public override PacketType Type { get { return PacketType.GroupTitlesReply; } } + /// AgentData block + public AgentDataBlock AgentData; + /// GroupData block + public GroupDataBlock[] GroupData; + + /// Default constructor public GroupTitlesReplyPacket() - { - Header = new LowHeader(); - Header.ID = 449; - Header.Reliable = true; - Header.Zerocoded = true; - AgentData = new AgentDataBlock(); - GroupData = new GroupDataBlock[0]; + { + Header = new LowHeader(); + Header.ID = 449; + Header.Reliable = true; + Header.Zerocoded = true; + AgentData = new AgentDataBlock(); + GroupData = new GroupDataBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public GroupTitlesReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); - int count = (int)bytes[i++]; - GroupData = new GroupDataBlock[count]; - for (int j = 0; j < count; j++) - { GroupData[j] = new GroupDataBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); + int count = (int)bytes[i++]; + GroupData = new GroupDataBlock[count]; + for (int j = 0; j < count; j++) + { GroupData[j] = new GroupDataBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public GroupTitlesReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); - int count = (int)bytes[i++]; - GroupData = new GroupDataBlock[count]; - for (int j = 0; j < count; j++) - { GroupData[j] = new GroupDataBlock(bytes, ref i); } + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); + int count = (int)bytes[i++]; + GroupData = new GroupDataBlock[count]; + for (int j = 0; j < count; j++) + { GroupData[j] = new GroupDataBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < GroupData.Length; j++) { length += GroupData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - bytes[i++] = (byte)GroupData.Length; - for (int j = 0; j < GroupData.Length; j++) { GroupData[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < GroupData.Length; j++) { length += GroupData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + bytes[i++] = (byte)GroupData.Length; + for (int j = 0; j < GroupData.Length; j++) { GroupData[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- GroupTitlesReply ---\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- GroupTitlesReply ---\n"; + output += AgentData.ToString() + "\n"; for (int j = 0; j < GroupData.Length; j++) - { + { output += GroupData[j].ToString() + "\n"; - } + } return output; } - + } - - /// GroupTitleUpdate packet + + /// GroupTitleUpdate packet public class GroupTitleUpdatePacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - /// GroupID field - public LLUUID GroupID; - /// TitleRoleID field - public LLUUID TitleRoleID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + /// GroupID field + public LLUUID GroupID; + /// TitleRoleID field + public LLUUID TitleRoleID; + + /// Length of this block serialized in bytes public int Length { get - { - return 64; + { + return 64; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; - GroupID = new LLUUID(bytes, i); i += 16; - TitleRoleID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; + GroupID = new LLUUID(bytes, i); i += 16; + TitleRoleID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; - if(TitleRoleID == null) { Console.WriteLine("Warning: TitleRoleID is null, in " + this.GetType()); } - Array.Copy(TitleRoleID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + if(TitleRoleID == null) { Console.WriteLine("Warning: TitleRoleID is null, in " + this.GetType()); } + Array.Copy(TitleRoleID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; - output += "TitleRoleID: " + TitleRoleID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; + output += "TitleRoleID: " + TitleRoleID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.GroupTitleUpdate - public override PacketType Type { get { return PacketType.GroupTitleUpdate; } } - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.GroupTitleUpdate + public override PacketType Type { get { return PacketType.GroupTitleUpdate; } } + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public GroupTitleUpdatePacket() - { - Header = new LowHeader(); - Header.ID = 450; - Header.Reliable = true; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 450; + Header.Reliable = true; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public GroupTitleUpdatePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public GroupTitleUpdatePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- GroupTitleUpdate ---\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- GroupTitleUpdate ---\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// GroupRoleUpdate packet + + /// GroupRoleUpdate packet public class GroupRoleUpdatePacket : Packet - { - /// RoleData block + { + /// RoleData block public class RoleDataBlock - { - private byte[] _name; - /// Name field + { + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - /// RoleID field - public LLUUID RoleID; - /// UpdateType field - public byte UpdateType; - /// Powers field - public ulong Powers; - private byte[] _description; - /// Description field + } + /// RoleID field + public LLUUID RoleID; + /// UpdateType field + public byte UpdateType; + /// Powers field + public ulong Powers; + private byte[] _description; + /// Description field public byte[] Description - { - get { return _description; } + { + get { return _description; } set - { - if (value == null) { _description = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } + { + if (value == null) { _description = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } } - } - private byte[] _title; - /// Title field + } + private byte[] _title; + /// Title field public byte[] Title - { - get { return _title; } + { + get { return _title; } set - { - if (value == null) { _title = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _title = new byte[value.Length]; Array.Copy(value, _title, value.Length); } + { + if (value == null) { _title = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _title = new byte[value.Length]; Array.Copy(value, _title, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 25; - if (Name != null) { length += 1 + Name.Length; } - if (Description != null) { length += 1 + Description.Length; } - if (Title != null) { length += 1 + Title.Length; } - return length; + { + int length = 25; + if (Name != null) { length += 1 + Name.Length; } + if (Description != null) { length += 1 + Description.Length; } + if (Title != null) { length += 1 + Title.Length; } + return length; } } - - /// Default constructor - public RoleDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public RoleDataBlock() { } + /// Constructor for building the block from a byte array public RoleDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; - RoleID = new LLUUID(bytes, i); i += 16; - UpdateType = (byte)bytes[i++]; - Powers = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); - length = (ushort)bytes[i++]; - _description = new byte[length]; - Array.Copy(bytes, i, _description, 0, length); i += length; - length = (ushort)bytes[i++]; - _title = new byte[length]; - Array.Copy(bytes, i, _title, 0, length); i += length; + { + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; + RoleID = new LLUUID(bytes, i); i += 16; + UpdateType = (byte)bytes[i++]; + Powers = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + length = (ushort)bytes[i++]; + _description = new byte[length]; + Array.Copy(bytes, i, _description, 0, length); i += length; + length = (ushort)bytes[i++]; + _title = new byte[length]; + Array.Copy(bytes, i, _title, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; - if(RoleID == null) { Console.WriteLine("Warning: RoleID is null, in " + this.GetType()); } - Array.Copy(RoleID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = UpdateType; - bytes[i++] = (byte)(Powers % 256); - bytes[i++] = (byte)((Powers >> 8) % 256); - bytes[i++] = (byte)((Powers >> 16) % 256); - bytes[i++] = (byte)((Powers >> 24) % 256); - bytes[i++] = (byte)((Powers >> 32) % 256); - bytes[i++] = (byte)((Powers >> 40) % 256); - bytes[i++] = (byte)((Powers >> 48) % 256); - bytes[i++] = (byte)((Powers >> 56) % 256); - if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } - bytes[i++] = (byte)Description.Length; - Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; - if(Title == null) { Console.WriteLine("Warning: Title is null, in " + this.GetType()); } - bytes[i++] = (byte)Title.Length; - Array.Copy(Title, 0, bytes, i, Title.Length); i += Title.Length; + { + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + if(RoleID == null) { Console.WriteLine("Warning: RoleID is null, in " + this.GetType()); } + Array.Copy(RoleID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = UpdateType; + bytes[i++] = (byte)(Powers % 256); + bytes[i++] = (byte)((Powers >> 8) % 256); + bytes[i++] = (byte)((Powers >> 16) % 256); + bytes[i++] = (byte)((Powers >> 24) % 256); + bytes[i++] = (byte)((Powers >> 32) % 256); + bytes[i++] = (byte)((Powers >> 40) % 256); + bytes[i++] = (byte)((Powers >> 48) % 256); + bytes[i++] = (byte)((Powers >> 56) % 256); + if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } + bytes[i++] = (byte)Description.Length; + Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; + if(Title == null) { Console.WriteLine("Warning: Title is null, in " + this.GetType()); } + bytes[i++] = (byte)Title.Length; + Array.Copy(Title, 0, bytes, i, Title.Length); i += Title.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- RoleData --\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; - output += "RoleID: " + RoleID.ToString() + "\n"; - output += "UpdateType: " + UpdateType.ToString() + "\n"; - output += "Powers: " + Powers.ToString() + "\n"; - output += Helpers.FieldToString(Description, "Description") + "\n"; - output += Helpers.FieldToString(Title, "Title") + "\n"; + { + string output = "-- RoleData --\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; + output += "RoleID: " + RoleID.ToString() + "\n"; + output += "UpdateType: " + UpdateType.ToString() + "\n"; + output += "Powers: " + Powers.ToString() + "\n"; + output += Helpers.FieldToString(Description, "Description") + "\n"; + output += Helpers.FieldToString(Title, "Title") + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - /// GroupID field - public LLUUID GroupID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + /// GroupID field + public LLUUID GroupID; + + /// Length of this block serialized in bytes public int Length { get - { - return 48; + { + return 48; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; - GroupID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; + GroupID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.GroupRoleUpdate - public override PacketType Type { get { return PacketType.GroupRoleUpdate; } } - /// RoleData block - public RoleDataBlock[] RoleData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.GroupRoleUpdate + public override PacketType Type { get { return PacketType.GroupRoleUpdate; } } + /// RoleData block + public RoleDataBlock[] RoleData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public GroupRoleUpdatePacket() - { - Header = new LowHeader(); - Header.ID = 451; - Header.Reliable = true; - RoleData = new RoleDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 451; + Header.Reliable = true; + RoleData = new RoleDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public GroupRoleUpdatePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - RoleData = new RoleDataBlock[count]; - for (int j = 0; j < count; j++) - { RoleData[j] = new RoleDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + RoleData = new RoleDataBlock[count]; + for (int j = 0; j < count; j++) + { RoleData[j] = new RoleDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public GroupRoleUpdatePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - RoleData = new RoleDataBlock[count]; - for (int j = 0; j < count; j++) - { RoleData[j] = new RoleDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + RoleData = new RoleDataBlock[count]; + for (int j = 0; j < count; j++) + { RoleData[j] = new RoleDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < RoleData.Length; j++) { length += RoleData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)RoleData.Length; - for (int j = 0; j < RoleData.Length; j++) { RoleData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < RoleData.Length; j++) { length += RoleData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)RoleData.Length; + for (int j = 0; j < RoleData.Length; j++) { RoleData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- GroupRoleUpdate ---\n"; + { + string output = "--- GroupRoleUpdate ---\n"; for (int j = 0; j < RoleData.Length; j++) - { + { output += RoleData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// LiveHelpGroupRequest packet + + /// LiveHelpGroupRequest packet public class LiveHelpGroupRequestPacket : Packet - { - /// RequestData block + { + /// RequestData block public class RequestDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// RequestID field - public LLUUID RequestID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// RequestID field + public LLUUID RequestID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public RequestDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public RequestDataBlock() { } + /// Constructor for building the block from a byte array public RequestDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - RequestID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + RequestID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(RequestID == null) { Console.WriteLine("Warning: RequestID is null, in " + this.GetType()); } - Array.Copy(RequestID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(RequestID == null) { Console.WriteLine("Warning: RequestID is null, in " + this.GetType()); } + Array.Copy(RequestID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- RequestData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "RequestID: " + RequestID.ToString() + "\n"; + { + string output = "-- RequestData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "RequestID: " + RequestID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.LiveHelpGroupRequest - public override PacketType Type { get { return PacketType.LiveHelpGroupRequest; } } - /// RequestData block - public RequestDataBlock RequestData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.LiveHelpGroupRequest + public override PacketType Type { get { return PacketType.LiveHelpGroupRequest; } } + /// RequestData block + public RequestDataBlock RequestData; + + /// Default constructor public LiveHelpGroupRequestPacket() - { - Header = new LowHeader(); - Header.ID = 452; - Header.Reliable = true; - RequestData = new RequestDataBlock(); + { + Header = new LowHeader(); + Header.ID = 452; + Header.Reliable = true; + RequestData = new RequestDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public LiveHelpGroupRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - RequestData = new RequestDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + RequestData = new RequestDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public LiveHelpGroupRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - RequestData = new RequestDataBlock(bytes, ref i); + { + Header = head; + RequestData = new RequestDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += RequestData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - RequestData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += RequestData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + RequestData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- LiveHelpGroupRequest ---\n"; - output += RequestData.ToString() + "\n"; + { + string output = "--- LiveHelpGroupRequest ---\n"; + output += RequestData.ToString() + "\n"; return output; } - + } - - /// LiveHelpGroupReply packet + + /// LiveHelpGroupReply packet public class LiveHelpGroupReplyPacket : Packet - { - /// ReplyData block + { + /// ReplyData block public class ReplyDataBlock - { - /// RequestID field - public LLUUID RequestID; - /// GroupID field - public LLUUID GroupID; - private byte[] _selection; - /// Selection field + { + /// RequestID field + public LLUUID RequestID; + /// GroupID field + public LLUUID GroupID; + private byte[] _selection; + /// Selection field public byte[] Selection - { - get { return _selection; } + { + get { return _selection; } set - { - if (value == null) { _selection = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _selection = new byte[value.Length]; Array.Copy(value, _selection, value.Length); } + { + if (value == null) { _selection = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _selection = new byte[value.Length]; Array.Copy(value, _selection, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 32; - if (Selection != null) { length += 1 + Selection.Length; } - return length; + { + int length = 32; + if (Selection != null) { length += 1 + Selection.Length; } + return length; } } - - /// Default constructor - public ReplyDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ReplyDataBlock() { } + /// Constructor for building the block from a byte array public ReplyDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - RequestID = new LLUUID(bytes, i); i += 16; - GroupID = new LLUUID(bytes, i); i += 16; - length = (ushort)bytes[i++]; - _selection = new byte[length]; - Array.Copy(bytes, i, _selection, 0, length); i += length; + { + RequestID = new LLUUID(bytes, i); i += 16; + GroupID = new LLUUID(bytes, i); i += 16; + length = (ushort)bytes[i++]; + _selection = new byte[length]; + Array.Copy(bytes, i, _selection, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(RequestID == null) { Console.WriteLine("Warning: RequestID is null, in " + this.GetType()); } - Array.Copy(RequestID.GetBytes(), 0, bytes, i, 16); i += 16; - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; - if(Selection == null) { Console.WriteLine("Warning: Selection is null, in " + this.GetType()); } - bytes[i++] = (byte)Selection.Length; - Array.Copy(Selection, 0, bytes, i, Selection.Length); i += Selection.Length; + { + if(RequestID == null) { Console.WriteLine("Warning: RequestID is null, in " + this.GetType()); } + Array.Copy(RequestID.GetBytes(), 0, bytes, i, 16); i += 16; + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + if(Selection == null) { Console.WriteLine("Warning: Selection is null, in " + this.GetType()); } + bytes[i++] = (byte)Selection.Length; + Array.Copy(Selection, 0, bytes, i, Selection.Length); i += Selection.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ReplyData --\n"; - output += "RequestID: " + RequestID.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; - output += Helpers.FieldToString(Selection, "Selection") + "\n"; + { + string output = "-- ReplyData --\n"; + output += "RequestID: " + RequestID.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; + output += Helpers.FieldToString(Selection, "Selection") + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.LiveHelpGroupReply - public override PacketType Type { get { return PacketType.LiveHelpGroupReply; } } - /// ReplyData block - public ReplyDataBlock ReplyData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.LiveHelpGroupReply + public override PacketType Type { get { return PacketType.LiveHelpGroupReply; } } + /// ReplyData block + public ReplyDataBlock ReplyData; + + /// Default constructor public LiveHelpGroupReplyPacket() - { - Header = new LowHeader(); - Header.ID = 453; - Header.Reliable = true; - ReplyData = new ReplyDataBlock(); + { + Header = new LowHeader(); + Header.ID = 453; + Header.Reliable = true; + ReplyData = new ReplyDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public LiveHelpGroupReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - ReplyData = new ReplyDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + ReplyData = new ReplyDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public LiveHelpGroupReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - ReplyData = new ReplyDataBlock(bytes, ref i); + { + Header = head; + ReplyData = new ReplyDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += ReplyData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - ReplyData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += ReplyData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + ReplyData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- LiveHelpGroupReply ---\n"; - output += ReplyData.ToString() + "\n"; + { + string output = "--- LiveHelpGroupReply ---\n"; + output += ReplyData.ToString() + "\n"; return output; } - + } - - /// AgentWearablesRequest packet + + /// AgentWearablesRequest packet public class AgentWearablesRequestPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AgentWearablesRequest - public override PacketType Type { get { return PacketType.AgentWearablesRequest; } } - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AgentWearablesRequest + public override PacketType Type { get { return PacketType.AgentWearablesRequest; } } + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public AgentWearablesRequestPacket() - { - Header = new LowHeader(); - Header.ID = 454; - Header.Reliable = true; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 454; + Header.Reliable = true; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AgentWearablesRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AgentWearablesRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AgentWearablesRequest ---\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- AgentWearablesRequest ---\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// AgentWearablesUpdate packet + + /// AgentWearablesUpdate packet public class AgentWearablesUpdatePacket : Packet - { - /// WearableData block + { + /// WearableData block public class WearableDataBlock - { - /// WearableType field - public byte WearableType; - /// AssetID field - public LLUUID AssetID; - /// ItemID field - public LLUUID ItemID; - - /// Length of this block serialized in bytes + { + /// WearableType field + public byte WearableType; + /// AssetID field + public LLUUID AssetID; + /// ItemID field + public LLUUID ItemID; + + /// Length of this block serialized in bytes public int Length { get - { - return 33; + { + return 33; } } - - /// Default constructor - public WearableDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public WearableDataBlock() { } + /// Constructor for building the block from a byte array public WearableDataBlock(byte[] bytes, ref int i) - { + { try - { - WearableType = (byte)bytes[i++]; - AssetID = new LLUUID(bytes, i); i += 16; - ItemID = new LLUUID(bytes, i); i += 16; + { + WearableType = (byte)bytes[i++]; + AssetID = new LLUUID(bytes, i); i += 16; + ItemID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = WearableType; - if(AssetID == null) { Console.WriteLine("Warning: AssetID is null, in " + this.GetType()); } - Array.Copy(AssetID.GetBytes(), 0, bytes, i, 16); i += 16; - if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } - Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; + { + bytes[i++] = WearableType; + if(AssetID == null) { Console.WriteLine("Warning: AssetID is null, in " + this.GetType()); } + Array.Copy(AssetID.GetBytes(), 0, bytes, i, 16); i += 16; + if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } + Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- WearableData --\n"; - output += "WearableType: " + WearableType.ToString() + "\n"; - output += "AssetID: " + AssetID.ToString() + "\n"; - output += "ItemID: " + ItemID.ToString() + "\n"; + { + string output = "-- WearableData --\n"; + output += "WearableType: " + WearableType.ToString() + "\n"; + output += "AssetID: " + AssetID.ToString() + "\n"; + output += "ItemID: " + ItemID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// SerialNum field - public uint SerialNum; - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// SerialNum field + public uint SerialNum; + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 36; + { + return 36; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - SerialNum = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + SerialNum = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(SerialNum % 256); - bytes[i++] = (byte)((SerialNum >> 8) % 256); - bytes[i++] = (byte)((SerialNum >> 16) % 256); - bytes[i++] = (byte)((SerialNum >> 24) % 256); - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + bytes[i++] = (byte)(SerialNum % 256); + bytes[i++] = (byte)((SerialNum >> 8) % 256); + bytes[i++] = (byte)((SerialNum >> 16) % 256); + bytes[i++] = (byte)((SerialNum >> 24) % 256); + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "SerialNum: " + SerialNum.ToString() + "\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "SerialNum: " + SerialNum.ToString() + "\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AgentWearablesUpdate - public override PacketType Type { get { return PacketType.AgentWearablesUpdate; } } - /// WearableData block - public WearableDataBlock[] WearableData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AgentWearablesUpdate + public override PacketType Type { get { return PacketType.AgentWearablesUpdate; } } + /// WearableData block + public WearableDataBlock[] WearableData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public AgentWearablesUpdatePacket() - { - Header = new LowHeader(); - Header.ID = 455; - Header.Reliable = true; - Header.Zerocoded = true; - WearableData = new WearableDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 455; + Header.Reliable = true; + Header.Zerocoded = true; + WearableData = new WearableDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AgentWearablesUpdatePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - WearableData = new WearableDataBlock[count]; - for (int j = 0; j < count; j++) - { WearableData[j] = new WearableDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + WearableData = new WearableDataBlock[count]; + for (int j = 0; j < count; j++) + { WearableData[j] = new WearableDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AgentWearablesUpdatePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - WearableData = new WearableDataBlock[count]; - for (int j = 0; j < count; j++) - { WearableData[j] = new WearableDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + WearableData = new WearableDataBlock[count]; + for (int j = 0; j < count; j++) + { WearableData[j] = new WearableDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < WearableData.Length; j++) { length += WearableData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)WearableData.Length; - for (int j = 0; j < WearableData.Length; j++) { WearableData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < WearableData.Length; j++) { length += WearableData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)WearableData.Length; + for (int j = 0; j < WearableData.Length; j++) { WearableData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AgentWearablesUpdate ---\n"; + { + string output = "--- AgentWearablesUpdate ---\n"; for (int j = 0; j < WearableData.Length; j++) - { + { output += WearableData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// AgentIsNowWearing packet + + /// AgentIsNowWearing packet public class AgentIsNowWearingPacket : Packet - { - /// WearableData block + { + /// WearableData block public class WearableDataBlock - { - /// WearableType field - public byte WearableType; - /// ItemID field - public LLUUID ItemID; - - /// Length of this block serialized in bytes + { + /// WearableType field + public byte WearableType; + /// ItemID field + public LLUUID ItemID; + + /// Length of this block serialized in bytes public int Length { get - { - return 17; + { + return 17; } } - - /// Default constructor - public WearableDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public WearableDataBlock() { } + /// Constructor for building the block from a byte array public WearableDataBlock(byte[] bytes, ref int i) - { + { try - { - WearableType = (byte)bytes[i++]; - ItemID = new LLUUID(bytes, i); i += 16; + { + WearableType = (byte)bytes[i++]; + ItemID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = WearableType; - if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } - Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; + { + bytes[i++] = WearableType; + if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } + Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- WearableData --\n"; - output += "WearableType: " + WearableType.ToString() + "\n"; - output += "ItemID: " + ItemID.ToString() + "\n"; + { + string output = "-- WearableData --\n"; + output += "WearableType: " + WearableType.ToString() + "\n"; + output += "ItemID: " + ItemID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AgentIsNowWearing - public override PacketType Type { get { return PacketType.AgentIsNowWearing; } } - /// WearableData block - public WearableDataBlock[] WearableData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AgentIsNowWearing + public override PacketType Type { get { return PacketType.AgentIsNowWearing; } } + /// WearableData block + public WearableDataBlock[] WearableData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public AgentIsNowWearingPacket() - { - Header = new LowHeader(); - Header.ID = 456; - Header.Reliable = true; - Header.Zerocoded = true; - WearableData = new WearableDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 456; + Header.Reliable = true; + Header.Zerocoded = true; + WearableData = new WearableDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AgentIsNowWearingPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - WearableData = new WearableDataBlock[count]; - for (int j = 0; j < count; j++) - { WearableData[j] = new WearableDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + WearableData = new WearableDataBlock[count]; + for (int j = 0; j < count; j++) + { WearableData[j] = new WearableDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AgentIsNowWearingPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - WearableData = new WearableDataBlock[count]; - for (int j = 0; j < count; j++) - { WearableData[j] = new WearableDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + WearableData = new WearableDataBlock[count]; + for (int j = 0; j < count; j++) + { WearableData[j] = new WearableDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < WearableData.Length; j++) { length += WearableData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)WearableData.Length; - for (int j = 0; j < WearableData.Length; j++) { WearableData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < WearableData.Length; j++) { length += WearableData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)WearableData.Length; + for (int j = 0; j < WearableData.Length; j++) { WearableData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AgentIsNowWearing ---\n"; + { + string output = "--- AgentIsNowWearing ---\n"; for (int j = 0; j < WearableData.Length; j++) - { + { output += WearableData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// AgentCachedTexture packet + + /// AgentCachedTexture packet public class AgentCachedTexturePacket : Packet - { - /// WearableData block + { + /// WearableData block public class WearableDataBlock - { - /// ID field - public LLUUID ID; - /// TextureIndex field - public byte TextureIndex; - - /// Length of this block serialized in bytes + { + /// ID field + public LLUUID ID; + /// TextureIndex field + public byte TextureIndex; + + /// Length of this block serialized in bytes public int Length { get - { - return 17; + { + return 17; } } - - /// Default constructor - public WearableDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public WearableDataBlock() { } + /// Constructor for building the block from a byte array public WearableDataBlock(byte[] bytes, ref int i) - { + { try - { - ID = new LLUUID(bytes, i); i += 16; - TextureIndex = (byte)bytes[i++]; + { + ID = new LLUUID(bytes, i); i += 16; + TextureIndex = (byte)bytes[i++]; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } - Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = TextureIndex; + { + if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } + Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = TextureIndex; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- WearableData --\n"; - output += "ID: " + ID.ToString() + "\n"; - output += "TextureIndex: " + TextureIndex.ToString() + "\n"; + { + string output = "-- WearableData --\n"; + output += "ID: " + ID.ToString() + "\n"; + output += "TextureIndex: " + TextureIndex.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// SerialNum field - public int SerialNum; - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// SerialNum field + public int SerialNum; + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 36; + { + return 36; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - SerialNum = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + SerialNum = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(SerialNum % 256); - bytes[i++] = (byte)((SerialNum >> 8) % 256); - bytes[i++] = (byte)((SerialNum >> 16) % 256); - bytes[i++] = (byte)((SerialNum >> 24) % 256); - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + bytes[i++] = (byte)(SerialNum % 256); + bytes[i++] = (byte)((SerialNum >> 8) % 256); + bytes[i++] = (byte)((SerialNum >> 16) % 256); + bytes[i++] = (byte)((SerialNum >> 24) % 256); + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "SerialNum: " + SerialNum.ToString() + "\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "SerialNum: " + SerialNum.ToString() + "\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AgentCachedTexture - public override PacketType Type { get { return PacketType.AgentCachedTexture; } } - /// WearableData block - public WearableDataBlock[] WearableData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AgentCachedTexture + public override PacketType Type { get { return PacketType.AgentCachedTexture; } } + /// WearableData block + public WearableDataBlock[] WearableData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public AgentCachedTexturePacket() - { - Header = new LowHeader(); - Header.ID = 457; - Header.Reliable = true; - WearableData = new WearableDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 457; + Header.Reliable = true; + WearableData = new WearableDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AgentCachedTexturePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - WearableData = new WearableDataBlock[count]; - for (int j = 0; j < count; j++) - { WearableData[j] = new WearableDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + WearableData = new WearableDataBlock[count]; + for (int j = 0; j < count; j++) + { WearableData[j] = new WearableDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AgentCachedTexturePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - WearableData = new WearableDataBlock[count]; - for (int j = 0; j < count; j++) - { WearableData[j] = new WearableDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + WearableData = new WearableDataBlock[count]; + for (int j = 0; j < count; j++) + { WearableData[j] = new WearableDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < WearableData.Length; j++) { length += WearableData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)WearableData.Length; - for (int j = 0; j < WearableData.Length; j++) { WearableData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < WearableData.Length; j++) { length += WearableData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)WearableData.Length; + for (int j = 0; j < WearableData.Length; j++) { WearableData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AgentCachedTexture ---\n"; + { + string output = "--- AgentCachedTexture ---\n"; for (int j = 0; j < WearableData.Length; j++) - { + { output += WearableData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// AgentCachedTextureResponse packet + + /// AgentCachedTextureResponse packet public class AgentCachedTextureResponsePacket : Packet - { - /// WearableData block + { + /// WearableData block public class WearableDataBlock - { - /// TextureID field - public LLUUID TextureID; - /// TextureIndex field - public byte TextureIndex; - private byte[] _hostname; - /// HostName field + { + /// TextureID field + public LLUUID TextureID; + /// TextureIndex field + public byte TextureIndex; + private byte[] _hostname; + /// HostName field public byte[] HostName - { - get { return _hostname; } + { + get { return _hostname; } set - { - if (value == null) { _hostname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _hostname = new byte[value.Length]; Array.Copy(value, _hostname, value.Length); } + { + if (value == null) { _hostname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _hostname = new byte[value.Length]; Array.Copy(value, _hostname, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 17; - if (HostName != null) { length += 1 + HostName.Length; } - return length; + { + int length = 17; + if (HostName != null) { length += 1 + HostName.Length; } + return length; } } - - /// Default constructor - public WearableDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public WearableDataBlock() { } + /// Constructor for building the block from a byte array public WearableDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - TextureID = new LLUUID(bytes, i); i += 16; - TextureIndex = (byte)bytes[i++]; - length = (ushort)bytes[i++]; - _hostname = new byte[length]; - Array.Copy(bytes, i, _hostname, 0, length); i += length; + { + TextureID = new LLUUID(bytes, i); i += 16; + TextureIndex = (byte)bytes[i++]; + length = (ushort)bytes[i++]; + _hostname = new byte[length]; + Array.Copy(bytes, i, _hostname, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(TextureID == null) { Console.WriteLine("Warning: TextureID is null, in " + this.GetType()); } - Array.Copy(TextureID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = TextureIndex; - if(HostName == null) { Console.WriteLine("Warning: HostName is null, in " + this.GetType()); } - bytes[i++] = (byte)HostName.Length; - Array.Copy(HostName, 0, bytes, i, HostName.Length); i += HostName.Length; + { + if(TextureID == null) { Console.WriteLine("Warning: TextureID is null, in " + this.GetType()); } + Array.Copy(TextureID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = TextureIndex; + if(HostName == null) { Console.WriteLine("Warning: HostName is null, in " + this.GetType()); } + bytes[i++] = (byte)HostName.Length; + Array.Copy(HostName, 0, bytes, i, HostName.Length); i += HostName.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- WearableData --\n"; - output += "TextureID: " + TextureID.ToString() + "\n"; - output += "TextureIndex: " + TextureIndex.ToString() + "\n"; - output += Helpers.FieldToString(HostName, "HostName") + "\n"; + { + string output = "-- WearableData --\n"; + output += "TextureID: " + TextureID.ToString() + "\n"; + output += "TextureIndex: " + TextureIndex.ToString() + "\n"; + output += Helpers.FieldToString(HostName, "HostName") + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// SerialNum field - public int SerialNum; - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// SerialNum field + public int SerialNum; + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 36; + { + return 36; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - SerialNum = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + SerialNum = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(SerialNum % 256); - bytes[i++] = (byte)((SerialNum >> 8) % 256); - bytes[i++] = (byte)((SerialNum >> 16) % 256); - bytes[i++] = (byte)((SerialNum >> 24) % 256); - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + bytes[i++] = (byte)(SerialNum % 256); + bytes[i++] = (byte)((SerialNum >> 8) % 256); + bytes[i++] = (byte)((SerialNum >> 16) % 256); + bytes[i++] = (byte)((SerialNum >> 24) % 256); + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "SerialNum: " + SerialNum.ToString() + "\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "SerialNum: " + SerialNum.ToString() + "\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AgentCachedTextureResponse - public override PacketType Type { get { return PacketType.AgentCachedTextureResponse; } } - /// WearableData block - public WearableDataBlock[] WearableData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AgentCachedTextureResponse + public override PacketType Type { get { return PacketType.AgentCachedTextureResponse; } } + /// WearableData block + public WearableDataBlock[] WearableData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public AgentCachedTextureResponsePacket() - { - Header = new LowHeader(); - Header.ID = 458; - Header.Reliable = true; - WearableData = new WearableDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 458; + Header.Reliable = true; + WearableData = new WearableDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AgentCachedTextureResponsePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - WearableData = new WearableDataBlock[count]; - for (int j = 0; j < count; j++) - { WearableData[j] = new WearableDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + WearableData = new WearableDataBlock[count]; + for (int j = 0; j < count; j++) + { WearableData[j] = new WearableDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AgentCachedTextureResponsePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - WearableData = new WearableDataBlock[count]; - for (int j = 0; j < count; j++) - { WearableData[j] = new WearableDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + WearableData = new WearableDataBlock[count]; + for (int j = 0; j < count; j++) + { WearableData[j] = new WearableDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < WearableData.Length; j++) { length += WearableData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)WearableData.Length; - for (int j = 0; j < WearableData.Length; j++) { WearableData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < WearableData.Length; j++) { length += WearableData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)WearableData.Length; + for (int j = 0; j < WearableData.Length; j++) { WearableData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AgentCachedTextureResponse ---\n"; + { + string output = "--- AgentCachedTextureResponse ---\n"; for (int j = 0; j < WearableData.Length; j++) - { + { output += WearableData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// AgentDataUpdateRequest packet + + /// AgentDataUpdateRequest packet public class AgentDataUpdateRequestPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AgentDataUpdateRequest - public override PacketType Type { get { return PacketType.AgentDataUpdateRequest; } } - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AgentDataUpdateRequest + public override PacketType Type { get { return PacketType.AgentDataUpdateRequest; } } + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public AgentDataUpdateRequestPacket() - { - Header = new LowHeader(); - Header.ID = 459; - Header.Reliable = true; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 459; + Header.Reliable = true; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AgentDataUpdateRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AgentDataUpdateRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AgentDataUpdateRequest ---\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- AgentDataUpdateRequest ---\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// AgentDataUpdate packet + + /// AgentDataUpdate packet public class AgentDataUpdatePacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - private byte[] _grouptitle; - /// GroupTitle field + { + private byte[] _grouptitle; + /// GroupTitle field public byte[] GroupTitle - { - get { return _grouptitle; } + { + get { return _grouptitle; } set - { - if (value == null) { _grouptitle = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _grouptitle = new byte[value.Length]; Array.Copy(value, _grouptitle, value.Length); } + { + if (value == null) { _grouptitle = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _grouptitle = new byte[value.Length]; Array.Copy(value, _grouptitle, value.Length); } } - } - /// GroupPowers field - public ulong GroupPowers; - /// AgentID field - public LLUUID AgentID; - private byte[] _lastname; - /// LastName field + } + /// GroupPowers field + public ulong GroupPowers; + /// AgentID field + public LLUUID AgentID; + private byte[] _lastname; + /// LastName field public byte[] LastName - { - get { return _lastname; } + { + get { return _lastname; } set - { - if (value == null) { _lastname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _lastname = new byte[value.Length]; Array.Copy(value, _lastname, value.Length); } + { + if (value == null) { _lastname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _lastname = new byte[value.Length]; Array.Copy(value, _lastname, value.Length); } } - } - private byte[] _firstname; - /// FirstName field + } + private byte[] _firstname; + /// FirstName field public byte[] FirstName - { - get { return _firstname; } + { + get { return _firstname; } set - { - if (value == null) { _firstname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _firstname = new byte[value.Length]; Array.Copy(value, _firstname, value.Length); } + { + if (value == null) { _firstname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _firstname = new byte[value.Length]; Array.Copy(value, _firstname, value.Length); } } - } - private byte[] _groupname; - /// GroupName field + } + private byte[] _groupname; + /// GroupName field public byte[] GroupName - { - get { return _groupname; } + { + get { return _groupname; } set - { - if (value == null) { _groupname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _groupname = new byte[value.Length]; Array.Copy(value, _groupname, value.Length); } + { + if (value == null) { _groupname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _groupname = new byte[value.Length]; Array.Copy(value, _groupname, value.Length); } } - } - /// ActiveGroupID field - public LLUUID ActiveGroupID; - - /// Length of this block serialized in bytes + } + /// ActiveGroupID field + public LLUUID ActiveGroupID; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 40; - if (GroupTitle != null) { length += 1 + GroupTitle.Length; } - if (LastName != null) { length += 1 + LastName.Length; } - if (FirstName != null) { length += 1 + FirstName.Length; } - if (GroupName != null) { length += 1 + GroupName.Length; } - return length; + { + int length = 40; + if (GroupTitle != null) { length += 1 + GroupTitle.Length; } + if (LastName != null) { length += 1 + LastName.Length; } + if (FirstName != null) { length += 1 + FirstName.Length; } + if (GroupName != null) { length += 1 + GroupName.Length; } + return length; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _grouptitle = new byte[length]; - Array.Copy(bytes, i, _grouptitle, 0, length); i += length; - GroupPowers = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); - AgentID = new LLUUID(bytes, i); i += 16; - length = (ushort)bytes[i++]; - _lastname = new byte[length]; - Array.Copy(bytes, i, _lastname, 0, length); i += length; - length = (ushort)bytes[i++]; - _firstname = new byte[length]; - Array.Copy(bytes, i, _firstname, 0, length); i += length; - length = (ushort)bytes[i++]; - _groupname = new byte[length]; - Array.Copy(bytes, i, _groupname, 0, length); i += length; - ActiveGroupID = new LLUUID(bytes, i); i += 16; + { + length = (ushort)bytes[i++]; + _grouptitle = new byte[length]; + Array.Copy(bytes, i, _grouptitle, 0, length); i += length; + GroupPowers = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + AgentID = new LLUUID(bytes, i); i += 16; + length = (ushort)bytes[i++]; + _lastname = new byte[length]; + Array.Copy(bytes, i, _lastname, 0, length); i += length; + length = (ushort)bytes[i++]; + _firstname = new byte[length]; + Array.Copy(bytes, i, _firstname, 0, length); i += length; + length = (ushort)bytes[i++]; + _groupname = new byte[length]; + Array.Copy(bytes, i, _groupname, 0, length); i += length; + ActiveGroupID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(GroupTitle == null) { Console.WriteLine("Warning: GroupTitle is null, in " + this.GetType()); } - bytes[i++] = (byte)GroupTitle.Length; - Array.Copy(GroupTitle, 0, bytes, i, GroupTitle.Length); i += GroupTitle.Length; - bytes[i++] = (byte)(GroupPowers % 256); - bytes[i++] = (byte)((GroupPowers >> 8) % 256); - bytes[i++] = (byte)((GroupPowers >> 16) % 256); - bytes[i++] = (byte)((GroupPowers >> 24) % 256); - bytes[i++] = (byte)((GroupPowers >> 32) % 256); - bytes[i++] = (byte)((GroupPowers >> 40) % 256); - bytes[i++] = (byte)((GroupPowers >> 48) % 256); - bytes[i++] = (byte)((GroupPowers >> 56) % 256); - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(LastName == null) { Console.WriteLine("Warning: LastName is null, in " + this.GetType()); } - bytes[i++] = (byte)LastName.Length; - Array.Copy(LastName, 0, bytes, i, LastName.Length); i += LastName.Length; - if(FirstName == null) { Console.WriteLine("Warning: FirstName is null, in " + this.GetType()); } - bytes[i++] = (byte)FirstName.Length; - Array.Copy(FirstName, 0, bytes, i, FirstName.Length); i += FirstName.Length; - if(GroupName == null) { Console.WriteLine("Warning: GroupName is null, in " + this.GetType()); } - bytes[i++] = (byte)GroupName.Length; - Array.Copy(GroupName, 0, bytes, i, GroupName.Length); i += GroupName.Length; - if(ActiveGroupID == null) { Console.WriteLine("Warning: ActiveGroupID is null, in " + this.GetType()); } - Array.Copy(ActiveGroupID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(GroupTitle == null) { Console.WriteLine("Warning: GroupTitle is null, in " + this.GetType()); } + bytes[i++] = (byte)GroupTitle.Length; + Array.Copy(GroupTitle, 0, bytes, i, GroupTitle.Length); i += GroupTitle.Length; + bytes[i++] = (byte)(GroupPowers % 256); + bytes[i++] = (byte)((GroupPowers >> 8) % 256); + bytes[i++] = (byte)((GroupPowers >> 16) % 256); + bytes[i++] = (byte)((GroupPowers >> 24) % 256); + bytes[i++] = (byte)((GroupPowers >> 32) % 256); + bytes[i++] = (byte)((GroupPowers >> 40) % 256); + bytes[i++] = (byte)((GroupPowers >> 48) % 256); + bytes[i++] = (byte)((GroupPowers >> 56) % 256); + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(LastName == null) { Console.WriteLine("Warning: LastName is null, in " + this.GetType()); } + bytes[i++] = (byte)LastName.Length; + Array.Copy(LastName, 0, bytes, i, LastName.Length); i += LastName.Length; + if(FirstName == null) { Console.WriteLine("Warning: FirstName is null, in " + this.GetType()); } + bytes[i++] = (byte)FirstName.Length; + Array.Copy(FirstName, 0, bytes, i, FirstName.Length); i += FirstName.Length; + if(GroupName == null) { Console.WriteLine("Warning: GroupName is null, in " + this.GetType()); } + bytes[i++] = (byte)GroupName.Length; + Array.Copy(GroupName, 0, bytes, i, GroupName.Length); i += GroupName.Length; + if(ActiveGroupID == null) { Console.WriteLine("Warning: ActiveGroupID is null, in " + this.GetType()); } + Array.Copy(ActiveGroupID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += Helpers.FieldToString(GroupTitle, "GroupTitle") + "\n"; - output += "GroupPowers: " + GroupPowers.ToString() + "\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += Helpers.FieldToString(LastName, "LastName") + "\n"; - output += Helpers.FieldToString(FirstName, "FirstName") + "\n"; - output += Helpers.FieldToString(GroupName, "GroupName") + "\n"; - output += "ActiveGroupID: " + ActiveGroupID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += Helpers.FieldToString(GroupTitle, "GroupTitle") + "\n"; + output += "GroupPowers: " + GroupPowers.ToString() + "\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += Helpers.FieldToString(LastName, "LastName") + "\n"; + output += Helpers.FieldToString(FirstName, "FirstName") + "\n"; + output += Helpers.FieldToString(GroupName, "GroupName") + "\n"; + output += "ActiveGroupID: " + ActiveGroupID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AgentDataUpdate - public override PacketType Type { get { return PacketType.AgentDataUpdate; } } - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AgentDataUpdate + public override PacketType Type { get { return PacketType.AgentDataUpdate; } } + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public AgentDataUpdatePacket() - { - Header = new LowHeader(); - Header.ID = 460; - Header.Reliable = true; - Header.Zerocoded = true; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 460; + Header.Reliable = true; + Header.Zerocoded = true; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AgentDataUpdatePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AgentDataUpdatePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AgentDataUpdate ---\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- AgentDataUpdate ---\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// GroupDataUpdate packet + + /// GroupDataUpdate packet public class GroupDataUpdatePacket : Packet - { - /// AgentGroupData block + { + /// AgentGroupData block public class AgentGroupDataBlock - { - private byte[] _grouptitle; - /// GroupTitle field + { + private byte[] _grouptitle; + /// GroupTitle field public byte[] GroupTitle - { - get { return _grouptitle; } + { + get { return _grouptitle; } set - { - if (value == null) { _grouptitle = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _grouptitle = new byte[value.Length]; Array.Copy(value, _grouptitle, value.Length); } + { + if (value == null) { _grouptitle = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _grouptitle = new byte[value.Length]; Array.Copy(value, _grouptitle, value.Length); } } - } - /// AgentID field - public LLUUID AgentID; - /// GroupID field - public LLUUID GroupID; - /// AgentPowers field - public ulong AgentPowers; - - /// Length of this block serialized in bytes + } + /// AgentID field + public LLUUID AgentID; + /// GroupID field + public LLUUID GroupID; + /// AgentPowers field + public ulong AgentPowers; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 40; - if (GroupTitle != null) { length += 1 + GroupTitle.Length; } - return length; + { + int length = 40; + if (GroupTitle != null) { length += 1 + GroupTitle.Length; } + return length; } } - - /// Default constructor - public AgentGroupDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentGroupDataBlock() { } + /// Constructor for building the block from a byte array public AgentGroupDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _grouptitle = new byte[length]; - Array.Copy(bytes, i, _grouptitle, 0, length); i += length; - AgentID = new LLUUID(bytes, i); i += 16; - GroupID = new LLUUID(bytes, i); i += 16; - AgentPowers = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + { + length = (ushort)bytes[i++]; + _grouptitle = new byte[length]; + Array.Copy(bytes, i, _grouptitle, 0, length); i += length; + AgentID = new LLUUID(bytes, i); i += 16; + GroupID = new LLUUID(bytes, i); i += 16; + AgentPowers = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(GroupTitle == null) { Console.WriteLine("Warning: GroupTitle is null, in " + this.GetType()); } - bytes[i++] = (byte)GroupTitle.Length; - Array.Copy(GroupTitle, 0, bytes, i, GroupTitle.Length); i += GroupTitle.Length; - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(AgentPowers % 256); - bytes[i++] = (byte)((AgentPowers >> 8) % 256); - bytes[i++] = (byte)((AgentPowers >> 16) % 256); - bytes[i++] = (byte)((AgentPowers >> 24) % 256); - bytes[i++] = (byte)((AgentPowers >> 32) % 256); - bytes[i++] = (byte)((AgentPowers >> 40) % 256); - bytes[i++] = (byte)((AgentPowers >> 48) % 256); - bytes[i++] = (byte)((AgentPowers >> 56) % 256); + { + if(GroupTitle == null) { Console.WriteLine("Warning: GroupTitle is null, in " + this.GetType()); } + bytes[i++] = (byte)GroupTitle.Length; + Array.Copy(GroupTitle, 0, bytes, i, GroupTitle.Length); i += GroupTitle.Length; + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(AgentPowers % 256); + bytes[i++] = (byte)((AgentPowers >> 8) % 256); + bytes[i++] = (byte)((AgentPowers >> 16) % 256); + bytes[i++] = (byte)((AgentPowers >> 24) % 256); + bytes[i++] = (byte)((AgentPowers >> 32) % 256); + bytes[i++] = (byte)((AgentPowers >> 40) % 256); + bytes[i++] = (byte)((AgentPowers >> 48) % 256); + bytes[i++] = (byte)((AgentPowers >> 56) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentGroupData --\n"; - output += Helpers.FieldToString(GroupTitle, "GroupTitle") + "\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; - output += "AgentPowers: " + AgentPowers.ToString() + "\n"; + { + string output = "-- AgentGroupData --\n"; + output += Helpers.FieldToString(GroupTitle, "GroupTitle") + "\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; + output += "AgentPowers: " + AgentPowers.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.GroupDataUpdate - public override PacketType Type { get { return PacketType.GroupDataUpdate; } } - /// AgentGroupData block - public AgentGroupDataBlock[] AgentGroupData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.GroupDataUpdate + public override PacketType Type { get { return PacketType.GroupDataUpdate; } } + /// AgentGroupData block + public AgentGroupDataBlock[] AgentGroupData; + + /// Default constructor public GroupDataUpdatePacket() - { - Header = new LowHeader(); - Header.ID = 461; - Header.Reliable = true; - Header.Zerocoded = true; - AgentGroupData = new AgentGroupDataBlock[0]; + { + Header = new LowHeader(); + Header.ID = 461; + Header.Reliable = true; + Header.Zerocoded = true; + AgentGroupData = new AgentGroupDataBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public GroupDataUpdatePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - AgentGroupData = new AgentGroupDataBlock[count]; - for (int j = 0; j < count; j++) - { AgentGroupData[j] = new AgentGroupDataBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + AgentGroupData = new AgentGroupDataBlock[count]; + for (int j = 0; j < count; j++) + { AgentGroupData[j] = new AgentGroupDataBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public GroupDataUpdatePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - AgentGroupData = new AgentGroupDataBlock[count]; - for (int j = 0; j < count; j++) - { AgentGroupData[j] = new AgentGroupDataBlock(bytes, ref i); } + { + Header = head; + int count = (int)bytes[i++]; + AgentGroupData = new AgentGroupDataBlock[count]; + for (int j = 0; j < count; j++) + { AgentGroupData[j] = new AgentGroupDataBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; -; - length++; - for (int j = 0; j < AgentGroupData.Length; j++) { length += AgentGroupData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)AgentGroupData.Length; - for (int j = 0; j < AgentGroupData.Length; j++) { AgentGroupData[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; +; + length++; + for (int j = 0; j < AgentGroupData.Length; j++) { length += AgentGroupData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)AgentGroupData.Length; + for (int j = 0; j < AgentGroupData.Length; j++) { AgentGroupData[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- GroupDataUpdate ---\n"; + { + string output = "--- GroupDataUpdate ---\n"; for (int j = 0; j < AgentGroupData.Length; j++) - { + { output += AgentGroupData[j].ToString() + "\n"; - } + } return output; } - + } - - /// AgentGroupDataUpdate packet + + /// AgentGroupDataUpdate packet public class AgentGroupDataUpdatePacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// GroupData block + + /// GroupData block public class GroupDataBlock - { - /// GroupPowers field - public ulong GroupPowers; - /// Contribution field - public int Contribution; - /// GroupID field - public LLUUID GroupID; - /// GroupInsigniaID field - public LLUUID GroupInsigniaID; - /// AcceptNotices field - public bool AcceptNotices; - private byte[] _groupname; - /// GroupName field + { + /// GroupPowers field + public ulong GroupPowers; + /// Contribution field + public int Contribution; + /// GroupID field + public LLUUID GroupID; + /// GroupInsigniaID field + public LLUUID GroupInsigniaID; + /// AcceptNotices field + public bool AcceptNotices; + private byte[] _groupname; + /// GroupName field public byte[] GroupName - { - get { return _groupname; } + { + get { return _groupname; } set - { - if (value == null) { _groupname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _groupname = new byte[value.Length]; Array.Copy(value, _groupname, value.Length); } + { + if (value == null) { _groupname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _groupname = new byte[value.Length]; Array.Copy(value, _groupname, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 45; - if (GroupName != null) { length += 1 + GroupName.Length; } - return length; + { + int length = 45; + if (GroupName != null) { length += 1 + GroupName.Length; } + return length; } } - - /// Default constructor - public GroupDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public GroupDataBlock() { } + /// Constructor for building the block from a byte array public GroupDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - GroupPowers = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); - Contribution = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - GroupID = new LLUUID(bytes, i); i += 16; - GroupInsigniaID = new LLUUID(bytes, i); i += 16; - AcceptNotices = (bytes[i++] != 0) ? (bool)true : (bool)false; - length = (ushort)bytes[i++]; - _groupname = new byte[length]; - Array.Copy(bytes, i, _groupname, 0, length); i += length; + { + GroupPowers = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + Contribution = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + GroupID = new LLUUID(bytes, i); i += 16; + GroupInsigniaID = new LLUUID(bytes, i); i += 16; + AcceptNotices = (bytes[i++] != 0) ? (bool)true : (bool)false; + length = (ushort)bytes[i++]; + _groupname = new byte[length]; + Array.Copy(bytes, i, _groupname, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(GroupPowers % 256); - bytes[i++] = (byte)((GroupPowers >> 8) % 256); - bytes[i++] = (byte)((GroupPowers >> 16) % 256); - bytes[i++] = (byte)((GroupPowers >> 24) % 256); - bytes[i++] = (byte)((GroupPowers >> 32) % 256); - bytes[i++] = (byte)((GroupPowers >> 40) % 256); - bytes[i++] = (byte)((GroupPowers >> 48) % 256); - bytes[i++] = (byte)((GroupPowers >> 56) % 256); - bytes[i++] = (byte)(Contribution % 256); - bytes[i++] = (byte)((Contribution >> 8) % 256); - bytes[i++] = (byte)((Contribution >> 16) % 256); - bytes[i++] = (byte)((Contribution >> 24) % 256); - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; - if(GroupInsigniaID == null) { Console.WriteLine("Warning: GroupInsigniaID is null, in " + this.GetType()); } - Array.Copy(GroupInsigniaID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((AcceptNotices) ? 1 : 0); - if(GroupName == null) { Console.WriteLine("Warning: GroupName is null, in " + this.GetType()); } - bytes[i++] = (byte)GroupName.Length; - Array.Copy(GroupName, 0, bytes, i, GroupName.Length); i += GroupName.Length; + { + bytes[i++] = (byte)(GroupPowers % 256); + bytes[i++] = (byte)((GroupPowers >> 8) % 256); + bytes[i++] = (byte)((GroupPowers >> 16) % 256); + bytes[i++] = (byte)((GroupPowers >> 24) % 256); + bytes[i++] = (byte)((GroupPowers >> 32) % 256); + bytes[i++] = (byte)((GroupPowers >> 40) % 256); + bytes[i++] = (byte)((GroupPowers >> 48) % 256); + bytes[i++] = (byte)((GroupPowers >> 56) % 256); + bytes[i++] = (byte)(Contribution % 256); + bytes[i++] = (byte)((Contribution >> 8) % 256); + bytes[i++] = (byte)((Contribution >> 16) % 256); + bytes[i++] = (byte)((Contribution >> 24) % 256); + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + if(GroupInsigniaID == null) { Console.WriteLine("Warning: GroupInsigniaID is null, in " + this.GetType()); } + Array.Copy(GroupInsigniaID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((AcceptNotices) ? 1 : 0); + if(GroupName == null) { Console.WriteLine("Warning: GroupName is null, in " + this.GetType()); } + bytes[i++] = (byte)GroupName.Length; + Array.Copy(GroupName, 0, bytes, i, GroupName.Length); i += GroupName.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- GroupData --\n"; - output += "GroupPowers: " + GroupPowers.ToString() + "\n"; - output += "Contribution: " + Contribution.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; - output += "GroupInsigniaID: " + GroupInsigniaID.ToString() + "\n"; - output += "AcceptNotices: " + AcceptNotices.ToString() + "\n"; - output += Helpers.FieldToString(GroupName, "GroupName") + "\n"; + { + string output = "-- GroupData --\n"; + output += "GroupPowers: " + GroupPowers.ToString() + "\n"; + output += "Contribution: " + Contribution.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; + output += "GroupInsigniaID: " + GroupInsigniaID.ToString() + "\n"; + output += "AcceptNotices: " + AcceptNotices.ToString() + "\n"; + output += Helpers.FieldToString(GroupName, "GroupName") + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AgentGroupDataUpdate - public override PacketType Type { get { return PacketType.AgentGroupDataUpdate; } } - /// AgentData block - public AgentDataBlock AgentData; - /// GroupData block - public GroupDataBlock[] GroupData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AgentGroupDataUpdate + public override PacketType Type { get { return PacketType.AgentGroupDataUpdate; } } + /// AgentData block + public AgentDataBlock AgentData; + /// GroupData block + public GroupDataBlock[] GroupData; + + /// Default constructor public AgentGroupDataUpdatePacket() - { - Header = new LowHeader(); - Header.ID = 462; - Header.Reliable = true; - Header.Zerocoded = true; - AgentData = new AgentDataBlock(); - GroupData = new GroupDataBlock[0]; + { + Header = new LowHeader(); + Header.ID = 462; + Header.Reliable = true; + Header.Zerocoded = true; + AgentData = new AgentDataBlock(); + GroupData = new GroupDataBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AgentGroupDataUpdatePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); - int count = (int)bytes[i++]; - GroupData = new GroupDataBlock[count]; - for (int j = 0; j < count; j++) - { GroupData[j] = new GroupDataBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); + int count = (int)bytes[i++]; + GroupData = new GroupDataBlock[count]; + for (int j = 0; j < count; j++) + { GroupData[j] = new GroupDataBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AgentGroupDataUpdatePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); - int count = (int)bytes[i++]; - GroupData = new GroupDataBlock[count]; - for (int j = 0; j < count; j++) - { GroupData[j] = new GroupDataBlock(bytes, ref i); } + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); + int count = (int)bytes[i++]; + GroupData = new GroupDataBlock[count]; + for (int j = 0; j < count; j++) + { GroupData[j] = new GroupDataBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < GroupData.Length; j++) { length += GroupData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - bytes[i++] = (byte)GroupData.Length; - for (int j = 0; j < GroupData.Length; j++) { GroupData[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < GroupData.Length; j++) { length += GroupData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + bytes[i++] = (byte)GroupData.Length; + for (int j = 0; j < GroupData.Length; j++) { GroupData[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AgentGroupDataUpdate ---\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- AgentGroupDataUpdate ---\n"; + output += AgentData.ToString() + "\n"; for (int j = 0; j < GroupData.Length; j++) - { + { output += GroupData[j].ToString() + "\n"; - } + } return output; } - + } - - /// AgentDropGroup packet + + /// AgentDropGroup packet public class AgentDropGroupPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// GroupID field - public LLUUID GroupID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// GroupID field + public LLUUID GroupID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - GroupID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + GroupID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AgentDropGroup - public override PacketType Type { get { return PacketType.AgentDropGroup; } } - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AgentDropGroup + public override PacketType Type { get { return PacketType.AgentDropGroup; } } + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public AgentDropGroupPacket() - { - Header = new LowHeader(); - Header.ID = 463; - Header.Reliable = true; - Header.Zerocoded = true; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 463; + Header.Reliable = true; + Header.Zerocoded = true; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AgentDropGroupPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AgentDropGroupPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AgentDropGroup ---\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- AgentDropGroup ---\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// LogTextMessage packet + + /// LogTextMessage packet public class LogTextMessagePacket : Packet - { - /// DataBlock block + { + /// DataBlock block public class DataBlockBlock - { - /// ToAgentId field - public LLUUID ToAgentId; - private byte[] _message; - /// Message field + { + /// ToAgentId field + public LLUUID ToAgentId; + private byte[] _message; + /// Message field public byte[] Message - { - get { return _message; } + { + get { return _message; } set - { - if (value == null) { _message = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _message = new byte[value.Length]; Array.Copy(value, _message, value.Length); } + { + if (value == null) { _message = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _message = new byte[value.Length]; Array.Copy(value, _message, value.Length); } } - } - /// GlobalX field - public double GlobalX; - /// GlobalY field - public double GlobalY; - /// Time field - public uint Time; - /// FromAgentId field - public LLUUID FromAgentId; - - /// Length of this block serialized in bytes + } + /// GlobalX field + public double GlobalX; + /// GlobalY field + public double GlobalY; + /// Time field + public uint Time; + /// FromAgentId field + public LLUUID FromAgentId; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 52; - if (Message != null) { length += 2 + Message.Length; } - return length; + { + int length = 52; + if (Message != null) { length += 2 + Message.Length; } + return length; } } - - /// Default constructor - public DataBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlockBlock() { } + /// Constructor for building the block from a byte array public DataBlockBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - ToAgentId = new LLUUID(bytes, i); i += 16; - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _message = new byte[length]; - Array.Copy(bytes, i, _message, 0, length); i += length; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 8); - GlobalX = BitConverter.ToDouble(bytes, i); i += 8; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 8); - GlobalY = BitConverter.ToDouble(bytes, i); i += 8; - Time = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - FromAgentId = new LLUUID(bytes, i); i += 16; + { + ToAgentId = new LLUUID(bytes, i); i += 16; + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _message = new byte[length]; + Array.Copy(bytes, i, _message, 0, length); i += length; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 8); + GlobalX = BitConverter.ToDouble(bytes, i); i += 8; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 8); + GlobalY = BitConverter.ToDouble(bytes, i); i += 8; + Time = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + FromAgentId = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; - if(ToAgentId == null) { Console.WriteLine("Warning: ToAgentId is null, in " + this.GetType()); } - Array.Copy(ToAgentId.GetBytes(), 0, bytes, i, 16); i += 16; - if(Message == null) { Console.WriteLine("Warning: Message is null, in " + this.GetType()); } - bytes[i++] = (byte)(Message.Length % 256); - bytes[i++] = (byte)((Message.Length >> 8) % 256); - Array.Copy(Message, 0, bytes, i, Message.Length); i += Message.Length; + { + byte[] ba; + if(ToAgentId == null) { Console.WriteLine("Warning: ToAgentId is null, in " + this.GetType()); } + Array.Copy(ToAgentId.GetBytes(), 0, bytes, i, 16); i += 16; + if(Message == null) { Console.WriteLine("Warning: Message is null, in " + this.GetType()); } + bytes[i++] = (byte)(Message.Length % 256); + bytes[i++] = (byte)((Message.Length >> 8) % 256); + Array.Copy(Message, 0, bytes, i, Message.Length); i += Message.Length; ba = BitConverter.GetBytes(GlobalX); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 8); } - Array.Copy(ba, 0, bytes, i, 8); i += 8; + Array.Copy(ba, 0, bytes, i, 8); i += 8; ba = BitConverter.GetBytes(GlobalY); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 8); } - Array.Copy(ba, 0, bytes, i, 8); i += 8; - bytes[i++] = (byte)(Time % 256); - bytes[i++] = (byte)((Time >> 8) % 256); - bytes[i++] = (byte)((Time >> 16) % 256); - bytes[i++] = (byte)((Time >> 24) % 256); - if(FromAgentId == null) { Console.WriteLine("Warning: FromAgentId is null, in " + this.GetType()); } - Array.Copy(FromAgentId.GetBytes(), 0, bytes, i, 16); i += 16; + Array.Copy(ba, 0, bytes, i, 8); i += 8; + bytes[i++] = (byte)(Time % 256); + bytes[i++] = (byte)((Time >> 8) % 256); + bytes[i++] = (byte)((Time >> 16) % 256); + bytes[i++] = (byte)((Time >> 24) % 256); + if(FromAgentId == null) { Console.WriteLine("Warning: FromAgentId is null, in " + this.GetType()); } + Array.Copy(FromAgentId.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- DataBlock --\n"; - output += "ToAgentId: " + ToAgentId.ToString() + "\n"; - output += Helpers.FieldToString(Message, "Message") + "\n"; - output += "GlobalX: " + GlobalX.ToString() + "\n"; - output += "GlobalY: " + GlobalY.ToString() + "\n"; - output += "Time: " + Time.ToString() + "\n"; - output += "FromAgentId: " + FromAgentId.ToString() + "\n"; + { + string output = "-- DataBlock --\n"; + output += "ToAgentId: " + ToAgentId.ToString() + "\n"; + output += Helpers.FieldToString(Message, "Message") + "\n"; + output += "GlobalX: " + GlobalX.ToString() + "\n"; + output += "GlobalY: " + GlobalY.ToString() + "\n"; + output += "Time: " + Time.ToString() + "\n"; + output += "FromAgentId: " + FromAgentId.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.LogTextMessage - public override PacketType Type { get { return PacketType.LogTextMessage; } } - /// DataBlock block - public DataBlockBlock[] DataBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.LogTextMessage + public override PacketType Type { get { return PacketType.LogTextMessage; } } + /// DataBlock block + public DataBlockBlock[] DataBlock; + + /// Default constructor public LogTextMessagePacket() - { - Header = new LowHeader(); - Header.ID = 464; - Header.Reliable = true; - Header.Zerocoded = true; - DataBlock = new DataBlockBlock[0]; + { + Header = new LowHeader(); + Header.ID = 464; + Header.Reliable = true; + Header.Zerocoded = true; + DataBlock = new DataBlockBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public LogTextMessagePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - DataBlock = new DataBlockBlock[count]; - for (int j = 0; j < count; j++) - { DataBlock[j] = new DataBlockBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + DataBlock = new DataBlockBlock[count]; + for (int j = 0; j < count; j++) + { DataBlock[j] = new DataBlockBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public LogTextMessagePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - DataBlock = new DataBlockBlock[count]; - for (int j = 0; j < count; j++) - { DataBlock[j] = new DataBlockBlock(bytes, ref i); } + { + Header = head; + int count = (int)bytes[i++]; + DataBlock = new DataBlockBlock[count]; + for (int j = 0; j < count; j++) + { DataBlock[j] = new DataBlockBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; -; - length++; - for (int j = 0; j < DataBlock.Length; j++) { length += DataBlock[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)DataBlock.Length; - for (int j = 0; j < DataBlock.Length; j++) { DataBlock[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; +; + length++; + for (int j = 0; j < DataBlock.Length; j++) { length += DataBlock[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)DataBlock.Length; + for (int j = 0; j < DataBlock.Length; j++) { DataBlock[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- LogTextMessage ---\n"; + { + string output = "--- LogTextMessage ---\n"; for (int j = 0; j < DataBlock.Length; j++) - { + { output += DataBlock[j].ToString() + "\n"; - } + } return output; } - + } - - /// CreateTrustedCircuit packet + + /// CreateTrustedCircuit packet public class CreateTrustedCircuitPacket : Packet - { - /// DataBlock block + { + /// DataBlock block public class DataBlockBlock - { - /// Digest field - public byte[] Digest; - /// EndPointID field - public LLUUID EndPointID; - - /// Length of this block serialized in bytes + { + /// Digest field + public byte[] Digest; + /// EndPointID field + public LLUUID EndPointID; + + /// Length of this block serialized in bytes public int Length { get - { - return 48; + { + return 48; } } - - /// Default constructor - public DataBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlockBlock() { } + /// Constructor for building the block from a byte array public DataBlockBlock(byte[] bytes, ref int i) - { + { try - { - Digest = new byte[32]; - Array.Copy(bytes, i, Digest, 0, 32); i += 32; - EndPointID = new LLUUID(bytes, i); i += 16; + { + Digest = new byte[32]; + Array.Copy(bytes, i, Digest, 0, 32); i += 32; + EndPointID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - Array.Copy(Digest, 0, bytes, i, 32);i += 32; - if(EndPointID == null) { Console.WriteLine("Warning: EndPointID is null, in " + this.GetType()); } - Array.Copy(EndPointID.GetBytes(), 0, bytes, i, 16); i += 16; + { + Array.Copy(Digest, 0, bytes, i, 32);i += 32; + if(EndPointID == null) { Console.WriteLine("Warning: EndPointID is null, in " + this.GetType()); } + Array.Copy(EndPointID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- DataBlock --\n"; - output += Helpers.FieldToString(Digest, "Digest") + "\n"; - output += "EndPointID: " + EndPointID.ToString() + "\n"; + { + string output = "-- DataBlock --\n"; + output += Helpers.FieldToString(Digest, "Digest") + "\n"; + output += "EndPointID: " + EndPointID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.CreateTrustedCircuit - public override PacketType Type { get { return PacketType.CreateTrustedCircuit; } } - /// DataBlock block - public DataBlockBlock DataBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.CreateTrustedCircuit + public override PacketType Type { get { return PacketType.CreateTrustedCircuit; } } + /// DataBlock block + public DataBlockBlock DataBlock; + + /// Default constructor public CreateTrustedCircuitPacket() - { - Header = new LowHeader(); - Header.ID = 465; - Header.Reliable = true; - DataBlock = new DataBlockBlock(); + { + Header = new LowHeader(); + Header.ID = 465; + Header.Reliable = true; + DataBlock = new DataBlockBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public CreateTrustedCircuitPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - DataBlock = new DataBlockBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + DataBlock = new DataBlockBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public CreateTrustedCircuitPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - DataBlock = new DataBlockBlock(bytes, ref i); + { + Header = head; + DataBlock = new DataBlockBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += DataBlock.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - DataBlock.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += DataBlock.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + DataBlock.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- CreateTrustedCircuit ---\n"; - output += DataBlock.ToString() + "\n"; + { + string output = "--- CreateTrustedCircuit ---\n"; + output += DataBlock.ToString() + "\n"; return output; } - + } - - /// DenyTrustedCircuit packet + + /// DenyTrustedCircuit packet public class DenyTrustedCircuitPacket : Packet - { - /// DataBlock block + { + /// DataBlock block public class DataBlockBlock - { - /// EndPointID field - public LLUUID EndPointID; - - /// Length of this block serialized in bytes + { + /// EndPointID field + public LLUUID EndPointID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public DataBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlockBlock() { } + /// Constructor for building the block from a byte array public DataBlockBlock(byte[] bytes, ref int i) - { + { try - { - EndPointID = new LLUUID(bytes, i); i += 16; + { + EndPointID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(EndPointID == null) { Console.WriteLine("Warning: EndPointID is null, in " + this.GetType()); } - Array.Copy(EndPointID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(EndPointID == null) { Console.WriteLine("Warning: EndPointID is null, in " + this.GetType()); } + Array.Copy(EndPointID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- DataBlock --\n"; - output += "EndPointID: " + EndPointID.ToString() + "\n"; + { + string output = "-- DataBlock --\n"; + output += "EndPointID: " + EndPointID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.DenyTrustedCircuit - public override PacketType Type { get { return PacketType.DenyTrustedCircuit; } } - /// DataBlock block - public DataBlockBlock DataBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.DenyTrustedCircuit + public override PacketType Type { get { return PacketType.DenyTrustedCircuit; } } + /// DataBlock block + public DataBlockBlock DataBlock; + + /// Default constructor public DenyTrustedCircuitPacket() - { - Header = new LowHeader(); - Header.ID = 466; - Header.Reliable = true; - DataBlock = new DataBlockBlock(); + { + Header = new LowHeader(); + Header.ID = 466; + Header.Reliable = true; + DataBlock = new DataBlockBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public DenyTrustedCircuitPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - DataBlock = new DataBlockBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + DataBlock = new DataBlockBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public DenyTrustedCircuitPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - DataBlock = new DataBlockBlock(bytes, ref i); + { + Header = head; + DataBlock = new DataBlockBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += DataBlock.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - DataBlock.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += DataBlock.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + DataBlock.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- DenyTrustedCircuit ---\n"; - output += DataBlock.ToString() + "\n"; + { + string output = "--- DenyTrustedCircuit ---\n"; + output += DataBlock.ToString() + "\n"; return output; } - + } - - /// RezSingleAttachmentFromInv packet + + /// RezSingleAttachmentFromInv packet public class RezSingleAttachmentFromInvPacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - private byte[] _name; - /// Name field + { + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - /// ItemFlags field - public uint ItemFlags; - /// OwnerID field - public LLUUID OwnerID; - /// ItemID field - public LLUUID ItemID; - /// EveryoneMask field - public uint EveryoneMask; - private byte[] _description; - /// Description field + } + /// ItemFlags field + public uint ItemFlags; + /// OwnerID field + public LLUUID OwnerID; + /// ItemID field + public LLUUID ItemID; + /// EveryoneMask field + public uint EveryoneMask; + private byte[] _description; + /// Description field public byte[] Description - { - get { return _description; } + { + get { return _description; } set - { - if (value == null) { _description = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } + { + if (value == null) { _description = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } } - } - /// AttachmentPt field - public byte AttachmentPt; - /// NextOwnerMask field - public uint NextOwnerMask; - /// GroupMask field - public uint GroupMask; - - /// Length of this block serialized in bytes + } + /// AttachmentPt field + public byte AttachmentPt; + /// NextOwnerMask field + public uint NextOwnerMask; + /// GroupMask field + public uint GroupMask; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 49; - if (Name != null) { length += 1 + Name.Length; } - if (Description != null) { length += 1 + Description.Length; } - return length; + { + int length = 49; + if (Name != null) { length += 1 + Name.Length; } + if (Description != null) { length += 1 + Description.Length; } + return length; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; - ItemFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - OwnerID = new LLUUID(bytes, i); i += 16; - ItemID = new LLUUID(bytes, i); i += 16; - EveryoneMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _description = new byte[length]; - Array.Copy(bytes, i, _description, 0, length); i += length; - AttachmentPt = (byte)bytes[i++]; - NextOwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - GroupMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; + ItemFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + OwnerID = new LLUUID(bytes, i); i += 16; + ItemID = new LLUUID(bytes, i); i += 16; + EveryoneMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _description = new byte[length]; + Array.Copy(bytes, i, _description, 0, length); i += length; + AttachmentPt = (byte)bytes[i++]; + NextOwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + GroupMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; - bytes[i++] = (byte)(ItemFlags % 256); - bytes[i++] = (byte)((ItemFlags >> 8) % 256); - bytes[i++] = (byte)((ItemFlags >> 16) % 256); - bytes[i++] = (byte)((ItemFlags >> 24) % 256); - if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } - Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; - if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } - Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(EveryoneMask % 256); - bytes[i++] = (byte)((EveryoneMask >> 8) % 256); - bytes[i++] = (byte)((EveryoneMask >> 16) % 256); - bytes[i++] = (byte)((EveryoneMask >> 24) % 256); - if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } - bytes[i++] = (byte)Description.Length; - Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; - bytes[i++] = AttachmentPt; - bytes[i++] = (byte)(NextOwnerMask % 256); - bytes[i++] = (byte)((NextOwnerMask >> 8) % 256); - bytes[i++] = (byte)((NextOwnerMask >> 16) % 256); - bytes[i++] = (byte)((NextOwnerMask >> 24) % 256); - bytes[i++] = (byte)(GroupMask % 256); - bytes[i++] = (byte)((GroupMask >> 8) % 256); - bytes[i++] = (byte)((GroupMask >> 16) % 256); - bytes[i++] = (byte)((GroupMask >> 24) % 256); + { + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + bytes[i++] = (byte)(ItemFlags % 256); + bytes[i++] = (byte)((ItemFlags >> 8) % 256); + bytes[i++] = (byte)((ItemFlags >> 16) % 256); + bytes[i++] = (byte)((ItemFlags >> 24) % 256); + if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } + Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; + if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } + Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(EveryoneMask % 256); + bytes[i++] = (byte)((EveryoneMask >> 8) % 256); + bytes[i++] = (byte)((EveryoneMask >> 16) % 256); + bytes[i++] = (byte)((EveryoneMask >> 24) % 256); + if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } + bytes[i++] = (byte)Description.Length; + Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; + bytes[i++] = AttachmentPt; + bytes[i++] = (byte)(NextOwnerMask % 256); + bytes[i++] = (byte)((NextOwnerMask >> 8) % 256); + bytes[i++] = (byte)((NextOwnerMask >> 16) % 256); + bytes[i++] = (byte)((NextOwnerMask >> 24) % 256); + bytes[i++] = (byte)(GroupMask % 256); + bytes[i++] = (byte)((GroupMask >> 8) % 256); + bytes[i++] = (byte)((GroupMask >> 16) % 256); + bytes[i++] = (byte)((GroupMask >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; - output += "ItemFlags: " + ItemFlags.ToString() + "\n"; - output += "OwnerID: " + OwnerID.ToString() + "\n"; - output += "ItemID: " + ItemID.ToString() + "\n"; - output += "EveryoneMask: " + EveryoneMask.ToString() + "\n"; - output += Helpers.FieldToString(Description, "Description") + "\n"; - output += "AttachmentPt: " + AttachmentPt.ToString() + "\n"; - output += "NextOwnerMask: " + NextOwnerMask.ToString() + "\n"; - output += "GroupMask: " + GroupMask.ToString() + "\n"; + { + string output = "-- ObjectData --\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; + output += "ItemFlags: " + ItemFlags.ToString() + "\n"; + output += "OwnerID: " + OwnerID.ToString() + "\n"; + output += "ItemID: " + ItemID.ToString() + "\n"; + output += "EveryoneMask: " + EveryoneMask.ToString() + "\n"; + output += Helpers.FieldToString(Description, "Description") + "\n"; + output += "AttachmentPt: " + AttachmentPt.ToString() + "\n"; + output += "NextOwnerMask: " + NextOwnerMask.ToString() + "\n"; + output += "GroupMask: " + GroupMask.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.RezSingleAttachmentFromInv - public override PacketType Type { get { return PacketType.RezSingleAttachmentFromInv; } } - /// ObjectData block - public ObjectDataBlock ObjectData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.RezSingleAttachmentFromInv + public override PacketType Type { get { return PacketType.RezSingleAttachmentFromInv; } } + /// ObjectData block + public ObjectDataBlock ObjectData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public RezSingleAttachmentFromInvPacket() - { - Header = new LowHeader(); - Header.ID = 467; - Header.Reliable = true; - Header.Zerocoded = true; - ObjectData = new ObjectDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 467; + Header.Reliable = true; + Header.Zerocoded = true; + ObjectData = new ObjectDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public RezSingleAttachmentFromInvPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - ObjectData = new ObjectDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + ObjectData = new ObjectDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public RezSingleAttachmentFromInvPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - ObjectData = new ObjectDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + ObjectData = new ObjectDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += ObjectData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - ObjectData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += ObjectData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + ObjectData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- RezSingleAttachmentFromInv ---\n"; - output += ObjectData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- RezSingleAttachmentFromInv ---\n"; + output += ObjectData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// RezMultipleAttachmentsFromInv packet + + /// RezMultipleAttachmentsFromInv packet public class RezMultipleAttachmentsFromInvPacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - private byte[] _name; - /// Name field + { + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - /// ItemFlags field - public uint ItemFlags; - /// OwnerID field - public LLUUID OwnerID; - /// ItemID field - public LLUUID ItemID; - /// EveryoneMask field - public uint EveryoneMask; - private byte[] _description; - /// Description field + } + /// ItemFlags field + public uint ItemFlags; + /// OwnerID field + public LLUUID OwnerID; + /// ItemID field + public LLUUID ItemID; + /// EveryoneMask field + public uint EveryoneMask; + private byte[] _description; + /// Description field public byte[] Description - { - get { return _description; } + { + get { return _description; } set - { - if (value == null) { _description = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } + { + if (value == null) { _description = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } } - } - /// AttachmentPt field - public byte AttachmentPt; - /// NextOwnerMask field - public uint NextOwnerMask; - /// GroupMask field - public uint GroupMask; - - /// Length of this block serialized in bytes + } + /// AttachmentPt field + public byte AttachmentPt; + /// NextOwnerMask field + public uint NextOwnerMask; + /// GroupMask field + public uint GroupMask; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 49; - if (Name != null) { length += 1 + Name.Length; } - if (Description != null) { length += 1 + Description.Length; } - return length; + { + int length = 49; + if (Name != null) { length += 1 + Name.Length; } + if (Description != null) { length += 1 + Description.Length; } + return length; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; - ItemFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - OwnerID = new LLUUID(bytes, i); i += 16; - ItemID = new LLUUID(bytes, i); i += 16; - EveryoneMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _description = new byte[length]; - Array.Copy(bytes, i, _description, 0, length); i += length; - AttachmentPt = (byte)bytes[i++]; - NextOwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - GroupMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; + ItemFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + OwnerID = new LLUUID(bytes, i); i += 16; + ItemID = new LLUUID(bytes, i); i += 16; + EveryoneMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _description = new byte[length]; + Array.Copy(bytes, i, _description, 0, length); i += length; + AttachmentPt = (byte)bytes[i++]; + NextOwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + GroupMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; - bytes[i++] = (byte)(ItemFlags % 256); - bytes[i++] = (byte)((ItemFlags >> 8) % 256); - bytes[i++] = (byte)((ItemFlags >> 16) % 256); - bytes[i++] = (byte)((ItemFlags >> 24) % 256); - if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } - Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; - if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } - Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(EveryoneMask % 256); - bytes[i++] = (byte)((EveryoneMask >> 8) % 256); - bytes[i++] = (byte)((EveryoneMask >> 16) % 256); - bytes[i++] = (byte)((EveryoneMask >> 24) % 256); - if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } - bytes[i++] = (byte)Description.Length; - Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; - bytes[i++] = AttachmentPt; - bytes[i++] = (byte)(NextOwnerMask % 256); - bytes[i++] = (byte)((NextOwnerMask >> 8) % 256); - bytes[i++] = (byte)((NextOwnerMask >> 16) % 256); - bytes[i++] = (byte)((NextOwnerMask >> 24) % 256); - bytes[i++] = (byte)(GroupMask % 256); - bytes[i++] = (byte)((GroupMask >> 8) % 256); - bytes[i++] = (byte)((GroupMask >> 16) % 256); - bytes[i++] = (byte)((GroupMask >> 24) % 256); + { + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + bytes[i++] = (byte)(ItemFlags % 256); + bytes[i++] = (byte)((ItemFlags >> 8) % 256); + bytes[i++] = (byte)((ItemFlags >> 16) % 256); + bytes[i++] = (byte)((ItemFlags >> 24) % 256); + if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } + Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; + if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } + Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(EveryoneMask % 256); + bytes[i++] = (byte)((EveryoneMask >> 8) % 256); + bytes[i++] = (byte)((EveryoneMask >> 16) % 256); + bytes[i++] = (byte)((EveryoneMask >> 24) % 256); + if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } + bytes[i++] = (byte)Description.Length; + Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; + bytes[i++] = AttachmentPt; + bytes[i++] = (byte)(NextOwnerMask % 256); + bytes[i++] = (byte)((NextOwnerMask >> 8) % 256); + bytes[i++] = (byte)((NextOwnerMask >> 16) % 256); + bytes[i++] = (byte)((NextOwnerMask >> 24) % 256); + bytes[i++] = (byte)(GroupMask % 256); + bytes[i++] = (byte)((GroupMask >> 8) % 256); + bytes[i++] = (byte)((GroupMask >> 16) % 256); + bytes[i++] = (byte)((GroupMask >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; - output += "ItemFlags: " + ItemFlags.ToString() + "\n"; - output += "OwnerID: " + OwnerID.ToString() + "\n"; - output += "ItemID: " + ItemID.ToString() + "\n"; - output += "EveryoneMask: " + EveryoneMask.ToString() + "\n"; - output += Helpers.FieldToString(Description, "Description") + "\n"; - output += "AttachmentPt: " + AttachmentPt.ToString() + "\n"; - output += "NextOwnerMask: " + NextOwnerMask.ToString() + "\n"; - output += "GroupMask: " + GroupMask.ToString() + "\n"; + { + string output = "-- ObjectData --\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; + output += "ItemFlags: " + ItemFlags.ToString() + "\n"; + output += "OwnerID: " + OwnerID.ToString() + "\n"; + output += "ItemID: " + ItemID.ToString() + "\n"; + output += "EveryoneMask: " + EveryoneMask.ToString() + "\n"; + output += Helpers.FieldToString(Description, "Description") + "\n"; + output += "AttachmentPt: " + AttachmentPt.ToString() + "\n"; + output += "NextOwnerMask: " + NextOwnerMask.ToString() + "\n"; + output += "GroupMask: " + GroupMask.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// HeaderData block + + /// HeaderData block public class HeaderDataBlock - { - /// CompoundMsgID field - public LLUUID CompoundMsgID; - /// FirstDetachAll field - public bool FirstDetachAll; - /// TotalObjects field - public byte TotalObjects; - - /// Length of this block serialized in bytes + { + /// CompoundMsgID field + public LLUUID CompoundMsgID; + /// FirstDetachAll field + public bool FirstDetachAll; + /// TotalObjects field + public byte TotalObjects; + + /// Length of this block serialized in bytes public int Length { get - { - return 18; + { + return 18; } } - - /// Default constructor - public HeaderDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public HeaderDataBlock() { } + /// Constructor for building the block from a byte array public HeaderDataBlock(byte[] bytes, ref int i) - { + { try - { - CompoundMsgID = new LLUUID(bytes, i); i += 16; - FirstDetachAll = (bytes[i++] != 0) ? (bool)true : (bool)false; - TotalObjects = (byte)bytes[i++]; + { + CompoundMsgID = new LLUUID(bytes, i); i += 16; + FirstDetachAll = (bytes[i++] != 0) ? (bool)true : (bool)false; + TotalObjects = (byte)bytes[i++]; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(CompoundMsgID == null) { Console.WriteLine("Warning: CompoundMsgID is null, in " + this.GetType()); } - Array.Copy(CompoundMsgID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((FirstDetachAll) ? 1 : 0); - bytes[i++] = TotalObjects; + { + if(CompoundMsgID == null) { Console.WriteLine("Warning: CompoundMsgID is null, in " + this.GetType()); } + Array.Copy(CompoundMsgID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((FirstDetachAll) ? 1 : 0); + bytes[i++] = TotalObjects; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- HeaderData --\n"; - output += "CompoundMsgID: " + CompoundMsgID.ToString() + "\n"; - output += "FirstDetachAll: " + FirstDetachAll.ToString() + "\n"; - output += "TotalObjects: " + TotalObjects.ToString() + "\n"; + { + string output = "-- HeaderData --\n"; + output += "CompoundMsgID: " + CompoundMsgID.ToString() + "\n"; + output += "FirstDetachAll: " + FirstDetachAll.ToString() + "\n"; + output += "TotalObjects: " + TotalObjects.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.RezMultipleAttachmentsFromInv - public override PacketType Type { get { return PacketType.RezMultipleAttachmentsFromInv; } } - /// ObjectData block - public ObjectDataBlock[] ObjectData; - /// AgentData block - public AgentDataBlock AgentData; - /// HeaderData block - public HeaderDataBlock HeaderData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.RezMultipleAttachmentsFromInv + public override PacketType Type { get { return PacketType.RezMultipleAttachmentsFromInv; } } + /// ObjectData block + public ObjectDataBlock[] ObjectData; + /// AgentData block + public AgentDataBlock AgentData; + /// HeaderData block + public HeaderDataBlock HeaderData; + + /// Default constructor public RezMultipleAttachmentsFromInvPacket() - { - Header = new LowHeader(); - Header.ID = 468; - Header.Reliable = true; - Header.Zerocoded = true; - ObjectData = new ObjectDataBlock[0]; - AgentData = new AgentDataBlock(); - HeaderData = new HeaderDataBlock(); + { + Header = new LowHeader(); + Header.ID = 468; + Header.Reliable = true; + Header.Zerocoded = true; + ObjectData = new ObjectDataBlock[0]; + AgentData = new AgentDataBlock(); + HeaderData = new HeaderDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public RezMultipleAttachmentsFromInvPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); - HeaderData = new HeaderDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); + HeaderData = new HeaderDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public RezMultipleAttachmentsFromInvPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); - HeaderData = new HeaderDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); + HeaderData = new HeaderDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length; length += HeaderData.Length;; - length++; - for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ObjectData.Length; - for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - HeaderData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length; length += HeaderData.Length;; + length++; + for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ObjectData.Length; + for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + HeaderData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- RezMultipleAttachmentsFromInv ---\n"; + { + string output = "--- RezMultipleAttachmentsFromInv ---\n"; for (int j = 0; j < ObjectData.Length; j++) - { + { output += ObjectData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; - output += HeaderData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; + output += HeaderData.ToString() + "\n"; return output; } - + } - - /// DetachAttachmentIntoInv packet + + /// DetachAttachmentIntoInv packet public class DetachAttachmentIntoInvPacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// ItemID field - public LLUUID ItemID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// ItemID field + public LLUUID ItemID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - ItemID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + ItemID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } - Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } + Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "ItemID: " + ItemID.ToString() + "\n"; + { + string output = "-- ObjectData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "ItemID: " + ItemID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.DetachAttachmentIntoInv - public override PacketType Type { get { return PacketType.DetachAttachmentIntoInv; } } - /// ObjectData block - public ObjectDataBlock ObjectData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.DetachAttachmentIntoInv + public override PacketType Type { get { return PacketType.DetachAttachmentIntoInv; } } + /// ObjectData block + public ObjectDataBlock ObjectData; + + /// Default constructor public DetachAttachmentIntoInvPacket() - { - Header = new LowHeader(); - Header.ID = 469; - Header.Reliable = true; - ObjectData = new ObjectDataBlock(); + { + Header = new LowHeader(); + Header.ID = 469; + Header.Reliable = true; + ObjectData = new ObjectDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public DetachAttachmentIntoInvPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - ObjectData = new ObjectDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + ObjectData = new ObjectDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public DetachAttachmentIntoInvPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - ObjectData = new ObjectDataBlock(bytes, ref i); + { + Header = head; + ObjectData = new ObjectDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += ObjectData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - ObjectData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += ObjectData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + ObjectData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- DetachAttachmentIntoInv ---\n"; - output += ObjectData.ToString() + "\n"; + { + string output = "--- DetachAttachmentIntoInv ---\n"; + output += ObjectData.ToString() + "\n"; return output; } - + } - - /// CreateNewOutfitAttachments packet + + /// CreateNewOutfitAttachments packet public class CreateNewOutfitAttachmentsPacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - /// OldFolderID field - public LLUUID OldFolderID; - /// OldItemID field - public LLUUID OldItemID; - - /// Length of this block serialized in bytes + { + /// OldFolderID field + public LLUUID OldFolderID; + /// OldItemID field + public LLUUID OldItemID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { + { try - { - OldFolderID = new LLUUID(bytes, i); i += 16; - OldItemID = new LLUUID(bytes, i); i += 16; + { + OldFolderID = new LLUUID(bytes, i); i += 16; + OldItemID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(OldFolderID == null) { Console.WriteLine("Warning: OldFolderID is null, in " + this.GetType()); } - Array.Copy(OldFolderID.GetBytes(), 0, bytes, i, 16); i += 16; - if(OldItemID == null) { Console.WriteLine("Warning: OldItemID is null, in " + this.GetType()); } - Array.Copy(OldItemID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(OldFolderID == null) { Console.WriteLine("Warning: OldFolderID is null, in " + this.GetType()); } + Array.Copy(OldFolderID.GetBytes(), 0, bytes, i, 16); i += 16; + if(OldItemID == null) { Console.WriteLine("Warning: OldItemID is null, in " + this.GetType()); } + Array.Copy(OldItemID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += "OldFolderID: " + OldFolderID.ToString() + "\n"; - output += "OldItemID: " + OldItemID.ToString() + "\n"; + { + string output = "-- ObjectData --\n"; + output += "OldFolderID: " + OldFolderID.ToString() + "\n"; + output += "OldItemID: " + OldItemID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// HeaderData block + + /// HeaderData block public class HeaderDataBlock - { - /// NewFolderID field - public LLUUID NewFolderID; - - /// Length of this block serialized in bytes + { + /// NewFolderID field + public LLUUID NewFolderID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public HeaderDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public HeaderDataBlock() { } + /// Constructor for building the block from a byte array public HeaderDataBlock(byte[] bytes, ref int i) - { + { try - { - NewFolderID = new LLUUID(bytes, i); i += 16; + { + NewFolderID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(NewFolderID == null) { Console.WriteLine("Warning: NewFolderID is null, in " + this.GetType()); } - Array.Copy(NewFolderID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(NewFolderID == null) { Console.WriteLine("Warning: NewFolderID is null, in " + this.GetType()); } + Array.Copy(NewFolderID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- HeaderData --\n"; - output += "NewFolderID: " + NewFolderID.ToString() + "\n"; + { + string output = "-- HeaderData --\n"; + output += "NewFolderID: " + NewFolderID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.CreateNewOutfitAttachments - public override PacketType Type { get { return PacketType.CreateNewOutfitAttachments; } } - /// ObjectData block - public ObjectDataBlock[] ObjectData; - /// AgentData block - public AgentDataBlock AgentData; - /// HeaderData block - public HeaderDataBlock HeaderData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.CreateNewOutfitAttachments + public override PacketType Type { get { return PacketType.CreateNewOutfitAttachments; } } + /// ObjectData block + public ObjectDataBlock[] ObjectData; + /// AgentData block + public AgentDataBlock AgentData; + /// HeaderData block + public HeaderDataBlock HeaderData; + + /// Default constructor public CreateNewOutfitAttachmentsPacket() - { - Header = new LowHeader(); - Header.ID = 470; - Header.Reliable = true; - ObjectData = new ObjectDataBlock[0]; - AgentData = new AgentDataBlock(); - HeaderData = new HeaderDataBlock(); + { + Header = new LowHeader(); + Header.ID = 470; + Header.Reliable = true; + ObjectData = new ObjectDataBlock[0]; + AgentData = new AgentDataBlock(); + HeaderData = new HeaderDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public CreateNewOutfitAttachmentsPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); - HeaderData = new HeaderDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); + HeaderData = new HeaderDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public CreateNewOutfitAttachmentsPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); - HeaderData = new HeaderDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); + HeaderData = new HeaderDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length; length += HeaderData.Length;; - length++; - for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ObjectData.Length; - for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - HeaderData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length; length += HeaderData.Length;; + length++; + for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ObjectData.Length; + for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + HeaderData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- CreateNewOutfitAttachments ---\n"; + { + string output = "--- CreateNewOutfitAttachments ---\n"; for (int j = 0; j < ObjectData.Length; j++) - { + { output += ObjectData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; - output += HeaderData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; + output += HeaderData.ToString() + "\n"; return output; } - + } - - /// UserInfoRequest packet + + /// UserInfoRequest packet public class UserInfoRequestPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.UserInfoRequest - public override PacketType Type { get { return PacketType.UserInfoRequest; } } - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.UserInfoRequest + public override PacketType Type { get { return PacketType.UserInfoRequest; } } + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public UserInfoRequestPacket() - { - Header = new LowHeader(); - Header.ID = 471; - Header.Reliable = true; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 471; + Header.Reliable = true; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public UserInfoRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public UserInfoRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- UserInfoRequest ---\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- UserInfoRequest ---\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// UserInfoReply packet + + /// UserInfoReply packet public class UserInfoReplyPacket : Packet - { - /// UserData block + { + /// UserData block public class UserDataBlock - { - private byte[] _email; - /// EMail field + { + private byte[] _email; + /// EMail field public byte[] EMail - { - get { return _email; } + { + get { return _email; } set - { - if (value == null) { _email = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _email = new byte[value.Length]; Array.Copy(value, _email, value.Length); } + { + if (value == null) { _email = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _email = new byte[value.Length]; Array.Copy(value, _email, value.Length); } } - } - /// IMViaEMail field - public bool IMViaEMail; - - /// Length of this block serialized in bytes + } + /// IMViaEMail field + public bool IMViaEMail; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 1; - if (EMail != null) { length += 2 + EMail.Length; } - return length; + { + int length = 1; + if (EMail != null) { length += 2 + EMail.Length; } + return length; } } - - /// Default constructor - public UserDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public UserDataBlock() { } + /// Constructor for building the block from a byte array public UserDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _email = new byte[length]; - Array.Copy(bytes, i, _email, 0, length); i += length; - IMViaEMail = (bytes[i++] != 0) ? (bool)true : (bool)false; + { + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _email = new byte[length]; + Array.Copy(bytes, i, _email, 0, length); i += length; + IMViaEMail = (bytes[i++] != 0) ? (bool)true : (bool)false; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(EMail == null) { Console.WriteLine("Warning: EMail is null, in " + this.GetType()); } - bytes[i++] = (byte)(EMail.Length % 256); - bytes[i++] = (byte)((EMail.Length >> 8) % 256); - Array.Copy(EMail, 0, bytes, i, EMail.Length); i += EMail.Length; - bytes[i++] = (byte)((IMViaEMail) ? 1 : 0); + { + if(EMail == null) { Console.WriteLine("Warning: EMail is null, in " + this.GetType()); } + bytes[i++] = (byte)(EMail.Length % 256); + bytes[i++] = (byte)((EMail.Length >> 8) % 256); + Array.Copy(EMail, 0, bytes, i, EMail.Length); i += EMail.Length; + bytes[i++] = (byte)((IMViaEMail) ? 1 : 0); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- UserData --\n"; - output += Helpers.FieldToString(EMail, "EMail") + "\n"; - output += "IMViaEMail: " + IMViaEMail.ToString() + "\n"; + { + string output = "-- UserData --\n"; + output += Helpers.FieldToString(EMail, "EMail") + "\n"; + output += "IMViaEMail: " + IMViaEMail.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.UserInfoReply - public override PacketType Type { get { return PacketType.UserInfoReply; } } - /// UserData block - public UserDataBlock UserData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.UserInfoReply + public override PacketType Type { get { return PacketType.UserInfoReply; } } + /// UserData block + public UserDataBlock UserData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public UserInfoReplyPacket() - { - Header = new LowHeader(); - Header.ID = 472; - Header.Reliable = true; - UserData = new UserDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 472; + Header.Reliable = true; + UserData = new UserDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public UserInfoReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - UserData = new UserDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + UserData = new UserDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public UserInfoReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - UserData = new UserDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + UserData = new UserDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += UserData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - UserData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += UserData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + UserData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- UserInfoReply ---\n"; - output += UserData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- UserInfoReply ---\n"; + output += UserData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// UpdateUserInfo packet + + /// UpdateUserInfo packet public class UpdateUserInfoPacket : Packet - { - /// UserData block + { + /// UserData block public class UserDataBlock - { - /// IMViaEMail field - public bool IMViaEMail; - - /// Length of this block serialized in bytes + { + /// IMViaEMail field + public bool IMViaEMail; + + /// Length of this block serialized in bytes public int Length { get - { - return 1; + { + return 1; } } - - /// Default constructor - public UserDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public UserDataBlock() { } + /// Constructor for building the block from a byte array public UserDataBlock(byte[] bytes, ref int i) - { + { try - { - IMViaEMail = (bytes[i++] != 0) ? (bool)true : (bool)false; + { + IMViaEMail = (bytes[i++] != 0) ? (bool)true : (bool)false; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)((IMViaEMail) ? 1 : 0); + { + bytes[i++] = (byte)((IMViaEMail) ? 1 : 0); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- UserData --\n"; - output += "IMViaEMail: " + IMViaEMail.ToString() + "\n"; + { + string output = "-- UserData --\n"; + output += "IMViaEMail: " + IMViaEMail.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.UpdateUserInfo - public override PacketType Type { get { return PacketType.UpdateUserInfo; } } - /// UserData block - public UserDataBlock UserData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.UpdateUserInfo + public override PacketType Type { get { return PacketType.UpdateUserInfo; } } + /// UserData block + public UserDataBlock UserData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public UpdateUserInfoPacket() - { - Header = new LowHeader(); - Header.ID = 473; - Header.Reliable = true; - UserData = new UserDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 473; + Header.Reliable = true; + UserData = new UserDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public UpdateUserInfoPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - UserData = new UserDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + UserData = new UserDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public UpdateUserInfoPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - UserData = new UserDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + UserData = new UserDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += UserData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - UserData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += UserData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + UserData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- UpdateUserInfo ---\n"; - output += UserData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- UpdateUserInfo ---\n"; + output += UserData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// GodExpungeUser packet + + /// GodExpungeUser packet public class GodExpungeUserPacket : Packet - { - /// ExpungeData block + { + /// ExpungeData block public class ExpungeDataBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public ExpungeDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ExpungeDataBlock() { } + /// Constructor for building the block from a byte array public ExpungeDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ExpungeData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- ExpungeData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.GodExpungeUser - public override PacketType Type { get { return PacketType.GodExpungeUser; } } - /// ExpungeData block - public ExpungeDataBlock[] ExpungeData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.GodExpungeUser + public override PacketType Type { get { return PacketType.GodExpungeUser; } } + /// ExpungeData block + public ExpungeDataBlock[] ExpungeData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public GodExpungeUserPacket() - { - Header = new LowHeader(); - Header.ID = 474; - Header.Reliable = true; - Header.Zerocoded = true; - ExpungeData = new ExpungeDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 474; + Header.Reliable = true; + Header.Zerocoded = true; + ExpungeData = new ExpungeDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public GodExpungeUserPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ExpungeData = new ExpungeDataBlock[count]; - for (int j = 0; j < count; j++) - { ExpungeData[j] = new ExpungeDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ExpungeData = new ExpungeDataBlock[count]; + for (int j = 0; j < count; j++) + { ExpungeData[j] = new ExpungeDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public GodExpungeUserPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ExpungeData = new ExpungeDataBlock[count]; - for (int j = 0; j < count; j++) - { ExpungeData[j] = new ExpungeDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + ExpungeData = new ExpungeDataBlock[count]; + for (int j = 0; j < count; j++) + { ExpungeData[j] = new ExpungeDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < ExpungeData.Length; j++) { length += ExpungeData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ExpungeData.Length; - for (int j = 0; j < ExpungeData.Length; j++) { ExpungeData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < ExpungeData.Length; j++) { length += ExpungeData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ExpungeData.Length; + for (int j = 0; j < ExpungeData.Length; j++) { ExpungeData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- GodExpungeUser ---\n"; + { + string output = "--- GodExpungeUser ---\n"; for (int j = 0; j < ExpungeData.Length; j++) - { + { output += ExpungeData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// StartExpungeProcess packet + + /// StartExpungeProcess packet public class StartExpungeProcessPacket : Packet - { - /// ExpungeData block + { + /// ExpungeData block public class ExpungeDataBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public ExpungeDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ExpungeDataBlock() { } + /// Constructor for building the block from a byte array public ExpungeDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ExpungeData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- ExpungeData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.StartExpungeProcess - public override PacketType Type { get { return PacketType.StartExpungeProcess; } } - /// ExpungeData block - public ExpungeDataBlock[] ExpungeData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.StartExpungeProcess + public override PacketType Type { get { return PacketType.StartExpungeProcess; } } + /// ExpungeData block + public ExpungeDataBlock[] ExpungeData; + + /// Default constructor public StartExpungeProcessPacket() - { - Header = new LowHeader(); - Header.ID = 475; - Header.Reliable = true; - Header.Zerocoded = true; - ExpungeData = new ExpungeDataBlock[0]; + { + Header = new LowHeader(); + Header.ID = 475; + Header.Reliable = true; + Header.Zerocoded = true; + ExpungeData = new ExpungeDataBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public StartExpungeProcessPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ExpungeData = new ExpungeDataBlock[count]; - for (int j = 0; j < count; j++) - { ExpungeData[j] = new ExpungeDataBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ExpungeData = new ExpungeDataBlock[count]; + for (int j = 0; j < count; j++) + { ExpungeData[j] = new ExpungeDataBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public StartExpungeProcessPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ExpungeData = new ExpungeDataBlock[count]; - for (int j = 0; j < count; j++) - { ExpungeData[j] = new ExpungeDataBlock(bytes, ref i); } + { + Header = head; + int count = (int)bytes[i++]; + ExpungeData = new ExpungeDataBlock[count]; + for (int j = 0; j < count; j++) + { ExpungeData[j] = new ExpungeDataBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; -; - length++; - for (int j = 0; j < ExpungeData.Length; j++) { length += ExpungeData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ExpungeData.Length; - for (int j = 0; j < ExpungeData.Length; j++) { ExpungeData[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; +; + length++; + for (int j = 0; j < ExpungeData.Length; j++) { length += ExpungeData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ExpungeData.Length; + for (int j = 0; j < ExpungeData.Length; j++) { ExpungeData[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- StartExpungeProcess ---\n"; + { + string output = "--- StartExpungeProcess ---\n"; for (int j = 0; j < ExpungeData.Length; j++) - { + { output += ExpungeData[j].ToString() + "\n"; - } + } return output; } - + } - - /// StartExpungeProcessAck packet + + /// StartExpungeProcessAck packet public class StartExpungeProcessAckPacket : Packet - { - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.StartExpungeProcessAck - public override PacketType Type { get { return PacketType.StartExpungeProcessAck; } } - - /// Default constructor + { + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.StartExpungeProcessAck + public override PacketType Type { get { return PacketType.StartExpungeProcessAck; } } + + /// Default constructor public StartExpungeProcessAckPacket() - { - Header = new LowHeader(); - Header.ID = 476; - Header.Reliable = true; + { + Header = new LowHeader(); + Header.ID = 476; + Header.Reliable = true; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public StartExpungeProcessAckPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public StartExpungeProcessAckPacket(Header head, byte[] bytes, ref int i) - { - Header = head; + { + Header = head; } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; -; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; +; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- StartExpungeProcessAck ---\n"; + { + string output = "--- StartExpungeProcessAck ---\n"; return output; } - + } - - /// StartParcelRename packet + + /// StartParcelRename packet public class StartParcelRenamePacket : Packet - { - /// ParcelData block + { + /// ParcelData block public class ParcelDataBlock - { - private byte[] _newname; - /// NewName field + { + private byte[] _newname; + /// NewName field public byte[] NewName - { - get { return _newname; } + { + get { return _newname; } set - { - if (value == null) { _newname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _newname = new byte[value.Length]; Array.Copy(value, _newname, value.Length); } + { + if (value == null) { _newname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _newname = new byte[value.Length]; Array.Copy(value, _newname, value.Length); } } - } - /// ParcelID field - public LLUUID ParcelID; - - /// Length of this block serialized in bytes + } + /// ParcelID field + public LLUUID ParcelID; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 16; - if (NewName != null) { length += 1 + NewName.Length; } - return length; + { + int length = 16; + if (NewName != null) { length += 1 + NewName.Length; } + return length; } } - - /// Default constructor - public ParcelDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ParcelDataBlock() { } + /// Constructor for building the block from a byte array public ParcelDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _newname = new byte[length]; - Array.Copy(bytes, i, _newname, 0, length); i += length; - ParcelID = new LLUUID(bytes, i); i += 16; + { + length = (ushort)bytes[i++]; + _newname = new byte[length]; + Array.Copy(bytes, i, _newname, 0, length); i += length; + ParcelID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(NewName == null) { Console.WriteLine("Warning: NewName is null, in " + this.GetType()); } - bytes[i++] = (byte)NewName.Length; - Array.Copy(NewName, 0, bytes, i, NewName.Length); i += NewName.Length; - if(ParcelID == null) { Console.WriteLine("Warning: ParcelID is null, in " + this.GetType()); } - Array.Copy(ParcelID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(NewName == null) { Console.WriteLine("Warning: NewName is null, in " + this.GetType()); } + bytes[i++] = (byte)NewName.Length; + Array.Copy(NewName, 0, bytes, i, NewName.Length); i += NewName.Length; + if(ParcelID == null) { Console.WriteLine("Warning: ParcelID is null, in " + this.GetType()); } + Array.Copy(ParcelID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ParcelData --\n"; - output += Helpers.FieldToString(NewName, "NewName") + "\n"; - output += "ParcelID: " + ParcelID.ToString() + "\n"; + { + string output = "-- ParcelData --\n"; + output += Helpers.FieldToString(NewName, "NewName") + "\n"; + output += "ParcelID: " + ParcelID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.StartParcelRename - public override PacketType Type { get { return PacketType.StartParcelRename; } } - /// ParcelData block - public ParcelDataBlock[] ParcelData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.StartParcelRename + public override PacketType Type { get { return PacketType.StartParcelRename; } } + /// ParcelData block + public ParcelDataBlock[] ParcelData; + + /// Default constructor public StartParcelRenamePacket() - { - Header = new LowHeader(); - Header.ID = 477; - Header.Reliable = true; - ParcelData = new ParcelDataBlock[0]; + { + Header = new LowHeader(); + Header.ID = 477; + Header.Reliable = true; + ParcelData = new ParcelDataBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public StartParcelRenamePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ParcelData = new ParcelDataBlock[count]; - for (int j = 0; j < count; j++) - { ParcelData[j] = new ParcelDataBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ParcelData = new ParcelDataBlock[count]; + for (int j = 0; j < count; j++) + { ParcelData[j] = new ParcelDataBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public StartParcelRenamePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ParcelData = new ParcelDataBlock[count]; - for (int j = 0; j < count; j++) - { ParcelData[j] = new ParcelDataBlock(bytes, ref i); } + { + Header = head; + int count = (int)bytes[i++]; + ParcelData = new ParcelDataBlock[count]; + for (int j = 0; j < count; j++) + { ParcelData[j] = new ParcelDataBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; -; - length++; - for (int j = 0; j < ParcelData.Length; j++) { length += ParcelData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ParcelData.Length; - for (int j = 0; j < ParcelData.Length; j++) { ParcelData[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; +; + length++; + for (int j = 0; j < ParcelData.Length; j++) { length += ParcelData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ParcelData.Length; + for (int j = 0; j < ParcelData.Length; j++) { ParcelData[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- StartParcelRename ---\n"; + { + string output = "--- StartParcelRename ---\n"; for (int j = 0; j < ParcelData.Length; j++) - { + { output += ParcelData[j].ToString() + "\n"; - } + } return output; } - + } - - /// StartParcelRenameAck packet + + /// StartParcelRenameAck packet public class StartParcelRenameAckPacket : Packet - { - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.StartParcelRenameAck - public override PacketType Type { get { return PacketType.StartParcelRenameAck; } } - - /// Default constructor + { + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.StartParcelRenameAck + public override PacketType Type { get { return PacketType.StartParcelRenameAck; } } + + /// Default constructor public StartParcelRenameAckPacket() - { - Header = new LowHeader(); - Header.ID = 478; - Header.Reliable = true; + { + Header = new LowHeader(); + Header.ID = 478; + Header.Reliable = true; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public StartParcelRenameAckPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public StartParcelRenameAckPacket(Header head, byte[] bytes, ref int i) - { - Header = head; + { + Header = head; } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; -; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; +; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- StartParcelRenameAck ---\n"; + { + string output = "--- StartParcelRenameAck ---\n"; return output; } - + } - - /// BulkParcelRename packet + + /// BulkParcelRename packet public class BulkParcelRenamePacket : Packet - { - /// ParcelData block + { + /// ParcelData block public class ParcelDataBlock - { - private byte[] _newname; - /// NewName field + { + private byte[] _newname; + /// NewName field public byte[] NewName - { - get { return _newname; } + { + get { return _newname; } set - { - if (value == null) { _newname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _newname = new byte[value.Length]; Array.Copy(value, _newname, value.Length); } + { + if (value == null) { _newname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _newname = new byte[value.Length]; Array.Copy(value, _newname, value.Length); } } - } - /// ParcelID field - public LLUUID ParcelID; - /// RegionHandle field - public ulong RegionHandle; - - /// Length of this block serialized in bytes + } + /// ParcelID field + public LLUUID ParcelID; + /// RegionHandle field + public ulong RegionHandle; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 24; - if (NewName != null) { length += 1 + NewName.Length; } - return length; + { + int length = 24; + if (NewName != null) { length += 1 + NewName.Length; } + return length; } } - - /// Default constructor - public ParcelDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ParcelDataBlock() { } + /// Constructor for building the block from a byte array public ParcelDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _newname = new byte[length]; - Array.Copy(bytes, i, _newname, 0, length); i += length; - ParcelID = new LLUUID(bytes, i); i += 16; - RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + { + length = (ushort)bytes[i++]; + _newname = new byte[length]; + Array.Copy(bytes, i, _newname, 0, length); i += length; + ParcelID = new LLUUID(bytes, i); i += 16; + RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(NewName == null) { Console.WriteLine("Warning: NewName is null, in " + this.GetType()); } - bytes[i++] = (byte)NewName.Length; - Array.Copy(NewName, 0, bytes, i, NewName.Length); i += NewName.Length; - if(ParcelID == null) { Console.WriteLine("Warning: ParcelID is null, in " + this.GetType()); } - Array.Copy(ParcelID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(RegionHandle % 256); - bytes[i++] = (byte)((RegionHandle >> 8) % 256); - bytes[i++] = (byte)((RegionHandle >> 16) % 256); - bytes[i++] = (byte)((RegionHandle >> 24) % 256); - bytes[i++] = (byte)((RegionHandle >> 32) % 256); - bytes[i++] = (byte)((RegionHandle >> 40) % 256); - bytes[i++] = (byte)((RegionHandle >> 48) % 256); - bytes[i++] = (byte)((RegionHandle >> 56) % 256); + { + if(NewName == null) { Console.WriteLine("Warning: NewName is null, in " + this.GetType()); } + bytes[i++] = (byte)NewName.Length; + Array.Copy(NewName, 0, bytes, i, NewName.Length); i += NewName.Length; + if(ParcelID == null) { Console.WriteLine("Warning: ParcelID is null, in " + this.GetType()); } + Array.Copy(ParcelID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(RegionHandle % 256); + bytes[i++] = (byte)((RegionHandle >> 8) % 256); + bytes[i++] = (byte)((RegionHandle >> 16) % 256); + bytes[i++] = (byte)((RegionHandle >> 24) % 256); + bytes[i++] = (byte)((RegionHandle >> 32) % 256); + bytes[i++] = (byte)((RegionHandle >> 40) % 256); + bytes[i++] = (byte)((RegionHandle >> 48) % 256); + bytes[i++] = (byte)((RegionHandle >> 56) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ParcelData --\n"; - output += Helpers.FieldToString(NewName, "NewName") + "\n"; - output += "ParcelID: " + ParcelID.ToString() + "\n"; - output += "RegionHandle: " + RegionHandle.ToString() + "\n"; + { + string output = "-- ParcelData --\n"; + output += Helpers.FieldToString(NewName, "NewName") + "\n"; + output += "ParcelID: " + ParcelID.ToString() + "\n"; + output += "RegionHandle: " + RegionHandle.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.BulkParcelRename - public override PacketType Type { get { return PacketType.BulkParcelRename; } } - /// ParcelData block - public ParcelDataBlock[] ParcelData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.BulkParcelRename + public override PacketType Type { get { return PacketType.BulkParcelRename; } } + /// ParcelData block + public ParcelDataBlock[] ParcelData; + + /// Default constructor public BulkParcelRenamePacket() - { - Header = new LowHeader(); - Header.ID = 479; - Header.Reliable = true; - Header.Zerocoded = true; - ParcelData = new ParcelDataBlock[0]; + { + Header = new LowHeader(); + Header.ID = 479; + Header.Reliable = true; + Header.Zerocoded = true; + ParcelData = new ParcelDataBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public BulkParcelRenamePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ParcelData = new ParcelDataBlock[count]; - for (int j = 0; j < count; j++) - { ParcelData[j] = new ParcelDataBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ParcelData = new ParcelDataBlock[count]; + for (int j = 0; j < count; j++) + { ParcelData[j] = new ParcelDataBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public BulkParcelRenamePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ParcelData = new ParcelDataBlock[count]; - for (int j = 0; j < count; j++) - { ParcelData[j] = new ParcelDataBlock(bytes, ref i); } + { + Header = head; + int count = (int)bytes[i++]; + ParcelData = new ParcelDataBlock[count]; + for (int j = 0; j < count; j++) + { ParcelData[j] = new ParcelDataBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; -; - length++; - for (int j = 0; j < ParcelData.Length; j++) { length += ParcelData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ParcelData.Length; - for (int j = 0; j < ParcelData.Length; j++) { ParcelData[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; +; + length++; + for (int j = 0; j < ParcelData.Length; j++) { length += ParcelData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ParcelData.Length; + for (int j = 0; j < ParcelData.Length; j++) { ParcelData[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- BulkParcelRename ---\n"; + { + string output = "--- BulkParcelRename ---\n"; for (int j = 0; j < ParcelData.Length; j++) - { + { output += ParcelData[j].ToString() + "\n"; - } + } return output; } - + } - - /// ParcelRename packet + + /// ParcelRename packet public class ParcelRenamePacket : Packet - { - /// ParcelData block + { + /// ParcelData block public class ParcelDataBlock - { - private byte[] _newname; - /// NewName field + { + private byte[] _newname; + /// NewName field public byte[] NewName - { - get { return _newname; } + { + get { return _newname; } set - { - if (value == null) { _newname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _newname = new byte[value.Length]; Array.Copy(value, _newname, value.Length); } + { + if (value == null) { _newname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _newname = new byte[value.Length]; Array.Copy(value, _newname, value.Length); } } - } - /// ParcelID field - public LLUUID ParcelID; - - /// Length of this block serialized in bytes + } + /// ParcelID field + public LLUUID ParcelID; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 16; - if (NewName != null) { length += 1 + NewName.Length; } - return length; + { + int length = 16; + if (NewName != null) { length += 1 + NewName.Length; } + return length; } } - - /// Default constructor - public ParcelDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ParcelDataBlock() { } + /// Constructor for building the block from a byte array public ParcelDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _newname = new byte[length]; - Array.Copy(bytes, i, _newname, 0, length); i += length; - ParcelID = new LLUUID(bytes, i); i += 16; + { + length = (ushort)bytes[i++]; + _newname = new byte[length]; + Array.Copy(bytes, i, _newname, 0, length); i += length; + ParcelID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(NewName == null) { Console.WriteLine("Warning: NewName is null, in " + this.GetType()); } - bytes[i++] = (byte)NewName.Length; - Array.Copy(NewName, 0, bytes, i, NewName.Length); i += NewName.Length; - if(ParcelID == null) { Console.WriteLine("Warning: ParcelID is null, in " + this.GetType()); } - Array.Copy(ParcelID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(NewName == null) { Console.WriteLine("Warning: NewName is null, in " + this.GetType()); } + bytes[i++] = (byte)NewName.Length; + Array.Copy(NewName, 0, bytes, i, NewName.Length); i += NewName.Length; + if(ParcelID == null) { Console.WriteLine("Warning: ParcelID is null, in " + this.GetType()); } + Array.Copy(ParcelID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ParcelData --\n"; - output += Helpers.FieldToString(NewName, "NewName") + "\n"; - output += "ParcelID: " + ParcelID.ToString() + "\n"; + { + string output = "-- ParcelData --\n"; + output += Helpers.FieldToString(NewName, "NewName") + "\n"; + output += "ParcelID: " + ParcelID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ParcelRename - public override PacketType Type { get { return PacketType.ParcelRename; } } - /// ParcelData block - public ParcelDataBlock[] ParcelData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ParcelRename + public override PacketType Type { get { return PacketType.ParcelRename; } } + /// ParcelData block + public ParcelDataBlock[] ParcelData; + + /// Default constructor public ParcelRenamePacket() - { - Header = new LowHeader(); - Header.ID = 480; - Header.Reliable = true; - ParcelData = new ParcelDataBlock[0]; + { + Header = new LowHeader(); + Header.ID = 480; + Header.Reliable = true; + ParcelData = new ParcelDataBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ParcelRenamePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ParcelData = new ParcelDataBlock[count]; - for (int j = 0; j < count; j++) - { ParcelData[j] = new ParcelDataBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ParcelData = new ParcelDataBlock[count]; + for (int j = 0; j < count; j++) + { ParcelData[j] = new ParcelDataBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ParcelRenamePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ParcelData = new ParcelDataBlock[count]; - for (int j = 0; j < count; j++) - { ParcelData[j] = new ParcelDataBlock(bytes, ref i); } + { + Header = head; + int count = (int)bytes[i++]; + ParcelData = new ParcelDataBlock[count]; + for (int j = 0; j < count; j++) + { ParcelData[j] = new ParcelDataBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; -; - length++; - for (int j = 0; j < ParcelData.Length; j++) { length += ParcelData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ParcelData.Length; - for (int j = 0; j < ParcelData.Length; j++) { ParcelData[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; +; + length++; + for (int j = 0; j < ParcelData.Length; j++) { length += ParcelData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ParcelData.Length; + for (int j = 0; j < ParcelData.Length; j++) { ParcelData[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ParcelRename ---\n"; + { + string output = "--- ParcelRename ---\n"; for (int j = 0; j < ParcelData.Length; j++) - { + { output += ParcelData[j].ToString() + "\n"; - } + } return output; } - + } - - /// StartParcelRemove packet + + /// StartParcelRemove packet public class StartParcelRemovePacket : Packet - { - /// ParcelData block + { + /// ParcelData block public class ParcelDataBlock - { - /// ParcelID field - public LLUUID ParcelID; - - /// Length of this block serialized in bytes + { + /// ParcelID field + public LLUUID ParcelID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public ParcelDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ParcelDataBlock() { } + /// Constructor for building the block from a byte array public ParcelDataBlock(byte[] bytes, ref int i) - { + { try - { - ParcelID = new LLUUID(bytes, i); i += 16; + { + ParcelID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ParcelID == null) { Console.WriteLine("Warning: ParcelID is null, in " + this.GetType()); } - Array.Copy(ParcelID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(ParcelID == null) { Console.WriteLine("Warning: ParcelID is null, in " + this.GetType()); } + Array.Copy(ParcelID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ParcelData --\n"; - output += "ParcelID: " + ParcelID.ToString() + "\n"; + { + string output = "-- ParcelData --\n"; + output += "ParcelID: " + ParcelID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.StartParcelRemove - public override PacketType Type { get { return PacketType.StartParcelRemove; } } - /// ParcelData block - public ParcelDataBlock[] ParcelData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.StartParcelRemove + public override PacketType Type { get { return PacketType.StartParcelRemove; } } + /// ParcelData block + public ParcelDataBlock[] ParcelData; + + /// Default constructor public StartParcelRemovePacket() - { - Header = new LowHeader(); - Header.ID = 481; - Header.Reliable = true; - ParcelData = new ParcelDataBlock[0]; + { + Header = new LowHeader(); + Header.ID = 481; + Header.Reliable = true; + ParcelData = new ParcelDataBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public StartParcelRemovePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ParcelData = new ParcelDataBlock[count]; - for (int j = 0; j < count; j++) - { ParcelData[j] = new ParcelDataBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ParcelData = new ParcelDataBlock[count]; + for (int j = 0; j < count; j++) + { ParcelData[j] = new ParcelDataBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public StartParcelRemovePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ParcelData = new ParcelDataBlock[count]; - for (int j = 0; j < count; j++) - { ParcelData[j] = new ParcelDataBlock(bytes, ref i); } + { + Header = head; + int count = (int)bytes[i++]; + ParcelData = new ParcelDataBlock[count]; + for (int j = 0; j < count; j++) + { ParcelData[j] = new ParcelDataBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; -; - length++; - for (int j = 0; j < ParcelData.Length; j++) { length += ParcelData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ParcelData.Length; - for (int j = 0; j < ParcelData.Length; j++) { ParcelData[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; +; + length++; + for (int j = 0; j < ParcelData.Length; j++) { length += ParcelData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ParcelData.Length; + for (int j = 0; j < ParcelData.Length; j++) { ParcelData[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- StartParcelRemove ---\n"; + { + string output = "--- StartParcelRemove ---\n"; for (int j = 0; j < ParcelData.Length; j++) - { + { output += ParcelData[j].ToString() + "\n"; - } + } return output; } - + } - - /// StartParcelRemoveAck packet + + /// StartParcelRemoveAck packet public class StartParcelRemoveAckPacket : Packet - { - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.StartParcelRemoveAck - public override PacketType Type { get { return PacketType.StartParcelRemoveAck; } } - - /// Default constructor + { + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.StartParcelRemoveAck + public override PacketType Type { get { return PacketType.StartParcelRemoveAck; } } + + /// Default constructor public StartParcelRemoveAckPacket() - { - Header = new LowHeader(); - Header.ID = 482; - Header.Reliable = true; + { + Header = new LowHeader(); + Header.ID = 482; + Header.Reliable = true; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public StartParcelRemoveAckPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public StartParcelRemoveAckPacket(Header head, byte[] bytes, ref int i) - { - Header = head; + { + Header = head; } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; -; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; +; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- StartParcelRemoveAck ---\n"; + { + string output = "--- StartParcelRemoveAck ---\n"; return output; } - + } - - /// BulkParcelRemove packet + + /// BulkParcelRemove packet public class BulkParcelRemovePacket : Packet - { - /// ParcelData block + { + /// ParcelData block public class ParcelDataBlock - { - /// ParcelID field - public LLUUID ParcelID; - /// RegionHandle field - public ulong RegionHandle; - - /// Length of this block serialized in bytes + { + /// ParcelID field + public LLUUID ParcelID; + /// RegionHandle field + public ulong RegionHandle; + + /// Length of this block serialized in bytes public int Length { get - { - return 24; + { + return 24; } } - - /// Default constructor - public ParcelDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ParcelDataBlock() { } + /// Constructor for building the block from a byte array public ParcelDataBlock(byte[] bytes, ref int i) - { + { try - { - ParcelID = new LLUUID(bytes, i); i += 16; - RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + { + ParcelID = new LLUUID(bytes, i); i += 16; + RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ParcelID == null) { Console.WriteLine("Warning: ParcelID is null, in " + this.GetType()); } - Array.Copy(ParcelID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(RegionHandle % 256); - bytes[i++] = (byte)((RegionHandle >> 8) % 256); - bytes[i++] = (byte)((RegionHandle >> 16) % 256); - bytes[i++] = (byte)((RegionHandle >> 24) % 256); - bytes[i++] = (byte)((RegionHandle >> 32) % 256); - bytes[i++] = (byte)((RegionHandle >> 40) % 256); - bytes[i++] = (byte)((RegionHandle >> 48) % 256); - bytes[i++] = (byte)((RegionHandle >> 56) % 256); + { + if(ParcelID == null) { Console.WriteLine("Warning: ParcelID is null, in " + this.GetType()); } + Array.Copy(ParcelID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(RegionHandle % 256); + bytes[i++] = (byte)((RegionHandle >> 8) % 256); + bytes[i++] = (byte)((RegionHandle >> 16) % 256); + bytes[i++] = (byte)((RegionHandle >> 24) % 256); + bytes[i++] = (byte)((RegionHandle >> 32) % 256); + bytes[i++] = (byte)((RegionHandle >> 40) % 256); + bytes[i++] = (byte)((RegionHandle >> 48) % 256); + bytes[i++] = (byte)((RegionHandle >> 56) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ParcelData --\n"; - output += "ParcelID: " + ParcelID.ToString() + "\n"; - output += "RegionHandle: " + RegionHandle.ToString() + "\n"; + { + string output = "-- ParcelData --\n"; + output += "ParcelID: " + ParcelID.ToString() + "\n"; + output += "RegionHandle: " + RegionHandle.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.BulkParcelRemove - public override PacketType Type { get { return PacketType.BulkParcelRemove; } } - /// ParcelData block - public ParcelDataBlock[] ParcelData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.BulkParcelRemove + public override PacketType Type { get { return PacketType.BulkParcelRemove; } } + /// ParcelData block + public ParcelDataBlock[] ParcelData; + + /// Default constructor public BulkParcelRemovePacket() - { - Header = new LowHeader(); - Header.ID = 483; - Header.Reliable = true; - Header.Zerocoded = true; - ParcelData = new ParcelDataBlock[0]; + { + Header = new LowHeader(); + Header.ID = 483; + Header.Reliable = true; + Header.Zerocoded = true; + ParcelData = new ParcelDataBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public BulkParcelRemovePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ParcelData = new ParcelDataBlock[count]; - for (int j = 0; j < count; j++) - { ParcelData[j] = new ParcelDataBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ParcelData = new ParcelDataBlock[count]; + for (int j = 0; j < count; j++) + { ParcelData[j] = new ParcelDataBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public BulkParcelRemovePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ParcelData = new ParcelDataBlock[count]; - for (int j = 0; j < count; j++) - { ParcelData[j] = new ParcelDataBlock(bytes, ref i); } + { + Header = head; + int count = (int)bytes[i++]; + ParcelData = new ParcelDataBlock[count]; + for (int j = 0; j < count; j++) + { ParcelData[j] = new ParcelDataBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; -; - length++; - for (int j = 0; j < ParcelData.Length; j++) { length += ParcelData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ParcelData.Length; - for (int j = 0; j < ParcelData.Length; j++) { ParcelData[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; +; + length++; + for (int j = 0; j < ParcelData.Length; j++) { length += ParcelData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ParcelData.Length; + for (int j = 0; j < ParcelData.Length; j++) { ParcelData[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- BulkParcelRemove ---\n"; + { + string output = "--- BulkParcelRemove ---\n"; for (int j = 0; j < ParcelData.Length; j++) - { + { output += ParcelData[j].ToString() + "\n"; - } + } return output; } - + } - - /// InitiateUpload packet + + /// InitiateUpload packet public class InitiateUploadPacket : Packet - { - /// FileData block + { + /// FileData block public class FileDataBlock - { - private byte[] _sourcefilename; - /// SourceFilename field + { + private byte[] _sourcefilename; + /// SourceFilename field public byte[] SourceFilename - { - get { return _sourcefilename; } + { + get { return _sourcefilename; } set - { - if (value == null) { _sourcefilename = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _sourcefilename = new byte[value.Length]; Array.Copy(value, _sourcefilename, value.Length); } + { + if (value == null) { _sourcefilename = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _sourcefilename = new byte[value.Length]; Array.Copy(value, _sourcefilename, value.Length); } } - } - private byte[] _basefilename; - /// BaseFilename field + } + private byte[] _basefilename; + /// BaseFilename field public byte[] BaseFilename - { - get { return _basefilename; } + { + get { return _basefilename; } set - { - if (value == null) { _basefilename = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _basefilename = new byte[value.Length]; Array.Copy(value, _basefilename, value.Length); } + { + if (value == null) { _basefilename = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _basefilename = new byte[value.Length]; Array.Copy(value, _basefilename, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 0; - if (SourceFilename != null) { length += 1 + SourceFilename.Length; } - if (BaseFilename != null) { length += 1 + BaseFilename.Length; } - return length; + { + int length = 0; + if (SourceFilename != null) { length += 1 + SourceFilename.Length; } + if (BaseFilename != null) { length += 1 + BaseFilename.Length; } + return length; } } - - /// Default constructor - public FileDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public FileDataBlock() { } + /// Constructor for building the block from a byte array public FileDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _sourcefilename = new byte[length]; - Array.Copy(bytes, i, _sourcefilename, 0, length); i += length; - length = (ushort)bytes[i++]; - _basefilename = new byte[length]; - Array.Copy(bytes, i, _basefilename, 0, length); i += length; + { + length = (ushort)bytes[i++]; + _sourcefilename = new byte[length]; + Array.Copy(bytes, i, _sourcefilename, 0, length); i += length; + length = (ushort)bytes[i++]; + _basefilename = new byte[length]; + Array.Copy(bytes, i, _basefilename, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(SourceFilename == null) { Console.WriteLine("Warning: SourceFilename is null, in " + this.GetType()); } - bytes[i++] = (byte)SourceFilename.Length; - Array.Copy(SourceFilename, 0, bytes, i, SourceFilename.Length); i += SourceFilename.Length; - if(BaseFilename == null) { Console.WriteLine("Warning: BaseFilename is null, in " + this.GetType()); } - bytes[i++] = (byte)BaseFilename.Length; - Array.Copy(BaseFilename, 0, bytes, i, BaseFilename.Length); i += BaseFilename.Length; + { + if(SourceFilename == null) { Console.WriteLine("Warning: SourceFilename is null, in " + this.GetType()); } + bytes[i++] = (byte)SourceFilename.Length; + Array.Copy(SourceFilename, 0, bytes, i, SourceFilename.Length); i += SourceFilename.Length; + if(BaseFilename == null) { Console.WriteLine("Warning: BaseFilename is null, in " + this.GetType()); } + bytes[i++] = (byte)BaseFilename.Length; + Array.Copy(BaseFilename, 0, bytes, i, BaseFilename.Length); i += BaseFilename.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- FileData --\n"; - output += Helpers.FieldToString(SourceFilename, "SourceFilename") + "\n"; - output += Helpers.FieldToString(BaseFilename, "BaseFilename") + "\n"; + { + string output = "-- FileData --\n"; + output += Helpers.FieldToString(SourceFilename, "SourceFilename") + "\n"; + output += Helpers.FieldToString(BaseFilename, "BaseFilename") + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.InitiateUpload - public override PacketType Type { get { return PacketType.InitiateUpload; } } - /// FileData block - public FileDataBlock FileData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.InitiateUpload + public override PacketType Type { get { return PacketType.InitiateUpload; } } + /// FileData block + public FileDataBlock FileData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public InitiateUploadPacket() - { - Header = new LowHeader(); - Header.ID = 484; - Header.Reliable = true; - FileData = new FileDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 484; + Header.Reliable = true; + FileData = new FileDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public InitiateUploadPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - FileData = new FileDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + FileData = new FileDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public InitiateUploadPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - FileData = new FileDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + FileData = new FileDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += FileData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - FileData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += FileData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + FileData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- InitiateUpload ---\n"; - output += FileData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- InitiateUpload ---\n"; + output += FileData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// InitiateDownload packet + + /// InitiateDownload packet public class InitiateDownloadPacket : Packet - { - /// FileData block + { + /// FileData block public class FileDataBlock - { - private byte[] _simfilename; - /// SimFilename field + { + private byte[] _simfilename; + /// SimFilename field public byte[] SimFilename - { - get { return _simfilename; } + { + get { return _simfilename; } set - { - if (value == null) { _simfilename = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _simfilename = new byte[value.Length]; Array.Copy(value, _simfilename, value.Length); } + { + if (value == null) { _simfilename = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _simfilename = new byte[value.Length]; Array.Copy(value, _simfilename, value.Length); } } - } - private byte[] _viewerfilename; - /// ViewerFilename field + } + private byte[] _viewerfilename; + /// ViewerFilename field public byte[] ViewerFilename - { - get { return _viewerfilename; } + { + get { return _viewerfilename; } set - { - if (value == null) { _viewerfilename = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _viewerfilename = new byte[value.Length]; Array.Copy(value, _viewerfilename, value.Length); } + { + if (value == null) { _viewerfilename = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _viewerfilename = new byte[value.Length]; Array.Copy(value, _viewerfilename, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 0; - if (SimFilename != null) { length += 1 + SimFilename.Length; } - if (ViewerFilename != null) { length += 1 + ViewerFilename.Length; } - return length; + { + int length = 0; + if (SimFilename != null) { length += 1 + SimFilename.Length; } + if (ViewerFilename != null) { length += 1 + ViewerFilename.Length; } + return length; } } - - /// Default constructor - public FileDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public FileDataBlock() { } + /// Constructor for building the block from a byte array public FileDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _simfilename = new byte[length]; - Array.Copy(bytes, i, _simfilename, 0, length); i += length; - length = (ushort)bytes[i++]; - _viewerfilename = new byte[length]; - Array.Copy(bytes, i, _viewerfilename, 0, length); i += length; + { + length = (ushort)bytes[i++]; + _simfilename = new byte[length]; + Array.Copy(bytes, i, _simfilename, 0, length); i += length; + length = (ushort)bytes[i++]; + _viewerfilename = new byte[length]; + Array.Copy(bytes, i, _viewerfilename, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(SimFilename == null) { Console.WriteLine("Warning: SimFilename is null, in " + this.GetType()); } - bytes[i++] = (byte)SimFilename.Length; - Array.Copy(SimFilename, 0, bytes, i, SimFilename.Length); i += SimFilename.Length; - if(ViewerFilename == null) { Console.WriteLine("Warning: ViewerFilename is null, in " + this.GetType()); } - bytes[i++] = (byte)ViewerFilename.Length; - Array.Copy(ViewerFilename, 0, bytes, i, ViewerFilename.Length); i += ViewerFilename.Length; + { + if(SimFilename == null) { Console.WriteLine("Warning: SimFilename is null, in " + this.GetType()); } + bytes[i++] = (byte)SimFilename.Length; + Array.Copy(SimFilename, 0, bytes, i, SimFilename.Length); i += SimFilename.Length; + if(ViewerFilename == null) { Console.WriteLine("Warning: ViewerFilename is null, in " + this.GetType()); } + bytes[i++] = (byte)ViewerFilename.Length; + Array.Copy(ViewerFilename, 0, bytes, i, ViewerFilename.Length); i += ViewerFilename.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- FileData --\n"; - output += Helpers.FieldToString(SimFilename, "SimFilename") + "\n"; - output += Helpers.FieldToString(ViewerFilename, "ViewerFilename") + "\n"; + { + string output = "-- FileData --\n"; + output += Helpers.FieldToString(SimFilename, "SimFilename") + "\n"; + output += Helpers.FieldToString(ViewerFilename, "ViewerFilename") + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.InitiateDownload - public override PacketType Type { get { return PacketType.InitiateDownload; } } - /// FileData block - public FileDataBlock FileData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.InitiateDownload + public override PacketType Type { get { return PacketType.InitiateDownload; } } + /// FileData block + public FileDataBlock FileData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public InitiateDownloadPacket() - { - Header = new LowHeader(); - Header.ID = 485; - Header.Reliable = true; - FileData = new FileDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 485; + Header.Reliable = true; + FileData = new FileDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public InitiateDownloadPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - FileData = new FileDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + FileData = new FileDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public InitiateDownloadPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - FileData = new FileDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + FileData = new FileDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += FileData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - FileData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += FileData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + FileData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- InitiateDownload ---\n"; - output += FileData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- InitiateDownload ---\n"; + output += FileData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// SystemMessage packet + + /// SystemMessage packet public class SystemMessagePacket : Packet - { - /// MethodData block + { + /// MethodData block public class MethodDataBlock - { - /// Invoice field - public LLUUID Invoice; - /// Digest field - public byte[] Digest; - private byte[] _method; - /// Method field + { + /// Invoice field + public LLUUID Invoice; + /// Digest field + public byte[] Digest; + private byte[] _method; + /// Method field public byte[] Method - { - get { return _method; } + { + get { return _method; } set - { - if (value == null) { _method = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _method = new byte[value.Length]; Array.Copy(value, _method, value.Length); } + { + if (value == null) { _method = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _method = new byte[value.Length]; Array.Copy(value, _method, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 48; - if (Method != null) { length += 1 + Method.Length; } - return length; + { + int length = 48; + if (Method != null) { length += 1 + Method.Length; } + return length; } } - - /// Default constructor - public MethodDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public MethodDataBlock() { } + /// Constructor for building the block from a byte array public MethodDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - Invoice = new LLUUID(bytes, i); i += 16; - Digest = new byte[32]; - Array.Copy(bytes, i, Digest, 0, 32); i += 32; - length = (ushort)bytes[i++]; - _method = new byte[length]; - Array.Copy(bytes, i, _method, 0, length); i += length; + { + Invoice = new LLUUID(bytes, i); i += 16; + Digest = new byte[32]; + Array.Copy(bytes, i, Digest, 0, 32); i += 32; + length = (ushort)bytes[i++]; + _method = new byte[length]; + Array.Copy(bytes, i, _method, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(Invoice == null) { Console.WriteLine("Warning: Invoice is null, in " + this.GetType()); } - Array.Copy(Invoice.GetBytes(), 0, bytes, i, 16); i += 16; - Array.Copy(Digest, 0, bytes, i, 32);i += 32; - if(Method == null) { Console.WriteLine("Warning: Method is null, in " + this.GetType()); } - bytes[i++] = (byte)Method.Length; - Array.Copy(Method, 0, bytes, i, Method.Length); i += Method.Length; + { + if(Invoice == null) { Console.WriteLine("Warning: Invoice is null, in " + this.GetType()); } + Array.Copy(Invoice.GetBytes(), 0, bytes, i, 16); i += 16; + Array.Copy(Digest, 0, bytes, i, 32);i += 32; + if(Method == null) { Console.WriteLine("Warning: Method is null, in " + this.GetType()); } + bytes[i++] = (byte)Method.Length; + Array.Copy(Method, 0, bytes, i, Method.Length); i += Method.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- MethodData --\n"; - output += "Invoice: " + Invoice.ToString() + "\n"; - output += Helpers.FieldToString(Digest, "Digest") + "\n"; - output += Helpers.FieldToString(Method, "Method") + "\n"; + { + string output = "-- MethodData --\n"; + output += "Invoice: " + Invoice.ToString() + "\n"; + output += Helpers.FieldToString(Digest, "Digest") + "\n"; + output += Helpers.FieldToString(Method, "Method") + "\n"; output = output.Trim(); return output; - } + } } - - /// ParamList block + + /// ParamList block public class ParamListBlock - { - private byte[] _parameter; - /// Parameter field + { + private byte[] _parameter; + /// Parameter field public byte[] Parameter - { - get { return _parameter; } + { + get { return _parameter; } set - { - if (value == null) { _parameter = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _parameter = new byte[value.Length]; Array.Copy(value, _parameter, value.Length); } + { + if (value == null) { _parameter = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _parameter = new byte[value.Length]; Array.Copy(value, _parameter, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 0; - if (Parameter != null) { length += 1 + Parameter.Length; } - return length; + { + int length = 0; + if (Parameter != null) { length += 1 + Parameter.Length; } + return length; } } - - /// Default constructor - public ParamListBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ParamListBlock() { } + /// Constructor for building the block from a byte array public ParamListBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _parameter = new byte[length]; - Array.Copy(bytes, i, _parameter, 0, length); i += length; + { + length = (ushort)bytes[i++]; + _parameter = new byte[length]; + Array.Copy(bytes, i, _parameter, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(Parameter == null) { Console.WriteLine("Warning: Parameter is null, in " + this.GetType()); } - bytes[i++] = (byte)Parameter.Length; - Array.Copy(Parameter, 0, bytes, i, Parameter.Length); i += Parameter.Length; + { + if(Parameter == null) { Console.WriteLine("Warning: Parameter is null, in " + this.GetType()); } + bytes[i++] = (byte)Parameter.Length; + Array.Copy(Parameter, 0, bytes, i, Parameter.Length); i += Parameter.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ParamList --\n"; - output += Helpers.FieldToString(Parameter, "Parameter") + "\n"; + { + string output = "-- ParamList --\n"; + output += Helpers.FieldToString(Parameter, "Parameter") + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.SystemMessage - public override PacketType Type { get { return PacketType.SystemMessage; } } - /// MethodData block - public MethodDataBlock MethodData; - /// ParamList block - public ParamListBlock[] ParamList; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.SystemMessage + public override PacketType Type { get { return PacketType.SystemMessage; } } + /// MethodData block + public MethodDataBlock MethodData; + /// ParamList block + public ParamListBlock[] ParamList; + + /// Default constructor public SystemMessagePacket() - { - Header = new LowHeader(); - Header.ID = 486; - Header.Reliable = true; - Header.Zerocoded = true; - MethodData = new MethodDataBlock(); - ParamList = new ParamListBlock[0]; + { + Header = new LowHeader(); + Header.ID = 486; + Header.Reliable = true; + Header.Zerocoded = true; + MethodData = new MethodDataBlock(); + ParamList = new ParamListBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public SystemMessagePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - MethodData = new MethodDataBlock(bytes, ref i); - int count = (int)bytes[i++]; - ParamList = new ParamListBlock[count]; - for (int j = 0; j < count; j++) - { ParamList[j] = new ParamListBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + MethodData = new MethodDataBlock(bytes, ref i); + int count = (int)bytes[i++]; + ParamList = new ParamListBlock[count]; + for (int j = 0; j < count; j++) + { ParamList[j] = new ParamListBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public SystemMessagePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - MethodData = new MethodDataBlock(bytes, ref i); - int count = (int)bytes[i++]; - ParamList = new ParamListBlock[count]; - for (int j = 0; j < count; j++) - { ParamList[j] = new ParamListBlock(bytes, ref i); } + { + Header = head; + MethodData = new MethodDataBlock(bytes, ref i); + int count = (int)bytes[i++]; + ParamList = new ParamListBlock[count]; + for (int j = 0; j < count; j++) + { ParamList[j] = new ParamListBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += MethodData.Length;; - length++; - for (int j = 0; j < ParamList.Length; j++) { length += ParamList[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - MethodData.ToBytes(bytes, ref i); - bytes[i++] = (byte)ParamList.Length; - for (int j = 0; j < ParamList.Length; j++) { ParamList[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += MethodData.Length;; + length++; + for (int j = 0; j < ParamList.Length; j++) { length += ParamList[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + MethodData.ToBytes(bytes, ref i); + bytes[i++] = (byte)ParamList.Length; + for (int j = 0; j < ParamList.Length; j++) { ParamList[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- SystemMessage ---\n"; - output += MethodData.ToString() + "\n"; + { + string output = "--- SystemMessage ---\n"; + output += MethodData.ToString() + "\n"; for (int j = 0; j < ParamList.Length; j++) - { + { output += ParamList[j].ToString() + "\n"; - } + } return output; } - + } - - /// MapLayerRequest packet + + /// MapLayerRequest packet public class MapLayerRequestPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - /// Godlike field - public bool Godlike; - /// Flags field - public uint Flags; - /// EstateID field - public uint EstateID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + /// Godlike field + public bool Godlike; + /// Flags field + public uint Flags; + /// EstateID field + public uint EstateID; + + /// Length of this block serialized in bytes public int Length { get - { - return 41; + { + return 41; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; - Godlike = (bytes[i++] != 0) ? (bool)true : (bool)false; - Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - EstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; + Godlike = (bytes[i++] != 0) ? (bool)true : (bool)false; + Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + EstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((Godlike) ? 1 : 0); - bytes[i++] = (byte)(Flags % 256); - bytes[i++] = (byte)((Flags >> 8) % 256); - bytes[i++] = (byte)((Flags >> 16) % 256); - bytes[i++] = (byte)((Flags >> 24) % 256); - bytes[i++] = (byte)(EstateID % 256); - bytes[i++] = (byte)((EstateID >> 8) % 256); - bytes[i++] = (byte)((EstateID >> 16) % 256); - bytes[i++] = (byte)((EstateID >> 24) % 256); + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((Godlike) ? 1 : 0); + bytes[i++] = (byte)(Flags % 256); + bytes[i++] = (byte)((Flags >> 8) % 256); + bytes[i++] = (byte)((Flags >> 16) % 256); + bytes[i++] = (byte)((Flags >> 24) % 256); + bytes[i++] = (byte)(EstateID % 256); + bytes[i++] = (byte)((EstateID >> 8) % 256); + bytes[i++] = (byte)((EstateID >> 16) % 256); + bytes[i++] = (byte)((EstateID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "Godlike: " + Godlike.ToString() + "\n"; - output += "Flags: " + Flags.ToString() + "\n"; - output += "EstateID: " + EstateID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "Godlike: " + Godlike.ToString() + "\n"; + output += "Flags: " + Flags.ToString() + "\n"; + output += "EstateID: " + EstateID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.MapLayerRequest - public override PacketType Type { get { return PacketType.MapLayerRequest; } } - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.MapLayerRequest + public override PacketType Type { get { return PacketType.MapLayerRequest; } } + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public MapLayerRequestPacket() - { - Header = new LowHeader(); - Header.ID = 487; - Header.Reliable = true; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 487; + Header.Reliable = true; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public MapLayerRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public MapLayerRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- MapLayerRequest ---\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- MapLayerRequest ---\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// MapLayerReply packet + + /// MapLayerReply packet public class MapLayerReplyPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// Flags field - public uint Flags; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// Flags field + public uint Flags; + + /// Length of this block serialized in bytes public int Length { get - { - return 20; + { + return 20; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + AgentID = new LLUUID(bytes, i); i += 16; + Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(Flags % 256); - bytes[i++] = (byte)((Flags >> 8) % 256); - bytes[i++] = (byte)((Flags >> 16) % 256); - bytes[i++] = (byte)((Flags >> 24) % 256); + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(Flags % 256); + bytes[i++] = (byte)((Flags >> 8) % 256); + bytes[i++] = (byte)((Flags >> 16) % 256); + bytes[i++] = (byte)((Flags >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "Flags: " + Flags.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "Flags: " + Flags.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// LayerData block + + /// LayerData block public class LayerDataBlock - { - /// Top field - public uint Top; - /// ImageID field - public LLUUID ImageID; - /// Left field - public uint Left; - /// Bottom field - public uint Bottom; - /// Right field - public uint Right; - - /// Length of this block serialized in bytes + { + /// Top field + public uint Top; + /// ImageID field + public LLUUID ImageID; + /// Left field + public uint Left; + /// Bottom field + public uint Bottom; + /// Right field + public uint Right; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public LayerDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public LayerDataBlock() { } + /// Constructor for building the block from a byte array public LayerDataBlock(byte[] bytes, ref int i) - { + { try - { - Top = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - ImageID = new LLUUID(bytes, i); i += 16; - Left = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Bottom = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Right = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + Top = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + ImageID = new LLUUID(bytes, i); i += 16; + Left = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Bottom = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Right = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(Top % 256); - bytes[i++] = (byte)((Top >> 8) % 256); - bytes[i++] = (byte)((Top >> 16) % 256); - bytes[i++] = (byte)((Top >> 24) % 256); - if(ImageID == null) { Console.WriteLine("Warning: ImageID is null, in " + this.GetType()); } - Array.Copy(ImageID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(Left % 256); - bytes[i++] = (byte)((Left >> 8) % 256); - bytes[i++] = (byte)((Left >> 16) % 256); - bytes[i++] = (byte)((Left >> 24) % 256); - bytes[i++] = (byte)(Bottom % 256); - bytes[i++] = (byte)((Bottom >> 8) % 256); - bytes[i++] = (byte)((Bottom >> 16) % 256); - bytes[i++] = (byte)((Bottom >> 24) % 256); - bytes[i++] = (byte)(Right % 256); - bytes[i++] = (byte)((Right >> 8) % 256); - bytes[i++] = (byte)((Right >> 16) % 256); - bytes[i++] = (byte)((Right >> 24) % 256); + { + bytes[i++] = (byte)(Top % 256); + bytes[i++] = (byte)((Top >> 8) % 256); + bytes[i++] = (byte)((Top >> 16) % 256); + bytes[i++] = (byte)((Top >> 24) % 256); + if(ImageID == null) { Console.WriteLine("Warning: ImageID is null, in " + this.GetType()); } + Array.Copy(ImageID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(Left % 256); + bytes[i++] = (byte)((Left >> 8) % 256); + bytes[i++] = (byte)((Left >> 16) % 256); + bytes[i++] = (byte)((Left >> 24) % 256); + bytes[i++] = (byte)(Bottom % 256); + bytes[i++] = (byte)((Bottom >> 8) % 256); + bytes[i++] = (byte)((Bottom >> 16) % 256); + bytes[i++] = (byte)((Bottom >> 24) % 256); + bytes[i++] = (byte)(Right % 256); + bytes[i++] = (byte)((Right >> 8) % 256); + bytes[i++] = (byte)((Right >> 16) % 256); + bytes[i++] = (byte)((Right >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- LayerData --\n"; - output += "Top: " + Top.ToString() + "\n"; - output += "ImageID: " + ImageID.ToString() + "\n"; - output += "Left: " + Left.ToString() + "\n"; - output += "Bottom: " + Bottom.ToString() + "\n"; - output += "Right: " + Right.ToString() + "\n"; + { + string output = "-- LayerData --\n"; + output += "Top: " + Top.ToString() + "\n"; + output += "ImageID: " + ImageID.ToString() + "\n"; + output += "Left: " + Left.ToString() + "\n"; + output += "Bottom: " + Bottom.ToString() + "\n"; + output += "Right: " + Right.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.MapLayerReply - public override PacketType Type { get { return PacketType.MapLayerReply; } } - /// AgentData block - public AgentDataBlock AgentData; - /// LayerData block - public LayerDataBlock[] LayerData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.MapLayerReply + public override PacketType Type { get { return PacketType.MapLayerReply; } } + /// AgentData block + public AgentDataBlock AgentData; + /// LayerData block + public LayerDataBlock[] LayerData; + + /// Default constructor public MapLayerReplyPacket() - { - Header = new LowHeader(); - Header.ID = 488; - Header.Reliable = true; - AgentData = new AgentDataBlock(); - LayerData = new LayerDataBlock[0]; + { + Header = new LowHeader(); + Header.ID = 488; + Header.Reliable = true; + AgentData = new AgentDataBlock(); + LayerData = new LayerDataBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public MapLayerReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); - int count = (int)bytes[i++]; - LayerData = new LayerDataBlock[count]; - for (int j = 0; j < count; j++) - { LayerData[j] = new LayerDataBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); + int count = (int)bytes[i++]; + LayerData = new LayerDataBlock[count]; + for (int j = 0; j < count; j++) + { LayerData[j] = new LayerDataBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public MapLayerReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); - int count = (int)bytes[i++]; - LayerData = new LayerDataBlock[count]; - for (int j = 0; j < count; j++) - { LayerData[j] = new LayerDataBlock(bytes, ref i); } + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); + int count = (int)bytes[i++]; + LayerData = new LayerDataBlock[count]; + for (int j = 0; j < count; j++) + { LayerData[j] = new LayerDataBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < LayerData.Length; j++) { length += LayerData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - bytes[i++] = (byte)LayerData.Length; - for (int j = 0; j < LayerData.Length; j++) { LayerData[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < LayerData.Length; j++) { length += LayerData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + bytes[i++] = (byte)LayerData.Length; + for (int j = 0; j < LayerData.Length; j++) { LayerData[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- MapLayerReply ---\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- MapLayerReply ---\n"; + output += AgentData.ToString() + "\n"; for (int j = 0; j < LayerData.Length; j++) - { + { output += LayerData[j].ToString() + "\n"; - } + } return output; } - + } - - /// MapBlockRequest packet + + /// MapBlockRequest packet public class MapBlockRequestPacket : Packet - { - /// PositionData block + { + /// PositionData block public class PositionDataBlock - { - /// MaxX field - public ushort MaxX; - /// MaxY field - public ushort MaxY; - /// MinX field - public ushort MinX; - /// MinY field - public ushort MinY; - - /// Length of this block serialized in bytes + { + /// MaxX field + public ushort MaxX; + /// MaxY field + public ushort MaxY; + /// MinX field + public ushort MinX; + /// MinY field + public ushort MinY; + + /// Length of this block serialized in bytes public int Length { get - { - return 8; + { + return 8; } } - - /// Default constructor - public PositionDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public PositionDataBlock() { } + /// Constructor for building the block from a byte array public PositionDataBlock(byte[] bytes, ref int i) - { + { try - { - MaxX = (ushort)(bytes[i++] + (bytes[i++] << 8)); - MaxY = (ushort)(bytes[i++] + (bytes[i++] << 8)); - MinX = (ushort)(bytes[i++] + (bytes[i++] << 8)); - MinY = (ushort)(bytes[i++] + (bytes[i++] << 8)); + { + MaxX = (ushort)(bytes[i++] + (bytes[i++] << 8)); + MaxY = (ushort)(bytes[i++] + (bytes[i++] << 8)); + MinX = (ushort)(bytes[i++] + (bytes[i++] << 8)); + MinY = (ushort)(bytes[i++] + (bytes[i++] << 8)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(MaxX % 256); - bytes[i++] = (byte)((MaxX >> 8) % 256); - bytes[i++] = (byte)(MaxY % 256); - bytes[i++] = (byte)((MaxY >> 8) % 256); - bytes[i++] = (byte)(MinX % 256); - bytes[i++] = (byte)((MinX >> 8) % 256); - bytes[i++] = (byte)(MinY % 256); - bytes[i++] = (byte)((MinY >> 8) % 256); + { + bytes[i++] = (byte)(MaxX % 256); + bytes[i++] = (byte)((MaxX >> 8) % 256); + bytes[i++] = (byte)(MaxY % 256); + bytes[i++] = (byte)((MaxY >> 8) % 256); + bytes[i++] = (byte)(MinX % 256); + bytes[i++] = (byte)((MinX >> 8) % 256); + bytes[i++] = (byte)(MinY % 256); + bytes[i++] = (byte)((MinY >> 8) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- PositionData --\n"; - output += "MaxX: " + MaxX.ToString() + "\n"; - output += "MaxY: " + MaxY.ToString() + "\n"; - output += "MinX: " + MinX.ToString() + "\n"; - output += "MinY: " + MinY.ToString() + "\n"; + { + string output = "-- PositionData --\n"; + output += "MaxX: " + MaxX.ToString() + "\n"; + output += "MaxY: " + MaxY.ToString() + "\n"; + output += "MinX: " + MinX.ToString() + "\n"; + output += "MinY: " + MinY.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - /// Godlike field - public bool Godlike; - /// Flags field - public uint Flags; - /// EstateID field - public uint EstateID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + /// Godlike field + public bool Godlike; + /// Flags field + public uint Flags; + /// EstateID field + public uint EstateID; + + /// Length of this block serialized in bytes public int Length { get - { - return 41; + { + return 41; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; - Godlike = (bytes[i++] != 0) ? (bool)true : (bool)false; - Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - EstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; + Godlike = (bytes[i++] != 0) ? (bool)true : (bool)false; + Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + EstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((Godlike) ? 1 : 0); - bytes[i++] = (byte)(Flags % 256); - bytes[i++] = (byte)((Flags >> 8) % 256); - bytes[i++] = (byte)((Flags >> 16) % 256); - bytes[i++] = (byte)((Flags >> 24) % 256); - bytes[i++] = (byte)(EstateID % 256); - bytes[i++] = (byte)((EstateID >> 8) % 256); - bytes[i++] = (byte)((EstateID >> 16) % 256); - bytes[i++] = (byte)((EstateID >> 24) % 256); + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((Godlike) ? 1 : 0); + bytes[i++] = (byte)(Flags % 256); + bytes[i++] = (byte)((Flags >> 8) % 256); + bytes[i++] = (byte)((Flags >> 16) % 256); + bytes[i++] = (byte)((Flags >> 24) % 256); + bytes[i++] = (byte)(EstateID % 256); + bytes[i++] = (byte)((EstateID >> 8) % 256); + bytes[i++] = (byte)((EstateID >> 16) % 256); + bytes[i++] = (byte)((EstateID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "Godlike: " + Godlike.ToString() + "\n"; - output += "Flags: " + Flags.ToString() + "\n"; - output += "EstateID: " + EstateID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "Godlike: " + Godlike.ToString() + "\n"; + output += "Flags: " + Flags.ToString() + "\n"; + output += "EstateID: " + EstateID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.MapBlockRequest - public override PacketType Type { get { return PacketType.MapBlockRequest; } } - /// PositionData block - public PositionDataBlock PositionData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.MapBlockRequest + public override PacketType Type { get { return PacketType.MapBlockRequest; } } + /// PositionData block + public PositionDataBlock PositionData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public MapBlockRequestPacket() - { - Header = new LowHeader(); - Header.ID = 489; - Header.Reliable = true; - PositionData = new PositionDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 489; + Header.Reliable = true; + PositionData = new PositionDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public MapBlockRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - PositionData = new PositionDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + PositionData = new PositionDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public MapBlockRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - PositionData = new PositionDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + PositionData = new PositionDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += PositionData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - PositionData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += PositionData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + PositionData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- MapBlockRequest ---\n"; - output += PositionData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- MapBlockRequest ---\n"; + output += PositionData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// MapNameRequest packet + + /// MapNameRequest packet public class MapNameRequestPacket : Packet - { - /// NameData block + { + /// NameData block public class NameDataBlock - { - private byte[] _name; - /// Name field + { + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 0; - if (Name != null) { length += 1 + Name.Length; } - return length; + { + int length = 0; + if (Name != null) { length += 1 + Name.Length; } + return length; } } - - /// Default constructor - public NameDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public NameDataBlock() { } + /// Constructor for building the block from a byte array public NameDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; + { + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + { + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- NameData --\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; + { + string output = "-- NameData --\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - /// Godlike field - public bool Godlike; - /// Flags field - public uint Flags; - /// EstateID field - public uint EstateID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + /// Godlike field + public bool Godlike; + /// Flags field + public uint Flags; + /// EstateID field + public uint EstateID; + + /// Length of this block serialized in bytes public int Length { get - { - return 41; + { + return 41; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; - Godlike = (bytes[i++] != 0) ? (bool)true : (bool)false; - Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - EstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; + Godlike = (bytes[i++] != 0) ? (bool)true : (bool)false; + Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + EstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((Godlike) ? 1 : 0); - bytes[i++] = (byte)(Flags % 256); - bytes[i++] = (byte)((Flags >> 8) % 256); - bytes[i++] = (byte)((Flags >> 16) % 256); - bytes[i++] = (byte)((Flags >> 24) % 256); - bytes[i++] = (byte)(EstateID % 256); - bytes[i++] = (byte)((EstateID >> 8) % 256); - bytes[i++] = (byte)((EstateID >> 16) % 256); - bytes[i++] = (byte)((EstateID >> 24) % 256); + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((Godlike) ? 1 : 0); + bytes[i++] = (byte)(Flags % 256); + bytes[i++] = (byte)((Flags >> 8) % 256); + bytes[i++] = (byte)((Flags >> 16) % 256); + bytes[i++] = (byte)((Flags >> 24) % 256); + bytes[i++] = (byte)(EstateID % 256); + bytes[i++] = (byte)((EstateID >> 8) % 256); + bytes[i++] = (byte)((EstateID >> 16) % 256); + bytes[i++] = (byte)((EstateID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "Godlike: " + Godlike.ToString() + "\n"; - output += "Flags: " + Flags.ToString() + "\n"; - output += "EstateID: " + EstateID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "Godlike: " + Godlike.ToString() + "\n"; + output += "Flags: " + Flags.ToString() + "\n"; + output += "EstateID: " + EstateID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.MapNameRequest - public override PacketType Type { get { return PacketType.MapNameRequest; } } - /// NameData block - public NameDataBlock NameData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.MapNameRequest + public override PacketType Type { get { return PacketType.MapNameRequest; } } + /// NameData block + public NameDataBlock NameData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public MapNameRequestPacket() - { - Header = new LowHeader(); - Header.ID = 490; - Header.Reliable = true; - NameData = new NameDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 490; + Header.Reliable = true; + NameData = new NameDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public MapNameRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - NameData = new NameDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + NameData = new NameDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public MapNameRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - NameData = new NameDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + NameData = new NameDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += NameData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - NameData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += NameData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + NameData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- MapNameRequest ---\n"; - output += NameData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- MapNameRequest ---\n"; + output += NameData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// MapBlockReply packet + + /// MapBlockReply packet public class MapBlockReplyPacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - /// X field - public ushort X; - /// Y field - public ushort Y; - /// RegionFlags field - public uint RegionFlags; - /// WaterHeight field - public byte WaterHeight; - private byte[] _name; - /// Name field + { + /// X field + public ushort X; + /// Y field + public ushort Y; + /// RegionFlags field + public uint RegionFlags; + /// WaterHeight field + public byte WaterHeight; + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - /// Access field - public byte Access; - /// MapImageID field - public LLUUID MapImageID; - /// Agents field - public byte Agents; - - /// Length of this block serialized in bytes + } + /// Access field + public byte Access; + /// MapImageID field + public LLUUID MapImageID; + /// Agents field + public byte Agents; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 27; - if (Name != null) { length += 1 + Name.Length; } - return length; + { + int length = 27; + if (Name != null) { length += 1 + Name.Length; } + return length; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - X = (ushort)(bytes[i++] + (bytes[i++] << 8)); - Y = (ushort)(bytes[i++] + (bytes[i++] << 8)); - RegionFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - WaterHeight = (byte)bytes[i++]; - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; - Access = (byte)bytes[i++]; - MapImageID = new LLUUID(bytes, i); i += 16; - Agents = (byte)bytes[i++]; + { + X = (ushort)(bytes[i++] + (bytes[i++] << 8)); + Y = (ushort)(bytes[i++] + (bytes[i++] << 8)); + RegionFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + WaterHeight = (byte)bytes[i++]; + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; + Access = (byte)bytes[i++]; + MapImageID = new LLUUID(bytes, i); i += 16; + Agents = (byte)bytes[i++]; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(X % 256); - bytes[i++] = (byte)((X >> 8) % 256); - bytes[i++] = (byte)(Y % 256); - bytes[i++] = (byte)((Y >> 8) % 256); - bytes[i++] = (byte)(RegionFlags % 256); - bytes[i++] = (byte)((RegionFlags >> 8) % 256); - bytes[i++] = (byte)((RegionFlags >> 16) % 256); - bytes[i++] = (byte)((RegionFlags >> 24) % 256); - bytes[i++] = WaterHeight; - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; - bytes[i++] = Access; - if(MapImageID == null) { Console.WriteLine("Warning: MapImageID is null, in " + this.GetType()); } - Array.Copy(MapImageID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = Agents; + { + bytes[i++] = (byte)(X % 256); + bytes[i++] = (byte)((X >> 8) % 256); + bytes[i++] = (byte)(Y % 256); + bytes[i++] = (byte)((Y >> 8) % 256); + bytes[i++] = (byte)(RegionFlags % 256); + bytes[i++] = (byte)((RegionFlags >> 8) % 256); + bytes[i++] = (byte)((RegionFlags >> 16) % 256); + bytes[i++] = (byte)((RegionFlags >> 24) % 256); + bytes[i++] = WaterHeight; + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + bytes[i++] = Access; + if(MapImageID == null) { Console.WriteLine("Warning: MapImageID is null, in " + this.GetType()); } + Array.Copy(MapImageID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = Agents; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "X: " + X.ToString() + "\n"; - output += "Y: " + Y.ToString() + "\n"; - output += "RegionFlags: " + RegionFlags.ToString() + "\n"; - output += "WaterHeight: " + WaterHeight.ToString() + "\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; - output += "Access: " + Access.ToString() + "\n"; - output += "MapImageID: " + MapImageID.ToString() + "\n"; - output += "Agents: " + Agents.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += "X: " + X.ToString() + "\n"; + output += "Y: " + Y.ToString() + "\n"; + output += "RegionFlags: " + RegionFlags.ToString() + "\n"; + output += "WaterHeight: " + WaterHeight.ToString() + "\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; + output += "Access: " + Access.ToString() + "\n"; + output += "MapImageID: " + MapImageID.ToString() + "\n"; + output += "Agents: " + Agents.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// Flags field - public uint Flags; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// Flags field + public uint Flags; + + /// Length of this block serialized in bytes public int Length { get - { - return 20; + { + return 20; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + AgentID = new LLUUID(bytes, i); i += 16; + Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(Flags % 256); - bytes[i++] = (byte)((Flags >> 8) % 256); - bytes[i++] = (byte)((Flags >> 16) % 256); - bytes[i++] = (byte)((Flags >> 24) % 256); + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(Flags % 256); + bytes[i++] = (byte)((Flags >> 8) % 256); + bytes[i++] = (byte)((Flags >> 16) % 256); + bytes[i++] = (byte)((Flags >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "Flags: " + Flags.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "Flags: " + Flags.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.MapBlockReply - public override PacketType Type { get { return PacketType.MapBlockReply; } } - /// Data block - public DataBlock[] Data; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.MapBlockReply + public override PacketType Type { get { return PacketType.MapBlockReply; } } + /// Data block + public DataBlock[] Data; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public MapBlockReplyPacket() - { - Header = new LowHeader(); - Header.ID = 491; - Header.Reliable = true; - Data = new DataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 491; + Header.Reliable = true; + Data = new DataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public MapBlockReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - Data = new DataBlock[count]; - for (int j = 0; j < count; j++) - { Data[j] = new DataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + Data = new DataBlock[count]; + for (int j = 0; j < count; j++) + { Data[j] = new DataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public MapBlockReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - Data = new DataBlock[count]; - for (int j = 0; j < count; j++) - { Data[j] = new DataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + Data = new DataBlock[count]; + for (int j = 0; j < count; j++) + { Data[j] = new DataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - length++; - for (int j = 0; j < Data.Length; j++) { length += Data[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)Data.Length; - for (int j = 0; j < Data.Length; j++) { Data[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + length++; + for (int j = 0; j < Data.Length; j++) { length += Data[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)Data.Length; + for (int j = 0; j < Data.Length; j++) { Data[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- MapBlockReply ---\n"; + { + string output = "--- MapBlockReply ---\n"; for (int j = 0; j < Data.Length; j++) - { + { output += Data[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// MapItemRequest packet + + /// MapItemRequest packet public class MapItemRequestPacket : Packet - { - /// RequestData block + { + /// RequestData block public class RequestDataBlock - { - /// RegionHandle field - public ulong RegionHandle; - /// ItemType field - public uint ItemType; - - /// Length of this block serialized in bytes + { + /// RegionHandle field + public ulong RegionHandle; + /// ItemType field + public uint ItemType; + + /// Length of this block serialized in bytes public int Length { get - { - return 12; + { + return 12; } } - - /// Default constructor - public RequestDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public RequestDataBlock() { } + /// Constructor for building the block from a byte array public RequestDataBlock(byte[] bytes, ref int i) - { + { try - { - RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); - ItemType = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + ItemType = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(RegionHandle % 256); - bytes[i++] = (byte)((RegionHandle >> 8) % 256); - bytes[i++] = (byte)((RegionHandle >> 16) % 256); - bytes[i++] = (byte)((RegionHandle >> 24) % 256); - bytes[i++] = (byte)((RegionHandle >> 32) % 256); - bytes[i++] = (byte)((RegionHandle >> 40) % 256); - bytes[i++] = (byte)((RegionHandle >> 48) % 256); - bytes[i++] = (byte)((RegionHandle >> 56) % 256); - bytes[i++] = (byte)(ItemType % 256); - bytes[i++] = (byte)((ItemType >> 8) % 256); - bytes[i++] = (byte)((ItemType >> 16) % 256); - bytes[i++] = (byte)((ItemType >> 24) % 256); + { + bytes[i++] = (byte)(RegionHandle % 256); + bytes[i++] = (byte)((RegionHandle >> 8) % 256); + bytes[i++] = (byte)((RegionHandle >> 16) % 256); + bytes[i++] = (byte)((RegionHandle >> 24) % 256); + bytes[i++] = (byte)((RegionHandle >> 32) % 256); + bytes[i++] = (byte)((RegionHandle >> 40) % 256); + bytes[i++] = (byte)((RegionHandle >> 48) % 256); + bytes[i++] = (byte)((RegionHandle >> 56) % 256); + bytes[i++] = (byte)(ItemType % 256); + bytes[i++] = (byte)((ItemType >> 8) % 256); + bytes[i++] = (byte)((ItemType >> 16) % 256); + bytes[i++] = (byte)((ItemType >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- RequestData --\n"; - output += "RegionHandle: " + RegionHandle.ToString() + "\n"; - output += "ItemType: " + ItemType.ToString() + "\n"; + { + string output = "-- RequestData --\n"; + output += "RegionHandle: " + RegionHandle.ToString() + "\n"; + output += "ItemType: " + ItemType.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - /// Godlike field - public bool Godlike; - /// Flags field - public uint Flags; - /// EstateID field - public uint EstateID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + /// Godlike field + public bool Godlike; + /// Flags field + public uint Flags; + /// EstateID field + public uint EstateID; + + /// Length of this block serialized in bytes public int Length { get - { - return 41; + { + return 41; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; - Godlike = (bytes[i++] != 0) ? (bool)true : (bool)false; - Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - EstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; + Godlike = (bytes[i++] != 0) ? (bool)true : (bool)false; + Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + EstateID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((Godlike) ? 1 : 0); - bytes[i++] = (byte)(Flags % 256); - bytes[i++] = (byte)((Flags >> 8) % 256); - bytes[i++] = (byte)((Flags >> 16) % 256); - bytes[i++] = (byte)((Flags >> 24) % 256); - bytes[i++] = (byte)(EstateID % 256); - bytes[i++] = (byte)((EstateID >> 8) % 256); - bytes[i++] = (byte)((EstateID >> 16) % 256); - bytes[i++] = (byte)((EstateID >> 24) % 256); + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((Godlike) ? 1 : 0); + bytes[i++] = (byte)(Flags % 256); + bytes[i++] = (byte)((Flags >> 8) % 256); + bytes[i++] = (byte)((Flags >> 16) % 256); + bytes[i++] = (byte)((Flags >> 24) % 256); + bytes[i++] = (byte)(EstateID % 256); + bytes[i++] = (byte)((EstateID >> 8) % 256); + bytes[i++] = (byte)((EstateID >> 16) % 256); + bytes[i++] = (byte)((EstateID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "Godlike: " + Godlike.ToString() + "\n"; - output += "Flags: " + Flags.ToString() + "\n"; - output += "EstateID: " + EstateID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "Godlike: " + Godlike.ToString() + "\n"; + output += "Flags: " + Flags.ToString() + "\n"; + output += "EstateID: " + EstateID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.MapItemRequest - public override PacketType Type { get { return PacketType.MapItemRequest; } } - /// RequestData block - public RequestDataBlock RequestData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.MapItemRequest + public override PacketType Type { get { return PacketType.MapItemRequest; } } + /// RequestData block + public RequestDataBlock RequestData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public MapItemRequestPacket() - { - Header = new LowHeader(); - Header.ID = 492; - Header.Reliable = true; - RequestData = new RequestDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 492; + Header.Reliable = true; + RequestData = new RequestDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public MapItemRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - RequestData = new RequestDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + RequestData = new RequestDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public MapItemRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - RequestData = new RequestDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + RequestData = new RequestDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += RequestData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - RequestData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += RequestData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + RequestData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- MapItemRequest ---\n"; - output += RequestData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- MapItemRequest ---\n"; + output += RequestData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// MapItemReply packet + + /// MapItemReply packet public class MapItemReplyPacket : Packet - { - /// RequestData block + { + /// RequestData block public class RequestDataBlock - { - /// ItemType field - public uint ItemType; - - /// Length of this block serialized in bytes + { + /// ItemType field + public uint ItemType; + + /// Length of this block serialized in bytes public int Length { get - { - return 4; + { + return 4; } } - - /// Default constructor - public RequestDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public RequestDataBlock() { } + /// Constructor for building the block from a byte array public RequestDataBlock(byte[] bytes, ref int i) - { + { try - { - ItemType = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + ItemType = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(ItemType % 256); - bytes[i++] = (byte)((ItemType >> 8) % 256); - bytes[i++] = (byte)((ItemType >> 16) % 256); - bytes[i++] = (byte)((ItemType >> 24) % 256); + { + bytes[i++] = (byte)(ItemType % 256); + bytes[i++] = (byte)((ItemType >> 8) % 256); + bytes[i++] = (byte)((ItemType >> 16) % 256); + bytes[i++] = (byte)((ItemType >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- RequestData --\n"; - output += "ItemType: " + ItemType.ToString() + "\n"; + { + string output = "-- RequestData --\n"; + output += "ItemType: " + ItemType.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// Data block + + /// Data block public class DataBlock - { - /// X field - public uint X; - /// Y field - public uint Y; - /// ID field - public LLUUID ID; - private byte[] _name; - /// Name field + { + /// X field + public uint X; + /// Y field + public uint Y; + /// ID field + public LLUUID ID; + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - /// Extra2 field - public int Extra2; - /// Extra field - public int Extra; - - /// Length of this block serialized in bytes + } + /// Extra2 field + public int Extra2; + /// Extra field + public int Extra; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 32; - if (Name != null) { length += 1 + Name.Length; } - return length; + { + int length = 32; + if (Name != null) { length += 1 + Name.Length; } + return length; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - X = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Y = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - ID = new LLUUID(bytes, i); i += 16; - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; - Extra2 = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Extra = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + X = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Y = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + ID = new LLUUID(bytes, i); i += 16; + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; + Extra2 = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Extra = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(X % 256); - bytes[i++] = (byte)((X >> 8) % 256); - bytes[i++] = (byte)((X >> 16) % 256); - bytes[i++] = (byte)((X >> 24) % 256); - bytes[i++] = (byte)(Y % 256); - bytes[i++] = (byte)((Y >> 8) % 256); - bytes[i++] = (byte)((Y >> 16) % 256); - bytes[i++] = (byte)((Y >> 24) % 256); - if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } - Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; - bytes[i++] = (byte)(Extra2 % 256); - bytes[i++] = (byte)((Extra2 >> 8) % 256); - bytes[i++] = (byte)((Extra2 >> 16) % 256); - bytes[i++] = (byte)((Extra2 >> 24) % 256); - bytes[i++] = (byte)(Extra % 256); - bytes[i++] = (byte)((Extra >> 8) % 256); - bytes[i++] = (byte)((Extra >> 16) % 256); - bytes[i++] = (byte)((Extra >> 24) % 256); + { + bytes[i++] = (byte)(X % 256); + bytes[i++] = (byte)((X >> 8) % 256); + bytes[i++] = (byte)((X >> 16) % 256); + bytes[i++] = (byte)((X >> 24) % 256); + bytes[i++] = (byte)(Y % 256); + bytes[i++] = (byte)((Y >> 8) % 256); + bytes[i++] = (byte)((Y >> 16) % 256); + bytes[i++] = (byte)((Y >> 24) % 256); + if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } + Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + bytes[i++] = (byte)(Extra2 % 256); + bytes[i++] = (byte)((Extra2 >> 8) % 256); + bytes[i++] = (byte)((Extra2 >> 16) % 256); + bytes[i++] = (byte)((Extra2 >> 24) % 256); + bytes[i++] = (byte)(Extra % 256); + bytes[i++] = (byte)((Extra >> 8) % 256); + bytes[i++] = (byte)((Extra >> 16) % 256); + bytes[i++] = (byte)((Extra >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "X: " + X.ToString() + "\n"; - output += "Y: " + Y.ToString() + "\n"; - output += "ID: " + ID.ToString() + "\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; - output += "Extra2: " + Extra2.ToString() + "\n"; - output += "Extra: " + Extra.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += "X: " + X.ToString() + "\n"; + output += "Y: " + Y.ToString() + "\n"; + output += "ID: " + ID.ToString() + "\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; + output += "Extra2: " + Extra2.ToString() + "\n"; + output += "Extra: " + Extra.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// Flags field - public uint Flags; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// Flags field + public uint Flags; + + /// Length of this block serialized in bytes public int Length { get - { - return 20; + { + return 20; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + AgentID = new LLUUID(bytes, i); i += 16; + Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(Flags % 256); - bytes[i++] = (byte)((Flags >> 8) % 256); - bytes[i++] = (byte)((Flags >> 16) % 256); - bytes[i++] = (byte)((Flags >> 24) % 256); + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(Flags % 256); + bytes[i++] = (byte)((Flags >> 8) % 256); + bytes[i++] = (byte)((Flags >> 16) % 256); + bytes[i++] = (byte)((Flags >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "Flags: " + Flags.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "Flags: " + Flags.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.MapItemReply - public override PacketType Type { get { return PacketType.MapItemReply; } } - /// RequestData block - public RequestDataBlock RequestData; - /// Data block - public DataBlock[] Data; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.MapItemReply + public override PacketType Type { get { return PacketType.MapItemReply; } } + /// RequestData block + public RequestDataBlock RequestData; + /// Data block + public DataBlock[] Data; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public MapItemReplyPacket() - { - Header = new LowHeader(); - Header.ID = 493; - Header.Reliable = true; - RequestData = new RequestDataBlock(); - Data = new DataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 493; + Header.Reliable = true; + RequestData = new RequestDataBlock(); + Data = new DataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public MapItemReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - RequestData = new RequestDataBlock(bytes, ref i); - int count = (int)bytes[i++]; - Data = new DataBlock[count]; - for (int j = 0; j < count; j++) - { Data[j] = new DataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + RequestData = new RequestDataBlock(bytes, ref i); + int count = (int)bytes[i++]; + Data = new DataBlock[count]; + for (int j = 0; j < count; j++) + { Data[j] = new DataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public MapItemReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - RequestData = new RequestDataBlock(bytes, ref i); - int count = (int)bytes[i++]; - Data = new DataBlock[count]; - for (int j = 0; j < count; j++) - { Data[j] = new DataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + RequestData = new RequestDataBlock(bytes, ref i); + int count = (int)bytes[i++]; + Data = new DataBlock[count]; + for (int j = 0; j < count; j++) + { Data[j] = new DataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += RequestData.Length; length += AgentData.Length;; - length++; - for (int j = 0; j < Data.Length; j++) { length += Data[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - RequestData.ToBytes(bytes, ref i); - bytes[i++] = (byte)Data.Length; - for (int j = 0; j < Data.Length; j++) { Data[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += RequestData.Length; length += AgentData.Length;; + length++; + for (int j = 0; j < Data.Length; j++) { length += Data[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + RequestData.ToBytes(bytes, ref i); + bytes[i++] = (byte)Data.Length; + for (int j = 0; j < Data.Length; j++) { Data[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- MapItemReply ---\n"; - output += RequestData.ToString() + "\n"; + { + string output = "--- MapItemReply ---\n"; + output += RequestData.ToString() + "\n"; for (int j = 0; j < Data.Length; j++) - { + { output += Data[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// SendPostcard packet + + /// SendPostcard packet public class SendPostcardPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - private byte[] _to; - /// To field + { + private byte[] _to; + /// To field public byte[] To - { - get { return _to; } + { + get { return _to; } set - { - if (value == null) { _to = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _to = new byte[value.Length]; Array.Copy(value, _to, value.Length); } + { + if (value == null) { _to = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _to = new byte[value.Length]; Array.Copy(value, _to, value.Length); } } - } - /// AgentID field - public LLUUID AgentID; - private byte[] _msg; - /// Msg field + } + /// AgentID field + public LLUUID AgentID; + private byte[] _msg; + /// Msg field public byte[] Msg - { - get { return _msg; } + { + get { return _msg; } set - { - if (value == null) { _msg = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _msg = new byte[value.Length]; Array.Copy(value, _msg, value.Length); } + { + if (value == null) { _msg = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _msg = new byte[value.Length]; Array.Copy(value, _msg, value.Length); } } - } - /// AllowPublish field - public bool AllowPublish; - /// PosGlobal field - public LLVector3d PosGlobal; - /// SessionID field - public LLUUID SessionID; - private byte[] _name; - /// Name field + } + /// AllowPublish field + public bool AllowPublish; + /// PosGlobal field + public LLVector3d PosGlobal; + /// SessionID field + public LLUUID SessionID; + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - private byte[] _subject; - /// Subject field + } + private byte[] _subject; + /// Subject field public byte[] Subject - { - get { return _subject; } + { + get { return _subject; } set - { - if (value == null) { _subject = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _subject = new byte[value.Length]; Array.Copy(value, _subject, value.Length); } + { + if (value == null) { _subject = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _subject = new byte[value.Length]; Array.Copy(value, _subject, value.Length); } } - } - private byte[] _from; - /// From field + } + private byte[] _from; + /// From field public byte[] From - { - get { return _from; } + { + get { return _from; } set - { - if (value == null) { _from = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _from = new byte[value.Length]; Array.Copy(value, _from, value.Length); } + { + if (value == null) { _from = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _from = new byte[value.Length]; Array.Copy(value, _from, value.Length); } } - } - /// AssetID field - public LLUUID AssetID; - /// MaturePublish field - public bool MaturePublish; - - /// Length of this block serialized in bytes + } + /// AssetID field + public LLUUID AssetID; + /// MaturePublish field + public bool MaturePublish; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 74; - if (To != null) { length += 1 + To.Length; } - if (Msg != null) { length += 2 + Msg.Length; } - if (Name != null) { length += 1 + Name.Length; } - if (Subject != null) { length += 1 + Subject.Length; } - if (From != null) { length += 1 + From.Length; } - return length; + { + int length = 74; + if (To != null) { length += 1 + To.Length; } + if (Msg != null) { length += 2 + Msg.Length; } + if (Name != null) { length += 1 + Name.Length; } + if (Subject != null) { length += 1 + Subject.Length; } + if (From != null) { length += 1 + From.Length; } + return length; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _to = new byte[length]; - Array.Copy(bytes, i, _to, 0, length); i += length; - AgentID = new LLUUID(bytes, i); i += 16; - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _msg = new byte[length]; - Array.Copy(bytes, i, _msg, 0, length); i += length; - AllowPublish = (bytes[i++] != 0) ? (bool)true : (bool)false; - PosGlobal = new LLVector3d(bytes, i); i += 24; - SessionID = new LLUUID(bytes, i); i += 16; - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; - length = (ushort)bytes[i++]; - _subject = new byte[length]; - Array.Copy(bytes, i, _subject, 0, length); i += length; - length = (ushort)bytes[i++]; - _from = new byte[length]; - Array.Copy(bytes, i, _from, 0, length); i += length; - AssetID = new LLUUID(bytes, i); i += 16; - MaturePublish = (bytes[i++] != 0) ? (bool)true : (bool)false; + { + length = (ushort)bytes[i++]; + _to = new byte[length]; + Array.Copy(bytes, i, _to, 0, length); i += length; + AgentID = new LLUUID(bytes, i); i += 16; + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _msg = new byte[length]; + Array.Copy(bytes, i, _msg, 0, length); i += length; + AllowPublish = (bytes[i++] != 0) ? (bool)true : (bool)false; + PosGlobal = new LLVector3d(bytes, i); i += 24; + SessionID = new LLUUID(bytes, i); i += 16; + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; + length = (ushort)bytes[i++]; + _subject = new byte[length]; + Array.Copy(bytes, i, _subject, 0, length); i += length; + length = (ushort)bytes[i++]; + _from = new byte[length]; + Array.Copy(bytes, i, _from, 0, length); i += length; + AssetID = new LLUUID(bytes, i); i += 16; + MaturePublish = (bytes[i++] != 0) ? (bool)true : (bool)false; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(To == null) { Console.WriteLine("Warning: To is null, in " + this.GetType()); } - bytes[i++] = (byte)To.Length; - Array.Copy(To, 0, bytes, i, To.Length); i += To.Length; - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(Msg == null) { Console.WriteLine("Warning: Msg is null, in " + this.GetType()); } - bytes[i++] = (byte)(Msg.Length % 256); - bytes[i++] = (byte)((Msg.Length >> 8) % 256); - Array.Copy(Msg, 0, bytes, i, Msg.Length); i += Msg.Length; - bytes[i++] = (byte)((AllowPublish) ? 1 : 0); - if(PosGlobal == null) { Console.WriteLine("Warning: PosGlobal is null, in " + this.GetType()); } - Array.Copy(PosGlobal.GetBytes(), 0, bytes, i, 24); i += 24; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; - if(Subject == null) { Console.WriteLine("Warning: Subject is null, in " + this.GetType()); } - bytes[i++] = (byte)Subject.Length; - Array.Copy(Subject, 0, bytes, i, Subject.Length); i += Subject.Length; - if(From == null) { Console.WriteLine("Warning: From is null, in " + this.GetType()); } - bytes[i++] = (byte)From.Length; - Array.Copy(From, 0, bytes, i, From.Length); i += From.Length; - if(AssetID == null) { Console.WriteLine("Warning: AssetID is null, in " + this.GetType()); } - Array.Copy(AssetID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((MaturePublish) ? 1 : 0); + { + if(To == null) { Console.WriteLine("Warning: To is null, in " + this.GetType()); } + bytes[i++] = (byte)To.Length; + Array.Copy(To, 0, bytes, i, To.Length); i += To.Length; + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(Msg == null) { Console.WriteLine("Warning: Msg is null, in " + this.GetType()); } + bytes[i++] = (byte)(Msg.Length % 256); + bytes[i++] = (byte)((Msg.Length >> 8) % 256); + Array.Copy(Msg, 0, bytes, i, Msg.Length); i += Msg.Length; + bytes[i++] = (byte)((AllowPublish) ? 1 : 0); + if(PosGlobal == null) { Console.WriteLine("Warning: PosGlobal is null, in " + this.GetType()); } + Array.Copy(PosGlobal.GetBytes(), 0, bytes, i, 24); i += 24; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + if(Subject == null) { Console.WriteLine("Warning: Subject is null, in " + this.GetType()); } + bytes[i++] = (byte)Subject.Length; + Array.Copy(Subject, 0, bytes, i, Subject.Length); i += Subject.Length; + if(From == null) { Console.WriteLine("Warning: From is null, in " + this.GetType()); } + bytes[i++] = (byte)From.Length; + Array.Copy(From, 0, bytes, i, From.Length); i += From.Length; + if(AssetID == null) { Console.WriteLine("Warning: AssetID is null, in " + this.GetType()); } + Array.Copy(AssetID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((MaturePublish) ? 1 : 0); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += Helpers.FieldToString(To, "To") + "\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += Helpers.FieldToString(Msg, "Msg") + "\n"; - output += "AllowPublish: " + AllowPublish.ToString() + "\n"; - output += "PosGlobal: " + PosGlobal.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; - output += Helpers.FieldToString(Subject, "Subject") + "\n"; - output += Helpers.FieldToString(From, "From") + "\n"; - output += "AssetID: " + AssetID.ToString() + "\n"; - output += "MaturePublish: " + MaturePublish.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += Helpers.FieldToString(To, "To") + "\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += Helpers.FieldToString(Msg, "Msg") + "\n"; + output += "AllowPublish: " + AllowPublish.ToString() + "\n"; + output += "PosGlobal: " + PosGlobal.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; + output += Helpers.FieldToString(Subject, "Subject") + "\n"; + output += Helpers.FieldToString(From, "From") + "\n"; + output += "AssetID: " + AssetID.ToString() + "\n"; + output += "MaturePublish: " + MaturePublish.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.SendPostcard - public override PacketType Type { get { return PacketType.SendPostcard; } } - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.SendPostcard + public override PacketType Type { get { return PacketType.SendPostcard; } } + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public SendPostcardPacket() - { - Header = new LowHeader(); - Header.ID = 494; - Header.Reliable = true; - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 494; + Header.Reliable = true; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public SendPostcardPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public SendPostcardPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- SendPostcard ---\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- SendPostcard ---\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// RpcChannelRequest packet + + /// RpcChannelRequest packet public class RpcChannelRequestPacket : Packet - { - /// DataBlock block + { + /// DataBlock block public class DataBlockBlock - { - /// TaskID field - public LLUUID TaskID; - /// ItemID field - public LLUUID ItemID; - /// GridX field - public uint GridX; - /// GridY field - public uint GridY; - - /// Length of this block serialized in bytes + { + /// TaskID field + public LLUUID TaskID; + /// ItemID field + public LLUUID ItemID; + /// GridX field + public uint GridX; + /// GridY field + public uint GridY; + + /// Length of this block serialized in bytes public int Length { get - { - return 40; + { + return 40; } } - - /// Default constructor - public DataBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlockBlock() { } + /// Constructor for building the block from a byte array public DataBlockBlock(byte[] bytes, ref int i) - { + { try - { - TaskID = new LLUUID(bytes, i); i += 16; - ItemID = new LLUUID(bytes, i); i += 16; - GridX = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - GridY = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + TaskID = new LLUUID(bytes, i); i += 16; + ItemID = new LLUUID(bytes, i); i += 16; + GridX = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + GridY = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(TaskID == null) { Console.WriteLine("Warning: TaskID is null, in " + this.GetType()); } - Array.Copy(TaskID.GetBytes(), 0, bytes, i, 16); i += 16; - if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } - Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(GridX % 256); - bytes[i++] = (byte)((GridX >> 8) % 256); - bytes[i++] = (byte)((GridX >> 16) % 256); - bytes[i++] = (byte)((GridX >> 24) % 256); - bytes[i++] = (byte)(GridY % 256); - bytes[i++] = (byte)((GridY >> 8) % 256); - bytes[i++] = (byte)((GridY >> 16) % 256); - bytes[i++] = (byte)((GridY >> 24) % 256); + { + if(TaskID == null) { Console.WriteLine("Warning: TaskID is null, in " + this.GetType()); } + Array.Copy(TaskID.GetBytes(), 0, bytes, i, 16); i += 16; + if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } + Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(GridX % 256); + bytes[i++] = (byte)((GridX >> 8) % 256); + bytes[i++] = (byte)((GridX >> 16) % 256); + bytes[i++] = (byte)((GridX >> 24) % 256); + bytes[i++] = (byte)(GridY % 256); + bytes[i++] = (byte)((GridY >> 8) % 256); + bytes[i++] = (byte)((GridY >> 16) % 256); + bytes[i++] = (byte)((GridY >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- DataBlock --\n"; - output += "TaskID: " + TaskID.ToString() + "\n"; - output += "ItemID: " + ItemID.ToString() + "\n"; - output += "GridX: " + GridX.ToString() + "\n"; - output += "GridY: " + GridY.ToString() + "\n"; + { + string output = "-- DataBlock --\n"; + output += "TaskID: " + TaskID.ToString() + "\n"; + output += "ItemID: " + ItemID.ToString() + "\n"; + output += "GridX: " + GridX.ToString() + "\n"; + output += "GridY: " + GridY.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.RpcChannelRequest - public override PacketType Type { get { return PacketType.RpcChannelRequest; } } - /// DataBlock block - public DataBlockBlock DataBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.RpcChannelRequest + public override PacketType Type { get { return PacketType.RpcChannelRequest; } } + /// DataBlock block + public DataBlockBlock DataBlock; + + /// Default constructor public RpcChannelRequestPacket() - { - Header = new LowHeader(); - Header.ID = 495; - Header.Reliable = true; - DataBlock = new DataBlockBlock(); + { + Header = new LowHeader(); + Header.ID = 495; + Header.Reliable = true; + DataBlock = new DataBlockBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public RpcChannelRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - DataBlock = new DataBlockBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + DataBlock = new DataBlockBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public RpcChannelRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - DataBlock = new DataBlockBlock(bytes, ref i); + { + Header = head; + DataBlock = new DataBlockBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += DataBlock.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - DataBlock.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += DataBlock.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + DataBlock.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- RpcChannelRequest ---\n"; - output += DataBlock.ToString() + "\n"; + { + string output = "--- RpcChannelRequest ---\n"; + output += DataBlock.ToString() + "\n"; return output; } - + } - - /// RpcChannelReply packet + + /// RpcChannelReply packet public class RpcChannelReplyPacket : Packet - { - /// DataBlock block + { + /// DataBlock block public class DataBlockBlock - { - /// TaskID field - public LLUUID TaskID; - /// ItemID field - public LLUUID ItemID; - /// ChannelID field - public LLUUID ChannelID; - - /// Length of this block serialized in bytes + { + /// TaskID field + public LLUUID TaskID; + /// ItemID field + public LLUUID ItemID; + /// ChannelID field + public LLUUID ChannelID; + + /// Length of this block serialized in bytes public int Length { get - { - return 48; + { + return 48; } } - - /// Default constructor - public DataBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlockBlock() { } + /// Constructor for building the block from a byte array public DataBlockBlock(byte[] bytes, ref int i) - { + { try - { - TaskID = new LLUUID(bytes, i); i += 16; - ItemID = new LLUUID(bytes, i); i += 16; - ChannelID = new LLUUID(bytes, i); i += 16; + { + TaskID = new LLUUID(bytes, i); i += 16; + ItemID = new LLUUID(bytes, i); i += 16; + ChannelID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(TaskID == null) { Console.WriteLine("Warning: TaskID is null, in " + this.GetType()); } - Array.Copy(TaskID.GetBytes(), 0, bytes, i, 16); i += 16; - if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } - Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; - if(ChannelID == null) { Console.WriteLine("Warning: ChannelID is null, in " + this.GetType()); } - Array.Copy(ChannelID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(TaskID == null) { Console.WriteLine("Warning: TaskID is null, in " + this.GetType()); } + Array.Copy(TaskID.GetBytes(), 0, bytes, i, 16); i += 16; + if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } + Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; + if(ChannelID == null) { Console.WriteLine("Warning: ChannelID is null, in " + this.GetType()); } + Array.Copy(ChannelID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- DataBlock --\n"; - output += "TaskID: " + TaskID.ToString() + "\n"; - output += "ItemID: " + ItemID.ToString() + "\n"; - output += "ChannelID: " + ChannelID.ToString() + "\n"; + { + string output = "-- DataBlock --\n"; + output += "TaskID: " + TaskID.ToString() + "\n"; + output += "ItemID: " + ItemID.ToString() + "\n"; + output += "ChannelID: " + ChannelID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.RpcChannelReply - public override PacketType Type { get { return PacketType.RpcChannelReply; } } - /// DataBlock block - public DataBlockBlock DataBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.RpcChannelReply + public override PacketType Type { get { return PacketType.RpcChannelReply; } } + /// DataBlock block + public DataBlockBlock DataBlock; + + /// Default constructor public RpcChannelReplyPacket() - { - Header = new LowHeader(); - Header.ID = 496; - Header.Reliable = true; - DataBlock = new DataBlockBlock(); + { + Header = new LowHeader(); + Header.ID = 496; + Header.Reliable = true; + DataBlock = new DataBlockBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public RpcChannelReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - DataBlock = new DataBlockBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + DataBlock = new DataBlockBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public RpcChannelReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - DataBlock = new DataBlockBlock(bytes, ref i); + { + Header = head; + DataBlock = new DataBlockBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += DataBlock.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - DataBlock.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += DataBlock.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + DataBlock.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- RpcChannelReply ---\n"; - output += DataBlock.ToString() + "\n"; + { + string output = "--- RpcChannelReply ---\n"; + output += DataBlock.ToString() + "\n"; return output; } - + } - - /// RpcScriptRequestInbound packet + + /// RpcScriptRequestInbound packet public class RpcScriptRequestInboundPacket : Packet - { - /// TargetBlock block + { + /// TargetBlock block public class TargetBlockBlock - { - /// GridX field - public uint GridX; - /// GridY field - public uint GridY; - - /// Length of this block serialized in bytes + { + /// GridX field + public uint GridX; + /// GridY field + public uint GridY; + + /// Length of this block serialized in bytes public int Length { get - { - return 8; + { + return 8; } } - - /// Default constructor - public TargetBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public TargetBlockBlock() { } + /// Constructor for building the block from a byte array public TargetBlockBlock(byte[] bytes, ref int i) - { + { try - { - GridX = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - GridY = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + GridX = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + GridY = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(GridX % 256); - bytes[i++] = (byte)((GridX >> 8) % 256); - bytes[i++] = (byte)((GridX >> 16) % 256); - bytes[i++] = (byte)((GridX >> 24) % 256); - bytes[i++] = (byte)(GridY % 256); - bytes[i++] = (byte)((GridY >> 8) % 256); - bytes[i++] = (byte)((GridY >> 16) % 256); - bytes[i++] = (byte)((GridY >> 24) % 256); + { + bytes[i++] = (byte)(GridX % 256); + bytes[i++] = (byte)((GridX >> 8) % 256); + bytes[i++] = (byte)((GridX >> 16) % 256); + bytes[i++] = (byte)((GridX >> 24) % 256); + bytes[i++] = (byte)(GridY % 256); + bytes[i++] = (byte)((GridY >> 8) % 256); + bytes[i++] = (byte)((GridY >> 16) % 256); + bytes[i++] = (byte)((GridY >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- TargetBlock --\n"; - output += "GridX: " + GridX.ToString() + "\n"; - output += "GridY: " + GridY.ToString() + "\n"; + { + string output = "-- TargetBlock --\n"; + output += "GridX: " + GridX.ToString() + "\n"; + output += "GridY: " + GridY.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// DataBlock block + + /// DataBlock block public class DataBlockBlock - { - private byte[] _stringvalue; - /// StringValue field + { + private byte[] _stringvalue; + /// StringValue field public byte[] StringValue - { - get { return _stringvalue; } + { + get { return _stringvalue; } set - { - if (value == null) { _stringvalue = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _stringvalue = new byte[value.Length]; Array.Copy(value, _stringvalue, value.Length); } + { + if (value == null) { _stringvalue = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _stringvalue = new byte[value.Length]; Array.Copy(value, _stringvalue, value.Length); } } - } - /// TaskID field - public LLUUID TaskID; - /// ItemID field - public LLUUID ItemID; - /// IntValue field - public uint IntValue; - /// ChannelID field - public LLUUID ChannelID; - - /// Length of this block serialized in bytes + } + /// TaskID field + public LLUUID TaskID; + /// ItemID field + public LLUUID ItemID; + /// IntValue field + public uint IntValue; + /// ChannelID field + public LLUUID ChannelID; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 52; - if (StringValue != null) { length += 2 + StringValue.Length; } - return length; + { + int length = 52; + if (StringValue != null) { length += 2 + StringValue.Length; } + return length; } } - - /// Default constructor - public DataBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlockBlock() { } + /// Constructor for building the block from a byte array public DataBlockBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _stringvalue = new byte[length]; - Array.Copy(bytes, i, _stringvalue, 0, length); i += length; - TaskID = new LLUUID(bytes, i); i += 16; - ItemID = new LLUUID(bytes, i); i += 16; - IntValue = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - ChannelID = new LLUUID(bytes, i); i += 16; + { + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _stringvalue = new byte[length]; + Array.Copy(bytes, i, _stringvalue, 0, length); i += length; + TaskID = new LLUUID(bytes, i); i += 16; + ItemID = new LLUUID(bytes, i); i += 16; + IntValue = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + ChannelID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(StringValue == null) { Console.WriteLine("Warning: StringValue is null, in " + this.GetType()); } - bytes[i++] = (byte)(StringValue.Length % 256); - bytes[i++] = (byte)((StringValue.Length >> 8) % 256); - Array.Copy(StringValue, 0, bytes, i, StringValue.Length); i += StringValue.Length; - if(TaskID == null) { Console.WriteLine("Warning: TaskID is null, in " + this.GetType()); } - Array.Copy(TaskID.GetBytes(), 0, bytes, i, 16); i += 16; - if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } - Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(IntValue % 256); - bytes[i++] = (byte)((IntValue >> 8) % 256); - bytes[i++] = (byte)((IntValue >> 16) % 256); - bytes[i++] = (byte)((IntValue >> 24) % 256); - if(ChannelID == null) { Console.WriteLine("Warning: ChannelID is null, in " + this.GetType()); } - Array.Copy(ChannelID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(StringValue == null) { Console.WriteLine("Warning: StringValue is null, in " + this.GetType()); } + bytes[i++] = (byte)(StringValue.Length % 256); + bytes[i++] = (byte)((StringValue.Length >> 8) % 256); + Array.Copy(StringValue, 0, bytes, i, StringValue.Length); i += StringValue.Length; + if(TaskID == null) { Console.WriteLine("Warning: TaskID is null, in " + this.GetType()); } + Array.Copy(TaskID.GetBytes(), 0, bytes, i, 16); i += 16; + if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } + Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(IntValue % 256); + bytes[i++] = (byte)((IntValue >> 8) % 256); + bytes[i++] = (byte)((IntValue >> 16) % 256); + bytes[i++] = (byte)((IntValue >> 24) % 256); + if(ChannelID == null) { Console.WriteLine("Warning: ChannelID is null, in " + this.GetType()); } + Array.Copy(ChannelID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- DataBlock --\n"; - output += Helpers.FieldToString(StringValue, "StringValue") + "\n"; - output += "TaskID: " + TaskID.ToString() + "\n"; - output += "ItemID: " + ItemID.ToString() + "\n"; - output += "IntValue: " + IntValue.ToString() + "\n"; - output += "ChannelID: " + ChannelID.ToString() + "\n"; + { + string output = "-- DataBlock --\n"; + output += Helpers.FieldToString(StringValue, "StringValue") + "\n"; + output += "TaskID: " + TaskID.ToString() + "\n"; + output += "ItemID: " + ItemID.ToString() + "\n"; + output += "IntValue: " + IntValue.ToString() + "\n"; + output += "ChannelID: " + ChannelID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.RpcScriptRequestInbound - public override PacketType Type { get { return PacketType.RpcScriptRequestInbound; } } - /// TargetBlock block - public TargetBlockBlock TargetBlock; - /// DataBlock block - public DataBlockBlock DataBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.RpcScriptRequestInbound + public override PacketType Type { get { return PacketType.RpcScriptRequestInbound; } } + /// TargetBlock block + public TargetBlockBlock TargetBlock; + /// DataBlock block + public DataBlockBlock DataBlock; + + /// Default constructor public RpcScriptRequestInboundPacket() - { - Header = new LowHeader(); - Header.ID = 497; - Header.Reliable = true; - TargetBlock = new TargetBlockBlock(); - DataBlock = new DataBlockBlock(); + { + Header = new LowHeader(); + Header.ID = 497; + Header.Reliable = true; + TargetBlock = new TargetBlockBlock(); + DataBlock = new DataBlockBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public RpcScriptRequestInboundPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - TargetBlock = new TargetBlockBlock(bytes, ref i); - DataBlock = new DataBlockBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + TargetBlock = new TargetBlockBlock(bytes, ref i); + DataBlock = new DataBlockBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public RpcScriptRequestInboundPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - TargetBlock = new TargetBlockBlock(bytes, ref i); - DataBlock = new DataBlockBlock(bytes, ref i); + { + Header = head; + TargetBlock = new TargetBlockBlock(bytes, ref i); + DataBlock = new DataBlockBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += TargetBlock.Length; length += DataBlock.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - TargetBlock.ToBytes(bytes, ref i); - DataBlock.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += TargetBlock.Length; length += DataBlock.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + TargetBlock.ToBytes(bytes, ref i); + DataBlock.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- RpcScriptRequestInbound ---\n"; - output += TargetBlock.ToString() + "\n"; - output += DataBlock.ToString() + "\n"; + { + string output = "--- RpcScriptRequestInbound ---\n"; + output += TargetBlock.ToString() + "\n"; + output += DataBlock.ToString() + "\n"; return output; } - + } - - /// RpcScriptRequestInboundForward packet + + /// RpcScriptRequestInboundForward packet public class RpcScriptRequestInboundForwardPacket : Packet - { - /// DataBlock block + { + /// DataBlock block public class DataBlockBlock - { - /// RPCServerIP field - public uint RPCServerIP; - private byte[] _stringvalue; - /// StringValue field + { + /// RPCServerIP field + public uint RPCServerIP; + private byte[] _stringvalue; + /// StringValue field public byte[] StringValue - { - get { return _stringvalue; } + { + get { return _stringvalue; } set - { - if (value == null) { _stringvalue = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _stringvalue = new byte[value.Length]; Array.Copy(value, _stringvalue, value.Length); } + { + if (value == null) { _stringvalue = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _stringvalue = new byte[value.Length]; Array.Copy(value, _stringvalue, value.Length); } } - } - /// TaskID field - public LLUUID TaskID; - /// ItemID field - public LLUUID ItemID; - /// IntValue field - public uint IntValue; - /// ChannelID field - public LLUUID ChannelID; - /// RPCServerPort field - public ushort RPCServerPort; - - /// Length of this block serialized in bytes + } + /// TaskID field + public LLUUID TaskID; + /// ItemID field + public LLUUID ItemID; + /// IntValue field + public uint IntValue; + /// ChannelID field + public LLUUID ChannelID; + /// RPCServerPort field + public ushort RPCServerPort; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 58; - if (StringValue != null) { length += 2 + StringValue.Length; } - return length; + { + int length = 58; + if (StringValue != null) { length += 2 + StringValue.Length; } + return length; } } - - /// Default constructor - public DataBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlockBlock() { } + /// Constructor for building the block from a byte array public DataBlockBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - RPCServerIP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _stringvalue = new byte[length]; - Array.Copy(bytes, i, _stringvalue, 0, length); i += length; - TaskID = new LLUUID(bytes, i); i += 16; - ItemID = new LLUUID(bytes, i); i += 16; - IntValue = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - ChannelID = new LLUUID(bytes, i); i += 16; - RPCServerPort = (ushort)((bytes[i++] << 8) + bytes[i++]); + { + RPCServerIP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _stringvalue = new byte[length]; + Array.Copy(bytes, i, _stringvalue, 0, length); i += length; + TaskID = new LLUUID(bytes, i); i += 16; + ItemID = new LLUUID(bytes, i); i += 16; + IntValue = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + ChannelID = new LLUUID(bytes, i); i += 16; + RPCServerPort = (ushort)((bytes[i++] << 8) + bytes[i++]); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(RPCServerIP % 256); - bytes[i++] = (byte)((RPCServerIP >> 8) % 256); - bytes[i++] = (byte)((RPCServerIP >> 16) % 256); - bytes[i++] = (byte)((RPCServerIP >> 24) % 256); - if(StringValue == null) { Console.WriteLine("Warning: StringValue is null, in " + this.GetType()); } - bytes[i++] = (byte)(StringValue.Length % 256); - bytes[i++] = (byte)((StringValue.Length >> 8) % 256); - Array.Copy(StringValue, 0, bytes, i, StringValue.Length); i += StringValue.Length; - if(TaskID == null) { Console.WriteLine("Warning: TaskID is null, in " + this.GetType()); } - Array.Copy(TaskID.GetBytes(), 0, bytes, i, 16); i += 16; - if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } - Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(IntValue % 256); - bytes[i++] = (byte)((IntValue >> 8) % 256); - bytes[i++] = (byte)((IntValue >> 16) % 256); - bytes[i++] = (byte)((IntValue >> 24) % 256); - if(ChannelID == null) { Console.WriteLine("Warning: ChannelID is null, in " + this.GetType()); } - Array.Copy(ChannelID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((RPCServerPort >> 8) % 256); - bytes[i++] = (byte)(RPCServerPort % 256); + { + bytes[i++] = (byte)(RPCServerIP % 256); + bytes[i++] = (byte)((RPCServerIP >> 8) % 256); + bytes[i++] = (byte)((RPCServerIP >> 16) % 256); + bytes[i++] = (byte)((RPCServerIP >> 24) % 256); + if(StringValue == null) { Console.WriteLine("Warning: StringValue is null, in " + this.GetType()); } + bytes[i++] = (byte)(StringValue.Length % 256); + bytes[i++] = (byte)((StringValue.Length >> 8) % 256); + Array.Copy(StringValue, 0, bytes, i, StringValue.Length); i += StringValue.Length; + if(TaskID == null) { Console.WriteLine("Warning: TaskID is null, in " + this.GetType()); } + Array.Copy(TaskID.GetBytes(), 0, bytes, i, 16); i += 16; + if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } + Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(IntValue % 256); + bytes[i++] = (byte)((IntValue >> 8) % 256); + bytes[i++] = (byte)((IntValue >> 16) % 256); + bytes[i++] = (byte)((IntValue >> 24) % 256); + if(ChannelID == null) { Console.WriteLine("Warning: ChannelID is null, in " + this.GetType()); } + Array.Copy(ChannelID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((RPCServerPort >> 8) % 256); + bytes[i++] = (byte)(RPCServerPort % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- DataBlock --\n"; - output += "RPCServerIP: " + RPCServerIP.ToString() + "\n"; - output += Helpers.FieldToString(StringValue, "StringValue") + "\n"; - output += "TaskID: " + TaskID.ToString() + "\n"; - output += "ItemID: " + ItemID.ToString() + "\n"; - output += "IntValue: " + IntValue.ToString() + "\n"; - output += "ChannelID: " + ChannelID.ToString() + "\n"; - output += "RPCServerPort: " + RPCServerPort.ToString() + "\n"; + { + string output = "-- DataBlock --\n"; + output += "RPCServerIP: " + RPCServerIP.ToString() + "\n"; + output += Helpers.FieldToString(StringValue, "StringValue") + "\n"; + output += "TaskID: " + TaskID.ToString() + "\n"; + output += "ItemID: " + ItemID.ToString() + "\n"; + output += "IntValue: " + IntValue.ToString() + "\n"; + output += "ChannelID: " + ChannelID.ToString() + "\n"; + output += "RPCServerPort: " + RPCServerPort.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.RpcScriptRequestInboundForward - public override PacketType Type { get { return PacketType.RpcScriptRequestInboundForward; } } - /// DataBlock block - public DataBlockBlock DataBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.RpcScriptRequestInboundForward + public override PacketType Type { get { return PacketType.RpcScriptRequestInboundForward; } } + /// DataBlock block + public DataBlockBlock DataBlock; + + /// Default constructor public RpcScriptRequestInboundForwardPacket() - { - Header = new LowHeader(); - Header.ID = 498; - Header.Reliable = true; - DataBlock = new DataBlockBlock(); + { + Header = new LowHeader(); + Header.ID = 498; + Header.Reliable = true; + DataBlock = new DataBlockBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public RpcScriptRequestInboundForwardPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - DataBlock = new DataBlockBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + DataBlock = new DataBlockBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public RpcScriptRequestInboundForwardPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - DataBlock = new DataBlockBlock(bytes, ref i); + { + Header = head; + DataBlock = new DataBlockBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += DataBlock.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - DataBlock.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += DataBlock.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + DataBlock.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- RpcScriptRequestInboundForward ---\n"; - output += DataBlock.ToString() + "\n"; + { + string output = "--- RpcScriptRequestInboundForward ---\n"; + output += DataBlock.ToString() + "\n"; return output; } - + } - - /// RpcScriptReplyInbound packet + + /// RpcScriptReplyInbound packet public class RpcScriptReplyInboundPacket : Packet - { - /// DataBlock block + { + /// DataBlock block public class DataBlockBlock - { - private byte[] _stringvalue; - /// StringValue field + { + private byte[] _stringvalue; + /// StringValue field public byte[] StringValue - { - get { return _stringvalue; } + { + get { return _stringvalue; } set - { - if (value == null) { _stringvalue = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _stringvalue = new byte[value.Length]; Array.Copy(value, _stringvalue, value.Length); } + { + if (value == null) { _stringvalue = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _stringvalue = new byte[value.Length]; Array.Copy(value, _stringvalue, value.Length); } } - } - /// TaskID field - public LLUUID TaskID; - /// ItemID field - public LLUUID ItemID; - /// IntValue field - public uint IntValue; - /// ChannelID field - public LLUUID ChannelID; - - /// Length of this block serialized in bytes + } + /// TaskID field + public LLUUID TaskID; + /// ItemID field + public LLUUID ItemID; + /// IntValue field + public uint IntValue; + /// ChannelID field + public LLUUID ChannelID; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 52; - if (StringValue != null) { length += 2 + StringValue.Length; } - return length; + { + int length = 52; + if (StringValue != null) { length += 2 + StringValue.Length; } + return length; } } - - /// Default constructor - public DataBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlockBlock() { } + /// Constructor for building the block from a byte array public DataBlockBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _stringvalue = new byte[length]; - Array.Copy(bytes, i, _stringvalue, 0, length); i += length; - TaskID = new LLUUID(bytes, i); i += 16; - ItemID = new LLUUID(bytes, i); i += 16; - IntValue = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - ChannelID = new LLUUID(bytes, i); i += 16; + { + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _stringvalue = new byte[length]; + Array.Copy(bytes, i, _stringvalue, 0, length); i += length; + TaskID = new LLUUID(bytes, i); i += 16; + ItemID = new LLUUID(bytes, i); i += 16; + IntValue = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + ChannelID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(StringValue == null) { Console.WriteLine("Warning: StringValue is null, in " + this.GetType()); } - bytes[i++] = (byte)(StringValue.Length % 256); - bytes[i++] = (byte)((StringValue.Length >> 8) % 256); - Array.Copy(StringValue, 0, bytes, i, StringValue.Length); i += StringValue.Length; - if(TaskID == null) { Console.WriteLine("Warning: TaskID is null, in " + this.GetType()); } - Array.Copy(TaskID.GetBytes(), 0, bytes, i, 16); i += 16; - if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } - Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(IntValue % 256); - bytes[i++] = (byte)((IntValue >> 8) % 256); - bytes[i++] = (byte)((IntValue >> 16) % 256); - bytes[i++] = (byte)((IntValue >> 24) % 256); - if(ChannelID == null) { Console.WriteLine("Warning: ChannelID is null, in " + this.GetType()); } - Array.Copy(ChannelID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(StringValue == null) { Console.WriteLine("Warning: StringValue is null, in " + this.GetType()); } + bytes[i++] = (byte)(StringValue.Length % 256); + bytes[i++] = (byte)((StringValue.Length >> 8) % 256); + Array.Copy(StringValue, 0, bytes, i, StringValue.Length); i += StringValue.Length; + if(TaskID == null) { Console.WriteLine("Warning: TaskID is null, in " + this.GetType()); } + Array.Copy(TaskID.GetBytes(), 0, bytes, i, 16); i += 16; + if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } + Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(IntValue % 256); + bytes[i++] = (byte)((IntValue >> 8) % 256); + bytes[i++] = (byte)((IntValue >> 16) % 256); + bytes[i++] = (byte)((IntValue >> 24) % 256); + if(ChannelID == null) { Console.WriteLine("Warning: ChannelID is null, in " + this.GetType()); } + Array.Copy(ChannelID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- DataBlock --\n"; - output += Helpers.FieldToString(StringValue, "StringValue") + "\n"; - output += "TaskID: " + TaskID.ToString() + "\n"; - output += "ItemID: " + ItemID.ToString() + "\n"; - output += "IntValue: " + IntValue.ToString() + "\n"; - output += "ChannelID: " + ChannelID.ToString() + "\n"; + { + string output = "-- DataBlock --\n"; + output += Helpers.FieldToString(StringValue, "StringValue") + "\n"; + output += "TaskID: " + TaskID.ToString() + "\n"; + output += "ItemID: " + ItemID.ToString() + "\n"; + output += "IntValue: " + IntValue.ToString() + "\n"; + output += "ChannelID: " + ChannelID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.RpcScriptReplyInbound - public override PacketType Type { get { return PacketType.RpcScriptReplyInbound; } } - /// DataBlock block - public DataBlockBlock DataBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.RpcScriptReplyInbound + public override PacketType Type { get { return PacketType.RpcScriptReplyInbound; } } + /// DataBlock block + public DataBlockBlock DataBlock; + + /// Default constructor public RpcScriptReplyInboundPacket() - { - Header = new LowHeader(); - Header.ID = 499; - Header.Reliable = true; - DataBlock = new DataBlockBlock(); + { + Header = new LowHeader(); + Header.ID = 499; + Header.Reliable = true; + DataBlock = new DataBlockBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public RpcScriptReplyInboundPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - DataBlock = new DataBlockBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + DataBlock = new DataBlockBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public RpcScriptReplyInboundPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - DataBlock = new DataBlockBlock(bytes, ref i); + { + Header = head; + DataBlock = new DataBlockBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += DataBlock.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - DataBlock.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += DataBlock.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + DataBlock.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- RpcScriptReplyInbound ---\n"; - output += DataBlock.ToString() + "\n"; + { + string output = "--- RpcScriptReplyInbound ---\n"; + output += DataBlock.ToString() + "\n"; return output; } - + } - - /// MailTaskSimRequest packet + + /// MailTaskSimRequest packet public class MailTaskSimRequestPacket : Packet - { - /// DataBlock block + { + /// DataBlock block public class DataBlockBlock - { - /// TaskID field - public LLUUID TaskID; - - /// Length of this block serialized in bytes + { + /// TaskID field + public LLUUID TaskID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public DataBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlockBlock() { } + /// Constructor for building the block from a byte array public DataBlockBlock(byte[] bytes, ref int i) - { + { try - { - TaskID = new LLUUID(bytes, i); i += 16; + { + TaskID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(TaskID == null) { Console.WriteLine("Warning: TaskID is null, in " + this.GetType()); } - Array.Copy(TaskID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(TaskID == null) { Console.WriteLine("Warning: TaskID is null, in " + this.GetType()); } + Array.Copy(TaskID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- DataBlock --\n"; - output += "TaskID: " + TaskID.ToString() + "\n"; + { + string output = "-- DataBlock --\n"; + output += "TaskID: " + TaskID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.MailTaskSimRequest - public override PacketType Type { get { return PacketType.MailTaskSimRequest; } } - /// DataBlock block - public DataBlockBlock DataBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.MailTaskSimRequest + public override PacketType Type { get { return PacketType.MailTaskSimRequest; } } + /// DataBlock block + public DataBlockBlock DataBlock; + + /// Default constructor public MailTaskSimRequestPacket() - { - Header = new LowHeader(); - Header.ID = 500; - Header.Reliable = true; - DataBlock = new DataBlockBlock(); + { + Header = new LowHeader(); + Header.ID = 500; + Header.Reliable = true; + DataBlock = new DataBlockBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public MailTaskSimRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - DataBlock = new DataBlockBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + DataBlock = new DataBlockBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public MailTaskSimRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - DataBlock = new DataBlockBlock(bytes, ref i); + { + Header = head; + DataBlock = new DataBlockBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += DataBlock.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - DataBlock.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += DataBlock.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + DataBlock.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- MailTaskSimRequest ---\n"; - output += DataBlock.ToString() + "\n"; + { + string output = "--- MailTaskSimRequest ---\n"; + output += DataBlock.ToString() + "\n"; return output; } - + } - - /// MailTaskSimReply packet + + /// MailTaskSimReply packet public class MailTaskSimReplyPacket : Packet - { - /// TargetBlock block + { + /// TargetBlock block public class TargetBlockBlock - { - private byte[] _targetip; - /// TargetIP field + { + private byte[] _targetip; + /// TargetIP field public byte[] TargetIP - { - get { return _targetip; } + { + get { return _targetip; } set - { - if (value == null) { _targetip = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _targetip = new byte[value.Length]; Array.Copy(value, _targetip, value.Length); } + { + if (value == null) { _targetip = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _targetip = new byte[value.Length]; Array.Copy(value, _targetip, value.Length); } } - } - /// TargetPort field - public ushort TargetPort; - - /// Length of this block serialized in bytes + } + /// TargetPort field + public ushort TargetPort; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 2; - if (TargetIP != null) { length += 1 + TargetIP.Length; } - return length; + { + int length = 2; + if (TargetIP != null) { length += 1 + TargetIP.Length; } + return length; } } - - /// Default constructor - public TargetBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public TargetBlockBlock() { } + /// Constructor for building the block from a byte array public TargetBlockBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _targetip = new byte[length]; - Array.Copy(bytes, i, _targetip, 0, length); i += length; - TargetPort = (ushort)((bytes[i++] << 8) + bytes[i++]); + { + length = (ushort)bytes[i++]; + _targetip = new byte[length]; + Array.Copy(bytes, i, _targetip, 0, length); i += length; + TargetPort = (ushort)((bytes[i++] << 8) + bytes[i++]); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(TargetIP == null) { Console.WriteLine("Warning: TargetIP is null, in " + this.GetType()); } - bytes[i++] = (byte)TargetIP.Length; - Array.Copy(TargetIP, 0, bytes, i, TargetIP.Length); i += TargetIP.Length; - bytes[i++] = (byte)((TargetPort >> 8) % 256); - bytes[i++] = (byte)(TargetPort % 256); + { + if(TargetIP == null) { Console.WriteLine("Warning: TargetIP is null, in " + this.GetType()); } + bytes[i++] = (byte)TargetIP.Length; + Array.Copy(TargetIP, 0, bytes, i, TargetIP.Length); i += TargetIP.Length; + bytes[i++] = (byte)((TargetPort >> 8) % 256); + bytes[i++] = (byte)(TargetPort % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- TargetBlock --\n"; - output += Helpers.FieldToString(TargetIP, "TargetIP") + "\n"; - output += "TargetPort: " + TargetPort.ToString() + "\n"; + { + string output = "-- TargetBlock --\n"; + output += Helpers.FieldToString(TargetIP, "TargetIP") + "\n"; + output += "TargetPort: " + TargetPort.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// DataBlock block + + /// DataBlock block public class DataBlockBlock - { - /// TaskID field - public LLUUID TaskID; - - /// Length of this block serialized in bytes + { + /// TaskID field + public LLUUID TaskID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public DataBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlockBlock() { } + /// Constructor for building the block from a byte array public DataBlockBlock(byte[] bytes, ref int i) - { + { try - { - TaskID = new LLUUID(bytes, i); i += 16; + { + TaskID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(TaskID == null) { Console.WriteLine("Warning: TaskID is null, in " + this.GetType()); } - Array.Copy(TaskID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(TaskID == null) { Console.WriteLine("Warning: TaskID is null, in " + this.GetType()); } + Array.Copy(TaskID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- DataBlock --\n"; - output += "TaskID: " + TaskID.ToString() + "\n"; + { + string output = "-- DataBlock --\n"; + output += "TaskID: " + TaskID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.MailTaskSimReply - public override PacketType Type { get { return PacketType.MailTaskSimReply; } } - /// TargetBlock block - public TargetBlockBlock TargetBlock; - /// DataBlock block - public DataBlockBlock DataBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.MailTaskSimReply + public override PacketType Type { get { return PacketType.MailTaskSimReply; } } + /// TargetBlock block + public TargetBlockBlock TargetBlock; + /// DataBlock block + public DataBlockBlock DataBlock; + + /// Default constructor public MailTaskSimReplyPacket() - { - Header = new LowHeader(); - Header.ID = 501; - Header.Reliable = true; - TargetBlock = new TargetBlockBlock(); - DataBlock = new DataBlockBlock(); + { + Header = new LowHeader(); + Header.ID = 501; + Header.Reliable = true; + TargetBlock = new TargetBlockBlock(); + DataBlock = new DataBlockBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public MailTaskSimReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - TargetBlock = new TargetBlockBlock(bytes, ref i); - DataBlock = new DataBlockBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + TargetBlock = new TargetBlockBlock(bytes, ref i); + DataBlock = new DataBlockBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public MailTaskSimReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - TargetBlock = new TargetBlockBlock(bytes, ref i); - DataBlock = new DataBlockBlock(bytes, ref i); + { + Header = head; + TargetBlock = new TargetBlockBlock(bytes, ref i); + DataBlock = new DataBlockBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += TargetBlock.Length; length += DataBlock.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - TargetBlock.ToBytes(bytes, ref i); - DataBlock.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += TargetBlock.Length; length += DataBlock.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + TargetBlock.ToBytes(bytes, ref i); + DataBlock.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- MailTaskSimReply ---\n"; - output += TargetBlock.ToString() + "\n"; - output += DataBlock.ToString() + "\n"; + { + string output = "--- MailTaskSimReply ---\n"; + output += TargetBlock.ToString() + "\n"; + output += DataBlock.ToString() + "\n"; return output; } - + } - - /// ScriptMailRegistration packet + + /// ScriptMailRegistration packet public class ScriptMailRegistrationPacket : Packet - { - /// DataBlock block + { + /// DataBlock block public class DataBlockBlock - { - private byte[] _targetip; - /// TargetIP field + { + private byte[] _targetip; + /// TargetIP field public byte[] TargetIP - { - get { return _targetip; } + { + get { return _targetip; } set - { - if (value == null) { _targetip = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _targetip = new byte[value.Length]; Array.Copy(value, _targetip, value.Length); } + { + if (value == null) { _targetip = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _targetip = new byte[value.Length]; Array.Copy(value, _targetip, value.Length); } } - } - /// TaskID field - public LLUUID TaskID; - /// TargetPort field - public ushort TargetPort; - /// Flags field - public uint Flags; - - /// Length of this block serialized in bytes + } + /// TaskID field + public LLUUID TaskID; + /// TargetPort field + public ushort TargetPort; + /// Flags field + public uint Flags; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 22; - if (TargetIP != null) { length += 1 + TargetIP.Length; } - return length; + { + int length = 22; + if (TargetIP != null) { length += 1 + TargetIP.Length; } + return length; } } - - /// Default constructor - public DataBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlockBlock() { } + /// Constructor for building the block from a byte array public DataBlockBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _targetip = new byte[length]; - Array.Copy(bytes, i, _targetip, 0, length); i += length; - TaskID = new LLUUID(bytes, i); i += 16; - TargetPort = (ushort)((bytes[i++] << 8) + bytes[i++]); - Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + length = (ushort)bytes[i++]; + _targetip = new byte[length]; + Array.Copy(bytes, i, _targetip, 0, length); i += length; + TaskID = new LLUUID(bytes, i); i += 16; + TargetPort = (ushort)((bytes[i++] << 8) + bytes[i++]); + Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(TargetIP == null) { Console.WriteLine("Warning: TargetIP is null, in " + this.GetType()); } - bytes[i++] = (byte)TargetIP.Length; - Array.Copy(TargetIP, 0, bytes, i, TargetIP.Length); i += TargetIP.Length; - if(TaskID == null) { Console.WriteLine("Warning: TaskID is null, in " + this.GetType()); } - Array.Copy(TaskID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((TargetPort >> 8) % 256); - bytes[i++] = (byte)(TargetPort % 256); - bytes[i++] = (byte)(Flags % 256); - bytes[i++] = (byte)((Flags >> 8) % 256); - bytes[i++] = (byte)((Flags >> 16) % 256); - bytes[i++] = (byte)((Flags >> 24) % 256); + { + if(TargetIP == null) { Console.WriteLine("Warning: TargetIP is null, in " + this.GetType()); } + bytes[i++] = (byte)TargetIP.Length; + Array.Copy(TargetIP, 0, bytes, i, TargetIP.Length); i += TargetIP.Length; + if(TaskID == null) { Console.WriteLine("Warning: TaskID is null, in " + this.GetType()); } + Array.Copy(TaskID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((TargetPort >> 8) % 256); + bytes[i++] = (byte)(TargetPort % 256); + bytes[i++] = (byte)(Flags % 256); + bytes[i++] = (byte)((Flags >> 8) % 256); + bytes[i++] = (byte)((Flags >> 16) % 256); + bytes[i++] = (byte)((Flags >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- DataBlock --\n"; - output += Helpers.FieldToString(TargetIP, "TargetIP") + "\n"; - output += "TaskID: " + TaskID.ToString() + "\n"; - output += "TargetPort: " + TargetPort.ToString() + "\n"; - output += "Flags: " + Flags.ToString() + "\n"; + { + string output = "-- DataBlock --\n"; + output += Helpers.FieldToString(TargetIP, "TargetIP") + "\n"; + output += "TaskID: " + TaskID.ToString() + "\n"; + output += "TargetPort: " + TargetPort.ToString() + "\n"; + output += "Flags: " + Flags.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ScriptMailRegistration - public override PacketType Type { get { return PacketType.ScriptMailRegistration; } } - /// DataBlock block - public DataBlockBlock DataBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ScriptMailRegistration + public override PacketType Type { get { return PacketType.ScriptMailRegistration; } } + /// DataBlock block + public DataBlockBlock DataBlock; + + /// Default constructor public ScriptMailRegistrationPacket() - { - Header = new LowHeader(); - Header.ID = 502; - Header.Reliable = true; - DataBlock = new DataBlockBlock(); + { + Header = new LowHeader(); + Header.ID = 502; + Header.Reliable = true; + DataBlock = new DataBlockBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ScriptMailRegistrationPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - DataBlock = new DataBlockBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + DataBlock = new DataBlockBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ScriptMailRegistrationPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - DataBlock = new DataBlockBlock(bytes, ref i); + { + Header = head; + DataBlock = new DataBlockBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += DataBlock.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - DataBlock.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += DataBlock.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + DataBlock.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ScriptMailRegistration ---\n"; - output += DataBlock.ToString() + "\n"; + { + string output = "--- ScriptMailRegistration ---\n"; + output += DataBlock.ToString() + "\n"; return output; } - + } - - /// ParcelMediaCommandMessage packet + + /// ParcelMediaCommandMessage packet public class ParcelMediaCommandMessagePacket : Packet - { - /// CommandBlock block + { + /// CommandBlock block public class CommandBlockBlock - { - /// Command field - public uint Command; - /// Time field - public float Time; - /// Flags field - public uint Flags; - - /// Length of this block serialized in bytes + { + /// Command field + public uint Command; + /// Time field + public float Time; + /// Flags field + public uint Flags; + + /// Length of this block serialized in bytes public int Length { get - { - return 12; + { + return 12; } } - - /// Default constructor - public CommandBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public CommandBlockBlock() { } + /// Constructor for building the block from a byte array public CommandBlockBlock(byte[] bytes, ref int i) - { + { try - { - Command = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - Time = BitConverter.ToSingle(bytes, i); i += 4; - Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + Command = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + Time = BitConverter.ToSingle(bytes, i); i += 4; + Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; - bytes[i++] = (byte)(Command % 256); - bytes[i++] = (byte)((Command >> 8) % 256); - bytes[i++] = (byte)((Command >> 16) % 256); - bytes[i++] = (byte)((Command >> 24) % 256); + { + byte[] ba; + bytes[i++] = (byte)(Command % 256); + bytes[i++] = (byte)((Command >> 8) % 256); + bytes[i++] = (byte)((Command >> 16) % 256); + bytes[i++] = (byte)((Command >> 24) % 256); ba = BitConverter.GetBytes(Time); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - bytes[i++] = (byte)(Flags % 256); - bytes[i++] = (byte)((Flags >> 8) % 256); - bytes[i++] = (byte)((Flags >> 16) % 256); - bytes[i++] = (byte)((Flags >> 24) % 256); + Array.Copy(ba, 0, bytes, i, 4); i += 4; + bytes[i++] = (byte)(Flags % 256); + bytes[i++] = (byte)((Flags >> 8) % 256); + bytes[i++] = (byte)((Flags >> 16) % 256); + bytes[i++] = (byte)((Flags >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- CommandBlock --\n"; - output += "Command: " + Command.ToString() + "\n"; - output += "Time: " + Time.ToString() + "\n"; - output += "Flags: " + Flags.ToString() + "\n"; + { + string output = "-- CommandBlock --\n"; + output += "Command: " + Command.ToString() + "\n"; + output += "Time: " + Time.ToString() + "\n"; + output += "Flags: " + Flags.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ParcelMediaCommandMessage - public override PacketType Type { get { return PacketType.ParcelMediaCommandMessage; } } - /// CommandBlock block - public CommandBlockBlock CommandBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ParcelMediaCommandMessage + public override PacketType Type { get { return PacketType.ParcelMediaCommandMessage; } } + /// CommandBlock block + public CommandBlockBlock CommandBlock; + + /// Default constructor public ParcelMediaCommandMessagePacket() - { - Header = new LowHeader(); - Header.ID = 503; - Header.Reliable = true; - CommandBlock = new CommandBlockBlock(); + { + Header = new LowHeader(); + Header.ID = 503; + Header.Reliable = true; + CommandBlock = new CommandBlockBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ParcelMediaCommandMessagePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - CommandBlock = new CommandBlockBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + CommandBlock = new CommandBlockBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ParcelMediaCommandMessagePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - CommandBlock = new CommandBlockBlock(bytes, ref i); + { + Header = head; + CommandBlock = new CommandBlockBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += CommandBlock.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - CommandBlock.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += CommandBlock.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + CommandBlock.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ParcelMediaCommandMessage ---\n"; - output += CommandBlock.ToString() + "\n"; + { + string output = "--- ParcelMediaCommandMessage ---\n"; + output += CommandBlock.ToString() + "\n"; return output; } - + } - - /// ParcelMediaUpdate packet + + /// ParcelMediaUpdate packet public class ParcelMediaUpdatePacket : Packet - { - /// DataBlock block + { + /// DataBlock block public class DataBlockBlock - { - /// MediaID field - public LLUUID MediaID; - private byte[] _mediaurl; - /// MediaURL field + { + /// MediaID field + public LLUUID MediaID; + private byte[] _mediaurl; + /// MediaURL field public byte[] MediaURL - { - get { return _mediaurl; } + { + get { return _mediaurl; } set - { - if (value == null) { _mediaurl = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _mediaurl = new byte[value.Length]; Array.Copy(value, _mediaurl, value.Length); } + { + if (value == null) { _mediaurl = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _mediaurl = new byte[value.Length]; Array.Copy(value, _mediaurl, value.Length); } } - } - /// MediaAutoScale field - public byte MediaAutoScale; - - /// Length of this block serialized in bytes + } + /// MediaAutoScale field + public byte MediaAutoScale; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 17; - if (MediaURL != null) { length += 1 + MediaURL.Length; } - return length; + { + int length = 17; + if (MediaURL != null) { length += 1 + MediaURL.Length; } + return length; } } - - /// Default constructor - public DataBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlockBlock() { } + /// Constructor for building the block from a byte array public DataBlockBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - MediaID = new LLUUID(bytes, i); i += 16; - length = (ushort)bytes[i++]; - _mediaurl = new byte[length]; - Array.Copy(bytes, i, _mediaurl, 0, length); i += length; - MediaAutoScale = (byte)bytes[i++]; + { + MediaID = new LLUUID(bytes, i); i += 16; + length = (ushort)bytes[i++]; + _mediaurl = new byte[length]; + Array.Copy(bytes, i, _mediaurl, 0, length); i += length; + MediaAutoScale = (byte)bytes[i++]; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(MediaID == null) { Console.WriteLine("Warning: MediaID is null, in " + this.GetType()); } - Array.Copy(MediaID.GetBytes(), 0, bytes, i, 16); i += 16; - if(MediaURL == null) { Console.WriteLine("Warning: MediaURL is null, in " + this.GetType()); } - bytes[i++] = (byte)MediaURL.Length; - Array.Copy(MediaURL, 0, bytes, i, MediaURL.Length); i += MediaURL.Length; - bytes[i++] = MediaAutoScale; + { + if(MediaID == null) { Console.WriteLine("Warning: MediaID is null, in " + this.GetType()); } + Array.Copy(MediaID.GetBytes(), 0, bytes, i, 16); i += 16; + if(MediaURL == null) { Console.WriteLine("Warning: MediaURL is null, in " + this.GetType()); } + bytes[i++] = (byte)MediaURL.Length; + Array.Copy(MediaURL, 0, bytes, i, MediaURL.Length); i += MediaURL.Length; + bytes[i++] = MediaAutoScale; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- DataBlock --\n"; - output += "MediaID: " + MediaID.ToString() + "\n"; - output += Helpers.FieldToString(MediaURL, "MediaURL") + "\n"; - output += "MediaAutoScale: " + MediaAutoScale.ToString() + "\n"; + { + string output = "-- DataBlock --\n"; + output += "MediaID: " + MediaID.ToString() + "\n"; + output += Helpers.FieldToString(MediaURL, "MediaURL") + "\n"; + output += "MediaAutoScale: " + MediaAutoScale.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ParcelMediaUpdate - public override PacketType Type { get { return PacketType.ParcelMediaUpdate; } } - /// DataBlock block - public DataBlockBlock DataBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ParcelMediaUpdate + public override PacketType Type { get { return PacketType.ParcelMediaUpdate; } } + /// DataBlock block + public DataBlockBlock DataBlock; + + /// Default constructor public ParcelMediaUpdatePacket() - { - Header = new LowHeader(); - Header.ID = 504; - Header.Reliable = true; - DataBlock = new DataBlockBlock(); + { + Header = new LowHeader(); + Header.ID = 504; + Header.Reliable = true; + DataBlock = new DataBlockBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ParcelMediaUpdatePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - DataBlock = new DataBlockBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + DataBlock = new DataBlockBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ParcelMediaUpdatePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - DataBlock = new DataBlockBlock(bytes, ref i); + { + Header = head; + DataBlock = new DataBlockBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += DataBlock.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - DataBlock.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += DataBlock.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + DataBlock.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ParcelMediaUpdate ---\n"; - output += DataBlock.ToString() + "\n"; + { + string output = "--- ParcelMediaUpdate ---\n"; + output += DataBlock.ToString() + "\n"; return output; } - + } - - /// LandStatRequest packet + + /// LandStatRequest packet public class LandStatRequestPacket : Packet - { - /// RequestData block + { + /// RequestData block public class RequestDataBlock - { - /// RequestFlags field - public uint RequestFlags; - /// ReportType field - public uint ReportType; - private byte[] _filter; - /// Filter field + { + /// RequestFlags field + public uint RequestFlags; + /// ReportType field + public uint ReportType; + private byte[] _filter; + /// Filter field public byte[] Filter - { - get { return _filter; } + { + get { return _filter; } set - { - if (value == null) { _filter = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _filter = new byte[value.Length]; Array.Copy(value, _filter, value.Length); } + { + if (value == null) { _filter = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _filter = new byte[value.Length]; Array.Copy(value, _filter, value.Length); } } - } - /// ParcelLocalID field - public int ParcelLocalID; - - /// Length of this block serialized in bytes + } + /// ParcelLocalID field + public int ParcelLocalID; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 12; - if (Filter != null) { length += 1 + Filter.Length; } - return length; + { + int length = 12; + if (Filter != null) { length += 1 + Filter.Length; } + return length; } } - - /// Default constructor - public RequestDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public RequestDataBlock() { } + /// Constructor for building the block from a byte array public RequestDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - RequestFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - ReportType = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _filter = new byte[length]; - Array.Copy(bytes, i, _filter, 0, length); i += length; - ParcelLocalID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + RequestFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + ReportType = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _filter = new byte[length]; + Array.Copy(bytes, i, _filter, 0, length); i += length; + ParcelLocalID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(RequestFlags % 256); - bytes[i++] = (byte)((RequestFlags >> 8) % 256); - bytes[i++] = (byte)((RequestFlags >> 16) % 256); - bytes[i++] = (byte)((RequestFlags >> 24) % 256); - bytes[i++] = (byte)(ReportType % 256); - bytes[i++] = (byte)((ReportType >> 8) % 256); - bytes[i++] = (byte)((ReportType >> 16) % 256); - bytes[i++] = (byte)((ReportType >> 24) % 256); - if(Filter == null) { Console.WriteLine("Warning: Filter is null, in " + this.GetType()); } - bytes[i++] = (byte)Filter.Length; - Array.Copy(Filter, 0, bytes, i, Filter.Length); i += Filter.Length; - bytes[i++] = (byte)(ParcelLocalID % 256); - bytes[i++] = (byte)((ParcelLocalID >> 8) % 256); - bytes[i++] = (byte)((ParcelLocalID >> 16) % 256); - bytes[i++] = (byte)((ParcelLocalID >> 24) % 256); + { + bytes[i++] = (byte)(RequestFlags % 256); + bytes[i++] = (byte)((RequestFlags >> 8) % 256); + bytes[i++] = (byte)((RequestFlags >> 16) % 256); + bytes[i++] = (byte)((RequestFlags >> 24) % 256); + bytes[i++] = (byte)(ReportType % 256); + bytes[i++] = (byte)((ReportType >> 8) % 256); + bytes[i++] = (byte)((ReportType >> 16) % 256); + bytes[i++] = (byte)((ReportType >> 24) % 256); + if(Filter == null) { Console.WriteLine("Warning: Filter is null, in " + this.GetType()); } + bytes[i++] = (byte)Filter.Length; + Array.Copy(Filter, 0, bytes, i, Filter.Length); i += Filter.Length; + bytes[i++] = (byte)(ParcelLocalID % 256); + bytes[i++] = (byte)((ParcelLocalID >> 8) % 256); + bytes[i++] = (byte)((ParcelLocalID >> 16) % 256); + bytes[i++] = (byte)((ParcelLocalID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- RequestData --\n"; - output += "RequestFlags: " + RequestFlags.ToString() + "\n"; - output += "ReportType: " + ReportType.ToString() + "\n"; - output += Helpers.FieldToString(Filter, "Filter") + "\n"; - output += "ParcelLocalID: " + ParcelLocalID.ToString() + "\n"; + { + string output = "-- RequestData --\n"; + output += "RequestFlags: " + RequestFlags.ToString() + "\n"; + output += "ReportType: " + ReportType.ToString() + "\n"; + output += Helpers.FieldToString(Filter, "Filter") + "\n"; + output += "ParcelLocalID: " + ParcelLocalID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.LandStatRequest - public override PacketType Type { get { return PacketType.LandStatRequest; } } - /// RequestData block - public RequestDataBlock RequestData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.LandStatRequest + public override PacketType Type { get { return PacketType.LandStatRequest; } } + /// RequestData block + public RequestDataBlock RequestData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public LandStatRequestPacket() - { - Header = new LowHeader(); - Header.ID = 505; - Header.Reliable = true; - RequestData = new RequestDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new LowHeader(); + Header.ID = 505; + Header.Reliable = true; + RequestData = new RequestDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public LandStatRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - RequestData = new RequestDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + RequestData = new RequestDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public LandStatRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - RequestData = new RequestDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + RequestData = new RequestDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += RequestData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - RequestData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += RequestData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + RequestData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- LandStatRequest ---\n"; - output += RequestData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- LandStatRequest ---\n"; + output += RequestData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// LandStatReply packet + + /// LandStatReply packet public class LandStatReplyPacket : Packet - { - /// RequestData block + { + /// RequestData block public class RequestDataBlock - { - /// RequestFlags field - public uint RequestFlags; - /// ReportType field - public uint ReportType; - /// TotalObjectCount field - public uint TotalObjectCount; - - /// Length of this block serialized in bytes + { + /// RequestFlags field + public uint RequestFlags; + /// ReportType field + public uint ReportType; + /// TotalObjectCount field + public uint TotalObjectCount; + + /// Length of this block serialized in bytes public int Length { get - { - return 12; + { + return 12; } } - - /// Default constructor - public RequestDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public RequestDataBlock() { } + /// Constructor for building the block from a byte array public RequestDataBlock(byte[] bytes, ref int i) - { + { try - { - RequestFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - ReportType = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - TotalObjectCount = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + RequestFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + ReportType = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + TotalObjectCount = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(RequestFlags % 256); - bytes[i++] = (byte)((RequestFlags >> 8) % 256); - bytes[i++] = (byte)((RequestFlags >> 16) % 256); - bytes[i++] = (byte)((RequestFlags >> 24) % 256); - bytes[i++] = (byte)(ReportType % 256); - bytes[i++] = (byte)((ReportType >> 8) % 256); - bytes[i++] = (byte)((ReportType >> 16) % 256); - bytes[i++] = (byte)((ReportType >> 24) % 256); - bytes[i++] = (byte)(TotalObjectCount % 256); - bytes[i++] = (byte)((TotalObjectCount >> 8) % 256); - bytes[i++] = (byte)((TotalObjectCount >> 16) % 256); - bytes[i++] = (byte)((TotalObjectCount >> 24) % 256); + { + bytes[i++] = (byte)(RequestFlags % 256); + bytes[i++] = (byte)((RequestFlags >> 8) % 256); + bytes[i++] = (byte)((RequestFlags >> 16) % 256); + bytes[i++] = (byte)((RequestFlags >> 24) % 256); + bytes[i++] = (byte)(ReportType % 256); + bytes[i++] = (byte)((ReportType >> 8) % 256); + bytes[i++] = (byte)((ReportType >> 16) % 256); + bytes[i++] = (byte)((ReportType >> 24) % 256); + bytes[i++] = (byte)(TotalObjectCount % 256); + bytes[i++] = (byte)((TotalObjectCount >> 8) % 256); + bytes[i++] = (byte)((TotalObjectCount >> 16) % 256); + bytes[i++] = (byte)((TotalObjectCount >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- RequestData --\n"; - output += "RequestFlags: " + RequestFlags.ToString() + "\n"; - output += "ReportType: " + ReportType.ToString() + "\n"; - output += "TotalObjectCount: " + TotalObjectCount.ToString() + "\n"; + { + string output = "-- RequestData --\n"; + output += "RequestFlags: " + RequestFlags.ToString() + "\n"; + output += "ReportType: " + ReportType.ToString() + "\n"; + output += "TotalObjectCount: " + TotalObjectCount.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// ReportData block + + /// ReportData block public class ReportDataBlock - { - /// LocationX field - public float LocationX; - /// LocationY field - public float LocationY; - /// LocationZ field - public float LocationZ; - private byte[] _taskname; - /// TaskName field + { + /// LocationX field + public float LocationX; + /// LocationY field + public float LocationY; + /// LocationZ field + public float LocationZ; + private byte[] _taskname; + /// TaskName field public byte[] TaskName - { - get { return _taskname; } + { + get { return _taskname; } set - { - if (value == null) { _taskname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _taskname = new byte[value.Length]; Array.Copy(value, _taskname, value.Length); } + { + if (value == null) { _taskname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _taskname = new byte[value.Length]; Array.Copy(value, _taskname, value.Length); } } - } - /// TaskID field - public LLUUID TaskID; - /// Score field - public float Score; - /// TaskLocalID field - public uint TaskLocalID; - private byte[] _ownername; - /// OwnerName field + } + /// TaskID field + public LLUUID TaskID; + /// Score field + public float Score; + /// TaskLocalID field + public uint TaskLocalID; + private byte[] _ownername; + /// OwnerName field public byte[] OwnerName - { - get { return _ownername; } + { + get { return _ownername; } set - { - if (value == null) { _ownername = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _ownername = new byte[value.Length]; Array.Copy(value, _ownername, value.Length); } + { + if (value == null) { _ownername = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _ownername = new byte[value.Length]; Array.Copy(value, _ownername, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 36; - if (TaskName != null) { length += 1 + TaskName.Length; } - if (OwnerName != null) { length += 1 + OwnerName.Length; } - return length; + { + int length = 36; + if (TaskName != null) { length += 1 + TaskName.Length; } + if (OwnerName != null) { length += 1 + OwnerName.Length; } + return length; } } - - /// Default constructor - public ReportDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ReportDataBlock() { } + /// Constructor for building the block from a byte array public ReportDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - LocationX = BitConverter.ToSingle(bytes, i); i += 4; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - LocationY = BitConverter.ToSingle(bytes, i); i += 4; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - LocationZ = BitConverter.ToSingle(bytes, i); i += 4; - length = (ushort)bytes[i++]; - _taskname = new byte[length]; - Array.Copy(bytes, i, _taskname, 0, length); i += length; - TaskID = new LLUUID(bytes, i); i += 16; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - Score = BitConverter.ToSingle(bytes, i); i += 4; - TaskLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _ownername = new byte[length]; - Array.Copy(bytes, i, _ownername, 0, length); i += length; + { + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + LocationX = BitConverter.ToSingle(bytes, i); i += 4; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + LocationY = BitConverter.ToSingle(bytes, i); i += 4; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + LocationZ = BitConverter.ToSingle(bytes, i); i += 4; + length = (ushort)bytes[i++]; + _taskname = new byte[length]; + Array.Copy(bytes, i, _taskname, 0, length); i += length; + TaskID = new LLUUID(bytes, i); i += 16; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + Score = BitConverter.ToSingle(bytes, i); i += 4; + TaskLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _ownername = new byte[length]; + Array.Copy(bytes, i, _ownername, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; + { + byte[] ba; ba = BitConverter.GetBytes(LocationX); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; ba = BitConverter.GetBytes(LocationY); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; ba = BitConverter.GetBytes(LocationZ); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - if(TaskName == null) { Console.WriteLine("Warning: TaskName is null, in " + this.GetType()); } - bytes[i++] = (byte)TaskName.Length; - Array.Copy(TaskName, 0, bytes, i, TaskName.Length); i += TaskName.Length; - if(TaskID == null) { Console.WriteLine("Warning: TaskID is null, in " + this.GetType()); } - Array.Copy(TaskID.GetBytes(), 0, bytes, i, 16); i += 16; + Array.Copy(ba, 0, bytes, i, 4); i += 4; + if(TaskName == null) { Console.WriteLine("Warning: TaskName is null, in " + this.GetType()); } + bytes[i++] = (byte)TaskName.Length; + Array.Copy(TaskName, 0, bytes, i, TaskName.Length); i += TaskName.Length; + if(TaskID == null) { Console.WriteLine("Warning: TaskID is null, in " + this.GetType()); } + Array.Copy(TaskID.GetBytes(), 0, bytes, i, 16); i += 16; ba = BitConverter.GetBytes(Score); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - bytes[i++] = (byte)(TaskLocalID % 256); - bytes[i++] = (byte)((TaskLocalID >> 8) % 256); - bytes[i++] = (byte)((TaskLocalID >> 16) % 256); - bytes[i++] = (byte)((TaskLocalID >> 24) % 256); - if(OwnerName == null) { Console.WriteLine("Warning: OwnerName is null, in " + this.GetType()); } - bytes[i++] = (byte)OwnerName.Length; - Array.Copy(OwnerName, 0, bytes, i, OwnerName.Length); i += OwnerName.Length; + Array.Copy(ba, 0, bytes, i, 4); i += 4; + bytes[i++] = (byte)(TaskLocalID % 256); + bytes[i++] = (byte)((TaskLocalID >> 8) % 256); + bytes[i++] = (byte)((TaskLocalID >> 16) % 256); + bytes[i++] = (byte)((TaskLocalID >> 24) % 256); + if(OwnerName == null) { Console.WriteLine("Warning: OwnerName is null, in " + this.GetType()); } + bytes[i++] = (byte)OwnerName.Length; + Array.Copy(OwnerName, 0, bytes, i, OwnerName.Length); i += OwnerName.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ReportData --\n"; - output += "LocationX: " + LocationX.ToString() + "\n"; - output += "LocationY: " + LocationY.ToString() + "\n"; - output += "LocationZ: " + LocationZ.ToString() + "\n"; - output += Helpers.FieldToString(TaskName, "TaskName") + "\n"; - output += "TaskID: " + TaskID.ToString() + "\n"; - output += "Score: " + Score.ToString() + "\n"; - output += "TaskLocalID: " + TaskLocalID.ToString() + "\n"; - output += Helpers.FieldToString(OwnerName, "OwnerName") + "\n"; + { + string output = "-- ReportData --\n"; + output += "LocationX: " + LocationX.ToString() + "\n"; + output += "LocationY: " + LocationY.ToString() + "\n"; + output += "LocationZ: " + LocationZ.ToString() + "\n"; + output += Helpers.FieldToString(TaskName, "TaskName") + "\n"; + output += "TaskID: " + TaskID.ToString() + "\n"; + output += "Score: " + Score.ToString() + "\n"; + output += "TaskLocalID: " + TaskLocalID.ToString() + "\n"; + output += Helpers.FieldToString(OwnerName, "OwnerName") + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.LandStatReply - public override PacketType Type { get { return PacketType.LandStatReply; } } - /// RequestData block - public RequestDataBlock RequestData; - /// ReportData block - public ReportDataBlock[] ReportData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.LandStatReply + public override PacketType Type { get { return PacketType.LandStatReply; } } + /// RequestData block + public RequestDataBlock RequestData; + /// ReportData block + public ReportDataBlock[] ReportData; + + /// Default constructor public LandStatReplyPacket() - { - Header = new LowHeader(); - Header.ID = 506; - Header.Reliable = true; - RequestData = new RequestDataBlock(); - ReportData = new ReportDataBlock[0]; + { + Header = new LowHeader(); + Header.ID = 506; + Header.Reliable = true; + RequestData = new RequestDataBlock(); + ReportData = new ReportDataBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public LandStatReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - RequestData = new RequestDataBlock(bytes, ref i); - int count = (int)bytes[i++]; - ReportData = new ReportDataBlock[count]; - for (int j = 0; j < count; j++) - { ReportData[j] = new ReportDataBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + RequestData = new RequestDataBlock(bytes, ref i); + int count = (int)bytes[i++]; + ReportData = new ReportDataBlock[count]; + for (int j = 0; j < count; j++) + { ReportData[j] = new ReportDataBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public LandStatReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - RequestData = new RequestDataBlock(bytes, ref i); - int count = (int)bytes[i++]; - ReportData = new ReportDataBlock[count]; - for (int j = 0; j < count; j++) - { ReportData[j] = new ReportDataBlock(bytes, ref i); } + { + Header = head; + RequestData = new RequestDataBlock(bytes, ref i); + int count = (int)bytes[i++]; + ReportData = new ReportDataBlock[count]; + for (int j = 0; j < count; j++) + { ReportData[j] = new ReportDataBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += RequestData.Length;; - length++; - for (int j = 0; j < ReportData.Length; j++) { length += ReportData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - RequestData.ToBytes(bytes, ref i); - bytes[i++] = (byte)ReportData.Length; - for (int j = 0; j < ReportData.Length; j++) { ReportData[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += RequestData.Length;; + length++; + for (int j = 0; j < ReportData.Length; j++) { length += ReportData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + RequestData.ToBytes(bytes, ref i); + bytes[i++] = (byte)ReportData.Length; + for (int j = 0; j < ReportData.Length; j++) { ReportData[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- LandStatReply ---\n"; - output += RequestData.ToString() + "\n"; + { + string output = "--- LandStatReply ---\n"; + output += RequestData.ToString() + "\n"; for (int j = 0; j < ReportData.Length; j++) - { + { output += ReportData[j].ToString() + "\n"; - } + } return output; } - + } - - /// SecuredTemplateChecksumRequest packet + + /// SecuredTemplateChecksumRequest packet public class SecuredTemplateChecksumRequestPacket : Packet - { - /// TokenBlock block + { + /// TokenBlock block public class TokenBlockBlock - { - /// Token field - public LLUUID Token; - - /// Length of this block serialized in bytes + { + /// Token field + public LLUUID Token; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public TokenBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public TokenBlockBlock() { } + /// Constructor for building the block from a byte array public TokenBlockBlock(byte[] bytes, ref int i) - { + { try - { - Token = new LLUUID(bytes, i); i += 16; + { + Token = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(Token == null) { Console.WriteLine("Warning: Token is null, in " + this.GetType()); } - Array.Copy(Token.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(Token == null) { Console.WriteLine("Warning: Token is null, in " + this.GetType()); } + Array.Copy(Token.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- TokenBlock --\n"; - output += "Token: " + Token.ToString() + "\n"; + { + string output = "-- TokenBlock --\n"; + output += "Token: " + Token.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.SecuredTemplateChecksumRequest - public override PacketType Type { get { return PacketType.SecuredTemplateChecksumRequest; } } - /// TokenBlock block - public TokenBlockBlock TokenBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.SecuredTemplateChecksumRequest + public override PacketType Type { get { return PacketType.SecuredTemplateChecksumRequest; } } + /// TokenBlock block + public TokenBlockBlock TokenBlock; + + /// Default constructor public SecuredTemplateChecksumRequestPacket() - { - Header = new LowHeader(); - Header.ID = 65530; - Header.Reliable = true; - TokenBlock = new TokenBlockBlock(); + { + Header = new LowHeader(); + Header.ID = 65530; + Header.Reliable = true; + TokenBlock = new TokenBlockBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public SecuredTemplateChecksumRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - TokenBlock = new TokenBlockBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + TokenBlock = new TokenBlockBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public SecuredTemplateChecksumRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - TokenBlock = new TokenBlockBlock(bytes, ref i); + { + Header = head; + TokenBlock = new TokenBlockBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += TokenBlock.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - TokenBlock.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += TokenBlock.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + TokenBlock.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- SecuredTemplateChecksumRequest ---\n"; - output += TokenBlock.ToString() + "\n"; + { + string output = "--- SecuredTemplateChecksumRequest ---\n"; + output += TokenBlock.ToString() + "\n"; return output; } - + } - - /// PacketAck packet + + /// PacketAck packet public class PacketAckPacket : Packet - { - /// Packets block + { + /// Packets block public class PacketsBlock - { - /// ID field - public uint ID; - - /// Length of this block serialized in bytes + { + /// ID field + public uint ID; + + /// Length of this block serialized in bytes public int Length { get - { - return 4; + { + return 4; } } - - /// Default constructor - public PacketsBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public PacketsBlock() { } + /// Constructor for building the block from a byte array public PacketsBlock(byte[] bytes, ref int i) - { + { try - { - ID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + ID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(ID % 256); - bytes[i++] = (byte)((ID >> 8) % 256); - bytes[i++] = (byte)((ID >> 16) % 256); - bytes[i++] = (byte)((ID >> 24) % 256); + { + bytes[i++] = (byte)(ID % 256); + bytes[i++] = (byte)((ID >> 8) % 256); + bytes[i++] = (byte)((ID >> 16) % 256); + bytes[i++] = (byte)((ID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Packets --\n"; - output += "ID: " + ID.ToString() + "\n"; + { + string output = "-- Packets --\n"; + output += "ID: " + ID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.PacketAck - public override PacketType Type { get { return PacketType.PacketAck; } } - /// Packets block - public PacketsBlock[] Packets; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.PacketAck + public override PacketType Type { get { return PacketType.PacketAck; } } + /// Packets block + public PacketsBlock[] Packets; + + /// Default constructor public PacketAckPacket() - { - Header = new LowHeader(); - Header.ID = 65531; - Header.Reliable = true; - Packets = new PacketsBlock[0]; + { + Header = new LowHeader(); + Header.ID = 65531; + Header.Reliable = true; + Packets = new PacketsBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public PacketAckPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - Packets = new PacketsBlock[count]; - for (int j = 0; j < count; j++) - { Packets[j] = new PacketsBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + Packets = new PacketsBlock[count]; + for (int j = 0; j < count; j++) + { Packets[j] = new PacketsBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public PacketAckPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - Packets = new PacketsBlock[count]; - for (int j = 0; j < count; j++) - { Packets[j] = new PacketsBlock(bytes, ref i); } + { + Header = head; + int count = (int)bytes[i++]; + Packets = new PacketsBlock[count]; + for (int j = 0; j < count; j++) + { Packets[j] = new PacketsBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; -; - length++; - for (int j = 0; j < Packets.Length; j++) { length += Packets[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)Packets.Length; - for (int j = 0; j < Packets.Length; j++) { Packets[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; +; + length++; + for (int j = 0; j < Packets.Length; j++) { length += Packets[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)Packets.Length; + for (int j = 0; j < Packets.Length; j++) { Packets[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- PacketAck ---\n"; + { + string output = "--- PacketAck ---\n"; for (int j = 0; j < Packets.Length; j++) - { + { output += Packets[j].ToString() + "\n"; - } + } return output; } - + } - - /// OpenCircuit packet + + /// OpenCircuit packet public class OpenCircuitPacket : Packet - { - /// CircuitInfo block + { + /// CircuitInfo block public class CircuitInfoBlock - { - /// IP field - public uint IP; - /// Port field - public ushort Port; - - /// Length of this block serialized in bytes + { + /// IP field + public uint IP; + /// Port field + public ushort Port; + + /// Length of this block serialized in bytes public int Length { get - { - return 6; + { + return 6; } } - - /// Default constructor - public CircuitInfoBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public CircuitInfoBlock() { } + /// Constructor for building the block from a byte array public CircuitInfoBlock(byte[] bytes, ref int i) - { + { try - { - IP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Port = (ushort)((bytes[i++] << 8) + bytes[i++]); + { + IP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Port = (ushort)((bytes[i++] << 8) + bytes[i++]); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(IP % 256); - bytes[i++] = (byte)((IP >> 8) % 256); - bytes[i++] = (byte)((IP >> 16) % 256); - bytes[i++] = (byte)((IP >> 24) % 256); - bytes[i++] = (byte)((Port >> 8) % 256); - bytes[i++] = (byte)(Port % 256); + { + bytes[i++] = (byte)(IP % 256); + bytes[i++] = (byte)((IP >> 8) % 256); + bytes[i++] = (byte)((IP >> 16) % 256); + bytes[i++] = (byte)((IP >> 24) % 256); + bytes[i++] = (byte)((Port >> 8) % 256); + bytes[i++] = (byte)(Port % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- CircuitInfo --\n"; - output += "IP: " + IP.ToString() + "\n"; - output += "Port: " + Port.ToString() + "\n"; + { + string output = "-- CircuitInfo --\n"; + output += "IP: " + IP.ToString() + "\n"; + output += "Port: " + Port.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.OpenCircuit - public override PacketType Type { get { return PacketType.OpenCircuit; } } - /// CircuitInfo block - public CircuitInfoBlock CircuitInfo; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.OpenCircuit + public override PacketType Type { get { return PacketType.OpenCircuit; } } + /// CircuitInfo block + public CircuitInfoBlock CircuitInfo; + + /// Default constructor public OpenCircuitPacket() - { - Header = new LowHeader(); - Header.ID = 65532; - Header.Reliable = true; - CircuitInfo = new CircuitInfoBlock(); + { + Header = new LowHeader(); + Header.ID = 65532; + Header.Reliable = true; + CircuitInfo = new CircuitInfoBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public OpenCircuitPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - CircuitInfo = new CircuitInfoBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + CircuitInfo = new CircuitInfoBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public OpenCircuitPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - CircuitInfo = new CircuitInfoBlock(bytes, ref i); + { + Header = head; + CircuitInfo = new CircuitInfoBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += CircuitInfo.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - CircuitInfo.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += CircuitInfo.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + CircuitInfo.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- OpenCircuit ---\n"; - output += CircuitInfo.ToString() + "\n"; + { + string output = "--- OpenCircuit ---\n"; + output += CircuitInfo.ToString() + "\n"; return output; } - + } - - /// CloseCircuit packet + + /// CloseCircuit packet public class CloseCircuitPacket : Packet - { - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.CloseCircuit - public override PacketType Type { get { return PacketType.CloseCircuit; } } - - /// Default constructor + { + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.CloseCircuit + public override PacketType Type { get { return PacketType.CloseCircuit; } } + + /// Default constructor public CloseCircuitPacket() - { - Header = new LowHeader(); - Header.ID = 65533; - Header.Reliable = true; + { + Header = new LowHeader(); + Header.ID = 65533; + Header.Reliable = true; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public CloseCircuitPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public CloseCircuitPacket(Header head, byte[] bytes, ref int i) - { - Header = head; + { + Header = head; } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; -; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; +; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- CloseCircuit ---\n"; + { + string output = "--- CloseCircuit ---\n"; return output; } - + } - - /// TemplateChecksumRequest packet + + /// TemplateChecksumRequest packet public class TemplateChecksumRequestPacket : Packet - { - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.TemplateChecksumRequest - public override PacketType Type { get { return PacketType.TemplateChecksumRequest; } } - - /// Default constructor + { + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.TemplateChecksumRequest + public override PacketType Type { get { return PacketType.TemplateChecksumRequest; } } + + /// Default constructor public TemplateChecksumRequestPacket() - { - Header = new LowHeader(); - Header.ID = 65534; - Header.Reliable = true; + { + Header = new LowHeader(); + Header.ID = 65534; + Header.Reliable = true; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public TemplateChecksumRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public TemplateChecksumRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; + { + Header = head; } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; -; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; +; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- TemplateChecksumRequest ---\n"; + { + string output = "--- TemplateChecksumRequest ---\n"; return output; } - + } - - /// TemplateChecksumReply packet + + /// TemplateChecksumReply packet public class TemplateChecksumReplyPacket : Packet - { - /// DataBlock block + { + /// DataBlock block public class DataBlockBlock - { - /// ServerVersion field - public byte ServerVersion; - /// PatchVersion field - public byte PatchVersion; - /// Checksum field - public uint Checksum; - /// Flags field - public uint Flags; - /// MajorVersion field - public byte MajorVersion; - /// MinorVersion field - public byte MinorVersion; - - /// Length of this block serialized in bytes + { + /// ServerVersion field + public byte ServerVersion; + /// PatchVersion field + public byte PatchVersion; + /// Checksum field + public uint Checksum; + /// Flags field + public uint Flags; + /// MajorVersion field + public byte MajorVersion; + /// MinorVersion field + public byte MinorVersion; + + /// Length of this block serialized in bytes public int Length { get - { - return 12; + { + return 12; } } - - /// Default constructor - public DataBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlockBlock() { } + /// Constructor for building the block from a byte array public DataBlockBlock(byte[] bytes, ref int i) - { + { try - { - ServerVersion = (byte)bytes[i++]; - PatchVersion = (byte)bytes[i++]; - Checksum = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - MajorVersion = (byte)bytes[i++]; - MinorVersion = (byte)bytes[i++]; + { + ServerVersion = (byte)bytes[i++]; + PatchVersion = (byte)bytes[i++]; + Checksum = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Flags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + MajorVersion = (byte)bytes[i++]; + MinorVersion = (byte)bytes[i++]; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = ServerVersion; - bytes[i++] = PatchVersion; - bytes[i++] = (byte)(Checksum % 256); - bytes[i++] = (byte)((Checksum >> 8) % 256); - bytes[i++] = (byte)((Checksum >> 16) % 256); - bytes[i++] = (byte)((Checksum >> 24) % 256); - bytes[i++] = (byte)(Flags % 256); - bytes[i++] = (byte)((Flags >> 8) % 256); - bytes[i++] = (byte)((Flags >> 16) % 256); - bytes[i++] = (byte)((Flags >> 24) % 256); - bytes[i++] = MajorVersion; - bytes[i++] = MinorVersion; + { + bytes[i++] = ServerVersion; + bytes[i++] = PatchVersion; + bytes[i++] = (byte)(Checksum % 256); + bytes[i++] = (byte)((Checksum >> 8) % 256); + bytes[i++] = (byte)((Checksum >> 16) % 256); + bytes[i++] = (byte)((Checksum >> 24) % 256); + bytes[i++] = (byte)(Flags % 256); + bytes[i++] = (byte)((Flags >> 8) % 256); + bytes[i++] = (byte)((Flags >> 16) % 256); + bytes[i++] = (byte)((Flags >> 24) % 256); + bytes[i++] = MajorVersion; + bytes[i++] = MinorVersion; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- DataBlock --\n"; - output += "ServerVersion: " + ServerVersion.ToString() + "\n"; - output += "PatchVersion: " + PatchVersion.ToString() + "\n"; - output += "Checksum: " + Checksum.ToString() + "\n"; - output += "Flags: " + Flags.ToString() + "\n"; - output += "MajorVersion: " + MajorVersion.ToString() + "\n"; - output += "MinorVersion: " + MinorVersion.ToString() + "\n"; + { + string output = "-- DataBlock --\n"; + output += "ServerVersion: " + ServerVersion.ToString() + "\n"; + output += "PatchVersion: " + PatchVersion.ToString() + "\n"; + output += "Checksum: " + Checksum.ToString() + "\n"; + output += "Flags: " + Flags.ToString() + "\n"; + output += "MajorVersion: " + MajorVersion.ToString() + "\n"; + output += "MinorVersion: " + MinorVersion.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// TokenBlock block + + /// TokenBlock block public class TokenBlockBlock - { - /// Token field - public LLUUID Token; - - /// Length of this block serialized in bytes + { + /// Token field + public LLUUID Token; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public TokenBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public TokenBlockBlock() { } + /// Constructor for building the block from a byte array public TokenBlockBlock(byte[] bytes, ref int i) - { + { try - { - Token = new LLUUID(bytes, i); i += 16; + { + Token = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(Token == null) { Console.WriteLine("Warning: Token is null, in " + this.GetType()); } - Array.Copy(Token.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(Token == null) { Console.WriteLine("Warning: Token is null, in " + this.GetType()); } + Array.Copy(Token.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- TokenBlock --\n"; - output += "Token: " + Token.ToString() + "\n"; + { + string output = "-- TokenBlock --\n"; + output += "Token: " + Token.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.TemplateChecksumReply - public override PacketType Type { get { return PacketType.TemplateChecksumReply; } } - /// DataBlock block - public DataBlockBlock DataBlock; - /// TokenBlock block - public TokenBlockBlock TokenBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.TemplateChecksumReply + public override PacketType Type { get { return PacketType.TemplateChecksumReply; } } + /// DataBlock block + public DataBlockBlock DataBlock; + /// TokenBlock block + public TokenBlockBlock TokenBlock; + + /// Default constructor public TemplateChecksumReplyPacket() - { - Header = new LowHeader(); - Header.ID = 65535; - Header.Reliable = true; - DataBlock = new DataBlockBlock(); - TokenBlock = new TokenBlockBlock(); + { + Header = new LowHeader(); + Header.ID = 65535; + Header.Reliable = true; + DataBlock = new DataBlockBlock(); + TokenBlock = new TokenBlockBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public TemplateChecksumReplyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new LowHeader(bytes, ref i, ref packetEnd); - DataBlock = new DataBlockBlock(bytes, ref i); - TokenBlock = new TokenBlockBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new LowHeader(bytes, ref i, ref packetEnd); + DataBlock = new DataBlockBlock(bytes, ref i); + TokenBlock = new TokenBlockBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public TemplateChecksumReplyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - DataBlock = new DataBlockBlock(bytes, ref i); - TokenBlock = new TokenBlockBlock(bytes, ref i); + { + Header = head; + DataBlock = new DataBlockBlock(bytes, ref i); + TokenBlock = new TokenBlockBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 8; - length += DataBlock.Length; length += TokenBlock.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - DataBlock.ToBytes(bytes, ref i); - TokenBlock.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 8; + length += DataBlock.Length; length += TokenBlock.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + DataBlock.ToBytes(bytes, ref i); + TokenBlock.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- TemplateChecksumReply ---\n"; - output += DataBlock.ToString() + "\n"; - output += TokenBlock.ToString() + "\n"; + { + string output = "--- TemplateChecksumReply ---\n"; + output += DataBlock.ToString() + "\n"; + output += TokenBlock.ToString() + "\n"; return output; } - + } - - /// ClosestSimulator packet + + /// ClosestSimulator packet public class ClosestSimulatorPacket : Packet - { - /// SimulatorBlock block + { + /// SimulatorBlock block public class SimulatorBlockBlock - { - /// IP field - public uint IP; - /// Port field - public ushort Port; - /// Handle field - public ulong Handle; - - /// Length of this block serialized in bytes + { + /// IP field + public uint IP; + /// Port field + public ushort Port; + /// Handle field + public ulong Handle; + + /// Length of this block serialized in bytes public int Length { get - { - return 14; + { + return 14; } } - - /// Default constructor - public SimulatorBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public SimulatorBlockBlock() { } + /// Constructor for building the block from a byte array public SimulatorBlockBlock(byte[] bytes, ref int i) - { + { try - { - IP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Port = (ushort)((bytes[i++] << 8) + bytes[i++]); - Handle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + { + IP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Port = (ushort)((bytes[i++] << 8) + bytes[i++]); + Handle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(IP % 256); - bytes[i++] = (byte)((IP >> 8) % 256); - bytes[i++] = (byte)((IP >> 16) % 256); - bytes[i++] = (byte)((IP >> 24) % 256); - bytes[i++] = (byte)((Port >> 8) % 256); - bytes[i++] = (byte)(Port % 256); - bytes[i++] = (byte)(Handle % 256); - bytes[i++] = (byte)((Handle >> 8) % 256); - bytes[i++] = (byte)((Handle >> 16) % 256); - bytes[i++] = (byte)((Handle >> 24) % 256); - bytes[i++] = (byte)((Handle >> 32) % 256); - bytes[i++] = (byte)((Handle >> 40) % 256); - bytes[i++] = (byte)((Handle >> 48) % 256); - bytes[i++] = (byte)((Handle >> 56) % 256); + { + bytes[i++] = (byte)(IP % 256); + bytes[i++] = (byte)((IP >> 8) % 256); + bytes[i++] = (byte)((IP >> 16) % 256); + bytes[i++] = (byte)((IP >> 24) % 256); + bytes[i++] = (byte)((Port >> 8) % 256); + bytes[i++] = (byte)(Port % 256); + bytes[i++] = (byte)(Handle % 256); + bytes[i++] = (byte)((Handle >> 8) % 256); + bytes[i++] = (byte)((Handle >> 16) % 256); + bytes[i++] = (byte)((Handle >> 24) % 256); + bytes[i++] = (byte)((Handle >> 32) % 256); + bytes[i++] = (byte)((Handle >> 40) % 256); + bytes[i++] = (byte)((Handle >> 48) % 256); + bytes[i++] = (byte)((Handle >> 56) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- SimulatorBlock --\n"; - output += "IP: " + IP.ToString() + "\n"; - output += "Port: " + Port.ToString() + "\n"; - output += "Handle: " + Handle.ToString() + "\n"; + { + string output = "-- SimulatorBlock --\n"; + output += "IP: " + IP.ToString() + "\n"; + output += "Port: " + Port.ToString() + "\n"; + output += "Handle: " + Handle.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// Viewer block + + /// Viewer block public class ViewerBlock - { - /// ID field - public LLUUID ID; - - /// Length of this block serialized in bytes + { + /// ID field + public LLUUID ID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public ViewerBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ViewerBlock() { } + /// Constructor for building the block from a byte array public ViewerBlock(byte[] bytes, ref int i) - { + { try - { - ID = new LLUUID(bytes, i); i += 16; + { + ID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } - Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } + Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Viewer --\n"; - output += "ID: " + ID.ToString() + "\n"; + { + string output = "-- Viewer --\n"; + output += "ID: " + ID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ClosestSimulator - public override PacketType Type { get { return PacketType.ClosestSimulator; } } - /// SimulatorBlock block - public SimulatorBlockBlock SimulatorBlock; - /// Viewer block - public ViewerBlock Viewer; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ClosestSimulator + public override PacketType Type { get { return PacketType.ClosestSimulator; } } + /// SimulatorBlock block + public SimulatorBlockBlock SimulatorBlock; + /// Viewer block + public ViewerBlock Viewer; + + /// Default constructor public ClosestSimulatorPacket() - { - Header = new MediumHeader(); - Header.ID = 1; - Header.Reliable = true; - SimulatorBlock = new SimulatorBlockBlock(); - Viewer = new ViewerBlock(); + { + Header = new MediumHeader(); + Header.ID = 1; + Header.Reliable = true; + SimulatorBlock = new SimulatorBlockBlock(); + Viewer = new ViewerBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ClosestSimulatorPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new MediumHeader(bytes, ref i, ref packetEnd); - SimulatorBlock = new SimulatorBlockBlock(bytes, ref i); - Viewer = new ViewerBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new MediumHeader(bytes, ref i, ref packetEnd); + SimulatorBlock = new SimulatorBlockBlock(bytes, ref i); + Viewer = new ViewerBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ClosestSimulatorPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - SimulatorBlock = new SimulatorBlockBlock(bytes, ref i); - Viewer = new ViewerBlock(bytes, ref i); + { + Header = head; + SimulatorBlock = new SimulatorBlockBlock(bytes, ref i); + Viewer = new ViewerBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 6; - length += SimulatorBlock.Length; length += Viewer.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - SimulatorBlock.ToBytes(bytes, ref i); - Viewer.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 6; + length += SimulatorBlock.Length; length += Viewer.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + SimulatorBlock.ToBytes(bytes, ref i); + Viewer.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ClosestSimulator ---\n"; - output += SimulatorBlock.ToString() + "\n"; - output += Viewer.ToString() + "\n"; + { + string output = "--- ClosestSimulator ---\n"; + output += SimulatorBlock.ToString() + "\n"; + output += Viewer.ToString() + "\n"; return output; } - + } - - /// ObjectAdd packet + + /// ObjectAdd packet public class ObjectAddPacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - /// AddFlags field - public uint AddFlags; - /// PathTwistBegin field - public sbyte PathTwistBegin; - /// PathEnd field - public byte PathEnd; - /// ProfileBegin field - public byte ProfileBegin; - /// PathRadiusOffset field - public sbyte PathRadiusOffset; - /// PathSkew field - public sbyte PathSkew; - /// RayStart field - public LLVector3 RayStart; - /// ProfileCurve field - public byte ProfileCurve; - /// PathScaleX field - public byte PathScaleX; - /// PathScaleY field - public byte PathScaleY; - /// Material field - public byte Material; - /// PathShearX field - public byte PathShearX; - /// PathShearY field - public byte PathShearY; - /// PathTaperX field - public sbyte PathTaperX; - /// PathTaperY field - public sbyte PathTaperY; - /// RayEndIsIntersection field - public byte RayEndIsIntersection; - /// RayEnd field - public LLVector3 RayEnd; - /// ProfileEnd field - public byte ProfileEnd; - /// PathBegin field - public byte PathBegin; - /// BypassRaycast field - public byte BypassRaycast; - /// PCode field - public byte PCode; - /// PathCurve field - public byte PathCurve; - /// Scale field - public LLVector3 Scale; - /// State field - public byte State; - /// PathTwist field - public sbyte PathTwist; - private byte[] _textureentry; - /// TextureEntry field + { + /// AddFlags field + public uint AddFlags; + /// PathTwistBegin field + public sbyte PathTwistBegin; + /// PathEnd field + public byte PathEnd; + /// ProfileBegin field + public byte ProfileBegin; + /// PathRadiusOffset field + public sbyte PathRadiusOffset; + /// PathSkew field + public sbyte PathSkew; + /// RayStart field + public LLVector3 RayStart; + /// ProfileCurve field + public byte ProfileCurve; + /// PathScaleX field + public byte PathScaleX; + /// PathScaleY field + public byte PathScaleY; + /// Material field + public byte Material; + /// PathShearX field + public byte PathShearX; + /// PathShearY field + public byte PathShearY; + /// PathTaperX field + public sbyte PathTaperX; + /// PathTaperY field + public sbyte PathTaperY; + /// RayEndIsIntersection field + public byte RayEndIsIntersection; + /// RayEnd field + public LLVector3 RayEnd; + /// ProfileEnd field + public byte ProfileEnd; + /// PathBegin field + public byte PathBegin; + /// BypassRaycast field + public byte BypassRaycast; + /// PCode field + public byte PCode; + /// PathCurve field + public byte PathCurve; + /// Scale field + public LLVector3 Scale; + /// State field + public byte State; + /// PathTwist field + public sbyte PathTwist; + private byte[] _textureentry; + /// TextureEntry field public byte[] TextureEntry - { - get { return _textureentry; } + { + get { return _textureentry; } set - { - if (value == null) { _textureentry = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _textureentry = new byte[value.Length]; Array.Copy(value, _textureentry, value.Length); } + { + if (value == null) { _textureentry = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _textureentry = new byte[value.Length]; Array.Copy(value, _textureentry, value.Length); } } - } - /// ProfileHollow field - public byte ProfileHollow; - /// PathRevolutions field - public byte PathRevolutions; - /// Rotation field - public LLQuaternion Rotation; - /// RayTargetID field - public LLUUID RayTargetID; - - /// Length of this block serialized in bytes + } + /// ProfileHollow field + public byte ProfileHollow; + /// PathRevolutions field + public byte PathRevolutions; + /// Rotation field + public LLQuaternion Rotation; + /// RayTargetID field + public LLUUID RayTargetID; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 91; - if (TextureEntry != null) { length += 2 + TextureEntry.Length; } - return length; + { + int length = 91; + if (TextureEntry != null) { length += 2 + TextureEntry.Length; } + return length; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - AddFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - PathTwistBegin = (sbyte)bytes[i++]; - PathEnd = (byte)bytes[i++]; - ProfileBegin = (byte)bytes[i++]; - PathRadiusOffset = (sbyte)bytes[i++]; - PathSkew = (sbyte)bytes[i++]; - RayStart = new LLVector3(bytes, i); i += 12; - ProfileCurve = (byte)bytes[i++]; - PathScaleX = (byte)bytes[i++]; - PathScaleY = (byte)bytes[i++]; - Material = (byte)bytes[i++]; - PathShearX = (byte)bytes[i++]; - PathShearY = (byte)bytes[i++]; - PathTaperX = (sbyte)bytes[i++]; - PathTaperY = (sbyte)bytes[i++]; - RayEndIsIntersection = (byte)bytes[i++]; - RayEnd = new LLVector3(bytes, i); i += 12; - ProfileEnd = (byte)bytes[i++]; - PathBegin = (byte)bytes[i++]; - BypassRaycast = (byte)bytes[i++]; - PCode = (byte)bytes[i++]; - PathCurve = (byte)bytes[i++]; - Scale = new LLVector3(bytes, i); i += 12; - State = (byte)bytes[i++]; - PathTwist = (sbyte)bytes[i++]; - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _textureentry = new byte[length]; - Array.Copy(bytes, i, _textureentry, 0, length); i += length; - ProfileHollow = (byte)bytes[i++]; - PathRevolutions = (byte)bytes[i++]; - Rotation = new LLQuaternion(bytes, i, true); i += 12; - RayTargetID = new LLUUID(bytes, i); i += 16; + { + AddFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + PathTwistBegin = (sbyte)bytes[i++]; + PathEnd = (byte)bytes[i++]; + ProfileBegin = (byte)bytes[i++]; + PathRadiusOffset = (sbyte)bytes[i++]; + PathSkew = (sbyte)bytes[i++]; + RayStart = new LLVector3(bytes, i); i += 12; + ProfileCurve = (byte)bytes[i++]; + PathScaleX = (byte)bytes[i++]; + PathScaleY = (byte)bytes[i++]; + Material = (byte)bytes[i++]; + PathShearX = (byte)bytes[i++]; + PathShearY = (byte)bytes[i++]; + PathTaperX = (sbyte)bytes[i++]; + PathTaperY = (sbyte)bytes[i++]; + RayEndIsIntersection = (byte)bytes[i++]; + RayEnd = new LLVector3(bytes, i); i += 12; + ProfileEnd = (byte)bytes[i++]; + PathBegin = (byte)bytes[i++]; + BypassRaycast = (byte)bytes[i++]; + PCode = (byte)bytes[i++]; + PathCurve = (byte)bytes[i++]; + Scale = new LLVector3(bytes, i); i += 12; + State = (byte)bytes[i++]; + PathTwist = (sbyte)bytes[i++]; + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _textureentry = new byte[length]; + Array.Copy(bytes, i, _textureentry, 0, length); i += length; + ProfileHollow = (byte)bytes[i++]; + PathRevolutions = (byte)bytes[i++]; + Rotation = new LLQuaternion(bytes, i, true); i += 12; + RayTargetID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(AddFlags % 256); - bytes[i++] = (byte)((AddFlags >> 8) % 256); - bytes[i++] = (byte)((AddFlags >> 16) % 256); - bytes[i++] = (byte)((AddFlags >> 24) % 256); - bytes[i++] = (byte)PathTwistBegin; - bytes[i++] = PathEnd; - bytes[i++] = ProfileBegin; - bytes[i++] = (byte)PathRadiusOffset; - bytes[i++] = (byte)PathSkew; - if(RayStart == null) { Console.WriteLine("Warning: RayStart is null, in " + this.GetType()); } - Array.Copy(RayStart.GetBytes(), 0, bytes, i, 12); i += 12; - bytes[i++] = ProfileCurve; - bytes[i++] = PathScaleX; - bytes[i++] = PathScaleY; - bytes[i++] = Material; - bytes[i++] = PathShearX; - bytes[i++] = PathShearY; - bytes[i++] = (byte)PathTaperX; - bytes[i++] = (byte)PathTaperY; - bytes[i++] = RayEndIsIntersection; - if(RayEnd == null) { Console.WriteLine("Warning: RayEnd is null, in " + this.GetType()); } - Array.Copy(RayEnd.GetBytes(), 0, bytes, i, 12); i += 12; - bytes[i++] = ProfileEnd; - bytes[i++] = PathBegin; - bytes[i++] = BypassRaycast; - bytes[i++] = PCode; - bytes[i++] = PathCurve; - if(Scale == null) { Console.WriteLine("Warning: Scale is null, in " + this.GetType()); } - Array.Copy(Scale.GetBytes(), 0, bytes, i, 12); i += 12; - bytes[i++] = State; - bytes[i++] = (byte)PathTwist; - if(TextureEntry == null) { Console.WriteLine("Warning: TextureEntry is null, in " + this.GetType()); } - bytes[i++] = (byte)(TextureEntry.Length % 256); - bytes[i++] = (byte)((TextureEntry.Length >> 8) % 256); - Array.Copy(TextureEntry, 0, bytes, i, TextureEntry.Length); i += TextureEntry.Length; - bytes[i++] = ProfileHollow; - bytes[i++] = PathRevolutions; - if(Rotation == null) { Console.WriteLine("Warning: Rotation is null, in " + this.GetType()); } - Array.Copy(Rotation.GetBytes(), 0, bytes, i, 12); i += 12; - if(RayTargetID == null) { Console.WriteLine("Warning: RayTargetID is null, in " + this.GetType()); } - Array.Copy(RayTargetID.GetBytes(), 0, bytes, i, 16); i += 16; + { + bytes[i++] = (byte)(AddFlags % 256); + bytes[i++] = (byte)((AddFlags >> 8) % 256); + bytes[i++] = (byte)((AddFlags >> 16) % 256); + bytes[i++] = (byte)((AddFlags >> 24) % 256); + bytes[i++] = (byte)PathTwistBegin; + bytes[i++] = PathEnd; + bytes[i++] = ProfileBegin; + bytes[i++] = (byte)PathRadiusOffset; + bytes[i++] = (byte)PathSkew; + if(RayStart == null) { Console.WriteLine("Warning: RayStart is null, in " + this.GetType()); } + Array.Copy(RayStart.GetBytes(), 0, bytes, i, 12); i += 12; + bytes[i++] = ProfileCurve; + bytes[i++] = PathScaleX; + bytes[i++] = PathScaleY; + bytes[i++] = Material; + bytes[i++] = PathShearX; + bytes[i++] = PathShearY; + bytes[i++] = (byte)PathTaperX; + bytes[i++] = (byte)PathTaperY; + bytes[i++] = RayEndIsIntersection; + if(RayEnd == null) { Console.WriteLine("Warning: RayEnd is null, in " + this.GetType()); } + Array.Copy(RayEnd.GetBytes(), 0, bytes, i, 12); i += 12; + bytes[i++] = ProfileEnd; + bytes[i++] = PathBegin; + bytes[i++] = BypassRaycast; + bytes[i++] = PCode; + bytes[i++] = PathCurve; + if(Scale == null) { Console.WriteLine("Warning: Scale is null, in " + this.GetType()); } + Array.Copy(Scale.GetBytes(), 0, bytes, i, 12); i += 12; + bytes[i++] = State; + bytes[i++] = (byte)PathTwist; + if(TextureEntry == null) { Console.WriteLine("Warning: TextureEntry is null, in " + this.GetType()); } + bytes[i++] = (byte)(TextureEntry.Length % 256); + bytes[i++] = (byte)((TextureEntry.Length >> 8) % 256); + Array.Copy(TextureEntry, 0, bytes, i, TextureEntry.Length); i += TextureEntry.Length; + bytes[i++] = ProfileHollow; + bytes[i++] = PathRevolutions; + if(Rotation == null) { Console.WriteLine("Warning: Rotation is null, in " + this.GetType()); } + Array.Copy(Rotation.GetBytes(), 0, bytes, i, 12); i += 12; + if(RayTargetID == null) { Console.WriteLine("Warning: RayTargetID is null, in " + this.GetType()); } + Array.Copy(RayTargetID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += "AddFlags: " + AddFlags.ToString() + "\n"; - output += "PathTwistBegin: " + PathTwistBegin.ToString() + "\n"; - output += "PathEnd: " + PathEnd.ToString() + "\n"; - output += "ProfileBegin: " + ProfileBegin.ToString() + "\n"; - output += "PathRadiusOffset: " + PathRadiusOffset.ToString() + "\n"; - output += "PathSkew: " + PathSkew.ToString() + "\n"; - output += "RayStart: " + RayStart.ToString() + "\n"; - output += "ProfileCurve: " + ProfileCurve.ToString() + "\n"; - output += "PathScaleX: " + PathScaleX.ToString() + "\n"; - output += "PathScaleY: " + PathScaleY.ToString() + "\n"; - output += "Material: " + Material.ToString() + "\n"; - output += "PathShearX: " + PathShearX.ToString() + "\n"; - output += "PathShearY: " + PathShearY.ToString() + "\n"; - output += "PathTaperX: " + PathTaperX.ToString() + "\n"; - output += "PathTaperY: " + PathTaperY.ToString() + "\n"; - output += "RayEndIsIntersection: " + RayEndIsIntersection.ToString() + "\n"; - output += "RayEnd: " + RayEnd.ToString() + "\n"; - output += "ProfileEnd: " + ProfileEnd.ToString() + "\n"; - output += "PathBegin: " + PathBegin.ToString() + "\n"; - output += "BypassRaycast: " + BypassRaycast.ToString() + "\n"; - output += "PCode: " + PCode.ToString() + "\n"; - output += "PathCurve: " + PathCurve.ToString() + "\n"; - output += "Scale: " + Scale.ToString() + "\n"; - output += "State: " + State.ToString() + "\n"; - output += "PathTwist: " + PathTwist.ToString() + "\n"; - output += Helpers.FieldToString(TextureEntry, "TextureEntry") + "\n"; - output += "ProfileHollow: " + ProfileHollow.ToString() + "\n"; - output += "PathRevolutions: " + PathRevolutions.ToString() + "\n"; - output += "Rotation: " + Rotation.ToString() + "\n"; - output += "RayTargetID: " + RayTargetID.ToString() + "\n"; + { + string output = "-- ObjectData --\n"; + output += "AddFlags: " + AddFlags.ToString() + "\n"; + output += "PathTwistBegin: " + PathTwistBegin.ToString() + "\n"; + output += "PathEnd: " + PathEnd.ToString() + "\n"; + output += "ProfileBegin: " + ProfileBegin.ToString() + "\n"; + output += "PathRadiusOffset: " + PathRadiusOffset.ToString() + "\n"; + output += "PathSkew: " + PathSkew.ToString() + "\n"; + output += "RayStart: " + RayStart.ToString() + "\n"; + output += "ProfileCurve: " + ProfileCurve.ToString() + "\n"; + output += "PathScaleX: " + PathScaleX.ToString() + "\n"; + output += "PathScaleY: " + PathScaleY.ToString() + "\n"; + output += "Material: " + Material.ToString() + "\n"; + output += "PathShearX: " + PathShearX.ToString() + "\n"; + output += "PathShearY: " + PathShearY.ToString() + "\n"; + output += "PathTaperX: " + PathTaperX.ToString() + "\n"; + output += "PathTaperY: " + PathTaperY.ToString() + "\n"; + output += "RayEndIsIntersection: " + RayEndIsIntersection.ToString() + "\n"; + output += "RayEnd: " + RayEnd.ToString() + "\n"; + output += "ProfileEnd: " + ProfileEnd.ToString() + "\n"; + output += "PathBegin: " + PathBegin.ToString() + "\n"; + output += "BypassRaycast: " + BypassRaycast.ToString() + "\n"; + output += "PCode: " + PCode.ToString() + "\n"; + output += "PathCurve: " + PathCurve.ToString() + "\n"; + output += "Scale: " + Scale.ToString() + "\n"; + output += "State: " + State.ToString() + "\n"; + output += "PathTwist: " + PathTwist.ToString() + "\n"; + output += Helpers.FieldToString(TextureEntry, "TextureEntry") + "\n"; + output += "ProfileHollow: " + ProfileHollow.ToString() + "\n"; + output += "PathRevolutions: " + PathRevolutions.ToString() + "\n"; + output += "Rotation: " + Rotation.ToString() + "\n"; + output += "RayTargetID: " + RayTargetID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - /// GroupID field - public LLUUID GroupID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + /// GroupID field + public LLUUID GroupID; + + /// Length of this block serialized in bytes public int Length { get - { - return 48; + { + return 48; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; - GroupID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; + GroupID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ObjectAdd - public override PacketType Type { get { return PacketType.ObjectAdd; } } - /// ObjectData block - public ObjectDataBlock ObjectData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ObjectAdd + public override PacketType Type { get { return PacketType.ObjectAdd; } } + /// ObjectData block + public ObjectDataBlock ObjectData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ObjectAddPacket() - { - Header = new MediumHeader(); - Header.ID = 2; - Header.Reliable = true; - Header.Zerocoded = true; - ObjectData = new ObjectDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new MediumHeader(); + Header.ID = 2; + Header.Reliable = true; + Header.Zerocoded = true; + ObjectData = new ObjectDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ObjectAddPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new MediumHeader(bytes, ref i, ref packetEnd); - ObjectData = new ObjectDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new MediumHeader(bytes, ref i, ref packetEnd); + ObjectData = new ObjectDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ObjectAddPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - ObjectData = new ObjectDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + ObjectData = new ObjectDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 6; - length += ObjectData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - ObjectData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 6; + length += ObjectData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + ObjectData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ObjectAdd ---\n"; - output += ObjectData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- ObjectAdd ---\n"; + output += ObjectData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// MultipleObjectUpdate packet + + /// MultipleObjectUpdate packet public class MultipleObjectUpdatePacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - private byte[] _data; - /// Data field + { + private byte[] _data; + /// Data field public byte[] Data - { - get { return _data; } + { + get { return _data; } set - { - if (value == null) { _data = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _data = new byte[value.Length]; Array.Copy(value, _data, value.Length); } + { + if (value == null) { _data = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _data = new byte[value.Length]; Array.Copy(value, _data, value.Length); } } - } - /// Type field - public byte Type; - /// ObjectLocalID field - public uint ObjectLocalID; - - /// Length of this block serialized in bytes + } + /// Type field + public byte Type; + /// ObjectLocalID field + public uint ObjectLocalID; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 5; - if (Data != null) { length += 1 + Data.Length; } - return length; + { + int length = 5; + if (Data != null) { length += 1 + Data.Length; } + return length; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _data = new byte[length]; - Array.Copy(bytes, i, _data, 0, length); i += length; - Type = (byte)bytes[i++]; - ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + length = (ushort)bytes[i++]; + _data = new byte[length]; + Array.Copy(bytes, i, _data, 0, length); i += length; + Type = (byte)bytes[i++]; + ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(Data == null) { Console.WriteLine("Warning: Data is null, in " + this.GetType()); } - bytes[i++] = (byte)Data.Length; - Array.Copy(Data, 0, bytes, i, Data.Length); i += Data.Length; - bytes[i++] = Type; - bytes[i++] = (byte)(ObjectLocalID % 256); - bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); + { + if(Data == null) { Console.WriteLine("Warning: Data is null, in " + this.GetType()); } + bytes[i++] = (byte)Data.Length; + Array.Copy(Data, 0, bytes, i, Data.Length); i += Data.Length; + bytes[i++] = Type; + bytes[i++] = (byte)(ObjectLocalID % 256); + bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += Helpers.FieldToString(Data, "Data") + "\n"; - output += "Type: " + Type.ToString() + "\n"; - output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; + { + string output = "-- ObjectData --\n"; + output += Helpers.FieldToString(Data, "Data") + "\n"; + output += "Type: " + Type.ToString() + "\n"; + output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.MultipleObjectUpdate - public override PacketType Type { get { return PacketType.MultipleObjectUpdate; } } - /// ObjectData block - public ObjectDataBlock[] ObjectData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.MultipleObjectUpdate + public override PacketType Type { get { return PacketType.MultipleObjectUpdate; } } + /// ObjectData block + public ObjectDataBlock[] ObjectData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public MultipleObjectUpdatePacket() - { - Header = new MediumHeader(); - Header.ID = 3; - Header.Reliable = true; - Header.Zerocoded = true; - ObjectData = new ObjectDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new MediumHeader(); + Header.ID = 3; + Header.Reliable = true; + Header.Zerocoded = true; + ObjectData = new ObjectDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public MultipleObjectUpdatePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new MediumHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new MediumHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public MultipleObjectUpdatePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 6; - length += AgentData.Length;; - length++; - for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ObjectData.Length; - for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 6; + length += AgentData.Length;; + length++; + for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ObjectData.Length; + for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- MultipleObjectUpdate ---\n"; + { + string output = "--- MultipleObjectUpdate ---\n"; for (int j = 0; j < ObjectData.Length; j++) - { + { output += ObjectData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// RequestMultipleObjects packet + + /// RequestMultipleObjects packet public class RequestMultipleObjectsPacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - /// ID field - public uint ID; - /// CacheMissType field - public byte CacheMissType; - - /// Length of this block serialized in bytes + { + /// ID field + public uint ID; + /// CacheMissType field + public byte CacheMissType; + + /// Length of this block serialized in bytes public int Length { get - { - return 5; + { + return 5; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { + { try - { - ID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - CacheMissType = (byte)bytes[i++]; + { + ID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + CacheMissType = (byte)bytes[i++]; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(ID % 256); - bytes[i++] = (byte)((ID >> 8) % 256); - bytes[i++] = (byte)((ID >> 16) % 256); - bytes[i++] = (byte)((ID >> 24) % 256); - bytes[i++] = CacheMissType; + { + bytes[i++] = (byte)(ID % 256); + bytes[i++] = (byte)((ID >> 8) % 256); + bytes[i++] = (byte)((ID >> 16) % 256); + bytes[i++] = (byte)((ID >> 24) % 256); + bytes[i++] = CacheMissType; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += "ID: " + ID.ToString() + "\n"; - output += "CacheMissType: " + CacheMissType.ToString() + "\n"; + { + string output = "-- ObjectData --\n"; + output += "ID: " + ID.ToString() + "\n"; + output += "CacheMissType: " + CacheMissType.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.RequestMultipleObjects - public override PacketType Type { get { return PacketType.RequestMultipleObjects; } } - /// ObjectData block - public ObjectDataBlock[] ObjectData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.RequestMultipleObjects + public override PacketType Type { get { return PacketType.RequestMultipleObjects; } } + /// ObjectData block + public ObjectDataBlock[] ObjectData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public RequestMultipleObjectsPacket() - { - Header = new MediumHeader(); - Header.ID = 4; - Header.Reliable = true; - Header.Zerocoded = true; - ObjectData = new ObjectDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new MediumHeader(); + Header.ID = 4; + Header.Reliable = true; + Header.Zerocoded = true; + ObjectData = new ObjectDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public RequestMultipleObjectsPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new MediumHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new MediumHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public RequestMultipleObjectsPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 6; - length += AgentData.Length;; - length++; - for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ObjectData.Length; - for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 6; + length += AgentData.Length;; + length++; + for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ObjectData.Length; + for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- RequestMultipleObjects ---\n"; + { + string output = "--- RequestMultipleObjects ---\n"; for (int j = 0; j < ObjectData.Length; j++) - { + { output += ObjectData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ObjectPosition packet + + /// ObjectPosition packet public class ObjectPositionPacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - /// ObjectLocalID field - public uint ObjectLocalID; - /// Position field - public LLVector3 Position; - - /// Length of this block serialized in bytes + { + /// ObjectLocalID field + public uint ObjectLocalID; + /// Position field + public LLVector3 Position; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { + { try - { - ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Position = new LLVector3(bytes, i); i += 12; + { + ObjectLocalID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Position = new LLVector3(bytes, i); i += 12; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(ObjectLocalID % 256); - bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); - bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); - if(Position == null) { Console.WriteLine("Warning: Position is null, in " + this.GetType()); } - Array.Copy(Position.GetBytes(), 0, bytes, i, 12); i += 12; + { + bytes[i++] = (byte)(ObjectLocalID % 256); + bytes[i++] = (byte)((ObjectLocalID >> 8) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 16) % 256); + bytes[i++] = (byte)((ObjectLocalID >> 24) % 256); + if(Position == null) { Console.WriteLine("Warning: Position is null, in " + this.GetType()); } + Array.Copy(Position.GetBytes(), 0, bytes, i, 12); i += 12; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; - output += "Position: " + Position.ToString() + "\n"; + { + string output = "-- ObjectData --\n"; + output += "ObjectLocalID: " + ObjectLocalID.ToString() + "\n"; + output += "Position: " + Position.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ObjectPosition - public override PacketType Type { get { return PacketType.ObjectPosition; } } - /// ObjectData block - public ObjectDataBlock[] ObjectData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ObjectPosition + public override PacketType Type { get { return PacketType.ObjectPosition; } } + /// ObjectData block + public ObjectDataBlock[] ObjectData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ObjectPositionPacket() - { - Header = new MediumHeader(); - Header.ID = 5; - Header.Reliable = true; - Header.Zerocoded = true; - ObjectData = new ObjectDataBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new MediumHeader(); + Header.ID = 5; + Header.Reliable = true; + Header.Zerocoded = true; + ObjectData = new ObjectDataBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ObjectPositionPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new MediumHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new MediumHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ObjectPositionPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 6; - length += AgentData.Length;; - length++; - for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ObjectData.Length; - for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 6; + length += AgentData.Length;; + length++; + for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ObjectData.Length; + for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ObjectPosition ---\n"; + { + string output = "--- ObjectPosition ---\n"; for (int j = 0; j < ObjectData.Length; j++) - { + { output += ObjectData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// RequestObjectPropertiesFamily packet + + /// RequestObjectPropertiesFamily packet public class RequestObjectPropertiesFamilyPacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - /// ObjectID field - public LLUUID ObjectID; - /// RequestFlags field - public uint RequestFlags; - - /// Length of this block serialized in bytes + { + /// ObjectID field + public LLUUID ObjectID; + /// RequestFlags field + public uint RequestFlags; + + /// Length of this block serialized in bytes public int Length { get - { - return 20; + { + return 20; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { + { try - { - ObjectID = new LLUUID(bytes, i); i += 16; - RequestFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + ObjectID = new LLUUID(bytes, i); i += 16; + RequestFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } - Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(RequestFlags % 256); - bytes[i++] = (byte)((RequestFlags >> 8) % 256); - bytes[i++] = (byte)((RequestFlags >> 16) % 256); - bytes[i++] = (byte)((RequestFlags >> 24) % 256); + { + if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } + Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(RequestFlags % 256); + bytes[i++] = (byte)((RequestFlags >> 8) % 256); + bytes[i++] = (byte)((RequestFlags >> 16) % 256); + bytes[i++] = (byte)((RequestFlags >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += "ObjectID: " + ObjectID.ToString() + "\n"; - output += "RequestFlags: " + RequestFlags.ToString() + "\n"; + { + string output = "-- ObjectData --\n"; + output += "ObjectID: " + ObjectID.ToString() + "\n"; + output += "RequestFlags: " + RequestFlags.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.RequestObjectPropertiesFamily - public override PacketType Type { get { return PacketType.RequestObjectPropertiesFamily; } } - /// ObjectData block - public ObjectDataBlock ObjectData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.RequestObjectPropertiesFamily + public override PacketType Type { get { return PacketType.RequestObjectPropertiesFamily; } } + /// ObjectData block + public ObjectDataBlock ObjectData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public RequestObjectPropertiesFamilyPacket() - { - Header = new MediumHeader(); - Header.ID = 6; - Header.Reliable = true; - Header.Zerocoded = true; - ObjectData = new ObjectDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new MediumHeader(); + Header.ID = 6; + Header.Reliable = true; + Header.Zerocoded = true; + ObjectData = new ObjectDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public RequestObjectPropertiesFamilyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new MediumHeader(bytes, ref i, ref packetEnd); - ObjectData = new ObjectDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new MediumHeader(bytes, ref i, ref packetEnd); + ObjectData = new ObjectDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public RequestObjectPropertiesFamilyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - ObjectData = new ObjectDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + ObjectData = new ObjectDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 6; - length += ObjectData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - ObjectData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 6; + length += ObjectData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + ObjectData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- RequestObjectPropertiesFamily ---\n"; - output += ObjectData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- RequestObjectPropertiesFamily ---\n"; + output += ObjectData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// CoarseLocationUpdate packet + + /// CoarseLocationUpdate packet public class CoarseLocationUpdatePacket : Packet - { - /// Location block + { + /// Location block public class LocationBlock - { - /// X field - public byte X; - /// Y field - public byte Y; - /// Z field - public byte Z; - - /// Length of this block serialized in bytes + { + /// X field + public byte X; + /// Y field + public byte Y; + /// Z field + public byte Z; + + /// Length of this block serialized in bytes public int Length { get - { - return 3; + { + return 3; } } - - /// Default constructor - public LocationBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public LocationBlock() { } + /// Constructor for building the block from a byte array public LocationBlock(byte[] bytes, ref int i) - { + { try - { - X = (byte)bytes[i++]; - Y = (byte)bytes[i++]; - Z = (byte)bytes[i++]; + { + X = (byte)bytes[i++]; + Y = (byte)bytes[i++]; + Z = (byte)bytes[i++]; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = X; - bytes[i++] = Y; - bytes[i++] = Z; + { + bytes[i++] = X; + bytes[i++] = Y; + bytes[i++] = Z; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Location --\n"; - output += "X: " + X.ToString() + "\n"; - output += "Y: " + Y.ToString() + "\n"; - output += "Z: " + Z.ToString() + "\n"; + { + string output = "-- Location --\n"; + output += "X: " + X.ToString() + "\n"; + output += "Y: " + Y.ToString() + "\n"; + output += "Z: " + Z.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// Index block + + /// Index block public class IndexBlock - { - /// You field - public short You; - /// Prey field - public short Prey; - - /// Length of this block serialized in bytes + { + /// You field + public short You; + /// Prey field + public short Prey; + + /// Length of this block serialized in bytes public int Length { get - { - return 4; + { + return 4; } } - - /// Default constructor - public IndexBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public IndexBlock() { } + /// Constructor for building the block from a byte array public IndexBlock(byte[] bytes, ref int i) - { + { try - { - You = (short)(bytes[i++] + (bytes[i++] << 8)); - Prey = (short)(bytes[i++] + (bytes[i++] << 8)); + { + You = (short)(bytes[i++] + (bytes[i++] << 8)); + Prey = (short)(bytes[i++] + (bytes[i++] << 8)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(You % 256); - bytes[i++] = (byte)((You >> 8) % 256); - bytes[i++] = (byte)(Prey % 256); - bytes[i++] = (byte)((Prey >> 8) % 256); + { + bytes[i++] = (byte)(You % 256); + bytes[i++] = (byte)((You >> 8) % 256); + bytes[i++] = (byte)(Prey % 256); + bytes[i++] = (byte)((Prey >> 8) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Index --\n"; - output += "You: " + You.ToString() + "\n"; - output += "Prey: " + Prey.ToString() + "\n"; + { + string output = "-- Index --\n"; + output += "You: " + You.ToString() + "\n"; + output += "Prey: " + Prey.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.CoarseLocationUpdate - public override PacketType Type { get { return PacketType.CoarseLocationUpdate; } } - /// Location block - public LocationBlock[] Location; - /// Index block - public IndexBlock Index; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.CoarseLocationUpdate + public override PacketType Type { get { return PacketType.CoarseLocationUpdate; } } + /// Location block + public LocationBlock[] Location; + /// Index block + public IndexBlock Index; + + /// Default constructor public CoarseLocationUpdatePacket() - { - Header = new MediumHeader(); - Header.ID = 7; - Header.Reliable = true; - Location = new LocationBlock[0]; - Index = new IndexBlock(); + { + Header = new MediumHeader(); + Header.ID = 7; + Header.Reliable = true; + Location = new LocationBlock[0]; + Index = new IndexBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public CoarseLocationUpdatePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new MediumHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - Location = new LocationBlock[count]; - for (int j = 0; j < count; j++) - { Location[j] = new LocationBlock(bytes, ref i); } - Index = new IndexBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new MediumHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + Location = new LocationBlock[count]; + for (int j = 0; j < count; j++) + { Location[j] = new LocationBlock(bytes, ref i); } + Index = new IndexBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public CoarseLocationUpdatePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - Location = new LocationBlock[count]; - for (int j = 0; j < count; j++) - { Location[j] = new LocationBlock(bytes, ref i); } - Index = new IndexBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + Location = new LocationBlock[count]; + for (int j = 0; j < count; j++) + { Location[j] = new LocationBlock(bytes, ref i); } + Index = new IndexBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 6; - length += Index.Length;; - length++; - for (int j = 0; j < Location.Length; j++) { length += Location[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)Location.Length; - for (int j = 0; j < Location.Length; j++) { Location[j].ToBytes(bytes, ref i); } - Index.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 6; + length += Index.Length;; + length++; + for (int j = 0; j < Location.Length; j++) { length += Location[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)Location.Length; + for (int j = 0; j < Location.Length; j++) { Location[j].ToBytes(bytes, ref i); } + Index.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- CoarseLocationUpdate ---\n"; + { + string output = "--- CoarseLocationUpdate ---\n"; for (int j = 0; j < Location.Length; j++) - { + { output += Location[j].ToString() + "\n"; - } - output += Index.ToString() + "\n"; + } + output += Index.ToString() + "\n"; return output; } - + } - - /// CrossedRegion packet + + /// CrossedRegion packet public class CrossedRegionPacket : Packet - { - /// Info block + { + /// Info block public class InfoBlock - { - /// LookAt field - public LLVector3 LookAt; - /// Position field - public LLVector3 Position; - - /// Length of this block serialized in bytes + { + /// LookAt field + public LLVector3 LookAt; + /// Position field + public LLVector3 Position; + + /// Length of this block serialized in bytes public int Length { get - { - return 24; + { + return 24; } } - - /// Default constructor - public InfoBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public InfoBlock() { } + /// Constructor for building the block from a byte array public InfoBlock(byte[] bytes, ref int i) - { + { try - { - LookAt = new LLVector3(bytes, i); i += 12; - Position = new LLVector3(bytes, i); i += 12; + { + LookAt = new LLVector3(bytes, i); i += 12; + Position = new LLVector3(bytes, i); i += 12; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(LookAt == null) { Console.WriteLine("Warning: LookAt is null, in " + this.GetType()); } - Array.Copy(LookAt.GetBytes(), 0, bytes, i, 12); i += 12; - if(Position == null) { Console.WriteLine("Warning: Position is null, in " + this.GetType()); } - Array.Copy(Position.GetBytes(), 0, bytes, i, 12); i += 12; + { + if(LookAt == null) { Console.WriteLine("Warning: LookAt is null, in " + this.GetType()); } + Array.Copy(LookAt.GetBytes(), 0, bytes, i, 12); i += 12; + if(Position == null) { Console.WriteLine("Warning: Position is null, in " + this.GetType()); } + Array.Copy(Position.GetBytes(), 0, bytes, i, 12); i += 12; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Info --\n"; - output += "LookAt: " + LookAt.ToString() + "\n"; - output += "Position: " + Position.ToString() + "\n"; + { + string output = "-- Info --\n"; + output += "LookAt: " + LookAt.ToString() + "\n"; + output += "Position: " + Position.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// RegionData block + + /// RegionData block public class RegionDataBlock - { - private byte[] _seedcapability; - /// SeedCapability field + { + private byte[] _seedcapability; + /// SeedCapability field public byte[] SeedCapability - { - get { return _seedcapability; } + { + get { return _seedcapability; } set - { - if (value == null) { _seedcapability = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _seedcapability = new byte[value.Length]; Array.Copy(value, _seedcapability, value.Length); } + { + if (value == null) { _seedcapability = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _seedcapability = new byte[value.Length]; Array.Copy(value, _seedcapability, value.Length); } } - } - /// SimPort field - public ushort SimPort; - /// RegionHandle field - public ulong RegionHandle; - /// SimIP field - public uint SimIP; - - /// Length of this block serialized in bytes + } + /// SimPort field + public ushort SimPort; + /// RegionHandle field + public ulong RegionHandle; + /// SimIP field + public uint SimIP; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 14; - if (SeedCapability != null) { length += 2 + SeedCapability.Length; } - return length; + { + int length = 14; + if (SeedCapability != null) { length += 2 + SeedCapability.Length; } + return length; } } - - /// Default constructor - public RegionDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public RegionDataBlock() { } + /// Constructor for building the block from a byte array public RegionDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _seedcapability = new byte[length]; - Array.Copy(bytes, i, _seedcapability, 0, length); i += length; - SimPort = (ushort)((bytes[i++] << 8) + bytes[i++]); - RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); - SimIP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _seedcapability = new byte[length]; + Array.Copy(bytes, i, _seedcapability, 0, length); i += length; + SimPort = (ushort)((bytes[i++] << 8) + bytes[i++]); + RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + SimIP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(SeedCapability == null) { Console.WriteLine("Warning: SeedCapability is null, in " + this.GetType()); } - bytes[i++] = (byte)(SeedCapability.Length % 256); - bytes[i++] = (byte)((SeedCapability.Length >> 8) % 256); - Array.Copy(SeedCapability, 0, bytes, i, SeedCapability.Length); i += SeedCapability.Length; - bytes[i++] = (byte)((SimPort >> 8) % 256); - bytes[i++] = (byte)(SimPort % 256); - bytes[i++] = (byte)(RegionHandle % 256); - bytes[i++] = (byte)((RegionHandle >> 8) % 256); - bytes[i++] = (byte)((RegionHandle >> 16) % 256); - bytes[i++] = (byte)((RegionHandle >> 24) % 256); - bytes[i++] = (byte)((RegionHandle >> 32) % 256); - bytes[i++] = (byte)((RegionHandle >> 40) % 256); - bytes[i++] = (byte)((RegionHandle >> 48) % 256); - bytes[i++] = (byte)((RegionHandle >> 56) % 256); - bytes[i++] = (byte)(SimIP % 256); - bytes[i++] = (byte)((SimIP >> 8) % 256); - bytes[i++] = (byte)((SimIP >> 16) % 256); - bytes[i++] = (byte)((SimIP >> 24) % 256); + { + if(SeedCapability == null) { Console.WriteLine("Warning: SeedCapability is null, in " + this.GetType()); } + bytes[i++] = (byte)(SeedCapability.Length % 256); + bytes[i++] = (byte)((SeedCapability.Length >> 8) % 256); + Array.Copy(SeedCapability, 0, bytes, i, SeedCapability.Length); i += SeedCapability.Length; + bytes[i++] = (byte)((SimPort >> 8) % 256); + bytes[i++] = (byte)(SimPort % 256); + bytes[i++] = (byte)(RegionHandle % 256); + bytes[i++] = (byte)((RegionHandle >> 8) % 256); + bytes[i++] = (byte)((RegionHandle >> 16) % 256); + bytes[i++] = (byte)((RegionHandle >> 24) % 256); + bytes[i++] = (byte)((RegionHandle >> 32) % 256); + bytes[i++] = (byte)((RegionHandle >> 40) % 256); + bytes[i++] = (byte)((RegionHandle >> 48) % 256); + bytes[i++] = (byte)((RegionHandle >> 56) % 256); + bytes[i++] = (byte)(SimIP % 256); + bytes[i++] = (byte)((SimIP >> 8) % 256); + bytes[i++] = (byte)((SimIP >> 16) % 256); + bytes[i++] = (byte)((SimIP >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- RegionData --\n"; - output += Helpers.FieldToString(SeedCapability, "SeedCapability") + "\n"; - output += "SimPort: " + SimPort.ToString() + "\n"; - output += "RegionHandle: " + RegionHandle.ToString() + "\n"; - output += "SimIP: " + SimIP.ToString() + "\n"; + { + string output = "-- RegionData --\n"; + output += Helpers.FieldToString(SeedCapability, "SeedCapability") + "\n"; + output += "SimPort: " + SimPort.ToString() + "\n"; + output += "RegionHandle: " + RegionHandle.ToString() + "\n"; + output += "SimIP: " + SimIP.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.CrossedRegion - public override PacketType Type { get { return PacketType.CrossedRegion; } } - /// Info block - public InfoBlock Info; - /// RegionData block - public RegionDataBlock RegionData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.CrossedRegion + public override PacketType Type { get { return PacketType.CrossedRegion; } } + /// Info block + public InfoBlock Info; + /// RegionData block + public RegionDataBlock RegionData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public CrossedRegionPacket() - { - Header = new MediumHeader(); - Header.ID = 8; - Header.Reliable = true; - Info = new InfoBlock(); - RegionData = new RegionDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new MediumHeader(); + Header.ID = 8; + Header.Reliable = true; + Info = new InfoBlock(); + RegionData = new RegionDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public CrossedRegionPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new MediumHeader(bytes, ref i, ref packetEnd); - Info = new InfoBlock(bytes, ref i); - RegionData = new RegionDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new MediumHeader(bytes, ref i, ref packetEnd); + Info = new InfoBlock(bytes, ref i); + RegionData = new RegionDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public CrossedRegionPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Info = new InfoBlock(bytes, ref i); - RegionData = new RegionDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + Info = new InfoBlock(bytes, ref i); + RegionData = new RegionDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 6; - length += Info.Length; length += RegionData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Info.ToBytes(bytes, ref i); - RegionData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 6; + length += Info.Length; length += RegionData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Info.ToBytes(bytes, ref i); + RegionData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- CrossedRegion ---\n"; - output += Info.ToString() + "\n"; - output += RegionData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- CrossedRegion ---\n"; + output += Info.ToString() + "\n"; + output += RegionData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ConfirmEnableSimulator packet + + /// ConfirmEnableSimulator packet public class ConfirmEnableSimulatorPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ConfirmEnableSimulator - public override PacketType Type { get { return PacketType.ConfirmEnableSimulator; } } - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ConfirmEnableSimulator + public override PacketType Type { get { return PacketType.ConfirmEnableSimulator; } } + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ConfirmEnableSimulatorPacket() - { - Header = new MediumHeader(); - Header.ID = 9; - Header.Reliable = true; - AgentData = new AgentDataBlock(); + { + Header = new MediumHeader(); + Header.ID = 9; + Header.Reliable = true; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ConfirmEnableSimulatorPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new MediumHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new MediumHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ConfirmEnableSimulatorPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 6; - length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 6; + length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ConfirmEnableSimulator ---\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- ConfirmEnableSimulator ---\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ObjectProperties packet + + /// ObjectProperties packet public class ObjectPropertiesPacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - /// OwnershipCost field - public int OwnershipCost; - /// AggregatePermTexturesOwner field - public byte AggregatePermTexturesOwner; - private byte[] _sitname; - /// SitName field + { + /// OwnershipCost field + public int OwnershipCost; + /// AggregatePermTexturesOwner field + public byte AggregatePermTexturesOwner; + private byte[] _sitname; + /// SitName field public byte[] SitName - { - get { return _sitname; } + { + get { return _sitname; } set - { - if (value == null) { _sitname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _sitname = new byte[value.Length]; Array.Copy(value, _sitname, value.Length); } + { + if (value == null) { _sitname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _sitname = new byte[value.Length]; Array.Copy(value, _sitname, value.Length); } } - } - /// ObjectID field - public LLUUID ObjectID; - /// SaleType field - public byte SaleType; - /// BaseMask field - public uint BaseMask; - private byte[] _name; - /// Name field + } + /// ObjectID field + public LLUUID ObjectID; + /// SaleType field + public byte SaleType; + /// BaseMask field + public uint BaseMask; + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - /// Category field - public uint Category; - /// FromTaskID field - public LLUUID FromTaskID; - /// GroupID field - public LLUUID GroupID; - /// SalePrice field - public int SalePrice; - /// OwnerID field - public LLUUID OwnerID; - /// CreatorID field - public LLUUID CreatorID; - private byte[] _textureid; - /// TextureID field + } + /// Category field + public uint Category; + /// FromTaskID field + public LLUUID FromTaskID; + /// GroupID field + public LLUUID GroupID; + /// SalePrice field + public int SalePrice; + /// OwnerID field + public LLUUID OwnerID; + /// CreatorID field + public LLUUID CreatorID; + private byte[] _textureid; + /// TextureID field public byte[] TextureID - { - get { return _textureid; } + { + get { return _textureid; } set - { - if (value == null) { _textureid = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _textureid = new byte[value.Length]; Array.Copy(value, _textureid, value.Length); } + { + if (value == null) { _textureid = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _textureid = new byte[value.Length]; Array.Copy(value, _textureid, value.Length); } } - } - private byte[] _touchname; - /// TouchName field + } + private byte[] _touchname; + /// TouchName field public byte[] TouchName - { - get { return _touchname; } + { + get { return _touchname; } set - { - if (value == null) { _touchname = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _touchname = new byte[value.Length]; Array.Copy(value, _touchname, value.Length); } + { + if (value == null) { _touchname = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _touchname = new byte[value.Length]; Array.Copy(value, _touchname, value.Length); } } - } - /// ItemID field - public LLUUID ItemID; - /// AggregatePermTextures field - public byte AggregatePermTextures; - /// FolderID field - public LLUUID FolderID; - /// InventorySerial field - public short InventorySerial; - /// EveryoneMask field - public uint EveryoneMask; - private byte[] _description; - /// Description field + } + /// ItemID field + public LLUUID ItemID; + /// AggregatePermTextures field + public byte AggregatePermTextures; + /// FolderID field + public LLUUID FolderID; + /// InventorySerial field + public short InventorySerial; + /// EveryoneMask field + public uint EveryoneMask; + private byte[] _description; + /// Description field public byte[] Description - { - get { return _description; } + { + get { return _description; } set - { - if (value == null) { _description = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } + { + if (value == null) { _description = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } } - } - /// LastOwnerID field - public LLUUID LastOwnerID; - /// AggregatePerms field - public byte AggregatePerms; - /// NextOwnerMask field - public uint NextOwnerMask; - /// GroupMask field - public uint GroupMask; - /// OwnerMask field - public uint OwnerMask; - - /// Length of this block serialized in bytes + } + /// LastOwnerID field + public LLUUID LastOwnerID; + /// AggregatePerms field + public byte AggregatePerms; + /// NextOwnerMask field + public uint NextOwnerMask; + /// GroupMask field + public uint GroupMask; + /// OwnerMask field + public uint OwnerMask; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 166; - if (SitName != null) { length += 1 + SitName.Length; } - if (Name != null) { length += 1 + Name.Length; } - if (TextureID != null) { length += 1 + TextureID.Length; } - if (TouchName != null) { length += 1 + TouchName.Length; } - if (Description != null) { length += 1 + Description.Length; } - return length; + { + int length = 166; + if (SitName != null) { length += 1 + SitName.Length; } + if (Name != null) { length += 1 + Name.Length; } + if (TextureID != null) { length += 1 + TextureID.Length; } + if (TouchName != null) { length += 1 + TouchName.Length; } + if (Description != null) { length += 1 + Description.Length; } + return length; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - OwnershipCost = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - AggregatePermTexturesOwner = (byte)bytes[i++]; - length = (ushort)bytes[i++]; - _sitname = new byte[length]; - Array.Copy(bytes, i, _sitname, 0, length); i += length; - ObjectID = new LLUUID(bytes, i); i += 16; - SaleType = (byte)bytes[i++]; - BaseMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; - Category = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - FromTaskID = new LLUUID(bytes, i); i += 16; - GroupID = new LLUUID(bytes, i); i += 16; - SalePrice = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - OwnerID = new LLUUID(bytes, i); i += 16; - CreatorID = new LLUUID(bytes, i); i += 16; - length = (ushort)bytes[i++]; - _textureid = new byte[length]; - Array.Copy(bytes, i, _textureid, 0, length); i += length; - length = (ushort)bytes[i++]; - _touchname = new byte[length]; - Array.Copy(bytes, i, _touchname, 0, length); i += length; - ItemID = new LLUUID(bytes, i); i += 16; - AggregatePermTextures = (byte)bytes[i++]; - FolderID = new LLUUID(bytes, i); i += 16; - InventorySerial = (short)(bytes[i++] + (bytes[i++] << 8)); - EveryoneMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _description = new byte[length]; - Array.Copy(bytes, i, _description, 0, length); i += length; - LastOwnerID = new LLUUID(bytes, i); i += 16; - AggregatePerms = (byte)bytes[i++]; - NextOwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - GroupMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - OwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + OwnershipCost = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + AggregatePermTexturesOwner = (byte)bytes[i++]; + length = (ushort)bytes[i++]; + _sitname = new byte[length]; + Array.Copy(bytes, i, _sitname, 0, length); i += length; + ObjectID = new LLUUID(bytes, i); i += 16; + SaleType = (byte)bytes[i++]; + BaseMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; + Category = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + FromTaskID = new LLUUID(bytes, i); i += 16; + GroupID = new LLUUID(bytes, i); i += 16; + SalePrice = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + OwnerID = new LLUUID(bytes, i); i += 16; + CreatorID = new LLUUID(bytes, i); i += 16; + length = (ushort)bytes[i++]; + _textureid = new byte[length]; + Array.Copy(bytes, i, _textureid, 0, length); i += length; + length = (ushort)bytes[i++]; + _touchname = new byte[length]; + Array.Copy(bytes, i, _touchname, 0, length); i += length; + ItemID = new LLUUID(bytes, i); i += 16; + AggregatePermTextures = (byte)bytes[i++]; + FolderID = new LLUUID(bytes, i); i += 16; + InventorySerial = (short)(bytes[i++] + (bytes[i++] << 8)); + EveryoneMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _description = new byte[length]; + Array.Copy(bytes, i, _description, 0, length); i += length; + LastOwnerID = new LLUUID(bytes, i); i += 16; + AggregatePerms = (byte)bytes[i++]; + NextOwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + GroupMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + OwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(OwnershipCost % 256); - bytes[i++] = (byte)((OwnershipCost >> 8) % 256); - bytes[i++] = (byte)((OwnershipCost >> 16) % 256); - bytes[i++] = (byte)((OwnershipCost >> 24) % 256); - bytes[i++] = AggregatePermTexturesOwner; - if(SitName == null) { Console.WriteLine("Warning: SitName is null, in " + this.GetType()); } - bytes[i++] = (byte)SitName.Length; - Array.Copy(SitName, 0, bytes, i, SitName.Length); i += SitName.Length; - if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } - Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = SaleType; - bytes[i++] = (byte)(BaseMask % 256); - bytes[i++] = (byte)((BaseMask >> 8) % 256); - bytes[i++] = (byte)((BaseMask >> 16) % 256); - bytes[i++] = (byte)((BaseMask >> 24) % 256); - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; - bytes[i++] = (byte)(Category % 256); - bytes[i++] = (byte)((Category >> 8) % 256); - bytes[i++] = (byte)((Category >> 16) % 256); - bytes[i++] = (byte)((Category >> 24) % 256); - if(FromTaskID == null) { Console.WriteLine("Warning: FromTaskID is null, in " + this.GetType()); } - Array.Copy(FromTaskID.GetBytes(), 0, bytes, i, 16); i += 16; - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(SalePrice % 256); - bytes[i++] = (byte)((SalePrice >> 8) % 256); - bytes[i++] = (byte)((SalePrice >> 16) % 256); - bytes[i++] = (byte)((SalePrice >> 24) % 256); - if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } - Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; - if(CreatorID == null) { Console.WriteLine("Warning: CreatorID is null, in " + this.GetType()); } - Array.Copy(CreatorID.GetBytes(), 0, bytes, i, 16); i += 16; - if(TextureID == null) { Console.WriteLine("Warning: TextureID is null, in " + this.GetType()); } - bytes[i++] = (byte)TextureID.Length; - Array.Copy(TextureID, 0, bytes, i, TextureID.Length); i += TextureID.Length; - if(TouchName == null) { Console.WriteLine("Warning: TouchName is null, in " + this.GetType()); } - bytes[i++] = (byte)TouchName.Length; - Array.Copy(TouchName, 0, bytes, i, TouchName.Length); i += TouchName.Length; - if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } - Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = AggregatePermTextures; - if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } - Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(InventorySerial % 256); - bytes[i++] = (byte)((InventorySerial >> 8) % 256); - bytes[i++] = (byte)(EveryoneMask % 256); - bytes[i++] = (byte)((EveryoneMask >> 8) % 256); - bytes[i++] = (byte)((EveryoneMask >> 16) % 256); - bytes[i++] = (byte)((EveryoneMask >> 24) % 256); - if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } - bytes[i++] = (byte)Description.Length; - Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; - if(LastOwnerID == null) { Console.WriteLine("Warning: LastOwnerID is null, in " + this.GetType()); } - Array.Copy(LastOwnerID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = AggregatePerms; - bytes[i++] = (byte)(NextOwnerMask % 256); - bytes[i++] = (byte)((NextOwnerMask >> 8) % 256); - bytes[i++] = (byte)((NextOwnerMask >> 16) % 256); - bytes[i++] = (byte)((NextOwnerMask >> 24) % 256); - bytes[i++] = (byte)(GroupMask % 256); - bytes[i++] = (byte)((GroupMask >> 8) % 256); - bytes[i++] = (byte)((GroupMask >> 16) % 256); - bytes[i++] = (byte)((GroupMask >> 24) % 256); - bytes[i++] = (byte)(OwnerMask % 256); - bytes[i++] = (byte)((OwnerMask >> 8) % 256); - bytes[i++] = (byte)((OwnerMask >> 16) % 256); - bytes[i++] = (byte)((OwnerMask >> 24) % 256); + { + bytes[i++] = (byte)(OwnershipCost % 256); + bytes[i++] = (byte)((OwnershipCost >> 8) % 256); + bytes[i++] = (byte)((OwnershipCost >> 16) % 256); + bytes[i++] = (byte)((OwnershipCost >> 24) % 256); + bytes[i++] = AggregatePermTexturesOwner; + if(SitName == null) { Console.WriteLine("Warning: SitName is null, in " + this.GetType()); } + bytes[i++] = (byte)SitName.Length; + Array.Copy(SitName, 0, bytes, i, SitName.Length); i += SitName.Length; + if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } + Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = SaleType; + bytes[i++] = (byte)(BaseMask % 256); + bytes[i++] = (byte)((BaseMask >> 8) % 256); + bytes[i++] = (byte)((BaseMask >> 16) % 256); + bytes[i++] = (byte)((BaseMask >> 24) % 256); + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + bytes[i++] = (byte)(Category % 256); + bytes[i++] = (byte)((Category >> 8) % 256); + bytes[i++] = (byte)((Category >> 16) % 256); + bytes[i++] = (byte)((Category >> 24) % 256); + if(FromTaskID == null) { Console.WriteLine("Warning: FromTaskID is null, in " + this.GetType()); } + Array.Copy(FromTaskID.GetBytes(), 0, bytes, i, 16); i += 16; + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(SalePrice % 256); + bytes[i++] = (byte)((SalePrice >> 8) % 256); + bytes[i++] = (byte)((SalePrice >> 16) % 256); + bytes[i++] = (byte)((SalePrice >> 24) % 256); + if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } + Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; + if(CreatorID == null) { Console.WriteLine("Warning: CreatorID is null, in " + this.GetType()); } + Array.Copy(CreatorID.GetBytes(), 0, bytes, i, 16); i += 16; + if(TextureID == null) { Console.WriteLine("Warning: TextureID is null, in " + this.GetType()); } + bytes[i++] = (byte)TextureID.Length; + Array.Copy(TextureID, 0, bytes, i, TextureID.Length); i += TextureID.Length; + if(TouchName == null) { Console.WriteLine("Warning: TouchName is null, in " + this.GetType()); } + bytes[i++] = (byte)TouchName.Length; + Array.Copy(TouchName, 0, bytes, i, TouchName.Length); i += TouchName.Length; + if(ItemID == null) { Console.WriteLine("Warning: ItemID is null, in " + this.GetType()); } + Array.Copy(ItemID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = AggregatePermTextures; + if(FolderID == null) { Console.WriteLine("Warning: FolderID is null, in " + this.GetType()); } + Array.Copy(FolderID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(InventorySerial % 256); + bytes[i++] = (byte)((InventorySerial >> 8) % 256); + bytes[i++] = (byte)(EveryoneMask % 256); + bytes[i++] = (byte)((EveryoneMask >> 8) % 256); + bytes[i++] = (byte)((EveryoneMask >> 16) % 256); + bytes[i++] = (byte)((EveryoneMask >> 24) % 256); + if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } + bytes[i++] = (byte)Description.Length; + Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; + if(LastOwnerID == null) { Console.WriteLine("Warning: LastOwnerID is null, in " + this.GetType()); } + Array.Copy(LastOwnerID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = AggregatePerms; + bytes[i++] = (byte)(NextOwnerMask % 256); + bytes[i++] = (byte)((NextOwnerMask >> 8) % 256); + bytes[i++] = (byte)((NextOwnerMask >> 16) % 256); + bytes[i++] = (byte)((NextOwnerMask >> 24) % 256); + bytes[i++] = (byte)(GroupMask % 256); + bytes[i++] = (byte)((GroupMask >> 8) % 256); + bytes[i++] = (byte)((GroupMask >> 16) % 256); + bytes[i++] = (byte)((GroupMask >> 24) % 256); + bytes[i++] = (byte)(OwnerMask % 256); + bytes[i++] = (byte)((OwnerMask >> 8) % 256); + bytes[i++] = (byte)((OwnerMask >> 16) % 256); + bytes[i++] = (byte)((OwnerMask >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += "OwnershipCost: " + OwnershipCost.ToString() + "\n"; - output += "AggregatePermTexturesOwner: " + AggregatePermTexturesOwner.ToString() + "\n"; - output += Helpers.FieldToString(SitName, "SitName") + "\n"; - output += "ObjectID: " + ObjectID.ToString() + "\n"; - output += "SaleType: " + SaleType.ToString() + "\n"; - output += "BaseMask: " + BaseMask.ToString() + "\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; - output += "Category: " + Category.ToString() + "\n"; - output += "FromTaskID: " + FromTaskID.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; - output += "SalePrice: " + SalePrice.ToString() + "\n"; - output += "OwnerID: " + OwnerID.ToString() + "\n"; - output += "CreatorID: " + CreatorID.ToString() + "\n"; - output += Helpers.FieldToString(TextureID, "TextureID") + "\n"; - output += Helpers.FieldToString(TouchName, "TouchName") + "\n"; - output += "ItemID: " + ItemID.ToString() + "\n"; - output += "AggregatePermTextures: " + AggregatePermTextures.ToString() + "\n"; - output += "FolderID: " + FolderID.ToString() + "\n"; - output += "InventorySerial: " + InventorySerial.ToString() + "\n"; - output += "EveryoneMask: " + EveryoneMask.ToString() + "\n"; - output += Helpers.FieldToString(Description, "Description") + "\n"; - output += "LastOwnerID: " + LastOwnerID.ToString() + "\n"; - output += "AggregatePerms: " + AggregatePerms.ToString() + "\n"; - output += "NextOwnerMask: " + NextOwnerMask.ToString() + "\n"; - output += "GroupMask: " + GroupMask.ToString() + "\n"; - output += "OwnerMask: " + OwnerMask.ToString() + "\n"; + { + string output = "-- ObjectData --\n"; + output += "OwnershipCost: " + OwnershipCost.ToString() + "\n"; + output += "AggregatePermTexturesOwner: " + AggregatePermTexturesOwner.ToString() + "\n"; + output += Helpers.FieldToString(SitName, "SitName") + "\n"; + output += "ObjectID: " + ObjectID.ToString() + "\n"; + output += "SaleType: " + SaleType.ToString() + "\n"; + output += "BaseMask: " + BaseMask.ToString() + "\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; + output += "Category: " + Category.ToString() + "\n"; + output += "FromTaskID: " + FromTaskID.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; + output += "SalePrice: " + SalePrice.ToString() + "\n"; + output += "OwnerID: " + OwnerID.ToString() + "\n"; + output += "CreatorID: " + CreatorID.ToString() + "\n"; + output += Helpers.FieldToString(TextureID, "TextureID") + "\n"; + output += Helpers.FieldToString(TouchName, "TouchName") + "\n"; + output += "ItemID: " + ItemID.ToString() + "\n"; + output += "AggregatePermTextures: " + AggregatePermTextures.ToString() + "\n"; + output += "FolderID: " + FolderID.ToString() + "\n"; + output += "InventorySerial: " + InventorySerial.ToString() + "\n"; + output += "EveryoneMask: " + EveryoneMask.ToString() + "\n"; + output += Helpers.FieldToString(Description, "Description") + "\n"; + output += "LastOwnerID: " + LastOwnerID.ToString() + "\n"; + output += "AggregatePerms: " + AggregatePerms.ToString() + "\n"; + output += "NextOwnerMask: " + NextOwnerMask.ToString() + "\n"; + output += "GroupMask: " + GroupMask.ToString() + "\n"; + output += "OwnerMask: " + OwnerMask.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ObjectProperties - public override PacketType Type { get { return PacketType.ObjectProperties; } } - /// ObjectData block - public ObjectDataBlock[] ObjectData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ObjectProperties + public override PacketType Type { get { return PacketType.ObjectProperties; } } + /// ObjectData block + public ObjectDataBlock[] ObjectData; + + /// Default constructor public ObjectPropertiesPacket() - { - Header = new MediumHeader(); - Header.ID = 10; - Header.Reliable = true; - Header.Zerocoded = true; - ObjectData = new ObjectDataBlock[0]; + { + Header = new MediumHeader(); + Header.ID = 10; + Header.Reliable = true; + Header.Zerocoded = true; + ObjectData = new ObjectDataBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ObjectPropertiesPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new MediumHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new MediumHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ObjectPropertiesPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + { + Header = head; + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 6; -; - length++; - for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ObjectData.Length; - for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 6; +; + length++; + for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ObjectData.Length; + for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ObjectProperties ---\n"; + { + string output = "--- ObjectProperties ---\n"; for (int j = 0; j < ObjectData.Length; j++) - { + { output += ObjectData[j].ToString() + "\n"; - } + } return output; } - + } - - /// ObjectPropertiesFamily packet + + /// ObjectPropertiesFamily packet public class ObjectPropertiesFamilyPacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - /// OwnershipCost field - public int OwnershipCost; - /// ObjectID field - public LLUUID ObjectID; - /// SaleType field - public byte SaleType; - /// BaseMask field - public uint BaseMask; - private byte[] _name; - /// Name field + { + /// OwnershipCost field + public int OwnershipCost; + /// ObjectID field + public LLUUID ObjectID; + /// SaleType field + public byte SaleType; + /// BaseMask field + public uint BaseMask; + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - /// RequestFlags field - public uint RequestFlags; - /// Category field - public uint Category; - /// GroupID field - public LLUUID GroupID; - /// SalePrice field - public int SalePrice; - /// OwnerID field - public LLUUID OwnerID; - /// EveryoneMask field - public uint EveryoneMask; - private byte[] _description; - /// Description field + } + /// RequestFlags field + public uint RequestFlags; + /// Category field + public uint Category; + /// GroupID field + public LLUUID GroupID; + /// SalePrice field + public int SalePrice; + /// OwnerID field + public LLUUID OwnerID; + /// EveryoneMask field + public uint EveryoneMask; + private byte[] _description; + /// Description field public byte[] Description - { - get { return _description; } + { + get { return _description; } set - { - if (value == null) { _description = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } + { + if (value == null) { _description = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _description = new byte[value.Length]; Array.Copy(value, _description, value.Length); } } - } - /// LastOwnerID field - public LLUUID LastOwnerID; - /// NextOwnerMask field - public uint NextOwnerMask; - /// GroupMask field - public uint GroupMask; - /// OwnerMask field - public uint OwnerMask; - - /// Length of this block serialized in bytes + } + /// LastOwnerID field + public LLUUID LastOwnerID; + /// NextOwnerMask field + public uint NextOwnerMask; + /// GroupMask field + public uint GroupMask; + /// OwnerMask field + public uint OwnerMask; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 101; - if (Name != null) { length += 1 + Name.Length; } - if (Description != null) { length += 1 + Description.Length; } - return length; + { + int length = 101; + if (Name != null) { length += 1 + Name.Length; } + if (Description != null) { length += 1 + Description.Length; } + return length; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - OwnershipCost = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - ObjectID = new LLUUID(bytes, i); i += 16; - SaleType = (byte)bytes[i++]; - BaseMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; - RequestFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Category = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - GroupID = new LLUUID(bytes, i); i += 16; - SalePrice = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - OwnerID = new LLUUID(bytes, i); i += 16; - EveryoneMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _description = new byte[length]; - Array.Copy(bytes, i, _description, 0, length); i += length; - LastOwnerID = new LLUUID(bytes, i); i += 16; - NextOwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - GroupMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - OwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + OwnershipCost = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + ObjectID = new LLUUID(bytes, i); i += 16; + SaleType = (byte)bytes[i++]; + BaseMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; + RequestFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Category = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + GroupID = new LLUUID(bytes, i); i += 16; + SalePrice = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + OwnerID = new LLUUID(bytes, i); i += 16; + EveryoneMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _description = new byte[length]; + Array.Copy(bytes, i, _description, 0, length); i += length; + LastOwnerID = new LLUUID(bytes, i); i += 16; + NextOwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + GroupMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + OwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(OwnershipCost % 256); - bytes[i++] = (byte)((OwnershipCost >> 8) % 256); - bytes[i++] = (byte)((OwnershipCost >> 16) % 256); - bytes[i++] = (byte)((OwnershipCost >> 24) % 256); - if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } - Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = SaleType; - bytes[i++] = (byte)(BaseMask % 256); - bytes[i++] = (byte)((BaseMask >> 8) % 256); - bytes[i++] = (byte)((BaseMask >> 16) % 256); - bytes[i++] = (byte)((BaseMask >> 24) % 256); - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; - bytes[i++] = (byte)(RequestFlags % 256); - bytes[i++] = (byte)((RequestFlags >> 8) % 256); - bytes[i++] = (byte)((RequestFlags >> 16) % 256); - bytes[i++] = (byte)((RequestFlags >> 24) % 256); - bytes[i++] = (byte)(Category % 256); - bytes[i++] = (byte)((Category >> 8) % 256); - bytes[i++] = (byte)((Category >> 16) % 256); - bytes[i++] = (byte)((Category >> 24) % 256); - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(SalePrice % 256); - bytes[i++] = (byte)((SalePrice >> 8) % 256); - bytes[i++] = (byte)((SalePrice >> 16) % 256); - bytes[i++] = (byte)((SalePrice >> 24) % 256); - if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } - Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(EveryoneMask % 256); - bytes[i++] = (byte)((EveryoneMask >> 8) % 256); - bytes[i++] = (byte)((EveryoneMask >> 16) % 256); - bytes[i++] = (byte)((EveryoneMask >> 24) % 256); - if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } - bytes[i++] = (byte)Description.Length; - Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; - if(LastOwnerID == null) { Console.WriteLine("Warning: LastOwnerID is null, in " + this.GetType()); } - Array.Copy(LastOwnerID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(NextOwnerMask % 256); - bytes[i++] = (byte)((NextOwnerMask >> 8) % 256); - bytes[i++] = (byte)((NextOwnerMask >> 16) % 256); - bytes[i++] = (byte)((NextOwnerMask >> 24) % 256); - bytes[i++] = (byte)(GroupMask % 256); - bytes[i++] = (byte)((GroupMask >> 8) % 256); - bytes[i++] = (byte)((GroupMask >> 16) % 256); - bytes[i++] = (byte)((GroupMask >> 24) % 256); - bytes[i++] = (byte)(OwnerMask % 256); - bytes[i++] = (byte)((OwnerMask >> 8) % 256); - bytes[i++] = (byte)((OwnerMask >> 16) % 256); - bytes[i++] = (byte)((OwnerMask >> 24) % 256); + { + bytes[i++] = (byte)(OwnershipCost % 256); + bytes[i++] = (byte)((OwnershipCost >> 8) % 256); + bytes[i++] = (byte)((OwnershipCost >> 16) % 256); + bytes[i++] = (byte)((OwnershipCost >> 24) % 256); + if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } + Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = SaleType; + bytes[i++] = (byte)(BaseMask % 256); + bytes[i++] = (byte)((BaseMask >> 8) % 256); + bytes[i++] = (byte)((BaseMask >> 16) % 256); + bytes[i++] = (byte)((BaseMask >> 24) % 256); + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + bytes[i++] = (byte)(RequestFlags % 256); + bytes[i++] = (byte)((RequestFlags >> 8) % 256); + bytes[i++] = (byte)((RequestFlags >> 16) % 256); + bytes[i++] = (byte)((RequestFlags >> 24) % 256); + bytes[i++] = (byte)(Category % 256); + bytes[i++] = (byte)((Category >> 8) % 256); + bytes[i++] = (byte)((Category >> 16) % 256); + bytes[i++] = (byte)((Category >> 24) % 256); + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(SalePrice % 256); + bytes[i++] = (byte)((SalePrice >> 8) % 256); + bytes[i++] = (byte)((SalePrice >> 16) % 256); + bytes[i++] = (byte)((SalePrice >> 24) % 256); + if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } + Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(EveryoneMask % 256); + bytes[i++] = (byte)((EveryoneMask >> 8) % 256); + bytes[i++] = (byte)((EveryoneMask >> 16) % 256); + bytes[i++] = (byte)((EveryoneMask >> 24) % 256); + if(Description == null) { Console.WriteLine("Warning: Description is null, in " + this.GetType()); } + bytes[i++] = (byte)Description.Length; + Array.Copy(Description, 0, bytes, i, Description.Length); i += Description.Length; + if(LastOwnerID == null) { Console.WriteLine("Warning: LastOwnerID is null, in " + this.GetType()); } + Array.Copy(LastOwnerID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(NextOwnerMask % 256); + bytes[i++] = (byte)((NextOwnerMask >> 8) % 256); + bytes[i++] = (byte)((NextOwnerMask >> 16) % 256); + bytes[i++] = (byte)((NextOwnerMask >> 24) % 256); + bytes[i++] = (byte)(GroupMask % 256); + bytes[i++] = (byte)((GroupMask >> 8) % 256); + bytes[i++] = (byte)((GroupMask >> 16) % 256); + bytes[i++] = (byte)((GroupMask >> 24) % 256); + bytes[i++] = (byte)(OwnerMask % 256); + bytes[i++] = (byte)((OwnerMask >> 8) % 256); + bytes[i++] = (byte)((OwnerMask >> 16) % 256); + bytes[i++] = (byte)((OwnerMask >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += "OwnershipCost: " + OwnershipCost.ToString() + "\n"; - output += "ObjectID: " + ObjectID.ToString() + "\n"; - output += "SaleType: " + SaleType.ToString() + "\n"; - output += "BaseMask: " + BaseMask.ToString() + "\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; - output += "RequestFlags: " + RequestFlags.ToString() + "\n"; - output += "Category: " + Category.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; - output += "SalePrice: " + SalePrice.ToString() + "\n"; - output += "OwnerID: " + OwnerID.ToString() + "\n"; - output += "EveryoneMask: " + EveryoneMask.ToString() + "\n"; - output += Helpers.FieldToString(Description, "Description") + "\n"; - output += "LastOwnerID: " + LastOwnerID.ToString() + "\n"; - output += "NextOwnerMask: " + NextOwnerMask.ToString() + "\n"; - output += "GroupMask: " + GroupMask.ToString() + "\n"; - output += "OwnerMask: " + OwnerMask.ToString() + "\n"; + { + string output = "-- ObjectData --\n"; + output += "OwnershipCost: " + OwnershipCost.ToString() + "\n"; + output += "ObjectID: " + ObjectID.ToString() + "\n"; + output += "SaleType: " + SaleType.ToString() + "\n"; + output += "BaseMask: " + BaseMask.ToString() + "\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; + output += "RequestFlags: " + RequestFlags.ToString() + "\n"; + output += "Category: " + Category.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; + output += "SalePrice: " + SalePrice.ToString() + "\n"; + output += "OwnerID: " + OwnerID.ToString() + "\n"; + output += "EveryoneMask: " + EveryoneMask.ToString() + "\n"; + output += Helpers.FieldToString(Description, "Description") + "\n"; + output += "LastOwnerID: " + LastOwnerID.ToString() + "\n"; + output += "NextOwnerMask: " + NextOwnerMask.ToString() + "\n"; + output += "GroupMask: " + GroupMask.ToString() + "\n"; + output += "OwnerMask: " + OwnerMask.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ObjectPropertiesFamily - public override PacketType Type { get { return PacketType.ObjectPropertiesFamily; } } - /// ObjectData block - public ObjectDataBlock ObjectData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ObjectPropertiesFamily + public override PacketType Type { get { return PacketType.ObjectPropertiesFamily; } } + /// ObjectData block + public ObjectDataBlock ObjectData; + + /// Default constructor public ObjectPropertiesFamilyPacket() - { - Header = new MediumHeader(); - Header.ID = 11; - Header.Reliable = true; - Header.Zerocoded = true; - ObjectData = new ObjectDataBlock(); + { + Header = new MediumHeader(); + Header.ID = 11; + Header.Reliable = true; + Header.Zerocoded = true; + ObjectData = new ObjectDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ObjectPropertiesFamilyPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new MediumHeader(bytes, ref i, ref packetEnd); - ObjectData = new ObjectDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new MediumHeader(bytes, ref i, ref packetEnd); + ObjectData = new ObjectDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ObjectPropertiesFamilyPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - ObjectData = new ObjectDataBlock(bytes, ref i); + { + Header = head; + ObjectData = new ObjectDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 6; - length += ObjectData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - ObjectData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 6; + length += ObjectData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + ObjectData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ObjectPropertiesFamily ---\n"; - output += ObjectData.ToString() + "\n"; + { + string output = "--- ObjectPropertiesFamily ---\n"; + output += ObjectData.ToString() + "\n"; return output; } - + } - - /// ParcelPropertiesRequest packet + + /// ParcelPropertiesRequest packet public class ParcelPropertiesRequestPacket : Packet - { - /// ParcelData block + { + /// ParcelData block public class ParcelDataBlock - { - /// East field - public float East; - /// West field - public float West; - /// SequenceID field - public int SequenceID; - /// SnapSelection field - public bool SnapSelection; - /// North field - public float North; - /// South field - public float South; - - /// Length of this block serialized in bytes + { + /// East field + public float East; + /// West field + public float West; + /// SequenceID field + public int SequenceID; + /// SnapSelection field + public bool SnapSelection; + /// North field + public float North; + /// South field + public float South; + + /// Length of this block serialized in bytes public int Length { get - { - return 21; + { + return 21; } } - - /// Default constructor - public ParcelDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ParcelDataBlock() { } + /// Constructor for building the block from a byte array public ParcelDataBlock(byte[] bytes, ref int i) - { + { try - { - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - East = BitConverter.ToSingle(bytes, i); i += 4; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - West = BitConverter.ToSingle(bytes, i); i += 4; - SequenceID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - SnapSelection = (bytes[i++] != 0) ? (bool)true : (bool)false; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - North = BitConverter.ToSingle(bytes, i); i += 4; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - South = BitConverter.ToSingle(bytes, i); i += 4; + { + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + East = BitConverter.ToSingle(bytes, i); i += 4; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + West = BitConverter.ToSingle(bytes, i); i += 4; + SequenceID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + SnapSelection = (bytes[i++] != 0) ? (bool)true : (bool)false; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + North = BitConverter.ToSingle(bytes, i); i += 4; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + South = BitConverter.ToSingle(bytes, i); i += 4; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; + { + byte[] ba; ba = BitConverter.GetBytes(East); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; ba = BitConverter.GetBytes(West); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - bytes[i++] = (byte)(SequenceID % 256); - bytes[i++] = (byte)((SequenceID >> 8) % 256); - bytes[i++] = (byte)((SequenceID >> 16) % 256); - bytes[i++] = (byte)((SequenceID >> 24) % 256); - bytes[i++] = (byte)((SnapSelection) ? 1 : 0); + Array.Copy(ba, 0, bytes, i, 4); i += 4; + bytes[i++] = (byte)(SequenceID % 256); + bytes[i++] = (byte)((SequenceID >> 8) % 256); + bytes[i++] = (byte)((SequenceID >> 16) % 256); + bytes[i++] = (byte)((SequenceID >> 24) % 256); + bytes[i++] = (byte)((SnapSelection) ? 1 : 0); ba = BitConverter.GetBytes(North); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; ba = BitConverter.GetBytes(South); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ParcelData --\n"; - output += "East: " + East.ToString() + "\n"; - output += "West: " + West.ToString() + "\n"; - output += "SequenceID: " + SequenceID.ToString() + "\n"; - output += "SnapSelection: " + SnapSelection.ToString() + "\n"; - output += "North: " + North.ToString() + "\n"; - output += "South: " + South.ToString() + "\n"; + { + string output = "-- ParcelData --\n"; + output += "East: " + East.ToString() + "\n"; + output += "West: " + West.ToString() + "\n"; + output += "SequenceID: " + SequenceID.ToString() + "\n"; + output += "SnapSelection: " + SnapSelection.ToString() + "\n"; + output += "North: " + North.ToString() + "\n"; + output += "South: " + South.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ParcelPropertiesRequest - public override PacketType Type { get { return PacketType.ParcelPropertiesRequest; } } - /// ParcelData block - public ParcelDataBlock ParcelData; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ParcelPropertiesRequest + public override PacketType Type { get { return PacketType.ParcelPropertiesRequest; } } + /// ParcelData block + public ParcelDataBlock ParcelData; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ParcelPropertiesRequestPacket() - { - Header = new MediumHeader(); - Header.ID = 12; - Header.Reliable = true; - Header.Zerocoded = true; - ParcelData = new ParcelDataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new MediumHeader(); + Header.ID = 12; + Header.Reliable = true; + Header.Zerocoded = true; + ParcelData = new ParcelDataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ParcelPropertiesRequestPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new MediumHeader(bytes, ref i, ref packetEnd); - ParcelData = new ParcelDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new MediumHeader(bytes, ref i, ref packetEnd); + ParcelData = new ParcelDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ParcelPropertiesRequestPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - ParcelData = new ParcelDataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + ParcelData = new ParcelDataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 6; - length += ParcelData.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - ParcelData.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 6; + length += ParcelData.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + ParcelData.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ParcelPropertiesRequest ---\n"; - output += ParcelData.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- ParcelPropertiesRequest ---\n"; + output += ParcelData.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// SimStatus packet + + /// SimStatus packet public class SimStatusPacket : Packet - { - /// SimStatus block + { + /// SimStatus block public class SimStatusBlock - { - /// CanAcceptAgents field - public bool CanAcceptAgents; - /// CanAcceptTasks field - public bool CanAcceptTasks; - - /// Length of this block serialized in bytes + { + /// CanAcceptAgents field + public bool CanAcceptAgents; + /// CanAcceptTasks field + public bool CanAcceptTasks; + + /// Length of this block serialized in bytes public int Length { get - { - return 2; + { + return 2; } } - - /// Default constructor - public SimStatusBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public SimStatusBlock() { } + /// Constructor for building the block from a byte array public SimStatusBlock(byte[] bytes, ref int i) - { + { try - { - CanAcceptAgents = (bytes[i++] != 0) ? (bool)true : (bool)false; - CanAcceptTasks = (bytes[i++] != 0) ? (bool)true : (bool)false; + { + CanAcceptAgents = (bytes[i++] != 0) ? (bool)true : (bool)false; + CanAcceptTasks = (bytes[i++] != 0) ? (bool)true : (bool)false; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)((CanAcceptAgents) ? 1 : 0); - bytes[i++] = (byte)((CanAcceptTasks) ? 1 : 0); + { + bytes[i++] = (byte)((CanAcceptAgents) ? 1 : 0); + bytes[i++] = (byte)((CanAcceptTasks) ? 1 : 0); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- SimStatus --\n"; - output += "CanAcceptAgents: " + CanAcceptAgents.ToString() + "\n"; - output += "CanAcceptTasks: " + CanAcceptTasks.ToString() + "\n"; + { + string output = "-- SimStatus --\n"; + output += "CanAcceptAgents: " + CanAcceptAgents.ToString() + "\n"; + output += "CanAcceptTasks: " + CanAcceptTasks.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.SimStatus - public override PacketType Type { get { return PacketType.SimStatus; } } - /// SimStatus block - public SimStatusBlock SimStatus; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.SimStatus + public override PacketType Type { get { return PacketType.SimStatus; } } + /// SimStatus block + public SimStatusBlock SimStatus; + + /// Default constructor public SimStatusPacket() - { - Header = new MediumHeader(); - Header.ID = 13; - Header.Reliable = true; - SimStatus = new SimStatusBlock(); + { + Header = new MediumHeader(); + Header.ID = 13; + Header.Reliable = true; + SimStatus = new SimStatusBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public SimStatusPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new MediumHeader(bytes, ref i, ref packetEnd); - SimStatus = new SimStatusBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new MediumHeader(bytes, ref i, ref packetEnd); + SimStatus = new SimStatusBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public SimStatusPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - SimStatus = new SimStatusBlock(bytes, ref i); + { + Header = head; + SimStatus = new SimStatusBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 6; - length += SimStatus.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - SimStatus.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 6; + length += SimStatus.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + SimStatus.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- SimStatus ---\n"; - output += SimStatus.ToString() + "\n"; + { + string output = "--- SimStatus ---\n"; + output += SimStatus.ToString() + "\n"; return output; } - + } - - /// GestureUpdate packet + + /// GestureUpdate packet public class GestureUpdatePacket : Packet - { - /// AgentBlock block + { + /// AgentBlock block public class AgentBlockBlock - { - /// AgentID field - public LLUUID AgentID; - /// ToViewer field - public bool ToViewer; - private byte[] _filename; - /// Filename field + { + /// AgentID field + public LLUUID AgentID; + /// ToViewer field + public bool ToViewer; + private byte[] _filename; + /// Filename field public byte[] Filename - { - get { return _filename; } + { + get { return _filename; } set - { - if (value == null) { _filename = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _filename = new byte[value.Length]; Array.Copy(value, _filename, value.Length); } + { + if (value == null) { _filename = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _filename = new byte[value.Length]; Array.Copy(value, _filename, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 17; - if (Filename != null) { length += 1 + Filename.Length; } - return length; + { + int length = 17; + if (Filename != null) { length += 1 + Filename.Length; } + return length; } } - - /// Default constructor - public AgentBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentBlockBlock() { } + /// Constructor for building the block from a byte array public AgentBlockBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - AgentID = new LLUUID(bytes, i); i += 16; - ToViewer = (bytes[i++] != 0) ? (bool)true : (bool)false; - length = (ushort)bytes[i++]; - _filename = new byte[length]; - Array.Copy(bytes, i, _filename, 0, length); i += length; + { + AgentID = new LLUUID(bytes, i); i += 16; + ToViewer = (bytes[i++] != 0) ? (bool)true : (bool)false; + length = (ushort)bytes[i++]; + _filename = new byte[length]; + Array.Copy(bytes, i, _filename, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((ToViewer) ? 1 : 0); - if(Filename == null) { Console.WriteLine("Warning: Filename is null, in " + this.GetType()); } - bytes[i++] = (byte)Filename.Length; - Array.Copy(Filename, 0, bytes, i, Filename.Length); i += Filename.Length; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((ToViewer) ? 1 : 0); + if(Filename == null) { Console.WriteLine("Warning: Filename is null, in " + this.GetType()); } + bytes[i++] = (byte)Filename.Length; + Array.Copy(Filename, 0, bytes, i, Filename.Length); i += Filename.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentBlock --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "ToViewer: " + ToViewer.ToString() + "\n"; - output += Helpers.FieldToString(Filename, "Filename") + "\n"; + { + string output = "-- AgentBlock --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "ToViewer: " + ToViewer.ToString() + "\n"; + output += Helpers.FieldToString(Filename, "Filename") + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.GestureUpdate - public override PacketType Type { get { return PacketType.GestureUpdate; } } - /// AgentBlock block - public AgentBlockBlock AgentBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.GestureUpdate + public override PacketType Type { get { return PacketType.GestureUpdate; } } + /// AgentBlock block + public AgentBlockBlock AgentBlock; + + /// Default constructor public GestureUpdatePacket() - { - Header = new MediumHeader(); - Header.ID = 14; - Header.Reliable = true; - AgentBlock = new AgentBlockBlock(); + { + Header = new MediumHeader(); + Header.ID = 14; + Header.Reliable = true; + AgentBlock = new AgentBlockBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public GestureUpdatePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new MediumHeader(bytes, ref i, ref packetEnd); - AgentBlock = new AgentBlockBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new MediumHeader(bytes, ref i, ref packetEnd); + AgentBlock = new AgentBlockBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public GestureUpdatePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentBlock = new AgentBlockBlock(bytes, ref i); + { + Header = head; + AgentBlock = new AgentBlockBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 6; - length += AgentBlock.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentBlock.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 6; + length += AgentBlock.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentBlock.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- GestureUpdate ---\n"; - output += AgentBlock.ToString() + "\n"; + { + string output = "--- GestureUpdate ---\n"; + output += AgentBlock.ToString() + "\n"; return output; } - + } - - /// AttachedSound packet + + /// AttachedSound packet public class AttachedSoundPacket : Packet - { - /// DataBlock block + { + /// DataBlock block public class DataBlockBlock - { - /// ObjectID field - public LLUUID ObjectID; - /// Gain field - public float Gain; - /// SoundID field - public LLUUID SoundID; - /// OwnerID field - public LLUUID OwnerID; - /// Flags field - public byte Flags; - - /// Length of this block serialized in bytes + { + /// ObjectID field + public LLUUID ObjectID; + /// Gain field + public float Gain; + /// SoundID field + public LLUUID SoundID; + /// OwnerID field + public LLUUID OwnerID; + /// Flags field + public byte Flags; + + /// Length of this block serialized in bytes public int Length { get - { - return 53; + { + return 53; } } - - /// Default constructor - public DataBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlockBlock() { } + /// Constructor for building the block from a byte array public DataBlockBlock(byte[] bytes, ref int i) - { + { try - { - ObjectID = new LLUUID(bytes, i); i += 16; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - Gain = BitConverter.ToSingle(bytes, i); i += 4; - SoundID = new LLUUID(bytes, i); i += 16; - OwnerID = new LLUUID(bytes, i); i += 16; - Flags = (byte)bytes[i++]; + { + ObjectID = new LLUUID(bytes, i); i += 16; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + Gain = BitConverter.ToSingle(bytes, i); i += 4; + SoundID = new LLUUID(bytes, i); i += 16; + OwnerID = new LLUUID(bytes, i); i += 16; + Flags = (byte)bytes[i++]; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; - if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } - Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; + { + byte[] ba; + if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } + Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; ba = BitConverter.GetBytes(Gain); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - if(SoundID == null) { Console.WriteLine("Warning: SoundID is null, in " + this.GetType()); } - Array.Copy(SoundID.GetBytes(), 0, bytes, i, 16); i += 16; - if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } - Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = Flags; + Array.Copy(ba, 0, bytes, i, 4); i += 4; + if(SoundID == null) { Console.WriteLine("Warning: SoundID is null, in " + this.GetType()); } + Array.Copy(SoundID.GetBytes(), 0, bytes, i, 16); i += 16; + if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } + Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = Flags; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- DataBlock --\n"; - output += "ObjectID: " + ObjectID.ToString() + "\n"; - output += "Gain: " + Gain.ToString() + "\n"; - output += "SoundID: " + SoundID.ToString() + "\n"; - output += "OwnerID: " + OwnerID.ToString() + "\n"; - output += "Flags: " + Flags.ToString() + "\n"; + { + string output = "-- DataBlock --\n"; + output += "ObjectID: " + ObjectID.ToString() + "\n"; + output += "Gain: " + Gain.ToString() + "\n"; + output += "SoundID: " + SoundID.ToString() + "\n"; + output += "OwnerID: " + OwnerID.ToString() + "\n"; + output += "Flags: " + Flags.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AttachedSound - public override PacketType Type { get { return PacketType.AttachedSound; } } - /// DataBlock block - public DataBlockBlock DataBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AttachedSound + public override PacketType Type { get { return PacketType.AttachedSound; } } + /// DataBlock block + public DataBlockBlock DataBlock; + + /// Default constructor public AttachedSoundPacket() - { - Header = new MediumHeader(); - Header.ID = 15; - Header.Reliable = true; - DataBlock = new DataBlockBlock(); + { + Header = new MediumHeader(); + Header.ID = 15; + Header.Reliable = true; + DataBlock = new DataBlockBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AttachedSoundPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new MediumHeader(bytes, ref i, ref packetEnd); - DataBlock = new DataBlockBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new MediumHeader(bytes, ref i, ref packetEnd); + DataBlock = new DataBlockBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AttachedSoundPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - DataBlock = new DataBlockBlock(bytes, ref i); + { + Header = head; + DataBlock = new DataBlockBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 6; - length += DataBlock.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - DataBlock.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 6; + length += DataBlock.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + DataBlock.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AttachedSound ---\n"; - output += DataBlock.ToString() + "\n"; + { + string output = "--- AttachedSound ---\n"; + output += DataBlock.ToString() + "\n"; return output; } - + } - - /// AttachedSoundGainChange packet + + /// AttachedSoundGainChange packet public class AttachedSoundGainChangePacket : Packet - { - /// DataBlock block + { + /// DataBlock block public class DataBlockBlock - { - /// ObjectID field - public LLUUID ObjectID; - /// Gain field - public float Gain; - - /// Length of this block serialized in bytes + { + /// ObjectID field + public LLUUID ObjectID; + /// Gain field + public float Gain; + + /// Length of this block serialized in bytes public int Length { get - { - return 20; + { + return 20; } } - - /// Default constructor - public DataBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlockBlock() { } + /// Constructor for building the block from a byte array public DataBlockBlock(byte[] bytes, ref int i) - { + { try - { - ObjectID = new LLUUID(bytes, i); i += 16; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - Gain = BitConverter.ToSingle(bytes, i); i += 4; + { + ObjectID = new LLUUID(bytes, i); i += 16; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + Gain = BitConverter.ToSingle(bytes, i); i += 4; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; - if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } - Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; + { + byte[] ba; + if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } + Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; ba = BitConverter.GetBytes(Gain); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- DataBlock --\n"; - output += "ObjectID: " + ObjectID.ToString() + "\n"; - output += "Gain: " + Gain.ToString() + "\n"; + { + string output = "-- DataBlock --\n"; + output += "ObjectID: " + ObjectID.ToString() + "\n"; + output += "Gain: " + Gain.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AttachedSoundGainChange - public override PacketType Type { get { return PacketType.AttachedSoundGainChange; } } - /// DataBlock block - public DataBlockBlock DataBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AttachedSoundGainChange + public override PacketType Type { get { return PacketType.AttachedSoundGainChange; } } + /// DataBlock block + public DataBlockBlock DataBlock; + + /// Default constructor public AttachedSoundGainChangePacket() - { - Header = new MediumHeader(); - Header.ID = 16; - Header.Reliable = true; - DataBlock = new DataBlockBlock(); + { + Header = new MediumHeader(); + Header.ID = 16; + Header.Reliable = true; + DataBlock = new DataBlockBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AttachedSoundGainChangePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new MediumHeader(bytes, ref i, ref packetEnd); - DataBlock = new DataBlockBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new MediumHeader(bytes, ref i, ref packetEnd); + DataBlock = new DataBlockBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AttachedSoundGainChangePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - DataBlock = new DataBlockBlock(bytes, ref i); + { + Header = head; + DataBlock = new DataBlockBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 6; - length += DataBlock.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - DataBlock.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 6; + length += DataBlock.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + DataBlock.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AttachedSoundGainChange ---\n"; - output += DataBlock.ToString() + "\n"; + { + string output = "--- AttachedSoundGainChange ---\n"; + output += DataBlock.ToString() + "\n"; return output; } - + } - - /// AttachedSoundCutoffRadius packet + + /// AttachedSoundCutoffRadius packet public class AttachedSoundCutoffRadiusPacket : Packet - { - /// DataBlock block + { + /// DataBlock block public class DataBlockBlock - { - /// ObjectID field - public LLUUID ObjectID; - /// Radius field - public float Radius; - - /// Length of this block serialized in bytes + { + /// ObjectID field + public LLUUID ObjectID; + /// Radius field + public float Radius; + + /// Length of this block serialized in bytes public int Length { get - { - return 20; + { + return 20; } } - - /// Default constructor - public DataBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlockBlock() { } + /// Constructor for building the block from a byte array public DataBlockBlock(byte[] bytes, ref int i) - { + { try - { - ObjectID = new LLUUID(bytes, i); i += 16; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - Radius = BitConverter.ToSingle(bytes, i); i += 4; + { + ObjectID = new LLUUID(bytes, i); i += 16; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + Radius = BitConverter.ToSingle(bytes, i); i += 4; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; - if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } - Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; + { + byte[] ba; + if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } + Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; ba = BitConverter.GetBytes(Radius); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- DataBlock --\n"; - output += "ObjectID: " + ObjectID.ToString() + "\n"; - output += "Radius: " + Radius.ToString() + "\n"; + { + string output = "-- DataBlock --\n"; + output += "ObjectID: " + ObjectID.ToString() + "\n"; + output += "Radius: " + Radius.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AttachedSoundCutoffRadius - public override PacketType Type { get { return PacketType.AttachedSoundCutoffRadius; } } - /// DataBlock block - public DataBlockBlock DataBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AttachedSoundCutoffRadius + public override PacketType Type { get { return PacketType.AttachedSoundCutoffRadius; } } + /// DataBlock block + public DataBlockBlock DataBlock; + + /// Default constructor public AttachedSoundCutoffRadiusPacket() - { - Header = new MediumHeader(); - Header.ID = 17; - Header.Reliable = true; - DataBlock = new DataBlockBlock(); + { + Header = new MediumHeader(); + Header.ID = 17; + Header.Reliable = true; + DataBlock = new DataBlockBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AttachedSoundCutoffRadiusPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new MediumHeader(bytes, ref i, ref packetEnd); - DataBlock = new DataBlockBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new MediumHeader(bytes, ref i, ref packetEnd); + DataBlock = new DataBlockBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AttachedSoundCutoffRadiusPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - DataBlock = new DataBlockBlock(bytes, ref i); + { + Header = head; + DataBlock = new DataBlockBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 6; - length += DataBlock.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - DataBlock.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 6; + length += DataBlock.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + DataBlock.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AttachedSoundCutoffRadius ---\n"; - output += DataBlock.ToString() + "\n"; + { + string output = "--- AttachedSoundCutoffRadius ---\n"; + output += DataBlock.ToString() + "\n"; return output; } - + } - - /// PreloadSound packet + + /// PreloadSound packet public class PreloadSoundPacket : Packet - { - /// DataBlock block + { + /// DataBlock block public class DataBlockBlock - { - /// ObjectID field - public LLUUID ObjectID; - /// SoundID field - public LLUUID SoundID; - /// OwnerID field - public LLUUID OwnerID; - - /// Length of this block serialized in bytes + { + /// ObjectID field + public LLUUID ObjectID; + /// SoundID field + public LLUUID SoundID; + /// OwnerID field + public LLUUID OwnerID; + + /// Length of this block serialized in bytes public int Length { get - { - return 48; + { + return 48; } } - - /// Default constructor - public DataBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlockBlock() { } + /// Constructor for building the block from a byte array public DataBlockBlock(byte[] bytes, ref int i) - { + { try - { - ObjectID = new LLUUID(bytes, i); i += 16; - SoundID = new LLUUID(bytes, i); i += 16; - OwnerID = new LLUUID(bytes, i); i += 16; + { + ObjectID = new LLUUID(bytes, i); i += 16; + SoundID = new LLUUID(bytes, i); i += 16; + OwnerID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } - Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SoundID == null) { Console.WriteLine("Warning: SoundID is null, in " + this.GetType()); } - Array.Copy(SoundID.GetBytes(), 0, bytes, i, 16); i += 16; - if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } - Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } + Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SoundID == null) { Console.WriteLine("Warning: SoundID is null, in " + this.GetType()); } + Array.Copy(SoundID.GetBytes(), 0, bytes, i, 16); i += 16; + if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } + Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- DataBlock --\n"; - output += "ObjectID: " + ObjectID.ToString() + "\n"; - output += "SoundID: " + SoundID.ToString() + "\n"; - output += "OwnerID: " + OwnerID.ToString() + "\n"; + { + string output = "-- DataBlock --\n"; + output += "ObjectID: " + ObjectID.ToString() + "\n"; + output += "SoundID: " + SoundID.ToString() + "\n"; + output += "OwnerID: " + OwnerID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.PreloadSound - public override PacketType Type { get { return PacketType.PreloadSound; } } - /// DataBlock block - public DataBlockBlock[] DataBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.PreloadSound + public override PacketType Type { get { return PacketType.PreloadSound; } } + /// DataBlock block + public DataBlockBlock[] DataBlock; + + /// Default constructor public PreloadSoundPacket() - { - Header = new MediumHeader(); - Header.ID = 18; - Header.Reliable = true; - DataBlock = new DataBlockBlock[0]; + { + Header = new MediumHeader(); + Header.ID = 18; + Header.Reliable = true; + DataBlock = new DataBlockBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public PreloadSoundPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new MediumHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - DataBlock = new DataBlockBlock[count]; - for (int j = 0; j < count; j++) - { DataBlock[j] = new DataBlockBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new MediumHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + DataBlock = new DataBlockBlock[count]; + for (int j = 0; j < count; j++) + { DataBlock[j] = new DataBlockBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public PreloadSoundPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - DataBlock = new DataBlockBlock[count]; - for (int j = 0; j < count; j++) - { DataBlock[j] = new DataBlockBlock(bytes, ref i); } + { + Header = head; + int count = (int)bytes[i++]; + DataBlock = new DataBlockBlock[count]; + for (int j = 0; j < count; j++) + { DataBlock[j] = new DataBlockBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 6; -; - length++; - for (int j = 0; j < DataBlock.Length; j++) { length += DataBlock[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)DataBlock.Length; - for (int j = 0; j < DataBlock.Length; j++) { DataBlock[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 6; +; + length++; + for (int j = 0; j < DataBlock.Length; j++) { length += DataBlock[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)DataBlock.Length; + for (int j = 0; j < DataBlock.Length; j++) { DataBlock[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- PreloadSound ---\n"; + { + string output = "--- PreloadSound ---\n"; for (int j = 0; j < DataBlock.Length; j++) - { + { output += DataBlock[j].ToString() + "\n"; - } + } return output; } - + } - - /// InternalScriptMail packet + + /// InternalScriptMail packet public class InternalScriptMailPacket : Packet - { - /// DataBlock block + { + /// DataBlock block public class DataBlockBlock - { - /// To field - public LLUUID To; - private byte[] _subject; - /// Subject field + { + /// To field + public LLUUID To; + private byte[] _subject; + /// Subject field public byte[] Subject - { - get { return _subject; } + { + get { return _subject; } set - { - if (value == null) { _subject = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _subject = new byte[value.Length]; Array.Copy(value, _subject, value.Length); } + { + if (value == null) { _subject = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _subject = new byte[value.Length]; Array.Copy(value, _subject, value.Length); } } - } - private byte[] _body; - /// Body field + } + private byte[] _body; + /// Body field public byte[] Body - { - get { return _body; } + { + get { return _body; } set - { - if (value == null) { _body = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _body = new byte[value.Length]; Array.Copy(value, _body, value.Length); } + { + if (value == null) { _body = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _body = new byte[value.Length]; Array.Copy(value, _body, value.Length); } } - } - private byte[] _from; - /// From field + } + private byte[] _from; + /// From field public byte[] From - { - get { return _from; } + { + get { return _from; } set - { - if (value == null) { _from = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _from = new byte[value.Length]; Array.Copy(value, _from, value.Length); } + { + if (value == null) { _from = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _from = new byte[value.Length]; Array.Copy(value, _from, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 16; - if (Subject != null) { length += 1 + Subject.Length; } - if (Body != null) { length += 2 + Body.Length; } - if (From != null) { length += 1 + From.Length; } - return length; + { + int length = 16; + if (Subject != null) { length += 1 + Subject.Length; } + if (Body != null) { length += 2 + Body.Length; } + if (From != null) { length += 1 + From.Length; } + return length; } } - - /// Default constructor - public DataBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlockBlock() { } + /// Constructor for building the block from a byte array public DataBlockBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - To = new LLUUID(bytes, i); i += 16; - length = (ushort)bytes[i++]; - _subject = new byte[length]; - Array.Copy(bytes, i, _subject, 0, length); i += length; - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _body = new byte[length]; - Array.Copy(bytes, i, _body, 0, length); i += length; - length = (ushort)bytes[i++]; - _from = new byte[length]; - Array.Copy(bytes, i, _from, 0, length); i += length; + { + To = new LLUUID(bytes, i); i += 16; + length = (ushort)bytes[i++]; + _subject = new byte[length]; + Array.Copy(bytes, i, _subject, 0, length); i += length; + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _body = new byte[length]; + Array.Copy(bytes, i, _body, 0, length); i += length; + length = (ushort)bytes[i++]; + _from = new byte[length]; + Array.Copy(bytes, i, _from, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(To == null) { Console.WriteLine("Warning: To is null, in " + this.GetType()); } - Array.Copy(To.GetBytes(), 0, bytes, i, 16); i += 16; - if(Subject == null) { Console.WriteLine("Warning: Subject is null, in " + this.GetType()); } - bytes[i++] = (byte)Subject.Length; - Array.Copy(Subject, 0, bytes, i, Subject.Length); i += Subject.Length; - if(Body == null) { Console.WriteLine("Warning: Body is null, in " + this.GetType()); } - bytes[i++] = (byte)(Body.Length % 256); - bytes[i++] = (byte)((Body.Length >> 8) % 256); - Array.Copy(Body, 0, bytes, i, Body.Length); i += Body.Length; - if(From == null) { Console.WriteLine("Warning: From is null, in " + this.GetType()); } - bytes[i++] = (byte)From.Length; - Array.Copy(From, 0, bytes, i, From.Length); i += From.Length; + { + if(To == null) { Console.WriteLine("Warning: To is null, in " + this.GetType()); } + Array.Copy(To.GetBytes(), 0, bytes, i, 16); i += 16; + if(Subject == null) { Console.WriteLine("Warning: Subject is null, in " + this.GetType()); } + bytes[i++] = (byte)Subject.Length; + Array.Copy(Subject, 0, bytes, i, Subject.Length); i += Subject.Length; + if(Body == null) { Console.WriteLine("Warning: Body is null, in " + this.GetType()); } + bytes[i++] = (byte)(Body.Length % 256); + bytes[i++] = (byte)((Body.Length >> 8) % 256); + Array.Copy(Body, 0, bytes, i, Body.Length); i += Body.Length; + if(From == null) { Console.WriteLine("Warning: From is null, in " + this.GetType()); } + bytes[i++] = (byte)From.Length; + Array.Copy(From, 0, bytes, i, From.Length); i += From.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- DataBlock --\n"; - output += "To: " + To.ToString() + "\n"; - output += Helpers.FieldToString(Subject, "Subject") + "\n"; - output += Helpers.FieldToString(Body, "Body") + "\n"; - output += Helpers.FieldToString(From, "From") + "\n"; + { + string output = "-- DataBlock --\n"; + output += "To: " + To.ToString() + "\n"; + output += Helpers.FieldToString(Subject, "Subject") + "\n"; + output += Helpers.FieldToString(Body, "Body") + "\n"; + output += Helpers.FieldToString(From, "From") + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.InternalScriptMail - public override PacketType Type { get { return PacketType.InternalScriptMail; } } - /// DataBlock block - public DataBlockBlock DataBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.InternalScriptMail + public override PacketType Type { get { return PacketType.InternalScriptMail; } } + /// DataBlock block + public DataBlockBlock DataBlock; + + /// Default constructor public InternalScriptMailPacket() - { - Header = new MediumHeader(); - Header.ID = 19; - Header.Reliable = true; - DataBlock = new DataBlockBlock(); + { + Header = new MediumHeader(); + Header.ID = 19; + Header.Reliable = true; + DataBlock = new DataBlockBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public InternalScriptMailPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new MediumHeader(bytes, ref i, ref packetEnd); - DataBlock = new DataBlockBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new MediumHeader(bytes, ref i, ref packetEnd); + DataBlock = new DataBlockBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public InternalScriptMailPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - DataBlock = new DataBlockBlock(bytes, ref i); + { + Header = head; + DataBlock = new DataBlockBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 6; - length += DataBlock.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - DataBlock.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 6; + length += DataBlock.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + DataBlock.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- InternalScriptMail ---\n"; - output += DataBlock.ToString() + "\n"; + { + string output = "--- InternalScriptMail ---\n"; + output += DataBlock.ToString() + "\n"; return output; } - + } - - /// ViewerEffect packet + + /// ViewerEffect packet public class ViewerEffectPacket : Packet - { - /// Effect block + { + /// Effect block public class EffectBlock - { - /// Duration field - public float Duration; - /// ID field - public LLUUID ID; - /// Type field - public byte Type; - /// Color field - public byte[] Color; - private byte[] _typedata; - /// TypeData field + { + /// Duration field + public float Duration; + /// ID field + public LLUUID ID; + /// Type field + public byte Type; + /// Color field + public byte[] Color; + private byte[] _typedata; + /// TypeData field public byte[] TypeData - { - get { return _typedata; } + { + get { return _typedata; } set - { - if (value == null) { _typedata = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _typedata = new byte[value.Length]; Array.Copy(value, _typedata, value.Length); } + { + if (value == null) { _typedata = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _typedata = new byte[value.Length]; Array.Copy(value, _typedata, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 25; - if (TypeData != null) { length += 1 + TypeData.Length; } - return length; + { + int length = 25; + if (TypeData != null) { length += 1 + TypeData.Length; } + return length; } } - - /// Default constructor - public EffectBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public EffectBlock() { } + /// Constructor for building the block from a byte array public EffectBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - Duration = BitConverter.ToSingle(bytes, i); i += 4; - ID = new LLUUID(bytes, i); i += 16; - Type = (byte)bytes[i++]; - Color = new byte[4]; - Array.Copy(bytes, i, Color, 0, 4); i += 4; - length = (ushort)bytes[i++]; - _typedata = new byte[length]; - Array.Copy(bytes, i, _typedata, 0, length); i += length; + { + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + Duration = BitConverter.ToSingle(bytes, i); i += 4; + ID = new LLUUID(bytes, i); i += 16; + Type = (byte)bytes[i++]; + Color = new byte[4]; + Array.Copy(bytes, i, Color, 0, 4); i += 4; + length = (ushort)bytes[i++]; + _typedata = new byte[length]; + Array.Copy(bytes, i, _typedata, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; + { + byte[] ba; ba = BitConverter.GetBytes(Duration); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } - Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = Type; - Array.Copy(Color, 0, bytes, i, 4);i += 4; - if(TypeData == null) { Console.WriteLine("Warning: TypeData is null, in " + this.GetType()); } - bytes[i++] = (byte)TypeData.Length; - Array.Copy(TypeData, 0, bytes, i, TypeData.Length); i += TypeData.Length; + Array.Copy(ba, 0, bytes, i, 4); i += 4; + if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } + Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = Type; + Array.Copy(Color, 0, bytes, i, 4);i += 4; + if(TypeData == null) { Console.WriteLine("Warning: TypeData is null, in " + this.GetType()); } + bytes[i++] = (byte)TypeData.Length; + Array.Copy(TypeData, 0, bytes, i, TypeData.Length); i += TypeData.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Effect --\n"; - output += "Duration: " + Duration.ToString() + "\n"; - output += "ID: " + ID.ToString() + "\n"; - output += "Type: " + Type.ToString() + "\n"; - output += Helpers.FieldToString(Color, "Color") + "\n"; - output += Helpers.FieldToString(TypeData, "TypeData") + "\n"; + { + string output = "-- Effect --\n"; + output += "Duration: " + Duration.ToString() + "\n"; + output += "ID: " + ID.ToString() + "\n"; + output += "Type: " + Type.ToString() + "\n"; + output += Helpers.FieldToString(Color, "Color") + "\n"; + output += Helpers.FieldToString(TypeData, "TypeData") + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ViewerEffect - public override PacketType Type { get { return PacketType.ViewerEffect; } } - /// Effect block - public EffectBlock[] Effect; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ViewerEffect + public override PacketType Type { get { return PacketType.ViewerEffect; } } + /// Effect block + public EffectBlock[] Effect; + + /// Default constructor public ViewerEffectPacket() - { - Header = new MediumHeader(); - Header.ID = 20; - Header.Reliable = true; - Header.Zerocoded = true; - Effect = new EffectBlock[0]; + { + Header = new MediumHeader(); + Header.ID = 20; + Header.Reliable = true; + Header.Zerocoded = true; + Effect = new EffectBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ViewerEffectPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new MediumHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - Effect = new EffectBlock[count]; - for (int j = 0; j < count; j++) - { Effect[j] = new EffectBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new MediumHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + Effect = new EffectBlock[count]; + for (int j = 0; j < count; j++) + { Effect[j] = new EffectBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ViewerEffectPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - Effect = new EffectBlock[count]; - for (int j = 0; j < count; j++) - { Effect[j] = new EffectBlock(bytes, ref i); } + { + Header = head; + int count = (int)bytes[i++]; + Effect = new EffectBlock[count]; + for (int j = 0; j < count; j++) + { Effect[j] = new EffectBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 6; -; - length++; - for (int j = 0; j < Effect.Length; j++) { length += Effect[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)Effect.Length; - for (int j = 0; j < Effect.Length; j++) { Effect[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 6; +; + length++; + for (int j = 0; j < Effect.Length; j++) { length += Effect[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)Effect.Length; + for (int j = 0; j < Effect.Length; j++) { Effect[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ViewerEffect ---\n"; + { + string output = "--- ViewerEffect ---\n"; for (int j = 0; j < Effect.Length; j++) - { + { output += Effect[j].ToString() + "\n"; - } + } return output; } - + } - - /// SetSunPhase packet + + /// SetSunPhase packet public class SetSunPhasePacket : Packet - { - /// Data block + { + /// Data block public class DataBlock - { - /// Phase field - public float Phase; - - /// Length of this block serialized in bytes + { + /// Phase field + public float Phase; + + /// Length of this block serialized in bytes public int Length { get - { - return 4; + { + return 4; } } - - /// Default constructor - public DataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataBlock() { } + /// Constructor for building the block from a byte array public DataBlock(byte[] bytes, ref int i) - { + { try - { - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - Phase = BitConverter.ToSingle(bytes, i); i += 4; + { + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + Phase = BitConverter.ToSingle(bytes, i); i += 4; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; + { + byte[] ba; ba = BitConverter.GetBytes(Phase); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; + Array.Copy(ba, 0, bytes, i, 4); i += 4; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Data --\n"; - output += "Phase: " + Phase.ToString() + "\n"; + { + string output = "-- Data --\n"; + output += "Phase: " + Phase.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.SetSunPhase - public override PacketType Type { get { return PacketType.SetSunPhase; } } - /// Data block - public DataBlock Data; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.SetSunPhase + public override PacketType Type { get { return PacketType.SetSunPhase; } } + /// Data block + public DataBlock Data; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public SetSunPhasePacket() - { - Header = new MediumHeader(); - Header.ID = 21; - Header.Reliable = true; - Data = new DataBlock(); - AgentData = new AgentDataBlock(); + { + Header = new MediumHeader(); + Header.ID = 21; + Header.Reliable = true; + Data = new DataBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public SetSunPhasePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new MediumHeader(bytes, ref i, ref packetEnd); - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new MediumHeader(bytes, ref i, ref packetEnd); + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public SetSunPhasePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Data = new DataBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + Data = new DataBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 6; - length += Data.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Data.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 6; + length += Data.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Data.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- SetSunPhase ---\n"; - output += Data.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- SetSunPhase ---\n"; + output += Data.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// StartPingCheck packet + + /// StartPingCheck packet public class StartPingCheckPacket : Packet - { - /// PingID block + { + /// PingID block public class PingIDBlock - { - /// PingID field - public byte PingID; - /// OldestUnacked field - public uint OldestUnacked; - - /// Length of this block serialized in bytes + { + /// PingID field + public byte PingID; + /// OldestUnacked field + public uint OldestUnacked; + + /// Length of this block serialized in bytes public int Length { get - { - return 5; + { + return 5; } } - - /// Default constructor - public PingIDBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public PingIDBlock() { } + /// Constructor for building the block from a byte array public PingIDBlock(byte[] bytes, ref int i) - { + { try - { - PingID = (byte)bytes[i++]; - OldestUnacked = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + PingID = (byte)bytes[i++]; + OldestUnacked = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = PingID; - bytes[i++] = (byte)(OldestUnacked % 256); - bytes[i++] = (byte)((OldestUnacked >> 8) % 256); - bytes[i++] = (byte)((OldestUnacked >> 16) % 256); - bytes[i++] = (byte)((OldestUnacked >> 24) % 256); + { + bytes[i++] = PingID; + bytes[i++] = (byte)(OldestUnacked % 256); + bytes[i++] = (byte)((OldestUnacked >> 8) % 256); + bytes[i++] = (byte)((OldestUnacked >> 16) % 256); + bytes[i++] = (byte)((OldestUnacked >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- PingID --\n"; - output += "PingID: " + PingID.ToString() + "\n"; - output += "OldestUnacked: " + OldestUnacked.ToString() + "\n"; + { + string output = "-- PingID --\n"; + output += "PingID: " + PingID.ToString() + "\n"; + output += "OldestUnacked: " + OldestUnacked.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.StartPingCheck - public override PacketType Type { get { return PacketType.StartPingCheck; } } - /// PingID block - public PingIDBlock PingID; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.StartPingCheck + public override PacketType Type { get { return PacketType.StartPingCheck; } } + /// PingID block + public PingIDBlock PingID; + + /// Default constructor public StartPingCheckPacket() - { - Header = new HighHeader(); - Header.ID = 1; - Header.Reliable = true; - PingID = new PingIDBlock(); + { + Header = new HighHeader(); + Header.ID = 1; + Header.Reliable = true; + PingID = new PingIDBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public StartPingCheckPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new HighHeader(bytes, ref i, ref packetEnd); - PingID = new PingIDBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new HighHeader(bytes, ref i, ref packetEnd); + PingID = new PingIDBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public StartPingCheckPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - PingID = new PingIDBlock(bytes, ref i); + { + Header = head; + PingID = new PingIDBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 5; - length += PingID.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - PingID.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 5; + length += PingID.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + PingID.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- StartPingCheck ---\n"; - output += PingID.ToString() + "\n"; + { + string output = "--- StartPingCheck ---\n"; + output += PingID.ToString() + "\n"; return output; } - + } - - /// CompletePingCheck packet + + /// CompletePingCheck packet public class CompletePingCheckPacket : Packet - { - /// PingID block + { + /// PingID block public class PingIDBlock - { - /// PingID field - public byte PingID; - - /// Length of this block serialized in bytes + { + /// PingID field + public byte PingID; + + /// Length of this block serialized in bytes public int Length { get - { - return 1; + { + return 1; } } - - /// Default constructor - public PingIDBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public PingIDBlock() { } + /// Constructor for building the block from a byte array public PingIDBlock(byte[] bytes, ref int i) - { + { try - { - PingID = (byte)bytes[i++]; + { + PingID = (byte)bytes[i++]; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = PingID; + { + bytes[i++] = PingID; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- PingID --\n"; - output += "PingID: " + PingID.ToString() + "\n"; + { + string output = "-- PingID --\n"; + output += "PingID: " + PingID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.CompletePingCheck - public override PacketType Type { get { return PacketType.CompletePingCheck; } } - /// PingID block - public PingIDBlock PingID; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.CompletePingCheck + public override PacketType Type { get { return PacketType.CompletePingCheck; } } + /// PingID block + public PingIDBlock PingID; + + /// Default constructor public CompletePingCheckPacket() - { - Header = new HighHeader(); - Header.ID = 2; - Header.Reliable = true; - PingID = new PingIDBlock(); + { + Header = new HighHeader(); + Header.ID = 2; + Header.Reliable = true; + PingID = new PingIDBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public CompletePingCheckPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new HighHeader(bytes, ref i, ref packetEnd); - PingID = new PingIDBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new HighHeader(bytes, ref i, ref packetEnd); + PingID = new PingIDBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public CompletePingCheckPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - PingID = new PingIDBlock(bytes, ref i); + { + Header = head; + PingID = new PingIDBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 5; - length += PingID.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - PingID.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 5; + length += PingID.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + PingID.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- CompletePingCheck ---\n"; - output += PingID.ToString() + "\n"; + { + string output = "--- CompletePingCheck ---\n"; + output += PingID.ToString() + "\n"; return output; } - + } - - /// NeighborList packet + + /// NeighborList packet public class NeighborListPacket : Packet - { - /// NeighborBlock block + { + /// NeighborBlock block public class NeighborBlockBlock - { - /// IP field - public uint IP; - /// PublicPort field - public ushort PublicPort; - /// RegionID field - public LLUUID RegionID; - private byte[] _name; - /// Name field + { + /// IP field + public uint IP; + /// PublicPort field + public ushort PublicPort; + /// RegionID field + public LLUUID RegionID; + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - /// Port field - public ushort Port; - /// SimAccess field - public byte SimAccess; - /// PublicIP field - public uint PublicIP; - - /// Length of this block serialized in bytes + } + /// Port field + public ushort Port; + /// SimAccess field + public byte SimAccess; + /// PublicIP field + public uint PublicIP; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 29; - if (Name != null) { length += 1 + Name.Length; } - return length; + { + int length = 29; + if (Name != null) { length += 1 + Name.Length; } + return length; } } - - /// Default constructor - public NeighborBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public NeighborBlockBlock() { } + /// Constructor for building the block from a byte array public NeighborBlockBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - IP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - PublicPort = (ushort)((bytes[i++] << 8) + bytes[i++]); - RegionID = new LLUUID(bytes, i); i += 16; - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; - Port = (ushort)((bytes[i++] << 8) + bytes[i++]); - SimAccess = (byte)bytes[i++]; - PublicIP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + IP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + PublicPort = (ushort)((bytes[i++] << 8) + bytes[i++]); + RegionID = new LLUUID(bytes, i); i += 16; + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; + Port = (ushort)((bytes[i++] << 8) + bytes[i++]); + SimAccess = (byte)bytes[i++]; + PublicIP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(IP % 256); - bytes[i++] = (byte)((IP >> 8) % 256); - bytes[i++] = (byte)((IP >> 16) % 256); - bytes[i++] = (byte)((IP >> 24) % 256); - bytes[i++] = (byte)((PublicPort >> 8) % 256); - bytes[i++] = (byte)(PublicPort % 256); - if(RegionID == null) { Console.WriteLine("Warning: RegionID is null, in " + this.GetType()); } - Array.Copy(RegionID.GetBytes(), 0, bytes, i, 16); i += 16; - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; - bytes[i++] = (byte)((Port >> 8) % 256); - bytes[i++] = (byte)(Port % 256); - bytes[i++] = SimAccess; - bytes[i++] = (byte)(PublicIP % 256); - bytes[i++] = (byte)((PublicIP >> 8) % 256); - bytes[i++] = (byte)((PublicIP >> 16) % 256); - bytes[i++] = (byte)((PublicIP >> 24) % 256); + { + bytes[i++] = (byte)(IP % 256); + bytes[i++] = (byte)((IP >> 8) % 256); + bytes[i++] = (byte)((IP >> 16) % 256); + bytes[i++] = (byte)((IP >> 24) % 256); + bytes[i++] = (byte)((PublicPort >> 8) % 256); + bytes[i++] = (byte)(PublicPort % 256); + if(RegionID == null) { Console.WriteLine("Warning: RegionID is null, in " + this.GetType()); } + Array.Copy(RegionID.GetBytes(), 0, bytes, i, 16); i += 16; + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + bytes[i++] = (byte)((Port >> 8) % 256); + bytes[i++] = (byte)(Port % 256); + bytes[i++] = SimAccess; + bytes[i++] = (byte)(PublicIP % 256); + bytes[i++] = (byte)((PublicIP >> 8) % 256); + bytes[i++] = (byte)((PublicIP >> 16) % 256); + bytes[i++] = (byte)((PublicIP >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- NeighborBlock --\n"; - output += "IP: " + IP.ToString() + "\n"; - output += "PublicPort: " + PublicPort.ToString() + "\n"; - output += "RegionID: " + RegionID.ToString() + "\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; - output += "Port: " + Port.ToString() + "\n"; - output += "SimAccess: " + SimAccess.ToString() + "\n"; - output += "PublicIP: " + PublicIP.ToString() + "\n"; + { + string output = "-- NeighborBlock --\n"; + output += "IP: " + IP.ToString() + "\n"; + output += "PublicPort: " + PublicPort.ToString() + "\n"; + output += "RegionID: " + RegionID.ToString() + "\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; + output += "Port: " + Port.ToString() + "\n"; + output += "SimAccess: " + SimAccess.ToString() + "\n"; + output += "PublicIP: " + PublicIP.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.NeighborList - public override PacketType Type { get { return PacketType.NeighborList; } } - /// NeighborBlock block - public NeighborBlockBlock[] NeighborBlock; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.NeighborList + public override PacketType Type { get { return PacketType.NeighborList; } } + /// NeighborBlock block + public NeighborBlockBlock[] NeighborBlock; + + /// Default constructor public NeighborListPacket() - { - Header = new HighHeader(); - Header.ID = 3; - Header.Reliable = true; - NeighborBlock = new NeighborBlockBlock[4]; + { + Header = new HighHeader(); + Header.ID = 3; + Header.Reliable = true; + NeighborBlock = new NeighborBlockBlock[4]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public NeighborListPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new HighHeader(bytes, ref i, ref packetEnd); - NeighborBlock = new NeighborBlockBlock[4]; - for (int j = 0; j < 4; j++) - { NeighborBlock[j] = new NeighborBlockBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new HighHeader(bytes, ref i, ref packetEnd); + NeighborBlock = new NeighborBlockBlock[4]; + for (int j = 0; j < 4; j++) + { NeighborBlock[j] = new NeighborBlockBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public NeighborListPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - NeighborBlock = new NeighborBlockBlock[4]; - for (int j = 0; j < 4; j++) - { NeighborBlock[j] = new NeighborBlockBlock(bytes, ref i); } + { + Header = head; + NeighborBlock = new NeighborBlockBlock[4]; + for (int j = 0; j < 4; j++) + { NeighborBlock[j] = new NeighborBlockBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 5; -; - for (int j = 0; j < 4; j++) { length += NeighborBlock[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - for (int j = 0; j < 4; j++) { NeighborBlock[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 5; +; + for (int j = 0; j < 4; j++) { length += NeighborBlock[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + for (int j = 0; j < 4; j++) { NeighborBlock[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- NeighborList ---\n"; + { + string output = "--- NeighborList ---\n"; for (int j = 0; j < 4; j++) - { + { output += NeighborBlock[j].ToString() + "\n"; - } + } return output; } - + } - - /// MovedIntoSimulator packet + + /// MovedIntoSimulator packet public class MovedIntoSimulatorPacket : Packet - { - /// Sender block + { + /// Sender block public class SenderBlock - { - /// ID field - public LLUUID ID; - /// SessionID field - public LLUUID SessionID; - /// CircuitCode field - public uint CircuitCode; - - /// Length of this block serialized in bytes + { + /// ID field + public LLUUID ID; + /// SessionID field + public LLUUID SessionID; + /// CircuitCode field + public uint CircuitCode; + + /// Length of this block serialized in bytes public int Length { get - { - return 36; + { + return 36; } } - - /// Default constructor - public SenderBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public SenderBlock() { } + /// Constructor for building the block from a byte array public SenderBlock(byte[] bytes, ref int i) - { + { try - { - ID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; - CircuitCode = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + ID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; + CircuitCode = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } - Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(CircuitCode % 256); - bytes[i++] = (byte)((CircuitCode >> 8) % 256); - bytes[i++] = (byte)((CircuitCode >> 16) % 256); - bytes[i++] = (byte)((CircuitCode >> 24) % 256); + { + if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } + Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(CircuitCode % 256); + bytes[i++] = (byte)((CircuitCode >> 8) % 256); + bytes[i++] = (byte)((CircuitCode >> 16) % 256); + bytes[i++] = (byte)((CircuitCode >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Sender --\n"; - output += "ID: " + ID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "CircuitCode: " + CircuitCode.ToString() + "\n"; + { + string output = "-- Sender --\n"; + output += "ID: " + ID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "CircuitCode: " + CircuitCode.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.MovedIntoSimulator - public override PacketType Type { get { return PacketType.MovedIntoSimulator; } } - /// Sender block - public SenderBlock Sender; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.MovedIntoSimulator + public override PacketType Type { get { return PacketType.MovedIntoSimulator; } } + /// Sender block + public SenderBlock Sender; + + /// Default constructor public MovedIntoSimulatorPacket() - { - Header = new HighHeader(); - Header.ID = 4; - Header.Reliable = true; - Sender = new SenderBlock(); + { + Header = new HighHeader(); + Header.ID = 4; + Header.Reliable = true; + Sender = new SenderBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public MovedIntoSimulatorPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new HighHeader(bytes, ref i, ref packetEnd); - Sender = new SenderBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new HighHeader(bytes, ref i, ref packetEnd); + Sender = new SenderBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public MovedIntoSimulatorPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - Sender = new SenderBlock(bytes, ref i); + { + Header = head; + Sender = new SenderBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 5; - length += Sender.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - Sender.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 5; + length += Sender.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + Sender.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- MovedIntoSimulator ---\n"; - output += Sender.ToString() + "\n"; + { + string output = "--- MovedIntoSimulator ---\n"; + output += Sender.ToString() + "\n"; return output; } - + } - - /// AgentUpdate packet + + /// AgentUpdate packet public class AgentUpdatePacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// ControlFlags field - public uint ControlFlags; - /// CameraAtAxis field - public LLVector3 CameraAtAxis; - /// Far field - public float Far; - /// AgentID field - public LLUUID AgentID; - /// CameraCenter field - public LLVector3 CameraCenter; - /// CameraLeftAxis field - public LLVector3 CameraLeftAxis; - /// HeadRotation field - public LLQuaternion HeadRotation; - /// SessionID field - public LLUUID SessionID; - /// CameraUpAxis field - public LLVector3 CameraUpAxis; - /// BodyRotation field - public LLQuaternion BodyRotation; - /// Flags field - public byte Flags; - /// State field - public byte State; - - /// Length of this block serialized in bytes + { + /// ControlFlags field + public uint ControlFlags; + /// CameraAtAxis field + public LLVector3 CameraAtAxis; + /// Far field + public float Far; + /// AgentID field + public LLUUID AgentID; + /// CameraCenter field + public LLVector3 CameraCenter; + /// CameraLeftAxis field + public LLVector3 CameraLeftAxis; + /// HeadRotation field + public LLQuaternion HeadRotation; + /// SessionID field + public LLUUID SessionID; + /// CameraUpAxis field + public LLVector3 CameraUpAxis; + /// BodyRotation field + public LLQuaternion BodyRotation; + /// Flags field + public byte Flags; + /// State field + public byte State; + + /// Length of this block serialized in bytes public int Length { get - { - return 114; + { + return 114; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - ControlFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - CameraAtAxis = new LLVector3(bytes, i); i += 12; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - Far = BitConverter.ToSingle(bytes, i); i += 4; - AgentID = new LLUUID(bytes, i); i += 16; - CameraCenter = new LLVector3(bytes, i); i += 12; - CameraLeftAxis = new LLVector3(bytes, i); i += 12; - HeadRotation = new LLQuaternion(bytes, i, true); i += 12; - SessionID = new LLUUID(bytes, i); i += 16; - CameraUpAxis = new LLVector3(bytes, i); i += 12; - BodyRotation = new LLQuaternion(bytes, i, true); i += 12; - Flags = (byte)bytes[i++]; - State = (byte)bytes[i++]; + { + ControlFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + CameraAtAxis = new LLVector3(bytes, i); i += 12; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + Far = BitConverter.ToSingle(bytes, i); i += 4; + AgentID = new LLUUID(bytes, i); i += 16; + CameraCenter = new LLVector3(bytes, i); i += 12; + CameraLeftAxis = new LLVector3(bytes, i); i += 12; + HeadRotation = new LLQuaternion(bytes, i, true); i += 12; + SessionID = new LLUUID(bytes, i); i += 16; + CameraUpAxis = new LLVector3(bytes, i); i += 12; + BodyRotation = new LLQuaternion(bytes, i, true); i += 12; + Flags = (byte)bytes[i++]; + State = (byte)bytes[i++]; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; - bytes[i++] = (byte)(ControlFlags % 256); - bytes[i++] = (byte)((ControlFlags >> 8) % 256); - bytes[i++] = (byte)((ControlFlags >> 16) % 256); - bytes[i++] = (byte)((ControlFlags >> 24) % 256); - if(CameraAtAxis == null) { Console.WriteLine("Warning: CameraAtAxis is null, in " + this.GetType()); } - Array.Copy(CameraAtAxis.GetBytes(), 0, bytes, i, 12); i += 12; + { + byte[] ba; + bytes[i++] = (byte)(ControlFlags % 256); + bytes[i++] = (byte)((ControlFlags >> 8) % 256); + bytes[i++] = (byte)((ControlFlags >> 16) % 256); + bytes[i++] = (byte)((ControlFlags >> 24) % 256); + if(CameraAtAxis == null) { Console.WriteLine("Warning: CameraAtAxis is null, in " + this.GetType()); } + Array.Copy(CameraAtAxis.GetBytes(), 0, bytes, i, 12); i += 12; ba = BitConverter.GetBytes(Far); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(CameraCenter == null) { Console.WriteLine("Warning: CameraCenter is null, in " + this.GetType()); } - Array.Copy(CameraCenter.GetBytes(), 0, bytes, i, 12); i += 12; - if(CameraLeftAxis == null) { Console.WriteLine("Warning: CameraLeftAxis is null, in " + this.GetType()); } - Array.Copy(CameraLeftAxis.GetBytes(), 0, bytes, i, 12); i += 12; - if(HeadRotation == null) { Console.WriteLine("Warning: HeadRotation is null, in " + this.GetType()); } - Array.Copy(HeadRotation.GetBytes(), 0, bytes, i, 12); i += 12; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - if(CameraUpAxis == null) { Console.WriteLine("Warning: CameraUpAxis is null, in " + this.GetType()); } - Array.Copy(CameraUpAxis.GetBytes(), 0, bytes, i, 12); i += 12; - if(BodyRotation == null) { Console.WriteLine("Warning: BodyRotation is null, in " + this.GetType()); } - Array.Copy(BodyRotation.GetBytes(), 0, bytes, i, 12); i += 12; - bytes[i++] = Flags; - bytes[i++] = State; + Array.Copy(ba, 0, bytes, i, 4); i += 4; + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(CameraCenter == null) { Console.WriteLine("Warning: CameraCenter is null, in " + this.GetType()); } + Array.Copy(CameraCenter.GetBytes(), 0, bytes, i, 12); i += 12; + if(CameraLeftAxis == null) { Console.WriteLine("Warning: CameraLeftAxis is null, in " + this.GetType()); } + Array.Copy(CameraLeftAxis.GetBytes(), 0, bytes, i, 12); i += 12; + if(HeadRotation == null) { Console.WriteLine("Warning: HeadRotation is null, in " + this.GetType()); } + Array.Copy(HeadRotation.GetBytes(), 0, bytes, i, 12); i += 12; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + if(CameraUpAxis == null) { Console.WriteLine("Warning: CameraUpAxis is null, in " + this.GetType()); } + Array.Copy(CameraUpAxis.GetBytes(), 0, bytes, i, 12); i += 12; + if(BodyRotation == null) { Console.WriteLine("Warning: BodyRotation is null, in " + this.GetType()); } + Array.Copy(BodyRotation.GetBytes(), 0, bytes, i, 12); i += 12; + bytes[i++] = Flags; + bytes[i++] = State; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "ControlFlags: " + ControlFlags.ToString() + "\n"; - output += "CameraAtAxis: " + CameraAtAxis.ToString() + "\n"; - output += "Far: " + Far.ToString() + "\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "CameraCenter: " + CameraCenter.ToString() + "\n"; - output += "CameraLeftAxis: " + CameraLeftAxis.ToString() + "\n"; - output += "HeadRotation: " + HeadRotation.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "CameraUpAxis: " + CameraUpAxis.ToString() + "\n"; - output += "BodyRotation: " + BodyRotation.ToString() + "\n"; - output += "Flags: " + Flags.ToString() + "\n"; - output += "State: " + State.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "ControlFlags: " + ControlFlags.ToString() + "\n"; + output += "CameraAtAxis: " + CameraAtAxis.ToString() + "\n"; + output += "Far: " + Far.ToString() + "\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "CameraCenter: " + CameraCenter.ToString() + "\n"; + output += "CameraLeftAxis: " + CameraLeftAxis.ToString() + "\n"; + output += "HeadRotation: " + HeadRotation.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "CameraUpAxis: " + CameraUpAxis.ToString() + "\n"; + output += "BodyRotation: " + BodyRotation.ToString() + "\n"; + output += "Flags: " + Flags.ToString() + "\n"; + output += "State: " + State.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AgentUpdate - public override PacketType Type { get { return PacketType.AgentUpdate; } } - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AgentUpdate + public override PacketType Type { get { return PacketType.AgentUpdate; } } + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public AgentUpdatePacket() - { - Header = new HighHeader(); - Header.ID = 5; - Header.Reliable = true; - Header.Zerocoded = true; - AgentData = new AgentDataBlock(); + { + Header = new HighHeader(); + Header.ID = 5; + Header.Reliable = true; + Header.Zerocoded = true; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AgentUpdatePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new HighHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new HighHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AgentUpdatePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 5; - length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 5; + length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AgentUpdate ---\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- AgentUpdate ---\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// AgentAnimation packet + + /// AgentAnimation packet public class AgentAnimationPacket : Packet - { - /// AnimationList block + { + /// AnimationList block public class AnimationListBlock - { - /// AnimID field - public LLUUID AnimID; - /// StartAnim field - public bool StartAnim; - - /// Length of this block serialized in bytes + { + /// AnimID field + public LLUUID AnimID; + /// StartAnim field + public bool StartAnim; + + /// Length of this block serialized in bytes public int Length { get - { - return 17; + { + return 17; } } - - /// Default constructor - public AnimationListBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AnimationListBlock() { } + /// Constructor for building the block from a byte array public AnimationListBlock(byte[] bytes, ref int i) - { + { try - { - AnimID = new LLUUID(bytes, i); i += 16; - StartAnim = (bytes[i++] != 0) ? (bool)true : (bool)false; + { + AnimID = new LLUUID(bytes, i); i += 16; + StartAnim = (bytes[i++] != 0) ? (bool)true : (bool)false; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AnimID == null) { Console.WriteLine("Warning: AnimID is null, in " + this.GetType()); } - Array.Copy(AnimID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((StartAnim) ? 1 : 0); + { + if(AnimID == null) { Console.WriteLine("Warning: AnimID is null, in " + this.GetType()); } + Array.Copy(AnimID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((StartAnim) ? 1 : 0); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AnimationList --\n"; - output += "AnimID: " + AnimID.ToString() + "\n"; - output += "StartAnim: " + StartAnim.ToString() + "\n"; + { + string output = "-- AnimationList --\n"; + output += "AnimID: " + AnimID.ToString() + "\n"; + output += "StartAnim: " + StartAnim.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AgentAnimation - public override PacketType Type { get { return PacketType.AgentAnimation; } } - /// AnimationList block - public AnimationListBlock[] AnimationList; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AgentAnimation + public override PacketType Type { get { return PacketType.AgentAnimation; } } + /// AnimationList block + public AnimationListBlock[] AnimationList; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public AgentAnimationPacket() - { - Header = new HighHeader(); - Header.ID = 6; - Header.Reliable = true; - AnimationList = new AnimationListBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new HighHeader(); + Header.ID = 6; + Header.Reliable = true; + AnimationList = new AnimationListBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AgentAnimationPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new HighHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - AnimationList = new AnimationListBlock[count]; - for (int j = 0; j < count; j++) - { AnimationList[j] = new AnimationListBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new HighHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + AnimationList = new AnimationListBlock[count]; + for (int j = 0; j < count; j++) + { AnimationList[j] = new AnimationListBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AgentAnimationPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - AnimationList = new AnimationListBlock[count]; - for (int j = 0; j < count; j++) - { AnimationList[j] = new AnimationListBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + AnimationList = new AnimationListBlock[count]; + for (int j = 0; j < count; j++) + { AnimationList[j] = new AnimationListBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 5; - length += AgentData.Length;; - length++; - for (int j = 0; j < AnimationList.Length; j++) { length += AnimationList[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)AnimationList.Length; - for (int j = 0; j < AnimationList.Length; j++) { AnimationList[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 5; + length += AgentData.Length;; + length++; + for (int j = 0; j < AnimationList.Length; j++) { length += AnimationList[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)AnimationList.Length; + for (int j = 0; j < AnimationList.Length; j++) { AnimationList[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AgentAnimation ---\n"; + { + string output = "--- AgentAnimation ---\n"; for (int j = 0; j < AnimationList.Length; j++) - { + { output += AnimationList[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// AgentRequestSit packet + + /// AgentRequestSit packet public class AgentRequestSitPacket : Packet - { - /// TargetObject block + { + /// TargetObject block public class TargetObjectBlock - { - /// TargetID field - public LLUUID TargetID; - /// Offset field - public LLVector3 Offset; - - /// Length of this block serialized in bytes + { + /// TargetID field + public LLUUID TargetID; + /// Offset field + public LLVector3 Offset; + + /// Length of this block serialized in bytes public int Length { get - { - return 28; + { + return 28; } } - - /// Default constructor - public TargetObjectBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public TargetObjectBlock() { } + /// Constructor for building the block from a byte array public TargetObjectBlock(byte[] bytes, ref int i) - { + { try - { - TargetID = new LLUUID(bytes, i); i += 16; - Offset = new LLVector3(bytes, i); i += 12; + { + TargetID = new LLUUID(bytes, i); i += 16; + Offset = new LLVector3(bytes, i); i += 12; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(TargetID == null) { Console.WriteLine("Warning: TargetID is null, in " + this.GetType()); } - Array.Copy(TargetID.GetBytes(), 0, bytes, i, 16); i += 16; - if(Offset == null) { Console.WriteLine("Warning: Offset is null, in " + this.GetType()); } - Array.Copy(Offset.GetBytes(), 0, bytes, i, 12); i += 12; + { + if(TargetID == null) { Console.WriteLine("Warning: TargetID is null, in " + this.GetType()); } + Array.Copy(TargetID.GetBytes(), 0, bytes, i, 16); i += 16; + if(Offset == null) { Console.WriteLine("Warning: Offset is null, in " + this.GetType()); } + Array.Copy(Offset.GetBytes(), 0, bytes, i, 12); i += 12; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- TargetObject --\n"; - output += "TargetID: " + TargetID.ToString() + "\n"; - output += "Offset: " + Offset.ToString() + "\n"; + { + string output = "-- TargetObject --\n"; + output += "TargetID: " + TargetID.ToString() + "\n"; + output += "Offset: " + Offset.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AgentRequestSit - public override PacketType Type { get { return PacketType.AgentRequestSit; } } - /// TargetObject block - public TargetObjectBlock TargetObject; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AgentRequestSit + public override PacketType Type { get { return PacketType.AgentRequestSit; } } + /// TargetObject block + public TargetObjectBlock TargetObject; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public AgentRequestSitPacket() - { - Header = new HighHeader(); - Header.ID = 7; - Header.Reliable = true; - Header.Zerocoded = true; - TargetObject = new TargetObjectBlock(); - AgentData = new AgentDataBlock(); + { + Header = new HighHeader(); + Header.ID = 7; + Header.Reliable = true; + Header.Zerocoded = true; + TargetObject = new TargetObjectBlock(); + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AgentRequestSitPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new HighHeader(bytes, ref i, ref packetEnd); - TargetObject = new TargetObjectBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new HighHeader(bytes, ref i, ref packetEnd); + TargetObject = new TargetObjectBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AgentRequestSitPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - TargetObject = new TargetObjectBlock(bytes, ref i); - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + TargetObject = new TargetObjectBlock(bytes, ref i); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 5; - length += TargetObject.Length; length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - TargetObject.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 5; + length += TargetObject.Length; length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + TargetObject.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AgentRequestSit ---\n"; - output += TargetObject.ToString() + "\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- AgentRequestSit ---\n"; + output += TargetObject.ToString() + "\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// AgentSit packet + + /// AgentSit packet public class AgentSitPacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AgentSit - public override PacketType Type { get { return PacketType.AgentSit; } } - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AgentSit + public override PacketType Type { get { return PacketType.AgentSit; } } + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public AgentSitPacket() - { - Header = new HighHeader(); - Header.ID = 8; - Header.Reliable = true; - AgentData = new AgentDataBlock(); + { + Header = new HighHeader(); + Header.ID = 8; + Header.Reliable = true; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AgentSitPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new HighHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new HighHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AgentSitPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 5; - length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 5; + length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AgentSit ---\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- AgentSit ---\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// RequestImage packet + + /// RequestImage packet public class RequestImagePacket : Packet - { - /// RequestImage block + { + /// RequestImage block public class RequestImageBlock - { - /// DownloadPriority field - public float DownloadPriority; - /// DiscardLevel field - public sbyte DiscardLevel; - /// Type field - public byte Type; - /// Packet field - public uint Packet; - /// Image field - public LLUUID Image; - - /// Length of this block serialized in bytes + { + /// DownloadPriority field + public float DownloadPriority; + /// DiscardLevel field + public sbyte DiscardLevel; + /// Type field + public byte Type; + /// Packet field + public uint Packet; + /// Image field + public LLUUID Image; + + /// Length of this block serialized in bytes public int Length { get - { - return 26; + { + return 26; } } - - /// Default constructor - public RequestImageBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public RequestImageBlock() { } + /// Constructor for building the block from a byte array public RequestImageBlock(byte[] bytes, ref int i) - { + { try - { - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - DownloadPriority = BitConverter.ToSingle(bytes, i); i += 4; - DiscardLevel = (sbyte)bytes[i++]; - Type = (byte)bytes[i++]; - Packet = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Image = new LLUUID(bytes, i); i += 16; + { + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + DownloadPriority = BitConverter.ToSingle(bytes, i); i += 4; + DiscardLevel = (sbyte)bytes[i++]; + Type = (byte)bytes[i++]; + Packet = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Image = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; + { + byte[] ba; ba = BitConverter.GetBytes(DownloadPriority); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - bytes[i++] = (byte)DiscardLevel; - bytes[i++] = Type; - bytes[i++] = (byte)(Packet % 256); - bytes[i++] = (byte)((Packet >> 8) % 256); - bytes[i++] = (byte)((Packet >> 16) % 256); - bytes[i++] = (byte)((Packet >> 24) % 256); - if(Image == null) { Console.WriteLine("Warning: Image is null, in " + this.GetType()); } - Array.Copy(Image.GetBytes(), 0, bytes, i, 16); i += 16; + Array.Copy(ba, 0, bytes, i, 4); i += 4; + bytes[i++] = (byte)DiscardLevel; + bytes[i++] = Type; + bytes[i++] = (byte)(Packet % 256); + bytes[i++] = (byte)((Packet >> 8) % 256); + bytes[i++] = (byte)((Packet >> 16) % 256); + bytes[i++] = (byte)((Packet >> 24) % 256); + if(Image == null) { Console.WriteLine("Warning: Image is null, in " + this.GetType()); } + Array.Copy(Image.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- RequestImage --\n"; - output += "DownloadPriority: " + DownloadPriority.ToString() + "\n"; - output += "DiscardLevel: " + DiscardLevel.ToString() + "\n"; - output += "Type: " + Type.ToString() + "\n"; - output += "Packet: " + Packet.ToString() + "\n"; - output += "Image: " + Image.ToString() + "\n"; + { + string output = "-- RequestImage --\n"; + output += "DownloadPriority: " + DownloadPriority.ToString() + "\n"; + output += "DiscardLevel: " + DiscardLevel.ToString() + "\n"; + output += "Type: " + Type.ToString() + "\n"; + output += "Packet: " + Packet.ToString() + "\n"; + output += "Image: " + Image.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - - /// Length of this block serialized in bytes + { + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; + { + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.RequestImage - public override PacketType Type { get { return PacketType.RequestImage; } } - /// RequestImage block - public RequestImageBlock[] RequestImage; - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.RequestImage + public override PacketType Type { get { return PacketType.RequestImage; } } + /// RequestImage block + public RequestImageBlock[] RequestImage; + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public RequestImagePacket() - { - Header = new HighHeader(); - Header.ID = 9; - Header.Reliable = true; - RequestImage = new RequestImageBlock[0]; - AgentData = new AgentDataBlock(); + { + Header = new HighHeader(); + Header.ID = 9; + Header.Reliable = true; + RequestImage = new RequestImageBlock[0]; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public RequestImagePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new HighHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - RequestImage = new RequestImageBlock[count]; - for (int j = 0; j < count; j++) - { RequestImage[j] = new RequestImageBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new HighHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + RequestImage = new RequestImageBlock[count]; + for (int j = 0; j < count; j++) + { RequestImage[j] = new RequestImageBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public RequestImagePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - RequestImage = new RequestImageBlock[count]; - for (int j = 0; j < count; j++) - { RequestImage[j] = new RequestImageBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + RequestImage = new RequestImageBlock[count]; + for (int j = 0; j < count; j++) + { RequestImage[j] = new RequestImageBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 5; - length += AgentData.Length;; - length++; - for (int j = 0; j < RequestImage.Length; j++) { length += RequestImage[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)RequestImage.Length; - for (int j = 0; j < RequestImage.Length; j++) { RequestImage[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 5; + length += AgentData.Length;; + length++; + for (int j = 0; j < RequestImage.Length; j++) { length += RequestImage[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)RequestImage.Length; + for (int j = 0; j < RequestImage.Length; j++) { RequestImage[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- RequestImage ---\n"; + { + string output = "--- RequestImage ---\n"; for (int j = 0; j < RequestImage.Length; j++) - { + { output += RequestImage[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ImageData packet + + /// ImageData packet public class ImageDataPacket : Packet - { - /// ImageID block + { + /// ImageID block public class ImageIDBlock - { - /// ID field - public LLUUID ID; - /// Packets field - public ushort Packets; - /// Size field - public uint Size; - /// Codec field - public byte Codec; - - /// Length of this block serialized in bytes + { + /// ID field + public LLUUID ID; + /// Packets field + public ushort Packets; + /// Size field + public uint Size; + /// Codec field + public byte Codec; + + /// Length of this block serialized in bytes public int Length { get - { - return 23; + { + return 23; } } - - /// Default constructor - public ImageIDBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ImageIDBlock() { } + /// Constructor for building the block from a byte array public ImageIDBlock(byte[] bytes, ref int i) - { + { try - { - ID = new LLUUID(bytes, i); i += 16; - Packets = (ushort)(bytes[i++] + (bytes[i++] << 8)); - Size = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Codec = (byte)bytes[i++]; + { + ID = new LLUUID(bytes, i); i += 16; + Packets = (ushort)(bytes[i++] + (bytes[i++] << 8)); + Size = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Codec = (byte)bytes[i++]; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } - Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(Packets % 256); - bytes[i++] = (byte)((Packets >> 8) % 256); - bytes[i++] = (byte)(Size % 256); - bytes[i++] = (byte)((Size >> 8) % 256); - bytes[i++] = (byte)((Size >> 16) % 256); - bytes[i++] = (byte)((Size >> 24) % 256); - bytes[i++] = Codec; + { + if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } + Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(Packets % 256); + bytes[i++] = (byte)((Packets >> 8) % 256); + bytes[i++] = (byte)(Size % 256); + bytes[i++] = (byte)((Size >> 8) % 256); + bytes[i++] = (byte)((Size >> 16) % 256); + bytes[i++] = (byte)((Size >> 24) % 256); + bytes[i++] = Codec; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ImageID --\n"; - output += "ID: " + ID.ToString() + "\n"; - output += "Packets: " + Packets.ToString() + "\n"; - output += "Size: " + Size.ToString() + "\n"; - output += "Codec: " + Codec.ToString() + "\n"; + { + string output = "-- ImageID --\n"; + output += "ID: " + ID.ToString() + "\n"; + output += "Packets: " + Packets.ToString() + "\n"; + output += "Size: " + Size.ToString() + "\n"; + output += "Codec: " + Codec.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// ImageData block + + /// ImageData block public class ImageDataBlock - { - private byte[] _data; - /// Data field + { + private byte[] _data; + /// Data field public byte[] Data - { - get { return _data; } + { + get { return _data; } set - { - if (value == null) { _data = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _data = new byte[value.Length]; Array.Copy(value, _data, value.Length); } + { + if (value == null) { _data = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _data = new byte[value.Length]; Array.Copy(value, _data, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 0; - if (Data != null) { length += 2 + Data.Length; } - return length; + { + int length = 0; + if (Data != null) { length += 2 + Data.Length; } + return length; } } - - /// Default constructor - public ImageDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ImageDataBlock() { } + /// Constructor for building the block from a byte array public ImageDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _data = new byte[length]; - Array.Copy(bytes, i, _data, 0, length); i += length; + { + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _data = new byte[length]; + Array.Copy(bytes, i, _data, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(Data == null) { Console.WriteLine("Warning: Data is null, in " + this.GetType()); } - bytes[i++] = (byte)(Data.Length % 256); - bytes[i++] = (byte)((Data.Length >> 8) % 256); - Array.Copy(Data, 0, bytes, i, Data.Length); i += Data.Length; + { + if(Data == null) { Console.WriteLine("Warning: Data is null, in " + this.GetType()); } + bytes[i++] = (byte)(Data.Length % 256); + bytes[i++] = (byte)((Data.Length >> 8) % 256); + Array.Copy(Data, 0, bytes, i, Data.Length); i += Data.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ImageData --\n"; - output += Helpers.FieldToString(Data, "Data") + "\n"; + { + string output = "-- ImageData --\n"; + output += Helpers.FieldToString(Data, "Data") + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ImageData - public override PacketType Type { get { return PacketType.ImageData; } } - /// ImageID block - public ImageIDBlock ImageID; - /// ImageData block - public ImageDataBlock ImageData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ImageData + public override PacketType Type { get { return PacketType.ImageData; } } + /// ImageID block + public ImageIDBlock ImageID; + /// ImageData block + public ImageDataBlock ImageData; + + /// Default constructor public ImageDataPacket() - { - Header = new HighHeader(); - Header.ID = 10; - Header.Reliable = true; - ImageID = new ImageIDBlock(); - ImageData = new ImageDataBlock(); + { + Header = new HighHeader(); + Header.ID = 10; + Header.Reliable = true; + ImageID = new ImageIDBlock(); + ImageData = new ImageDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ImageDataPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new HighHeader(bytes, ref i, ref packetEnd); - ImageID = new ImageIDBlock(bytes, ref i); - ImageData = new ImageDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new HighHeader(bytes, ref i, ref packetEnd); + ImageID = new ImageIDBlock(bytes, ref i); + ImageData = new ImageDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ImageDataPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - ImageID = new ImageIDBlock(bytes, ref i); - ImageData = new ImageDataBlock(bytes, ref i); + { + Header = head; + ImageID = new ImageIDBlock(bytes, ref i); + ImageData = new ImageDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 5; - length += ImageID.Length; length += ImageData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - ImageID.ToBytes(bytes, ref i); - ImageData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 5; + length += ImageID.Length; length += ImageData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + ImageID.ToBytes(bytes, ref i); + ImageData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ImageData ---\n"; - output += ImageID.ToString() + "\n"; - output += ImageData.ToString() + "\n"; + { + string output = "--- ImageData ---\n"; + output += ImageID.ToString() + "\n"; + output += ImageData.ToString() + "\n"; return output; } - + } - - /// ImagePacket packet + + /// ImagePacket packet public class ImagePacketPacket : Packet - { - /// ImageID block + { + /// ImageID block public class ImageIDBlock - { - /// ID field - public LLUUID ID; - /// Packet field - public ushort Packet; - - /// Length of this block serialized in bytes + { + /// ID field + public LLUUID ID; + /// Packet field + public ushort Packet; + + /// Length of this block serialized in bytes public int Length { get - { - return 18; + { + return 18; } } - - /// Default constructor - public ImageIDBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ImageIDBlock() { } + /// Constructor for building the block from a byte array public ImageIDBlock(byte[] bytes, ref int i) - { + { try - { - ID = new LLUUID(bytes, i); i += 16; - Packet = (ushort)(bytes[i++] + (bytes[i++] << 8)); + { + ID = new LLUUID(bytes, i); i += 16; + Packet = (ushort)(bytes[i++] + (bytes[i++] << 8)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } - Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(Packet % 256); - bytes[i++] = (byte)((Packet >> 8) % 256); + { + if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } + Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(Packet % 256); + bytes[i++] = (byte)((Packet >> 8) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ImageID --\n"; - output += "ID: " + ID.ToString() + "\n"; - output += "Packet: " + Packet.ToString() + "\n"; + { + string output = "-- ImageID --\n"; + output += "ID: " + ID.ToString() + "\n"; + output += "Packet: " + Packet.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// ImageData block + + /// ImageData block public class ImageDataBlock - { - private byte[] _data; - /// Data field + { + private byte[] _data; + /// Data field public byte[] Data - { - get { return _data; } + { + get { return _data; } set - { - if (value == null) { _data = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _data = new byte[value.Length]; Array.Copy(value, _data, value.Length); } + { + if (value == null) { _data = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _data = new byte[value.Length]; Array.Copy(value, _data, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 0; - if (Data != null) { length += 2 + Data.Length; } - return length; + { + int length = 0; + if (Data != null) { length += 2 + Data.Length; } + return length; } } - - /// Default constructor - public ImageDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ImageDataBlock() { } + /// Constructor for building the block from a byte array public ImageDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _data = new byte[length]; - Array.Copy(bytes, i, _data, 0, length); i += length; + { + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _data = new byte[length]; + Array.Copy(bytes, i, _data, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(Data == null) { Console.WriteLine("Warning: Data is null, in " + this.GetType()); } - bytes[i++] = (byte)(Data.Length % 256); - bytes[i++] = (byte)((Data.Length >> 8) % 256); - Array.Copy(Data, 0, bytes, i, Data.Length); i += Data.Length; + { + if(Data == null) { Console.WriteLine("Warning: Data is null, in " + this.GetType()); } + bytes[i++] = (byte)(Data.Length % 256); + bytes[i++] = (byte)((Data.Length >> 8) % 256); + Array.Copy(Data, 0, bytes, i, Data.Length); i += Data.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ImageData --\n"; - output += Helpers.FieldToString(Data, "Data") + "\n"; + { + string output = "-- ImageData --\n"; + output += Helpers.FieldToString(Data, "Data") + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ImagePacket - public override PacketType Type { get { return PacketType.ImagePacket; } } - /// ImageID block - public ImageIDBlock ImageID; - /// ImageData block - public ImageDataBlock ImageData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ImagePacket + public override PacketType Type { get { return PacketType.ImagePacket; } } + /// ImageID block + public ImageIDBlock ImageID; + /// ImageData block + public ImageDataBlock ImageData; + + /// Default constructor public ImagePacketPacket() - { - Header = new HighHeader(); - Header.ID = 11; - Header.Reliable = true; - ImageID = new ImageIDBlock(); - ImageData = new ImageDataBlock(); + { + Header = new HighHeader(); + Header.ID = 11; + Header.Reliable = true; + ImageID = new ImageIDBlock(); + ImageData = new ImageDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ImagePacketPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new HighHeader(bytes, ref i, ref packetEnd); - ImageID = new ImageIDBlock(bytes, ref i); - ImageData = new ImageDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new HighHeader(bytes, ref i, ref packetEnd); + ImageID = new ImageIDBlock(bytes, ref i); + ImageData = new ImageDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ImagePacketPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - ImageID = new ImageIDBlock(bytes, ref i); - ImageData = new ImageDataBlock(bytes, ref i); + { + Header = head; + ImageID = new ImageIDBlock(bytes, ref i); + ImageData = new ImageDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 5; - length += ImageID.Length; length += ImageData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - ImageID.ToBytes(bytes, ref i); - ImageData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 5; + length += ImageID.Length; length += ImageData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + ImageID.ToBytes(bytes, ref i); + ImageData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ImagePacket ---\n"; - output += ImageID.ToString() + "\n"; - output += ImageData.ToString() + "\n"; + { + string output = "--- ImagePacket ---\n"; + output += ImageID.ToString() + "\n"; + output += ImageData.ToString() + "\n"; return output; } - + } - - /// LayerData packet + + /// LayerData packet public class LayerDataPacket : Packet - { - /// LayerID block + { + /// LayerID block public class LayerIDBlock - { - /// Type field - public byte Type; - - /// Length of this block serialized in bytes + { + /// Type field + public byte Type; + + /// Length of this block serialized in bytes public int Length { get - { - return 1; + { + return 1; } } - - /// Default constructor - public LayerIDBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public LayerIDBlock() { } + /// Constructor for building the block from a byte array public LayerIDBlock(byte[] bytes, ref int i) - { + { try - { - Type = (byte)bytes[i++]; + { + Type = (byte)bytes[i++]; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = Type; + { + bytes[i++] = Type; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- LayerID --\n"; - output += "Type: " + Type.ToString() + "\n"; + { + string output = "-- LayerID --\n"; + output += "Type: " + Type.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// LayerData block + + /// LayerData block public class LayerDataBlock - { - private byte[] _data; - /// Data field + { + private byte[] _data; + /// Data field public byte[] Data - { - get { return _data; } + { + get { return _data; } set - { - if (value == null) { _data = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _data = new byte[value.Length]; Array.Copy(value, _data, value.Length); } + { + if (value == null) { _data = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _data = new byte[value.Length]; Array.Copy(value, _data, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 0; - if (Data != null) { length += 2 + Data.Length; } - return length; + { + int length = 0; + if (Data != null) { length += 2 + Data.Length; } + return length; } } - - /// Default constructor - public LayerDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public LayerDataBlock() { } + /// Constructor for building the block from a byte array public LayerDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _data = new byte[length]; - Array.Copy(bytes, i, _data, 0, length); i += length; + { + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _data = new byte[length]; + Array.Copy(bytes, i, _data, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(Data == null) { Console.WriteLine("Warning: Data is null, in " + this.GetType()); } - bytes[i++] = (byte)(Data.Length % 256); - bytes[i++] = (byte)((Data.Length >> 8) % 256); - Array.Copy(Data, 0, bytes, i, Data.Length); i += Data.Length; + { + if(Data == null) { Console.WriteLine("Warning: Data is null, in " + this.GetType()); } + bytes[i++] = (byte)(Data.Length % 256); + bytes[i++] = (byte)((Data.Length >> 8) % 256); + Array.Copy(Data, 0, bytes, i, Data.Length); i += Data.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- LayerData --\n"; - output += Helpers.FieldToString(Data, "Data") + "\n"; + { + string output = "-- LayerData --\n"; + output += Helpers.FieldToString(Data, "Data") + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.LayerData - public override PacketType Type { get { return PacketType.LayerData; } } - /// LayerID block - public LayerIDBlock LayerID; - /// LayerData block - public LayerDataBlock LayerData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.LayerData + public override PacketType Type { get { return PacketType.LayerData; } } + /// LayerID block + public LayerIDBlock LayerID; + /// LayerData block + public LayerDataBlock LayerData; + + /// Default constructor public LayerDataPacket() - { - Header = new HighHeader(); - Header.ID = 12; - Header.Reliable = true; - LayerID = new LayerIDBlock(); - LayerData = new LayerDataBlock(); + { + Header = new HighHeader(); + Header.ID = 12; + Header.Reliable = true; + LayerID = new LayerIDBlock(); + LayerData = new LayerDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public LayerDataPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new HighHeader(bytes, ref i, ref packetEnd); - LayerID = new LayerIDBlock(bytes, ref i); - LayerData = new LayerDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new HighHeader(bytes, ref i, ref packetEnd); + LayerID = new LayerIDBlock(bytes, ref i); + LayerData = new LayerDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public LayerDataPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - LayerID = new LayerIDBlock(bytes, ref i); - LayerData = new LayerDataBlock(bytes, ref i); + { + Header = head; + LayerID = new LayerIDBlock(bytes, ref i); + LayerData = new LayerDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 5; - length += LayerID.Length; length += LayerData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - LayerID.ToBytes(bytes, ref i); - LayerData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 5; + length += LayerID.Length; length += LayerData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + LayerID.ToBytes(bytes, ref i); + LayerData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- LayerData ---\n"; - output += LayerID.ToString() + "\n"; - output += LayerData.ToString() + "\n"; + { + string output = "--- LayerData ---\n"; + output += LayerID.ToString() + "\n"; + output += LayerData.ToString() + "\n"; return output; } - + } - - /// ObjectUpdate packet + + /// ObjectUpdate packet public class ObjectUpdatePacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - /// ID field - public uint ID; - /// UpdateFlags field - public uint UpdateFlags; - private byte[] _objectdata; - /// ObjectData field + { + /// ID field + public uint ID; + /// UpdateFlags field + public uint UpdateFlags; + private byte[] _objectdata; + /// ObjectData field public byte[] ObjectData - { - get { return _objectdata; } + { + get { return _objectdata; } set - { - if (value == null) { _objectdata = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _objectdata = new byte[value.Length]; Array.Copy(value, _objectdata, value.Length); } + { + if (value == null) { _objectdata = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _objectdata = new byte[value.Length]; Array.Copy(value, _objectdata, value.Length); } } - } - /// PathTwistBegin field - public sbyte PathTwistBegin; - /// CRC field - public uint CRC; - /// JointPivot field - public LLVector3 JointPivot; - /// PathEnd field - public byte PathEnd; - private byte[] _mediaurl; - /// MediaURL field + } + /// PathTwistBegin field + public sbyte PathTwistBegin; + /// CRC field + public uint CRC; + /// JointPivot field + public LLVector3 JointPivot; + /// PathEnd field + public byte PathEnd; + private byte[] _mediaurl; + /// MediaURL field public byte[] MediaURL - { - get { return _mediaurl; } + { + get { return _mediaurl; } set - { - if (value == null) { _mediaurl = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _mediaurl = new byte[value.Length]; Array.Copy(value, _mediaurl, value.Length); } + { + if (value == null) { _mediaurl = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _mediaurl = new byte[value.Length]; Array.Copy(value, _mediaurl, value.Length); } } - } - /// TextColor field - public byte[] TextColor; - /// ClickAction field - public byte ClickAction; - /// ProfileBegin field - public byte ProfileBegin; - /// PathRadiusOffset field - public sbyte PathRadiusOffset; - /// Gain field - public float Gain; - /// PathSkew field - public sbyte PathSkew; - private byte[] _data; - /// Data field + } + /// TextColor field + public byte[] TextColor; + /// ClickAction field + public byte ClickAction; + /// ProfileBegin field + public byte ProfileBegin; + /// PathRadiusOffset field + public sbyte PathRadiusOffset; + /// Gain field + public float Gain; + /// PathSkew field + public sbyte PathSkew; + private byte[] _data; + /// Data field public byte[] Data - { - get { return _data; } + { + get { return _data; } set - { - if (value == null) { _data = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _data = new byte[value.Length]; Array.Copy(value, _data, value.Length); } + { + if (value == null) { _data = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _data = new byte[value.Length]; Array.Copy(value, _data, value.Length); } } - } - private byte[] _textureanim; - /// TextureAnim field + } + private byte[] _textureanim; + /// TextureAnim field public byte[] TextureAnim - { - get { return _textureanim; } + { + get { return _textureanim; } set - { - if (value == null) { _textureanim = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _textureanim = new byte[value.Length]; Array.Copy(value, _textureanim, value.Length); } + { + if (value == null) { _textureanim = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _textureanim = new byte[value.Length]; Array.Copy(value, _textureanim, value.Length); } } - } - /// ParentID field - public uint ParentID; - private byte[] _text; - /// Text field + } + /// ParentID field + public uint ParentID; + private byte[] _text; + /// Text field public byte[] Text - { - get { return _text; } + { + get { return _text; } set - { - if (value == null) { _text = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _text = new byte[value.Length]; Array.Copy(value, _text, value.Length); } + { + if (value == null) { _text = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _text = new byte[value.Length]; Array.Copy(value, _text, value.Length); } } - } - /// ProfileCurve field - public byte ProfileCurve; - /// PathScaleX field - public byte PathScaleX; - /// PathScaleY field - public byte PathScaleY; - /// Material field - public byte Material; - /// OwnerID field - public LLUUID OwnerID; - private byte[] _extraparams; - /// ExtraParams field + } + /// ProfileCurve field + public byte ProfileCurve; + /// PathScaleX field + public byte PathScaleX; + /// PathScaleY field + public byte PathScaleY; + /// Material field + public byte Material; + /// OwnerID field + public LLUUID OwnerID; + private byte[] _extraparams; + /// ExtraParams field public byte[] ExtraParams - { - get { return _extraparams; } + { + get { return _extraparams; } set - { - if (value == null) { _extraparams = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _extraparams = new byte[value.Length]; Array.Copy(value, _extraparams, value.Length); } + { + if (value == null) { _extraparams = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _extraparams = new byte[value.Length]; Array.Copy(value, _extraparams, value.Length); } } - } - private byte[] _namevalue; - /// NameValue field + } + private byte[] _namevalue; + /// NameValue field public byte[] NameValue - { - get { return _namevalue; } + { + get { return _namevalue; } set - { - if (value == null) { _namevalue = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _namevalue = new byte[value.Length]; Array.Copy(value, _namevalue, value.Length); } + { + if (value == null) { _namevalue = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _namevalue = new byte[value.Length]; Array.Copy(value, _namevalue, value.Length); } } - } - /// PathShearX field - public byte PathShearX; - /// PathShearY field - public byte PathShearY; - /// PathTaperX field - public sbyte PathTaperX; - /// PathTaperY field - public sbyte PathTaperY; - /// Radius field - public float Radius; - /// ProfileEnd field - public byte ProfileEnd; - /// JointType field - public byte JointType; - /// PathBegin field - public byte PathBegin; - private byte[] _psblock; - /// PSBlock field + } + /// PathShearX field + public byte PathShearX; + /// PathShearY field + public byte PathShearY; + /// PathTaperX field + public sbyte PathTaperX; + /// PathTaperY field + public sbyte PathTaperY; + /// Radius field + public float Radius; + /// ProfileEnd field + public byte ProfileEnd; + /// JointType field + public byte JointType; + /// PathBegin field + public byte PathBegin; + private byte[] _psblock; + /// PSBlock field public byte[] PSBlock - { - get { return _psblock; } + { + get { return _psblock; } set - { - if (value == null) { _psblock = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _psblock = new byte[value.Length]; Array.Copy(value, _psblock, value.Length); } + { + if (value == null) { _psblock = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _psblock = new byte[value.Length]; Array.Copy(value, _psblock, value.Length); } } - } - /// PCode field - public byte PCode; - /// FullID field - public LLUUID FullID; - /// PathCurve field - public byte PathCurve; - /// Scale field - public LLVector3 Scale; - /// JointAxisOrAnchor field - public LLVector3 JointAxisOrAnchor; - /// Flags field - public byte Flags; - /// State field - public byte State; - /// PathTwist field - public sbyte PathTwist; - /// Sound field - public LLUUID Sound; - private byte[] _textureentry; - /// TextureEntry field + } + /// PCode field + public byte PCode; + /// FullID field + public LLUUID FullID; + /// PathCurve field + public byte PathCurve; + /// Scale field + public LLVector3 Scale; + /// JointAxisOrAnchor field + public LLVector3 JointAxisOrAnchor; + /// Flags field + public byte Flags; + /// State field + public byte State; + /// PathTwist field + public sbyte PathTwist; + /// Sound field + public LLUUID Sound; + private byte[] _textureentry; + /// TextureEntry field public byte[] TextureEntry - { - get { return _textureentry; } + { + get { return _textureentry; } set - { - if (value == null) { _textureentry = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _textureentry = new byte[value.Length]; Array.Copy(value, _textureentry, value.Length); } + { + if (value == null) { _textureentry = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _textureentry = new byte[value.Length]; Array.Copy(value, _textureentry, value.Length); } } - } - /// ProfileHollow field - public byte ProfileHollow; - /// PathRevolutions field - public byte PathRevolutions; - - /// Length of this block serialized in bytes + } + /// ProfileHollow field + public byte ProfileHollow; + /// PathRevolutions field + public byte PathRevolutions; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 136; - if (ObjectData != null) { length += 1 + ObjectData.Length; } - if (MediaURL != null) { length += 1 + MediaURL.Length; } - if (Data != null) { length += 2 + Data.Length; } - if (TextureAnim != null) { length += 1 + TextureAnim.Length; } - if (Text != null) { length += 1 + Text.Length; } - if (ExtraParams != null) { length += 1 + ExtraParams.Length; } - if (NameValue != null) { length += 2 + NameValue.Length; } - if (PSBlock != null) { length += 1 + PSBlock.Length; } - if (TextureEntry != null) { length += 2 + TextureEntry.Length; } - return length; + { + int length = 136; + if (ObjectData != null) { length += 1 + ObjectData.Length; } + if (MediaURL != null) { length += 1 + MediaURL.Length; } + if (Data != null) { length += 2 + Data.Length; } + if (TextureAnim != null) { length += 1 + TextureAnim.Length; } + if (Text != null) { length += 1 + Text.Length; } + if (ExtraParams != null) { length += 1 + ExtraParams.Length; } + if (NameValue != null) { length += 2 + NameValue.Length; } + if (PSBlock != null) { length += 1 + PSBlock.Length; } + if (TextureEntry != null) { length += 2 + TextureEntry.Length; } + return length; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - ID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - UpdateFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _objectdata = new byte[length]; - Array.Copy(bytes, i, _objectdata, 0, length); i += length; - PathTwistBegin = (sbyte)bytes[i++]; - CRC = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - JointPivot = new LLVector3(bytes, i); i += 12; - PathEnd = (byte)bytes[i++]; - length = (ushort)bytes[i++]; - _mediaurl = new byte[length]; - Array.Copy(bytes, i, _mediaurl, 0, length); i += length; - TextColor = new byte[4]; - Array.Copy(bytes, i, TextColor, 0, 4); i += 4; - ClickAction = (byte)bytes[i++]; - ProfileBegin = (byte)bytes[i++]; - PathRadiusOffset = (sbyte)bytes[i++]; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - Gain = BitConverter.ToSingle(bytes, i); i += 4; - PathSkew = (sbyte)bytes[i++]; - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _data = new byte[length]; - Array.Copy(bytes, i, _data, 0, length); i += length; - length = (ushort)bytes[i++]; - _textureanim = new byte[length]; - Array.Copy(bytes, i, _textureanim, 0, length); i += length; - ParentID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _text = new byte[length]; - Array.Copy(bytes, i, _text, 0, length); i += length; - ProfileCurve = (byte)bytes[i++]; - PathScaleX = (byte)bytes[i++]; - PathScaleY = (byte)bytes[i++]; - Material = (byte)bytes[i++]; - OwnerID = new LLUUID(bytes, i); i += 16; - length = (ushort)bytes[i++]; - _extraparams = new byte[length]; - Array.Copy(bytes, i, _extraparams, 0, length); i += length; - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _namevalue = new byte[length]; - Array.Copy(bytes, i, _namevalue, 0, length); i += length; - PathShearX = (byte)bytes[i++]; - PathShearY = (byte)bytes[i++]; - PathTaperX = (sbyte)bytes[i++]; - PathTaperY = (sbyte)bytes[i++]; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - Radius = BitConverter.ToSingle(bytes, i); i += 4; - ProfileEnd = (byte)bytes[i++]; - JointType = (byte)bytes[i++]; - PathBegin = (byte)bytes[i++]; - length = (ushort)bytes[i++]; - _psblock = new byte[length]; - Array.Copy(bytes, i, _psblock, 0, length); i += length; - PCode = (byte)bytes[i++]; - FullID = new LLUUID(bytes, i); i += 16; - PathCurve = (byte)bytes[i++]; - Scale = new LLVector3(bytes, i); i += 12; - JointAxisOrAnchor = new LLVector3(bytes, i); i += 12; - Flags = (byte)bytes[i++]; - State = (byte)bytes[i++]; - PathTwist = (sbyte)bytes[i++]; - Sound = new LLUUID(bytes, i); i += 16; - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _textureentry = new byte[length]; - Array.Copy(bytes, i, _textureentry, 0, length); i += length; - ProfileHollow = (byte)bytes[i++]; - PathRevolutions = (byte)bytes[i++]; + { + ID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + UpdateFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _objectdata = new byte[length]; + Array.Copy(bytes, i, _objectdata, 0, length); i += length; + PathTwistBegin = (sbyte)bytes[i++]; + CRC = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + JointPivot = new LLVector3(bytes, i); i += 12; + PathEnd = (byte)bytes[i++]; + length = (ushort)bytes[i++]; + _mediaurl = new byte[length]; + Array.Copy(bytes, i, _mediaurl, 0, length); i += length; + TextColor = new byte[4]; + Array.Copy(bytes, i, TextColor, 0, 4); i += 4; + ClickAction = (byte)bytes[i++]; + ProfileBegin = (byte)bytes[i++]; + PathRadiusOffset = (sbyte)bytes[i++]; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + Gain = BitConverter.ToSingle(bytes, i); i += 4; + PathSkew = (sbyte)bytes[i++]; + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _data = new byte[length]; + Array.Copy(bytes, i, _data, 0, length); i += length; + length = (ushort)bytes[i++]; + _textureanim = new byte[length]; + Array.Copy(bytes, i, _textureanim, 0, length); i += length; + ParentID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _text = new byte[length]; + Array.Copy(bytes, i, _text, 0, length); i += length; + ProfileCurve = (byte)bytes[i++]; + PathScaleX = (byte)bytes[i++]; + PathScaleY = (byte)bytes[i++]; + Material = (byte)bytes[i++]; + OwnerID = new LLUUID(bytes, i); i += 16; + length = (ushort)bytes[i++]; + _extraparams = new byte[length]; + Array.Copy(bytes, i, _extraparams, 0, length); i += length; + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _namevalue = new byte[length]; + Array.Copy(bytes, i, _namevalue, 0, length); i += length; + PathShearX = (byte)bytes[i++]; + PathShearY = (byte)bytes[i++]; + PathTaperX = (sbyte)bytes[i++]; + PathTaperY = (sbyte)bytes[i++]; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + Radius = BitConverter.ToSingle(bytes, i); i += 4; + ProfileEnd = (byte)bytes[i++]; + JointType = (byte)bytes[i++]; + PathBegin = (byte)bytes[i++]; + length = (ushort)bytes[i++]; + _psblock = new byte[length]; + Array.Copy(bytes, i, _psblock, 0, length); i += length; + PCode = (byte)bytes[i++]; + FullID = new LLUUID(bytes, i); i += 16; + PathCurve = (byte)bytes[i++]; + Scale = new LLVector3(bytes, i); i += 12; + JointAxisOrAnchor = new LLVector3(bytes, i); i += 12; + Flags = (byte)bytes[i++]; + State = (byte)bytes[i++]; + PathTwist = (sbyte)bytes[i++]; + Sound = new LLUUID(bytes, i); i += 16; + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _textureentry = new byte[length]; + Array.Copy(bytes, i, _textureentry, 0, length); i += length; + ProfileHollow = (byte)bytes[i++]; + PathRevolutions = (byte)bytes[i++]; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; - bytes[i++] = (byte)(ID % 256); - bytes[i++] = (byte)((ID >> 8) % 256); - bytes[i++] = (byte)((ID >> 16) % 256); - bytes[i++] = (byte)((ID >> 24) % 256); - bytes[i++] = (byte)(UpdateFlags % 256); - bytes[i++] = (byte)((UpdateFlags >> 8) % 256); - bytes[i++] = (byte)((UpdateFlags >> 16) % 256); - bytes[i++] = (byte)((UpdateFlags >> 24) % 256); - if(ObjectData == null) { Console.WriteLine("Warning: ObjectData is null, in " + this.GetType()); } - bytes[i++] = (byte)ObjectData.Length; - Array.Copy(ObjectData, 0, bytes, i, ObjectData.Length); i += ObjectData.Length; - bytes[i++] = (byte)PathTwistBegin; - bytes[i++] = (byte)(CRC % 256); - bytes[i++] = (byte)((CRC >> 8) % 256); - bytes[i++] = (byte)((CRC >> 16) % 256); - bytes[i++] = (byte)((CRC >> 24) % 256); - if(JointPivot == null) { Console.WriteLine("Warning: JointPivot is null, in " + this.GetType()); } - Array.Copy(JointPivot.GetBytes(), 0, bytes, i, 12); i += 12; - bytes[i++] = PathEnd; - if(MediaURL == null) { Console.WriteLine("Warning: MediaURL is null, in " + this.GetType()); } - bytes[i++] = (byte)MediaURL.Length; - Array.Copy(MediaURL, 0, bytes, i, MediaURL.Length); i += MediaURL.Length; - Array.Copy(TextColor, 0, bytes, i, 4);i += 4; - bytes[i++] = ClickAction; - bytes[i++] = ProfileBegin; - bytes[i++] = (byte)PathRadiusOffset; + { + byte[] ba; + bytes[i++] = (byte)(ID % 256); + bytes[i++] = (byte)((ID >> 8) % 256); + bytes[i++] = (byte)((ID >> 16) % 256); + bytes[i++] = (byte)((ID >> 24) % 256); + bytes[i++] = (byte)(UpdateFlags % 256); + bytes[i++] = (byte)((UpdateFlags >> 8) % 256); + bytes[i++] = (byte)((UpdateFlags >> 16) % 256); + bytes[i++] = (byte)((UpdateFlags >> 24) % 256); + if(ObjectData == null) { Console.WriteLine("Warning: ObjectData is null, in " + this.GetType()); } + bytes[i++] = (byte)ObjectData.Length; + Array.Copy(ObjectData, 0, bytes, i, ObjectData.Length); i += ObjectData.Length; + bytes[i++] = (byte)PathTwistBegin; + bytes[i++] = (byte)(CRC % 256); + bytes[i++] = (byte)((CRC >> 8) % 256); + bytes[i++] = (byte)((CRC >> 16) % 256); + bytes[i++] = (byte)((CRC >> 24) % 256); + if(JointPivot == null) { Console.WriteLine("Warning: JointPivot is null, in " + this.GetType()); } + Array.Copy(JointPivot.GetBytes(), 0, bytes, i, 12); i += 12; + bytes[i++] = PathEnd; + if(MediaURL == null) { Console.WriteLine("Warning: MediaURL is null, in " + this.GetType()); } + bytes[i++] = (byte)MediaURL.Length; + Array.Copy(MediaURL, 0, bytes, i, MediaURL.Length); i += MediaURL.Length; + Array.Copy(TextColor, 0, bytes, i, 4);i += 4; + bytes[i++] = ClickAction; + bytes[i++] = ProfileBegin; + bytes[i++] = (byte)PathRadiusOffset; ba = BitConverter.GetBytes(Gain); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - bytes[i++] = (byte)PathSkew; - if(Data == null) { Console.WriteLine("Warning: Data is null, in " + this.GetType()); } - bytes[i++] = (byte)(Data.Length % 256); - bytes[i++] = (byte)((Data.Length >> 8) % 256); - Array.Copy(Data, 0, bytes, i, Data.Length); i += Data.Length; - if(TextureAnim == null) { Console.WriteLine("Warning: TextureAnim is null, in " + this.GetType()); } - bytes[i++] = (byte)TextureAnim.Length; - Array.Copy(TextureAnim, 0, bytes, i, TextureAnim.Length); i += TextureAnim.Length; - bytes[i++] = (byte)(ParentID % 256); - bytes[i++] = (byte)((ParentID >> 8) % 256); - bytes[i++] = (byte)((ParentID >> 16) % 256); - bytes[i++] = (byte)((ParentID >> 24) % 256); - if(Text == null) { Console.WriteLine("Warning: Text is null, in " + this.GetType()); } - bytes[i++] = (byte)Text.Length; - Array.Copy(Text, 0, bytes, i, Text.Length); i += Text.Length; - bytes[i++] = ProfileCurve; - bytes[i++] = PathScaleX; - bytes[i++] = PathScaleY; - bytes[i++] = Material; - if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } - Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; - if(ExtraParams == null) { Console.WriteLine("Warning: ExtraParams is null, in " + this.GetType()); } - bytes[i++] = (byte)ExtraParams.Length; - Array.Copy(ExtraParams, 0, bytes, i, ExtraParams.Length); i += ExtraParams.Length; - if(NameValue == null) { Console.WriteLine("Warning: NameValue is null, in " + this.GetType()); } - bytes[i++] = (byte)(NameValue.Length % 256); - bytes[i++] = (byte)((NameValue.Length >> 8) % 256); - Array.Copy(NameValue, 0, bytes, i, NameValue.Length); i += NameValue.Length; - bytes[i++] = PathShearX; - bytes[i++] = PathShearY; - bytes[i++] = (byte)PathTaperX; - bytes[i++] = (byte)PathTaperY; + Array.Copy(ba, 0, bytes, i, 4); i += 4; + bytes[i++] = (byte)PathSkew; + if(Data == null) { Console.WriteLine("Warning: Data is null, in " + this.GetType()); } + bytes[i++] = (byte)(Data.Length % 256); + bytes[i++] = (byte)((Data.Length >> 8) % 256); + Array.Copy(Data, 0, bytes, i, Data.Length); i += Data.Length; + if(TextureAnim == null) { Console.WriteLine("Warning: TextureAnim is null, in " + this.GetType()); } + bytes[i++] = (byte)TextureAnim.Length; + Array.Copy(TextureAnim, 0, bytes, i, TextureAnim.Length); i += TextureAnim.Length; + bytes[i++] = (byte)(ParentID % 256); + bytes[i++] = (byte)((ParentID >> 8) % 256); + bytes[i++] = (byte)((ParentID >> 16) % 256); + bytes[i++] = (byte)((ParentID >> 24) % 256); + if(Text == null) { Console.WriteLine("Warning: Text is null, in " + this.GetType()); } + bytes[i++] = (byte)Text.Length; + Array.Copy(Text, 0, bytes, i, Text.Length); i += Text.Length; + bytes[i++] = ProfileCurve; + bytes[i++] = PathScaleX; + bytes[i++] = PathScaleY; + bytes[i++] = Material; + if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } + Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; + if(ExtraParams == null) { Console.WriteLine("Warning: ExtraParams is null, in " + this.GetType()); } + bytes[i++] = (byte)ExtraParams.Length; + Array.Copy(ExtraParams, 0, bytes, i, ExtraParams.Length); i += ExtraParams.Length; + if(NameValue == null) { Console.WriteLine("Warning: NameValue is null, in " + this.GetType()); } + bytes[i++] = (byte)(NameValue.Length % 256); + bytes[i++] = (byte)((NameValue.Length >> 8) % 256); + Array.Copy(NameValue, 0, bytes, i, NameValue.Length); i += NameValue.Length; + bytes[i++] = PathShearX; + bytes[i++] = PathShearY; + bytes[i++] = (byte)PathTaperX; + bytes[i++] = (byte)PathTaperY; ba = BitConverter.GetBytes(Radius); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - bytes[i++] = ProfileEnd; - bytes[i++] = JointType; - bytes[i++] = PathBegin; - if(PSBlock == null) { Console.WriteLine("Warning: PSBlock is null, in " + this.GetType()); } - bytes[i++] = (byte)PSBlock.Length; - Array.Copy(PSBlock, 0, bytes, i, PSBlock.Length); i += PSBlock.Length; - bytes[i++] = PCode; - if(FullID == null) { Console.WriteLine("Warning: FullID is null, in " + this.GetType()); } - Array.Copy(FullID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = PathCurve; - if(Scale == null) { Console.WriteLine("Warning: Scale is null, in " + this.GetType()); } - Array.Copy(Scale.GetBytes(), 0, bytes, i, 12); i += 12; - if(JointAxisOrAnchor == null) { Console.WriteLine("Warning: JointAxisOrAnchor is null, in " + this.GetType()); } - Array.Copy(JointAxisOrAnchor.GetBytes(), 0, bytes, i, 12); i += 12; - bytes[i++] = Flags; - bytes[i++] = State; - bytes[i++] = (byte)PathTwist; - if(Sound == null) { Console.WriteLine("Warning: Sound is null, in " + this.GetType()); } - Array.Copy(Sound.GetBytes(), 0, bytes, i, 16); i += 16; - if(TextureEntry == null) { Console.WriteLine("Warning: TextureEntry is null, in " + this.GetType()); } - bytes[i++] = (byte)(TextureEntry.Length % 256); - bytes[i++] = (byte)((TextureEntry.Length >> 8) % 256); - Array.Copy(TextureEntry, 0, bytes, i, TextureEntry.Length); i += TextureEntry.Length; - bytes[i++] = ProfileHollow; - bytes[i++] = PathRevolutions; + Array.Copy(ba, 0, bytes, i, 4); i += 4; + bytes[i++] = ProfileEnd; + bytes[i++] = JointType; + bytes[i++] = PathBegin; + if(PSBlock == null) { Console.WriteLine("Warning: PSBlock is null, in " + this.GetType()); } + bytes[i++] = (byte)PSBlock.Length; + Array.Copy(PSBlock, 0, bytes, i, PSBlock.Length); i += PSBlock.Length; + bytes[i++] = PCode; + if(FullID == null) { Console.WriteLine("Warning: FullID is null, in " + this.GetType()); } + Array.Copy(FullID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = PathCurve; + if(Scale == null) { Console.WriteLine("Warning: Scale is null, in " + this.GetType()); } + Array.Copy(Scale.GetBytes(), 0, bytes, i, 12); i += 12; + if(JointAxisOrAnchor == null) { Console.WriteLine("Warning: JointAxisOrAnchor is null, in " + this.GetType()); } + Array.Copy(JointAxisOrAnchor.GetBytes(), 0, bytes, i, 12); i += 12; + bytes[i++] = Flags; + bytes[i++] = State; + bytes[i++] = (byte)PathTwist; + if(Sound == null) { Console.WriteLine("Warning: Sound is null, in " + this.GetType()); } + Array.Copy(Sound.GetBytes(), 0, bytes, i, 16); i += 16; + if(TextureEntry == null) { Console.WriteLine("Warning: TextureEntry is null, in " + this.GetType()); } + bytes[i++] = (byte)(TextureEntry.Length % 256); + bytes[i++] = (byte)((TextureEntry.Length >> 8) % 256); + Array.Copy(TextureEntry, 0, bytes, i, TextureEntry.Length); i += TextureEntry.Length; + bytes[i++] = ProfileHollow; + bytes[i++] = PathRevolutions; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += "ID: " + ID.ToString() + "\n"; - output += "UpdateFlags: " + UpdateFlags.ToString() + "\n"; - output += Helpers.FieldToString(ObjectData, "ObjectData") + "\n"; - output += "PathTwistBegin: " + PathTwistBegin.ToString() + "\n"; - output += "CRC: " + CRC.ToString() + "\n"; - output += "JointPivot: " + JointPivot.ToString() + "\n"; - output += "PathEnd: " + PathEnd.ToString() + "\n"; - output += Helpers.FieldToString(MediaURL, "MediaURL") + "\n"; - output += Helpers.FieldToString(TextColor, "TextColor") + "\n"; - output += "ClickAction: " + ClickAction.ToString() + "\n"; - output += "ProfileBegin: " + ProfileBegin.ToString() + "\n"; - output += "PathRadiusOffset: " + PathRadiusOffset.ToString() + "\n"; - output += "Gain: " + Gain.ToString() + "\n"; - output += "PathSkew: " + PathSkew.ToString() + "\n"; - output += Helpers.FieldToString(Data, "Data") + "\n"; - output += Helpers.FieldToString(TextureAnim, "TextureAnim") + "\n"; - output += "ParentID: " + ParentID.ToString() + "\n"; - output += Helpers.FieldToString(Text, "Text") + "\n"; - output += "ProfileCurve: " + ProfileCurve.ToString() + "\n"; - output += "PathScaleX: " + PathScaleX.ToString() + "\n"; - output += "PathScaleY: " + PathScaleY.ToString() + "\n"; - output += "Material: " + Material.ToString() + "\n"; - output += "OwnerID: " + OwnerID.ToString() + "\n"; - output += Helpers.FieldToString(ExtraParams, "ExtraParams") + "\n"; - output += Helpers.FieldToString(NameValue, "NameValue") + "\n"; - output += "PathShearX: " + PathShearX.ToString() + "\n"; - output += "PathShearY: " + PathShearY.ToString() + "\n"; - output += "PathTaperX: " + PathTaperX.ToString() + "\n"; - output += "PathTaperY: " + PathTaperY.ToString() + "\n"; - output += "Radius: " + Radius.ToString() + "\n"; - output += "ProfileEnd: " + ProfileEnd.ToString() + "\n"; - output += "JointType: " + JointType.ToString() + "\n"; - output += "PathBegin: " + PathBegin.ToString() + "\n"; - output += Helpers.FieldToString(PSBlock, "PSBlock") + "\n"; - output += "PCode: " + PCode.ToString() + "\n"; - output += "FullID: " + FullID.ToString() + "\n"; - output += "PathCurve: " + PathCurve.ToString() + "\n"; - output += "Scale: " + Scale.ToString() + "\n"; - output += "JointAxisOrAnchor: " + JointAxisOrAnchor.ToString() + "\n"; - output += "Flags: " + Flags.ToString() + "\n"; - output += "State: " + State.ToString() + "\n"; - output += "PathTwist: " + PathTwist.ToString() + "\n"; - output += "Sound: " + Sound.ToString() + "\n"; - output += Helpers.FieldToString(TextureEntry, "TextureEntry") + "\n"; - output += "ProfileHollow: " + ProfileHollow.ToString() + "\n"; - output += "PathRevolutions: " + PathRevolutions.ToString() + "\n"; + { + string output = "-- ObjectData --\n"; + output += "ID: " + ID.ToString() + "\n"; + output += "UpdateFlags: " + UpdateFlags.ToString() + "\n"; + output += Helpers.FieldToString(ObjectData, "ObjectData") + "\n"; + output += "PathTwistBegin: " + PathTwistBegin.ToString() + "\n"; + output += "CRC: " + CRC.ToString() + "\n"; + output += "JointPivot: " + JointPivot.ToString() + "\n"; + output += "PathEnd: " + PathEnd.ToString() + "\n"; + output += Helpers.FieldToString(MediaURL, "MediaURL") + "\n"; + output += Helpers.FieldToString(TextColor, "TextColor") + "\n"; + output += "ClickAction: " + ClickAction.ToString() + "\n"; + output += "ProfileBegin: " + ProfileBegin.ToString() + "\n"; + output += "PathRadiusOffset: " + PathRadiusOffset.ToString() + "\n"; + output += "Gain: " + Gain.ToString() + "\n"; + output += "PathSkew: " + PathSkew.ToString() + "\n"; + output += Helpers.FieldToString(Data, "Data") + "\n"; + output += Helpers.FieldToString(TextureAnim, "TextureAnim") + "\n"; + output += "ParentID: " + ParentID.ToString() + "\n"; + output += Helpers.FieldToString(Text, "Text") + "\n"; + output += "ProfileCurve: " + ProfileCurve.ToString() + "\n"; + output += "PathScaleX: " + PathScaleX.ToString() + "\n"; + output += "PathScaleY: " + PathScaleY.ToString() + "\n"; + output += "Material: " + Material.ToString() + "\n"; + output += "OwnerID: " + OwnerID.ToString() + "\n"; + output += Helpers.FieldToString(ExtraParams, "ExtraParams") + "\n"; + output += Helpers.FieldToString(NameValue, "NameValue") + "\n"; + output += "PathShearX: " + PathShearX.ToString() + "\n"; + output += "PathShearY: " + PathShearY.ToString() + "\n"; + output += "PathTaperX: " + PathTaperX.ToString() + "\n"; + output += "PathTaperY: " + PathTaperY.ToString() + "\n"; + output += "Radius: " + Radius.ToString() + "\n"; + output += "ProfileEnd: " + ProfileEnd.ToString() + "\n"; + output += "JointType: " + JointType.ToString() + "\n"; + output += "PathBegin: " + PathBegin.ToString() + "\n"; + output += Helpers.FieldToString(PSBlock, "PSBlock") + "\n"; + output += "PCode: " + PCode.ToString() + "\n"; + output += "FullID: " + FullID.ToString() + "\n"; + output += "PathCurve: " + PathCurve.ToString() + "\n"; + output += "Scale: " + Scale.ToString() + "\n"; + output += "JointAxisOrAnchor: " + JointAxisOrAnchor.ToString() + "\n"; + output += "Flags: " + Flags.ToString() + "\n"; + output += "State: " + State.ToString() + "\n"; + output += "PathTwist: " + PathTwist.ToString() + "\n"; + output += "Sound: " + Sound.ToString() + "\n"; + output += Helpers.FieldToString(TextureEntry, "TextureEntry") + "\n"; + output += "ProfileHollow: " + ProfileHollow.ToString() + "\n"; + output += "PathRevolutions: " + PathRevolutions.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// RegionData block + + /// RegionData block public class RegionDataBlock - { - /// TimeDilation field - public ushort TimeDilation; - /// RegionHandle field - public ulong RegionHandle; - - /// Length of this block serialized in bytes + { + /// TimeDilation field + public ushort TimeDilation; + /// RegionHandle field + public ulong RegionHandle; + + /// Length of this block serialized in bytes public int Length { get - { - return 10; + { + return 10; } } - - /// Default constructor - public RegionDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public RegionDataBlock() { } + /// Constructor for building the block from a byte array public RegionDataBlock(byte[] bytes, ref int i) - { + { try - { - TimeDilation = (ushort)(bytes[i++] + (bytes[i++] << 8)); - RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + { + TimeDilation = (ushort)(bytes[i++] + (bytes[i++] << 8)); + RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(TimeDilation % 256); - bytes[i++] = (byte)((TimeDilation >> 8) % 256); - bytes[i++] = (byte)(RegionHandle % 256); - bytes[i++] = (byte)((RegionHandle >> 8) % 256); - bytes[i++] = (byte)((RegionHandle >> 16) % 256); - bytes[i++] = (byte)((RegionHandle >> 24) % 256); - bytes[i++] = (byte)((RegionHandle >> 32) % 256); - bytes[i++] = (byte)((RegionHandle >> 40) % 256); - bytes[i++] = (byte)((RegionHandle >> 48) % 256); - bytes[i++] = (byte)((RegionHandle >> 56) % 256); + { + bytes[i++] = (byte)(TimeDilation % 256); + bytes[i++] = (byte)((TimeDilation >> 8) % 256); + bytes[i++] = (byte)(RegionHandle % 256); + bytes[i++] = (byte)((RegionHandle >> 8) % 256); + bytes[i++] = (byte)((RegionHandle >> 16) % 256); + bytes[i++] = (byte)((RegionHandle >> 24) % 256); + bytes[i++] = (byte)((RegionHandle >> 32) % 256); + bytes[i++] = (byte)((RegionHandle >> 40) % 256); + bytes[i++] = (byte)((RegionHandle >> 48) % 256); + bytes[i++] = (byte)((RegionHandle >> 56) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- RegionData --\n"; - output += "TimeDilation: " + TimeDilation.ToString() + "\n"; - output += "RegionHandle: " + RegionHandle.ToString() + "\n"; + { + string output = "-- RegionData --\n"; + output += "TimeDilation: " + TimeDilation.ToString() + "\n"; + output += "RegionHandle: " + RegionHandle.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ObjectUpdate - public override PacketType Type { get { return PacketType.ObjectUpdate; } } - /// ObjectData block - public ObjectDataBlock[] ObjectData; - /// RegionData block - public RegionDataBlock RegionData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ObjectUpdate + public override PacketType Type { get { return PacketType.ObjectUpdate; } } + /// ObjectData block + public ObjectDataBlock[] ObjectData; + /// RegionData block + public RegionDataBlock RegionData; + + /// Default constructor public ObjectUpdatePacket() - { - Header = new HighHeader(); - Header.ID = 13; - Header.Reliable = true; - Header.Zerocoded = true; - ObjectData = new ObjectDataBlock[0]; - RegionData = new RegionDataBlock(); + { + Header = new HighHeader(); + Header.ID = 13; + Header.Reliable = true; + Header.Zerocoded = true; + ObjectData = new ObjectDataBlock[0]; + RegionData = new RegionDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ObjectUpdatePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new HighHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - RegionData = new RegionDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new HighHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + RegionData = new RegionDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ObjectUpdatePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - RegionData = new RegionDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + RegionData = new RegionDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 5; - length += RegionData.Length;; - length++; - for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ObjectData.Length; - for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } - RegionData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 5; + length += RegionData.Length;; + length++; + for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ObjectData.Length; + for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } + RegionData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ObjectUpdate ---\n"; + { + string output = "--- ObjectUpdate ---\n"; for (int j = 0; j < ObjectData.Length; j++) - { + { output += ObjectData[j].ToString() + "\n"; - } - output += RegionData.ToString() + "\n"; + } + output += RegionData.ToString() + "\n"; return output; } - + } - - /// ObjectUpdateCompressed packet + + /// ObjectUpdateCompressed packet public class ObjectUpdateCompressedPacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - /// UpdateFlags field - public uint UpdateFlags; - private byte[] _data; - /// Data field + { + /// UpdateFlags field + public uint UpdateFlags; + private byte[] _data; + /// Data field public byte[] Data - { - get { return _data; } + { + get { return _data; } set - { - if (value == null) { _data = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _data = new byte[value.Length]; Array.Copy(value, _data, value.Length); } + { + if (value == null) { _data = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _data = new byte[value.Length]; Array.Copy(value, _data, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 4; - if (Data != null) { length += 2 + Data.Length; } - return length; + { + int length = 4; + if (Data != null) { length += 2 + Data.Length; } + return length; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - UpdateFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _data = new byte[length]; - Array.Copy(bytes, i, _data, 0, length); i += length; + { + UpdateFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _data = new byte[length]; + Array.Copy(bytes, i, _data, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(UpdateFlags % 256); - bytes[i++] = (byte)((UpdateFlags >> 8) % 256); - bytes[i++] = (byte)((UpdateFlags >> 16) % 256); - bytes[i++] = (byte)((UpdateFlags >> 24) % 256); - if(Data == null) { Console.WriteLine("Warning: Data is null, in " + this.GetType()); } - bytes[i++] = (byte)(Data.Length % 256); - bytes[i++] = (byte)((Data.Length >> 8) % 256); - Array.Copy(Data, 0, bytes, i, Data.Length); i += Data.Length; + { + bytes[i++] = (byte)(UpdateFlags % 256); + bytes[i++] = (byte)((UpdateFlags >> 8) % 256); + bytes[i++] = (byte)((UpdateFlags >> 16) % 256); + bytes[i++] = (byte)((UpdateFlags >> 24) % 256); + if(Data == null) { Console.WriteLine("Warning: Data is null, in " + this.GetType()); } + bytes[i++] = (byte)(Data.Length % 256); + bytes[i++] = (byte)((Data.Length >> 8) % 256); + Array.Copy(Data, 0, bytes, i, Data.Length); i += Data.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += "UpdateFlags: " + UpdateFlags.ToString() + "\n"; - output += Helpers.FieldToString(Data, "Data") + "\n"; + { + string output = "-- ObjectData --\n"; + output += "UpdateFlags: " + UpdateFlags.ToString() + "\n"; + output += Helpers.FieldToString(Data, "Data") + "\n"; output = output.Trim(); return output; - } + } } - - /// RegionData block + + /// RegionData block public class RegionDataBlock - { - /// TimeDilation field - public ushort TimeDilation; - /// RegionHandle field - public ulong RegionHandle; - - /// Length of this block serialized in bytes + { + /// TimeDilation field + public ushort TimeDilation; + /// RegionHandle field + public ulong RegionHandle; + + /// Length of this block serialized in bytes public int Length { get - { - return 10; + { + return 10; } } - - /// Default constructor - public RegionDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public RegionDataBlock() { } + /// Constructor for building the block from a byte array public RegionDataBlock(byte[] bytes, ref int i) - { + { try - { - TimeDilation = (ushort)(bytes[i++] + (bytes[i++] << 8)); - RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + { + TimeDilation = (ushort)(bytes[i++] + (bytes[i++] << 8)); + RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(TimeDilation % 256); - bytes[i++] = (byte)((TimeDilation >> 8) % 256); - bytes[i++] = (byte)(RegionHandle % 256); - bytes[i++] = (byte)((RegionHandle >> 8) % 256); - bytes[i++] = (byte)((RegionHandle >> 16) % 256); - bytes[i++] = (byte)((RegionHandle >> 24) % 256); - bytes[i++] = (byte)((RegionHandle >> 32) % 256); - bytes[i++] = (byte)((RegionHandle >> 40) % 256); - bytes[i++] = (byte)((RegionHandle >> 48) % 256); - bytes[i++] = (byte)((RegionHandle >> 56) % 256); + { + bytes[i++] = (byte)(TimeDilation % 256); + bytes[i++] = (byte)((TimeDilation >> 8) % 256); + bytes[i++] = (byte)(RegionHandle % 256); + bytes[i++] = (byte)((RegionHandle >> 8) % 256); + bytes[i++] = (byte)((RegionHandle >> 16) % 256); + bytes[i++] = (byte)((RegionHandle >> 24) % 256); + bytes[i++] = (byte)((RegionHandle >> 32) % 256); + bytes[i++] = (byte)((RegionHandle >> 40) % 256); + bytes[i++] = (byte)((RegionHandle >> 48) % 256); + bytes[i++] = (byte)((RegionHandle >> 56) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- RegionData --\n"; - output += "TimeDilation: " + TimeDilation.ToString() + "\n"; - output += "RegionHandle: " + RegionHandle.ToString() + "\n"; + { + string output = "-- RegionData --\n"; + output += "TimeDilation: " + TimeDilation.ToString() + "\n"; + output += "RegionHandle: " + RegionHandle.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ObjectUpdateCompressed - public override PacketType Type { get { return PacketType.ObjectUpdateCompressed; } } - /// ObjectData block - public ObjectDataBlock[] ObjectData; - /// RegionData block - public RegionDataBlock RegionData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ObjectUpdateCompressed + public override PacketType Type { get { return PacketType.ObjectUpdateCompressed; } } + /// ObjectData block + public ObjectDataBlock[] ObjectData; + /// RegionData block + public RegionDataBlock RegionData; + + /// Default constructor public ObjectUpdateCompressedPacket() - { - Header = new HighHeader(); - Header.ID = 14; - Header.Reliable = true; - ObjectData = new ObjectDataBlock[0]; - RegionData = new RegionDataBlock(); + { + Header = new HighHeader(); + Header.ID = 14; + Header.Reliable = true; + ObjectData = new ObjectDataBlock[0]; + RegionData = new RegionDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ObjectUpdateCompressedPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new HighHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - RegionData = new RegionDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new HighHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + RegionData = new RegionDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ObjectUpdateCompressedPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - RegionData = new RegionDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + RegionData = new RegionDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 5; - length += RegionData.Length;; - length++; - for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ObjectData.Length; - for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } - RegionData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 5; + length += RegionData.Length;; + length++; + for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ObjectData.Length; + for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } + RegionData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ObjectUpdateCompressed ---\n"; + { + string output = "--- ObjectUpdateCompressed ---\n"; for (int j = 0; j < ObjectData.Length; j++) - { + { output += ObjectData[j].ToString() + "\n"; - } - output += RegionData.ToString() + "\n"; + } + output += RegionData.ToString() + "\n"; return output; } - + } - - /// ObjectUpdateCached packet + + /// ObjectUpdateCached packet public class ObjectUpdateCachedPacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - /// ID field - public uint ID; - /// UpdateFlags field - public uint UpdateFlags; - /// CRC field - public uint CRC; - - /// Length of this block serialized in bytes + { + /// ID field + public uint ID; + /// UpdateFlags field + public uint UpdateFlags; + /// CRC field + public uint CRC; + + /// Length of this block serialized in bytes public int Length { get - { - return 12; + { + return 12; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { + { try - { - ID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - UpdateFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - CRC = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + ID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + UpdateFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + CRC = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(ID % 256); - bytes[i++] = (byte)((ID >> 8) % 256); - bytes[i++] = (byte)((ID >> 16) % 256); - bytes[i++] = (byte)((ID >> 24) % 256); - bytes[i++] = (byte)(UpdateFlags % 256); - bytes[i++] = (byte)((UpdateFlags >> 8) % 256); - bytes[i++] = (byte)((UpdateFlags >> 16) % 256); - bytes[i++] = (byte)((UpdateFlags >> 24) % 256); - bytes[i++] = (byte)(CRC % 256); - bytes[i++] = (byte)((CRC >> 8) % 256); - bytes[i++] = (byte)((CRC >> 16) % 256); - bytes[i++] = (byte)((CRC >> 24) % 256); + { + bytes[i++] = (byte)(ID % 256); + bytes[i++] = (byte)((ID >> 8) % 256); + bytes[i++] = (byte)((ID >> 16) % 256); + bytes[i++] = (byte)((ID >> 24) % 256); + bytes[i++] = (byte)(UpdateFlags % 256); + bytes[i++] = (byte)((UpdateFlags >> 8) % 256); + bytes[i++] = (byte)((UpdateFlags >> 16) % 256); + bytes[i++] = (byte)((UpdateFlags >> 24) % 256); + bytes[i++] = (byte)(CRC % 256); + bytes[i++] = (byte)((CRC >> 8) % 256); + bytes[i++] = (byte)((CRC >> 16) % 256); + bytes[i++] = (byte)((CRC >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += "ID: " + ID.ToString() + "\n"; - output += "UpdateFlags: " + UpdateFlags.ToString() + "\n"; - output += "CRC: " + CRC.ToString() + "\n"; + { + string output = "-- ObjectData --\n"; + output += "ID: " + ID.ToString() + "\n"; + output += "UpdateFlags: " + UpdateFlags.ToString() + "\n"; + output += "CRC: " + CRC.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// RegionData block + + /// RegionData block public class RegionDataBlock - { - /// TimeDilation field - public ushort TimeDilation; - /// RegionHandle field - public ulong RegionHandle; - - /// Length of this block serialized in bytes + { + /// TimeDilation field + public ushort TimeDilation; + /// RegionHandle field + public ulong RegionHandle; + + /// Length of this block serialized in bytes public int Length { get - { - return 10; + { + return 10; } } - - /// Default constructor - public RegionDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public RegionDataBlock() { } + /// Constructor for building the block from a byte array public RegionDataBlock(byte[] bytes, ref int i) - { + { try - { - TimeDilation = (ushort)(bytes[i++] + (bytes[i++] << 8)); - RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + { + TimeDilation = (ushort)(bytes[i++] + (bytes[i++] << 8)); + RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(TimeDilation % 256); - bytes[i++] = (byte)((TimeDilation >> 8) % 256); - bytes[i++] = (byte)(RegionHandle % 256); - bytes[i++] = (byte)((RegionHandle >> 8) % 256); - bytes[i++] = (byte)((RegionHandle >> 16) % 256); - bytes[i++] = (byte)((RegionHandle >> 24) % 256); - bytes[i++] = (byte)((RegionHandle >> 32) % 256); - bytes[i++] = (byte)((RegionHandle >> 40) % 256); - bytes[i++] = (byte)((RegionHandle >> 48) % 256); - bytes[i++] = (byte)((RegionHandle >> 56) % 256); + { + bytes[i++] = (byte)(TimeDilation % 256); + bytes[i++] = (byte)((TimeDilation >> 8) % 256); + bytes[i++] = (byte)(RegionHandle % 256); + bytes[i++] = (byte)((RegionHandle >> 8) % 256); + bytes[i++] = (byte)((RegionHandle >> 16) % 256); + bytes[i++] = (byte)((RegionHandle >> 24) % 256); + bytes[i++] = (byte)((RegionHandle >> 32) % 256); + bytes[i++] = (byte)((RegionHandle >> 40) % 256); + bytes[i++] = (byte)((RegionHandle >> 48) % 256); + bytes[i++] = (byte)((RegionHandle >> 56) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- RegionData --\n"; - output += "TimeDilation: " + TimeDilation.ToString() + "\n"; - output += "RegionHandle: " + RegionHandle.ToString() + "\n"; + { + string output = "-- RegionData --\n"; + output += "TimeDilation: " + TimeDilation.ToString() + "\n"; + output += "RegionHandle: " + RegionHandle.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ObjectUpdateCached - public override PacketType Type { get { return PacketType.ObjectUpdateCached; } } - /// ObjectData block - public ObjectDataBlock[] ObjectData; - /// RegionData block - public RegionDataBlock RegionData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ObjectUpdateCached + public override PacketType Type { get { return PacketType.ObjectUpdateCached; } } + /// ObjectData block + public ObjectDataBlock[] ObjectData; + /// RegionData block + public RegionDataBlock RegionData; + + /// Default constructor public ObjectUpdateCachedPacket() - { - Header = new HighHeader(); - Header.ID = 15; - Header.Reliable = true; - ObjectData = new ObjectDataBlock[0]; - RegionData = new RegionDataBlock(); + { + Header = new HighHeader(); + Header.ID = 15; + Header.Reliable = true; + ObjectData = new ObjectDataBlock[0]; + RegionData = new RegionDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ObjectUpdateCachedPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new HighHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - RegionData = new RegionDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new HighHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + RegionData = new RegionDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ObjectUpdateCachedPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - RegionData = new RegionDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + RegionData = new RegionDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 5; - length += RegionData.Length;; - length++; - for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ObjectData.Length; - for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } - RegionData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 5; + length += RegionData.Length;; + length++; + for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ObjectData.Length; + for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } + RegionData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ObjectUpdateCached ---\n"; + { + string output = "--- ObjectUpdateCached ---\n"; for (int j = 0; j < ObjectData.Length; j++) - { + { output += ObjectData[j].ToString() + "\n"; - } - output += RegionData.ToString() + "\n"; + } + output += RegionData.ToString() + "\n"; return output; } - + } - - /// ImprovedTerseObjectUpdate packet + + /// ImprovedTerseObjectUpdate packet public class ImprovedTerseObjectUpdatePacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - private byte[] _data; - /// Data field + { + private byte[] _data; + /// Data field public byte[] Data - { - get { return _data; } + { + get { return _data; } set - { - if (value == null) { _data = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _data = new byte[value.Length]; Array.Copy(value, _data, value.Length); } + { + if (value == null) { _data = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _data = new byte[value.Length]; Array.Copy(value, _data, value.Length); } } - } - private byte[] _textureentry; - /// TextureEntry field + } + private byte[] _textureentry; + /// TextureEntry field public byte[] TextureEntry - { - get { return _textureentry; } + { + get { return _textureentry; } set - { - if (value == null) { _textureentry = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _textureentry = new byte[value.Length]; Array.Copy(value, _textureentry, value.Length); } + { + if (value == null) { _textureentry = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _textureentry = new byte[value.Length]; Array.Copy(value, _textureentry, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 0; - if (Data != null) { length += 1 + Data.Length; } - if (TextureEntry != null) { length += 2 + TextureEntry.Length; } - return length; + { + int length = 0; + if (Data != null) { length += 1 + Data.Length; } + if (TextureEntry != null) { length += 2 + TextureEntry.Length; } + return length; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)bytes[i++]; - _data = new byte[length]; - Array.Copy(bytes, i, _data, 0, length); i += length; - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _textureentry = new byte[length]; - Array.Copy(bytes, i, _textureentry, 0, length); i += length; + { + length = (ushort)bytes[i++]; + _data = new byte[length]; + Array.Copy(bytes, i, _data, 0, length); i += length; + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _textureentry = new byte[length]; + Array.Copy(bytes, i, _textureentry, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(Data == null) { Console.WriteLine("Warning: Data is null, in " + this.GetType()); } - bytes[i++] = (byte)Data.Length; - Array.Copy(Data, 0, bytes, i, Data.Length); i += Data.Length; - if(TextureEntry == null) { Console.WriteLine("Warning: TextureEntry is null, in " + this.GetType()); } - bytes[i++] = (byte)(TextureEntry.Length % 256); - bytes[i++] = (byte)((TextureEntry.Length >> 8) % 256); - Array.Copy(TextureEntry, 0, bytes, i, TextureEntry.Length); i += TextureEntry.Length; + { + if(Data == null) { Console.WriteLine("Warning: Data is null, in " + this.GetType()); } + bytes[i++] = (byte)Data.Length; + Array.Copy(Data, 0, bytes, i, Data.Length); i += Data.Length; + if(TextureEntry == null) { Console.WriteLine("Warning: TextureEntry is null, in " + this.GetType()); } + bytes[i++] = (byte)(TextureEntry.Length % 256); + bytes[i++] = (byte)((TextureEntry.Length >> 8) % 256); + Array.Copy(TextureEntry, 0, bytes, i, TextureEntry.Length); i += TextureEntry.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += Helpers.FieldToString(Data, "Data") + "\n"; - output += Helpers.FieldToString(TextureEntry, "TextureEntry") + "\n"; + { + string output = "-- ObjectData --\n"; + output += Helpers.FieldToString(Data, "Data") + "\n"; + output += Helpers.FieldToString(TextureEntry, "TextureEntry") + "\n"; output = output.Trim(); return output; - } + } } - - /// RegionData block + + /// RegionData block public class RegionDataBlock - { - /// TimeDilation field - public ushort TimeDilation; - /// RegionHandle field - public ulong RegionHandle; - - /// Length of this block serialized in bytes + { + /// TimeDilation field + public ushort TimeDilation; + /// RegionHandle field + public ulong RegionHandle; + + /// Length of this block serialized in bytes public int Length { get - { - return 10; + { + return 10; } } - - /// Default constructor - public RegionDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public RegionDataBlock() { } + /// Constructor for building the block from a byte array public RegionDataBlock(byte[] bytes, ref int i) - { + { try - { - TimeDilation = (ushort)(bytes[i++] + (bytes[i++] << 8)); - RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + { + TimeDilation = (ushort)(bytes[i++] + (bytes[i++] << 8)); + RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(TimeDilation % 256); - bytes[i++] = (byte)((TimeDilation >> 8) % 256); - bytes[i++] = (byte)(RegionHandle % 256); - bytes[i++] = (byte)((RegionHandle >> 8) % 256); - bytes[i++] = (byte)((RegionHandle >> 16) % 256); - bytes[i++] = (byte)((RegionHandle >> 24) % 256); - bytes[i++] = (byte)((RegionHandle >> 32) % 256); - bytes[i++] = (byte)((RegionHandle >> 40) % 256); - bytes[i++] = (byte)((RegionHandle >> 48) % 256); - bytes[i++] = (byte)((RegionHandle >> 56) % 256); + { + bytes[i++] = (byte)(TimeDilation % 256); + bytes[i++] = (byte)((TimeDilation >> 8) % 256); + bytes[i++] = (byte)(RegionHandle % 256); + bytes[i++] = (byte)((RegionHandle >> 8) % 256); + bytes[i++] = (byte)((RegionHandle >> 16) % 256); + bytes[i++] = (byte)((RegionHandle >> 24) % 256); + bytes[i++] = (byte)((RegionHandle >> 32) % 256); + bytes[i++] = (byte)((RegionHandle >> 40) % 256); + bytes[i++] = (byte)((RegionHandle >> 48) % 256); + bytes[i++] = (byte)((RegionHandle >> 56) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- RegionData --\n"; - output += "TimeDilation: " + TimeDilation.ToString() + "\n"; - output += "RegionHandle: " + RegionHandle.ToString() + "\n"; + { + string output = "-- RegionData --\n"; + output += "TimeDilation: " + TimeDilation.ToString() + "\n"; + output += "RegionHandle: " + RegionHandle.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ImprovedTerseObjectUpdate - public override PacketType Type { get { return PacketType.ImprovedTerseObjectUpdate; } } - /// ObjectData block - public ObjectDataBlock[] ObjectData; - /// RegionData block - public RegionDataBlock RegionData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ImprovedTerseObjectUpdate + public override PacketType Type { get { return PacketType.ImprovedTerseObjectUpdate; } } + /// ObjectData block + public ObjectDataBlock[] ObjectData; + /// RegionData block + public RegionDataBlock RegionData; + + /// Default constructor public ImprovedTerseObjectUpdatePacket() - { - Header = new HighHeader(); - Header.ID = 16; - Header.Reliable = true; - ObjectData = new ObjectDataBlock[0]; - RegionData = new RegionDataBlock(); + { + Header = new HighHeader(); + Header.ID = 16; + Header.Reliable = true; + ObjectData = new ObjectDataBlock[0]; + RegionData = new RegionDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ImprovedTerseObjectUpdatePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new HighHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - RegionData = new RegionDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new HighHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + RegionData = new RegionDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ImprovedTerseObjectUpdatePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } - RegionData = new RegionDataBlock(bytes, ref i); + { + Header = head; + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + RegionData = new RegionDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 5; - length += RegionData.Length;; - length++; - for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ObjectData.Length; - for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } - RegionData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 5; + length += RegionData.Length;; + length++; + for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ObjectData.Length; + for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } + RegionData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ImprovedTerseObjectUpdate ---\n"; + { + string output = "--- ImprovedTerseObjectUpdate ---\n"; for (int j = 0; j < ObjectData.Length; j++) - { + { output += ObjectData[j].ToString() + "\n"; - } - output += RegionData.ToString() + "\n"; + } + output += RegionData.ToString() + "\n"; return output; } - + } - - /// KillObject packet + + /// KillObject packet public class KillObjectPacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - /// ID field - public uint ID; - - /// Length of this block serialized in bytes + { + /// ID field + public uint ID; + + /// Length of this block serialized in bytes public int Length { get - { - return 4; + { + return 4; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { + { try - { - ID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + ID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(ID % 256); - bytes[i++] = (byte)((ID >> 8) % 256); - bytes[i++] = (byte)((ID >> 16) % 256); - bytes[i++] = (byte)((ID >> 24) % 256); + { + bytes[i++] = (byte)(ID % 256); + bytes[i++] = (byte)((ID >> 8) % 256); + bytes[i++] = (byte)((ID >> 16) % 256); + bytes[i++] = (byte)((ID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += "ID: " + ID.ToString() + "\n"; + { + string output = "-- ObjectData --\n"; + output += "ID: " + ID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.KillObject - public override PacketType Type { get { return PacketType.KillObject; } } - /// ObjectData block - public ObjectDataBlock[] ObjectData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.KillObject + public override PacketType Type { get { return PacketType.KillObject; } } + /// ObjectData block + public ObjectDataBlock[] ObjectData; + + /// Default constructor public KillObjectPacket() - { - Header = new HighHeader(); - Header.ID = 17; - Header.Reliable = true; - ObjectData = new ObjectDataBlock[0]; + { + Header = new HighHeader(); + Header.ID = 17; + Header.Reliable = true; + ObjectData = new ObjectDataBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public KillObjectPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new HighHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new HighHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public KillObjectPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - ObjectData = new ObjectDataBlock[count]; - for (int j = 0; j < count; j++) - { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } + { + Header = head; + int count = (int)bytes[i++]; + ObjectData = new ObjectDataBlock[count]; + for (int j = 0; j < count; j++) + { ObjectData[j] = new ObjectDataBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 5; -; - length++; - for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)ObjectData.Length; - for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 5; +; + length++; + for (int j = 0; j < ObjectData.Length; j++) { length += ObjectData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)ObjectData.Length; + for (int j = 0; j < ObjectData.Length; j++) { ObjectData[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- KillObject ---\n"; + { + string output = "--- KillObject ---\n"; for (int j = 0; j < ObjectData.Length; j++) - { + { output += ObjectData[j].ToString() + "\n"; - } + } return output; } - + } - - /// AgentToNewRegion packet + + /// AgentToNewRegion packet public class AgentToNewRegionPacket : Packet - { - /// RegionData block + { + /// RegionData block public class RegionDataBlock - { - /// IP field - public uint IP; - /// SessionID field - public LLUUID SessionID; - /// Port field - public ushort Port; - /// Handle field - public ulong Handle; - - /// Length of this block serialized in bytes + { + /// IP field + public uint IP; + /// SessionID field + public LLUUID SessionID; + /// Port field + public ushort Port; + /// Handle field + public ulong Handle; + + /// Length of this block serialized in bytes public int Length { get - { - return 30; + { + return 30; } } - - /// Default constructor - public RegionDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public RegionDataBlock() { } + /// Constructor for building the block from a byte array public RegionDataBlock(byte[] bytes, ref int i) - { + { try - { - IP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - SessionID = new LLUUID(bytes, i); i += 16; - Port = (ushort)((bytes[i++] << 8) + bytes[i++]); - Handle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + { + IP = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + SessionID = new LLUUID(bytes, i); i += 16; + Port = (ushort)((bytes[i++] << 8) + bytes[i++]); + Handle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(IP % 256); - bytes[i++] = (byte)((IP >> 8) % 256); - bytes[i++] = (byte)((IP >> 16) % 256); - bytes[i++] = (byte)((IP >> 24) % 256); - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((Port >> 8) % 256); - bytes[i++] = (byte)(Port % 256); - bytes[i++] = (byte)(Handle % 256); - bytes[i++] = (byte)((Handle >> 8) % 256); - bytes[i++] = (byte)((Handle >> 16) % 256); - bytes[i++] = (byte)((Handle >> 24) % 256); - bytes[i++] = (byte)((Handle >> 32) % 256); - bytes[i++] = (byte)((Handle >> 40) % 256); - bytes[i++] = (byte)((Handle >> 48) % 256); - bytes[i++] = (byte)((Handle >> 56) % 256); + { + bytes[i++] = (byte)(IP % 256); + bytes[i++] = (byte)((IP >> 8) % 256); + bytes[i++] = (byte)((IP >> 16) % 256); + bytes[i++] = (byte)((IP >> 24) % 256); + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((Port >> 8) % 256); + bytes[i++] = (byte)(Port % 256); + bytes[i++] = (byte)(Handle % 256); + bytes[i++] = (byte)((Handle >> 8) % 256); + bytes[i++] = (byte)((Handle >> 16) % 256); + bytes[i++] = (byte)((Handle >> 24) % 256); + bytes[i++] = (byte)((Handle >> 32) % 256); + bytes[i++] = (byte)((Handle >> 40) % 256); + bytes[i++] = (byte)((Handle >> 48) % 256); + bytes[i++] = (byte)((Handle >> 56) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- RegionData --\n"; - output += "IP: " + IP.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "Port: " + Port.ToString() + "\n"; - output += "Handle: " + Handle.ToString() + "\n"; + { + string output = "-- RegionData --\n"; + output += "IP: " + IP.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "Port: " + Port.ToString() + "\n"; + output += "Handle: " + Handle.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AgentToNewRegion - public override PacketType Type { get { return PacketType.AgentToNewRegion; } } - /// RegionData block - public RegionDataBlock RegionData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AgentToNewRegion + public override PacketType Type { get { return PacketType.AgentToNewRegion; } } + /// RegionData block + public RegionDataBlock RegionData; + + /// Default constructor public AgentToNewRegionPacket() - { - Header = new HighHeader(); - Header.ID = 18; - Header.Reliable = true; - RegionData = new RegionDataBlock(); + { + Header = new HighHeader(); + Header.ID = 18; + Header.Reliable = true; + RegionData = new RegionDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AgentToNewRegionPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new HighHeader(bytes, ref i, ref packetEnd); - RegionData = new RegionDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new HighHeader(bytes, ref i, ref packetEnd); + RegionData = new RegionDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AgentToNewRegionPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - RegionData = new RegionDataBlock(bytes, ref i); + { + Header = head; + RegionData = new RegionDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 5; - length += RegionData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - RegionData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 5; + length += RegionData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + RegionData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AgentToNewRegion ---\n"; - output += RegionData.ToString() + "\n"; + { + string output = "--- AgentToNewRegion ---\n"; + output += RegionData.ToString() + "\n"; return output; } - + } - - /// TransferPacket packet + + /// TransferPacket packet public class TransferPacketPacket : Packet - { - /// TransferData block + { + /// TransferData block public class TransferDataBlock - { - /// TransferID field - public LLUUID TransferID; - private byte[] _data; - /// Data field + { + /// TransferID field + public LLUUID TransferID; + private byte[] _data; + /// Data field public byte[] Data - { - get { return _data; } + { + get { return _data; } set - { - if (value == null) { _data = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _data = new byte[value.Length]; Array.Copy(value, _data, value.Length); } + { + if (value == null) { _data = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _data = new byte[value.Length]; Array.Copy(value, _data, value.Length); } } - } - /// Packet field - public int Packet; - /// ChannelType field - public int ChannelType; - /// Status field - public int Status; - - /// Length of this block serialized in bytes + } + /// Packet field + public int Packet; + /// ChannelType field + public int ChannelType; + /// Status field + public int Status; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 28; - if (Data != null) { length += 2 + Data.Length; } - return length; + { + int length = 28; + if (Data != null) { length += 2 + Data.Length; } + return length; } } - - /// Default constructor - public TransferDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public TransferDataBlock() { } + /// Constructor for building the block from a byte array public TransferDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - TransferID = new LLUUID(bytes, i); i += 16; - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _data = new byte[length]; - Array.Copy(bytes, i, _data, 0, length); i += length; - Packet = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - ChannelType = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Status = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + TransferID = new LLUUID(bytes, i); i += 16; + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _data = new byte[length]; + Array.Copy(bytes, i, _data, 0, length); i += length; + Packet = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + ChannelType = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Status = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(TransferID == null) { Console.WriteLine("Warning: TransferID is null, in " + this.GetType()); } - Array.Copy(TransferID.GetBytes(), 0, bytes, i, 16); i += 16; - if(Data == null) { Console.WriteLine("Warning: Data is null, in " + this.GetType()); } - bytes[i++] = (byte)(Data.Length % 256); - bytes[i++] = (byte)((Data.Length >> 8) % 256); - Array.Copy(Data, 0, bytes, i, Data.Length); i += Data.Length; - bytes[i++] = (byte)(Packet % 256); - bytes[i++] = (byte)((Packet >> 8) % 256); - bytes[i++] = (byte)((Packet >> 16) % 256); - bytes[i++] = (byte)((Packet >> 24) % 256); - bytes[i++] = (byte)(ChannelType % 256); - bytes[i++] = (byte)((ChannelType >> 8) % 256); - bytes[i++] = (byte)((ChannelType >> 16) % 256); - bytes[i++] = (byte)((ChannelType >> 24) % 256); - bytes[i++] = (byte)(Status % 256); - bytes[i++] = (byte)((Status >> 8) % 256); - bytes[i++] = (byte)((Status >> 16) % 256); - bytes[i++] = (byte)((Status >> 24) % 256); + { + if(TransferID == null) { Console.WriteLine("Warning: TransferID is null, in " + this.GetType()); } + Array.Copy(TransferID.GetBytes(), 0, bytes, i, 16); i += 16; + if(Data == null) { Console.WriteLine("Warning: Data is null, in " + this.GetType()); } + bytes[i++] = (byte)(Data.Length % 256); + bytes[i++] = (byte)((Data.Length >> 8) % 256); + Array.Copy(Data, 0, bytes, i, Data.Length); i += Data.Length; + bytes[i++] = (byte)(Packet % 256); + bytes[i++] = (byte)((Packet >> 8) % 256); + bytes[i++] = (byte)((Packet >> 16) % 256); + bytes[i++] = (byte)((Packet >> 24) % 256); + bytes[i++] = (byte)(ChannelType % 256); + bytes[i++] = (byte)((ChannelType >> 8) % 256); + bytes[i++] = (byte)((ChannelType >> 16) % 256); + bytes[i++] = (byte)((ChannelType >> 24) % 256); + bytes[i++] = (byte)(Status % 256); + bytes[i++] = (byte)((Status >> 8) % 256); + bytes[i++] = (byte)((Status >> 16) % 256); + bytes[i++] = (byte)((Status >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- TransferData --\n"; - output += "TransferID: " + TransferID.ToString() + "\n"; - output += Helpers.FieldToString(Data, "Data") + "\n"; - output += "Packet: " + Packet.ToString() + "\n"; - output += "ChannelType: " + ChannelType.ToString() + "\n"; - output += "Status: " + Status.ToString() + "\n"; + { + string output = "-- TransferData --\n"; + output += "TransferID: " + TransferID.ToString() + "\n"; + output += Helpers.FieldToString(Data, "Data") + "\n"; + output += "Packet: " + Packet.ToString() + "\n"; + output += "ChannelType: " + ChannelType.ToString() + "\n"; + output += "Status: " + Status.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.TransferPacket - public override PacketType Type { get { return PacketType.TransferPacket; } } - /// TransferData block - public TransferDataBlock TransferData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.TransferPacket + public override PacketType Type { get { return PacketType.TransferPacket; } } + /// TransferData block + public TransferDataBlock TransferData; + + /// Default constructor public TransferPacketPacket() - { - Header = new HighHeader(); - Header.ID = 19; - Header.Reliable = true; - TransferData = new TransferDataBlock(); + { + Header = new HighHeader(); + Header.ID = 19; + Header.Reliable = true; + TransferData = new TransferDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public TransferPacketPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new HighHeader(bytes, ref i, ref packetEnd); - TransferData = new TransferDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new HighHeader(bytes, ref i, ref packetEnd); + TransferData = new TransferDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public TransferPacketPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - TransferData = new TransferDataBlock(bytes, ref i); + { + Header = head; + TransferData = new TransferDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 5; - length += TransferData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - TransferData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 5; + length += TransferData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + TransferData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- TransferPacket ---\n"; - output += TransferData.ToString() + "\n"; + { + string output = "--- TransferPacket ---\n"; + output += TransferData.ToString() + "\n"; return output; } - + } - - /// SendXferPacket packet + + /// SendXferPacket packet public class SendXferPacketPacket : Packet - { - /// DataPacket block + { + /// DataPacket block public class DataPacketBlock - { - private byte[] _data; - /// Data field + { + private byte[] _data; + /// Data field public byte[] Data - { - get { return _data; } + { + get { return _data; } set - { - if (value == null) { _data = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _data = new byte[value.Length]; Array.Copy(value, _data, value.Length); } + { + if (value == null) { _data = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _data = new byte[value.Length]; Array.Copy(value, _data, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 0; - if (Data != null) { length += 2 + Data.Length; } - return length; + { + int length = 0; + if (Data != null) { length += 2 + Data.Length; } + return length; } } - - /// Default constructor - public DataPacketBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public DataPacketBlock() { } + /// Constructor for building the block from a byte array public DataPacketBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _data = new byte[length]; - Array.Copy(bytes, i, _data, 0, length); i += length; + { + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _data = new byte[length]; + Array.Copy(bytes, i, _data, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(Data == null) { Console.WriteLine("Warning: Data is null, in " + this.GetType()); } - bytes[i++] = (byte)(Data.Length % 256); - bytes[i++] = (byte)((Data.Length >> 8) % 256); - Array.Copy(Data, 0, bytes, i, Data.Length); i += Data.Length; + { + if(Data == null) { Console.WriteLine("Warning: Data is null, in " + this.GetType()); } + bytes[i++] = (byte)(Data.Length % 256); + bytes[i++] = (byte)((Data.Length >> 8) % 256); + Array.Copy(Data, 0, bytes, i, Data.Length); i += Data.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- DataPacket --\n"; - output += Helpers.FieldToString(Data, "Data") + "\n"; + { + string output = "-- DataPacket --\n"; + output += Helpers.FieldToString(Data, "Data") + "\n"; output = output.Trim(); return output; - } + } } - - /// XferID block + + /// XferID block public class XferIDBlock - { - /// ID field - public ulong ID; - /// Packet field - public uint Packet; - - /// Length of this block serialized in bytes + { + /// ID field + public ulong ID; + /// Packet field + public uint Packet; + + /// Length of this block serialized in bytes public int Length { get - { - return 12; + { + return 12; } } - - /// Default constructor - public XferIDBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public XferIDBlock() { } + /// Constructor for building the block from a byte array public XferIDBlock(byte[] bytes, ref int i) - { + { try - { - ID = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); - Packet = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + ID = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + Packet = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(ID % 256); - bytes[i++] = (byte)((ID >> 8) % 256); - bytes[i++] = (byte)((ID >> 16) % 256); - bytes[i++] = (byte)((ID >> 24) % 256); - bytes[i++] = (byte)((ID >> 32) % 256); - bytes[i++] = (byte)((ID >> 40) % 256); - bytes[i++] = (byte)((ID >> 48) % 256); - bytes[i++] = (byte)((ID >> 56) % 256); - bytes[i++] = (byte)(Packet % 256); - bytes[i++] = (byte)((Packet >> 8) % 256); - bytes[i++] = (byte)((Packet >> 16) % 256); - bytes[i++] = (byte)((Packet >> 24) % 256); + { + bytes[i++] = (byte)(ID % 256); + bytes[i++] = (byte)((ID >> 8) % 256); + bytes[i++] = (byte)((ID >> 16) % 256); + bytes[i++] = (byte)((ID >> 24) % 256); + bytes[i++] = (byte)((ID >> 32) % 256); + bytes[i++] = (byte)((ID >> 40) % 256); + bytes[i++] = (byte)((ID >> 48) % 256); + bytes[i++] = (byte)((ID >> 56) % 256); + bytes[i++] = (byte)(Packet % 256); + bytes[i++] = (byte)((Packet >> 8) % 256); + bytes[i++] = (byte)((Packet >> 16) % 256); + bytes[i++] = (byte)((Packet >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- XferID --\n"; - output += "ID: " + ID.ToString() + "\n"; - output += "Packet: " + Packet.ToString() + "\n"; + { + string output = "-- XferID --\n"; + output += "ID: " + ID.ToString() + "\n"; + output += "Packet: " + Packet.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.SendXferPacket - public override PacketType Type { get { return PacketType.SendXferPacket; } } - /// DataPacket block - public DataPacketBlock DataPacket; - /// XferID block - public XferIDBlock XferID; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.SendXferPacket + public override PacketType Type { get { return PacketType.SendXferPacket; } } + /// DataPacket block + public DataPacketBlock DataPacket; + /// XferID block + public XferIDBlock XferID; + + /// Default constructor public SendXferPacketPacket() - { - Header = new HighHeader(); - Header.ID = 20; - Header.Reliable = true; - DataPacket = new DataPacketBlock(); - XferID = new XferIDBlock(); + { + Header = new HighHeader(); + Header.ID = 20; + Header.Reliable = true; + DataPacket = new DataPacketBlock(); + XferID = new XferIDBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public SendXferPacketPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new HighHeader(bytes, ref i, ref packetEnd); - DataPacket = new DataPacketBlock(bytes, ref i); - XferID = new XferIDBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new HighHeader(bytes, ref i, ref packetEnd); + DataPacket = new DataPacketBlock(bytes, ref i); + XferID = new XferIDBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public SendXferPacketPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - DataPacket = new DataPacketBlock(bytes, ref i); - XferID = new XferIDBlock(bytes, ref i); + { + Header = head; + DataPacket = new DataPacketBlock(bytes, ref i); + XferID = new XferIDBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 5; - length += DataPacket.Length; length += XferID.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - DataPacket.ToBytes(bytes, ref i); - XferID.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 5; + length += DataPacket.Length; length += XferID.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + DataPacket.ToBytes(bytes, ref i); + XferID.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- SendXferPacket ---\n"; - output += DataPacket.ToString() + "\n"; - output += XferID.ToString() + "\n"; + { + string output = "--- SendXferPacket ---\n"; + output += DataPacket.ToString() + "\n"; + output += XferID.ToString() + "\n"; return output; } - + } - - /// ConfirmXferPacket packet + + /// ConfirmXferPacket packet public class ConfirmXferPacketPacket : Packet - { - /// XferID block + { + /// XferID block public class XferIDBlock - { - /// ID field - public ulong ID; - /// Packet field - public uint Packet; - - /// Length of this block serialized in bytes + { + /// ID field + public ulong ID; + /// Packet field + public uint Packet; + + /// Length of this block serialized in bytes public int Length { get - { - return 12; + { + return 12; } } - - /// Default constructor - public XferIDBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public XferIDBlock() { } + /// Constructor for building the block from a byte array public XferIDBlock(byte[] bytes, ref int i) - { + { try - { - ID = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); - Packet = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + ID = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + Packet = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(ID % 256); - bytes[i++] = (byte)((ID >> 8) % 256); - bytes[i++] = (byte)((ID >> 16) % 256); - bytes[i++] = (byte)((ID >> 24) % 256); - bytes[i++] = (byte)((ID >> 32) % 256); - bytes[i++] = (byte)((ID >> 40) % 256); - bytes[i++] = (byte)((ID >> 48) % 256); - bytes[i++] = (byte)((ID >> 56) % 256); - bytes[i++] = (byte)(Packet % 256); - bytes[i++] = (byte)((Packet >> 8) % 256); - bytes[i++] = (byte)((Packet >> 16) % 256); - bytes[i++] = (byte)((Packet >> 24) % 256); + { + bytes[i++] = (byte)(ID % 256); + bytes[i++] = (byte)((ID >> 8) % 256); + bytes[i++] = (byte)((ID >> 16) % 256); + bytes[i++] = (byte)((ID >> 24) % 256); + bytes[i++] = (byte)((ID >> 32) % 256); + bytes[i++] = (byte)((ID >> 40) % 256); + bytes[i++] = (byte)((ID >> 48) % 256); + bytes[i++] = (byte)((ID >> 56) % 256); + bytes[i++] = (byte)(Packet % 256); + bytes[i++] = (byte)((Packet >> 8) % 256); + bytes[i++] = (byte)((Packet >> 16) % 256); + bytes[i++] = (byte)((Packet >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- XferID --\n"; - output += "ID: " + ID.ToString() + "\n"; - output += "Packet: " + Packet.ToString() + "\n"; + { + string output = "-- XferID --\n"; + output += "ID: " + ID.ToString() + "\n"; + output += "Packet: " + Packet.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ConfirmXferPacket - public override PacketType Type { get { return PacketType.ConfirmXferPacket; } } - /// XferID block - public XferIDBlock XferID; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ConfirmXferPacket + public override PacketType Type { get { return PacketType.ConfirmXferPacket; } } + /// XferID block + public XferIDBlock XferID; + + /// Default constructor public ConfirmXferPacketPacket() - { - Header = new HighHeader(); - Header.ID = 21; - Header.Reliable = true; - XferID = new XferIDBlock(); + { + Header = new HighHeader(); + Header.ID = 21; + Header.Reliable = true; + XferID = new XferIDBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ConfirmXferPacketPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new HighHeader(bytes, ref i, ref packetEnd); - XferID = new XferIDBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new HighHeader(bytes, ref i, ref packetEnd); + XferID = new XferIDBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ConfirmXferPacketPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - XferID = new XferIDBlock(bytes, ref i); + { + Header = head; + XferID = new XferIDBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 5; - length += XferID.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - XferID.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 5; + length += XferID.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + XferID.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ConfirmXferPacket ---\n"; - output += XferID.ToString() + "\n"; + { + string output = "--- ConfirmXferPacket ---\n"; + output += XferID.ToString() + "\n"; return output; } - + } - - /// AvatarAnimation packet + + /// AvatarAnimation packet public class AvatarAnimationPacket : Packet - { - /// AnimationSourceList block + { + /// AnimationSourceList block public class AnimationSourceListBlock - { - /// ObjectID field - public LLUUID ObjectID; - - /// Length of this block serialized in bytes + { + /// ObjectID field + public LLUUID ObjectID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public AnimationSourceListBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AnimationSourceListBlock() { } + /// Constructor for building the block from a byte array public AnimationSourceListBlock(byte[] bytes, ref int i) - { + { try - { - ObjectID = new LLUUID(bytes, i); i += 16; + { + ObjectID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } - Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } + Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AnimationSourceList --\n"; - output += "ObjectID: " + ObjectID.ToString() + "\n"; + { + string output = "-- AnimationSourceList --\n"; + output += "ObjectID: " + ObjectID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// Sender block + + /// Sender block public class SenderBlock - { - /// ID field - public LLUUID ID; - - /// Length of this block serialized in bytes + { + /// ID field + public LLUUID ID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public SenderBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public SenderBlock() { } + /// Constructor for building the block from a byte array public SenderBlock(byte[] bytes, ref int i) - { + { try - { - ID = new LLUUID(bytes, i); i += 16; + { + ID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } - Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } + Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- Sender --\n"; - output += "ID: " + ID.ToString() + "\n"; + { + string output = "-- Sender --\n"; + output += "ID: " + ID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AnimationList block + + /// AnimationList block public class AnimationListBlock - { - /// AnimID field - public LLUUID AnimID; - /// AnimSequenceID field - public int AnimSequenceID; - - /// Length of this block serialized in bytes + { + /// AnimID field + public LLUUID AnimID; + /// AnimSequenceID field + public int AnimSequenceID; + + /// Length of this block serialized in bytes public int Length { get - { - return 20; + { + return 20; } } - - /// Default constructor - public AnimationListBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AnimationListBlock() { } + /// Constructor for building the block from a byte array public AnimationListBlock(byte[] bytes, ref int i) - { + { try - { - AnimID = new LLUUID(bytes, i); i += 16; - AnimSequenceID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + AnimID = new LLUUID(bytes, i); i += 16; + AnimSequenceID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(AnimID == null) { Console.WriteLine("Warning: AnimID is null, in " + this.GetType()); } - Array.Copy(AnimID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(AnimSequenceID % 256); - bytes[i++] = (byte)((AnimSequenceID >> 8) % 256); - bytes[i++] = (byte)((AnimSequenceID >> 16) % 256); - bytes[i++] = (byte)((AnimSequenceID >> 24) % 256); + { + if(AnimID == null) { Console.WriteLine("Warning: AnimID is null, in " + this.GetType()); } + Array.Copy(AnimID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(AnimSequenceID % 256); + bytes[i++] = (byte)((AnimSequenceID >> 8) % 256); + bytes[i++] = (byte)((AnimSequenceID >> 16) % 256); + bytes[i++] = (byte)((AnimSequenceID >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AnimationList --\n"; - output += "AnimID: " + AnimID.ToString() + "\n"; - output += "AnimSequenceID: " + AnimSequenceID.ToString() + "\n"; + { + string output = "-- AnimationList --\n"; + output += "AnimID: " + AnimID.ToString() + "\n"; + output += "AnimSequenceID: " + AnimSequenceID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AvatarAnimation - public override PacketType Type { get { return PacketType.AvatarAnimation; } } - /// AnimationSourceList block - public AnimationSourceListBlock[] AnimationSourceList; - /// Sender block - public SenderBlock Sender; - /// AnimationList block - public AnimationListBlock[] AnimationList; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AvatarAnimation + public override PacketType Type { get { return PacketType.AvatarAnimation; } } + /// AnimationSourceList block + public AnimationSourceListBlock[] AnimationSourceList; + /// Sender block + public SenderBlock Sender; + /// AnimationList block + public AnimationListBlock[] AnimationList; + + /// Default constructor public AvatarAnimationPacket() - { - Header = new HighHeader(); - Header.ID = 22; - Header.Reliable = true; - AnimationSourceList = new AnimationSourceListBlock[0]; - Sender = new SenderBlock(); - AnimationList = new AnimationListBlock[0]; + { + Header = new HighHeader(); + Header.ID = 22; + Header.Reliable = true; + AnimationSourceList = new AnimationSourceListBlock[0]; + Sender = new SenderBlock(); + AnimationList = new AnimationListBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AvatarAnimationPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new HighHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - AnimationSourceList = new AnimationSourceListBlock[count]; - for (int j = 0; j < count; j++) - { AnimationSourceList[j] = new AnimationSourceListBlock(bytes, ref i); } - Sender = new SenderBlock(bytes, ref i); - count = (int)bytes[i++]; - AnimationList = new AnimationListBlock[count]; - for (int j = 0; j < count; j++) - { AnimationList[j] = new AnimationListBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new HighHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + AnimationSourceList = new AnimationSourceListBlock[count]; + for (int j = 0; j < count; j++) + { AnimationSourceList[j] = new AnimationSourceListBlock(bytes, ref i); } + Sender = new SenderBlock(bytes, ref i); + count = (int)bytes[i++]; + AnimationList = new AnimationListBlock[count]; + for (int j = 0; j < count; j++) + { AnimationList[j] = new AnimationListBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AvatarAnimationPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - AnimationSourceList = new AnimationSourceListBlock[count]; - for (int j = 0; j < count; j++) - { AnimationSourceList[j] = new AnimationSourceListBlock(bytes, ref i); } - Sender = new SenderBlock(bytes, ref i); - count = (int)bytes[i++]; - AnimationList = new AnimationListBlock[count]; - for (int j = 0; j < count; j++) - { AnimationList[j] = new AnimationListBlock(bytes, ref i); } + { + Header = head; + int count = (int)bytes[i++]; + AnimationSourceList = new AnimationSourceListBlock[count]; + for (int j = 0; j < count; j++) + { AnimationSourceList[j] = new AnimationSourceListBlock(bytes, ref i); } + Sender = new SenderBlock(bytes, ref i); + count = (int)bytes[i++]; + AnimationList = new AnimationListBlock[count]; + for (int j = 0; j < count; j++) + { AnimationList[j] = new AnimationListBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 5; - length += Sender.Length;; - length++; - for (int j = 0; j < AnimationSourceList.Length; j++) { length += AnimationSourceList[j].Length; } - length++; - for (int j = 0; j < AnimationList.Length; j++) { length += AnimationList[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)AnimationSourceList.Length; - for (int j = 0; j < AnimationSourceList.Length; j++) { AnimationSourceList[j].ToBytes(bytes, ref i); } - Sender.ToBytes(bytes, ref i); - bytes[i++] = (byte)AnimationList.Length; - for (int j = 0; j < AnimationList.Length; j++) { AnimationList[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 5; + length += Sender.Length;; + length++; + for (int j = 0; j < AnimationSourceList.Length; j++) { length += AnimationSourceList[j].Length; } + length++; + for (int j = 0; j < AnimationList.Length; j++) { length += AnimationList[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)AnimationSourceList.Length; + for (int j = 0; j < AnimationSourceList.Length; j++) { AnimationSourceList[j].ToBytes(bytes, ref i); } + Sender.ToBytes(bytes, ref i); + bytes[i++] = (byte)AnimationList.Length; + for (int j = 0; j < AnimationList.Length; j++) { AnimationList[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AvatarAnimation ---\n"; + { + string output = "--- AvatarAnimation ---\n"; for (int j = 0; j < AnimationSourceList.Length; j++) - { + { output += AnimationSourceList[j].ToString() + "\n"; - } - output += Sender.ToString() + "\n"; + } + output += Sender.ToString() + "\n"; for (int j = 0; j < AnimationList.Length; j++) - { + { output += AnimationList[j].ToString() + "\n"; - } + } return output; } - + } - - /// AvatarSitResponse packet + + /// AvatarSitResponse packet public class AvatarSitResponsePacket : Packet - { - /// SitTransform block + { + /// SitTransform block public class SitTransformBlock - { - /// AutoPilot field - public bool AutoPilot; - /// ForceMouselook field - public bool ForceMouselook; - /// CameraEyeOffset field - public LLVector3 CameraEyeOffset; - /// CameraAtOffset field - public LLVector3 CameraAtOffset; - /// SitPosition field - public LLVector3 SitPosition; - /// SitRotation field - public LLQuaternion SitRotation; - - /// Length of this block serialized in bytes + { + /// AutoPilot field + public bool AutoPilot; + /// ForceMouselook field + public bool ForceMouselook; + /// CameraEyeOffset field + public LLVector3 CameraEyeOffset; + /// CameraAtOffset field + public LLVector3 CameraAtOffset; + /// SitPosition field + public LLVector3 SitPosition; + /// SitRotation field + public LLQuaternion SitRotation; + + /// Length of this block serialized in bytes public int Length { get - { - return 50; + { + return 50; } } - - /// Default constructor - public SitTransformBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public SitTransformBlock() { } + /// Constructor for building the block from a byte array public SitTransformBlock(byte[] bytes, ref int i) - { + { try - { - AutoPilot = (bytes[i++] != 0) ? (bool)true : (bool)false; - ForceMouselook = (bytes[i++] != 0) ? (bool)true : (bool)false; - CameraEyeOffset = new LLVector3(bytes, i); i += 12; - CameraAtOffset = new LLVector3(bytes, i); i += 12; - SitPosition = new LLVector3(bytes, i); i += 12; - SitRotation = new LLQuaternion(bytes, i, true); i += 12; + { + AutoPilot = (bytes[i++] != 0) ? (bool)true : (bool)false; + ForceMouselook = (bytes[i++] != 0) ? (bool)true : (bool)false; + CameraEyeOffset = new LLVector3(bytes, i); i += 12; + CameraAtOffset = new LLVector3(bytes, i); i += 12; + SitPosition = new LLVector3(bytes, i); i += 12; + SitRotation = new LLQuaternion(bytes, i, true); i += 12; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)((AutoPilot) ? 1 : 0); - bytes[i++] = (byte)((ForceMouselook) ? 1 : 0); - if(CameraEyeOffset == null) { Console.WriteLine("Warning: CameraEyeOffset is null, in " + this.GetType()); } - Array.Copy(CameraEyeOffset.GetBytes(), 0, bytes, i, 12); i += 12; - if(CameraAtOffset == null) { Console.WriteLine("Warning: CameraAtOffset is null, in " + this.GetType()); } - Array.Copy(CameraAtOffset.GetBytes(), 0, bytes, i, 12); i += 12; - if(SitPosition == null) { Console.WriteLine("Warning: SitPosition is null, in " + this.GetType()); } - Array.Copy(SitPosition.GetBytes(), 0, bytes, i, 12); i += 12; - if(SitRotation == null) { Console.WriteLine("Warning: SitRotation is null, in " + this.GetType()); } - Array.Copy(SitRotation.GetBytes(), 0, bytes, i, 12); i += 12; + { + bytes[i++] = (byte)((AutoPilot) ? 1 : 0); + bytes[i++] = (byte)((ForceMouselook) ? 1 : 0); + if(CameraEyeOffset == null) { Console.WriteLine("Warning: CameraEyeOffset is null, in " + this.GetType()); } + Array.Copy(CameraEyeOffset.GetBytes(), 0, bytes, i, 12); i += 12; + if(CameraAtOffset == null) { Console.WriteLine("Warning: CameraAtOffset is null, in " + this.GetType()); } + Array.Copy(CameraAtOffset.GetBytes(), 0, bytes, i, 12); i += 12; + if(SitPosition == null) { Console.WriteLine("Warning: SitPosition is null, in " + this.GetType()); } + Array.Copy(SitPosition.GetBytes(), 0, bytes, i, 12); i += 12; + if(SitRotation == null) { Console.WriteLine("Warning: SitRotation is null, in " + this.GetType()); } + Array.Copy(SitRotation.GetBytes(), 0, bytes, i, 12); i += 12; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- SitTransform --\n"; - output += "AutoPilot: " + AutoPilot.ToString() + "\n"; - output += "ForceMouselook: " + ForceMouselook.ToString() + "\n"; - output += "CameraEyeOffset: " + CameraEyeOffset.ToString() + "\n"; - output += "CameraAtOffset: " + CameraAtOffset.ToString() + "\n"; - output += "SitPosition: " + SitPosition.ToString() + "\n"; - output += "SitRotation: " + SitRotation.ToString() + "\n"; + { + string output = "-- SitTransform --\n"; + output += "AutoPilot: " + AutoPilot.ToString() + "\n"; + output += "ForceMouselook: " + ForceMouselook.ToString() + "\n"; + output += "CameraEyeOffset: " + CameraEyeOffset.ToString() + "\n"; + output += "CameraAtOffset: " + CameraAtOffset.ToString() + "\n"; + output += "SitPosition: " + SitPosition.ToString() + "\n"; + output += "SitRotation: " + SitRotation.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// SitObject block + + /// SitObject block public class SitObjectBlock - { - /// ID field - public LLUUID ID; - - /// Length of this block serialized in bytes + { + /// ID field + public LLUUID ID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public SitObjectBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public SitObjectBlock() { } + /// Constructor for building the block from a byte array public SitObjectBlock(byte[] bytes, ref int i) - { + { try - { - ID = new LLUUID(bytes, i); i += 16; + { + ID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } - Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } + Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- SitObject --\n"; - output += "ID: " + ID.ToString() + "\n"; + { + string output = "-- SitObject --\n"; + output += "ID: " + ID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AvatarSitResponse - public override PacketType Type { get { return PacketType.AvatarSitResponse; } } - /// SitTransform block - public SitTransformBlock SitTransform; - /// SitObject block - public SitObjectBlock SitObject; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AvatarSitResponse + public override PacketType Type { get { return PacketType.AvatarSitResponse; } } + /// SitTransform block + public SitTransformBlock SitTransform; + /// SitObject block + public SitObjectBlock SitObject; + + /// Default constructor public AvatarSitResponsePacket() - { - Header = new HighHeader(); - Header.ID = 23; - Header.Reliable = true; - Header.Zerocoded = true; - SitTransform = new SitTransformBlock(); - SitObject = new SitObjectBlock(); + { + Header = new HighHeader(); + Header.ID = 23; + Header.Reliable = true; + Header.Zerocoded = true; + SitTransform = new SitTransformBlock(); + SitObject = new SitObjectBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AvatarSitResponsePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new HighHeader(bytes, ref i, ref packetEnd); - SitTransform = new SitTransformBlock(bytes, ref i); - SitObject = new SitObjectBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new HighHeader(bytes, ref i, ref packetEnd); + SitTransform = new SitTransformBlock(bytes, ref i); + SitObject = new SitObjectBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AvatarSitResponsePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - SitTransform = new SitTransformBlock(bytes, ref i); - SitObject = new SitObjectBlock(bytes, ref i); + { + Header = head; + SitTransform = new SitTransformBlock(bytes, ref i); + SitObject = new SitObjectBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 5; - length += SitTransform.Length; length += SitObject.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - SitTransform.ToBytes(bytes, ref i); - SitObject.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 5; + length += SitTransform.Length; length += SitObject.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + SitTransform.ToBytes(bytes, ref i); + SitObject.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AvatarSitResponse ---\n"; - output += SitTransform.ToString() + "\n"; - output += SitObject.ToString() + "\n"; + { + string output = "--- AvatarSitResponse ---\n"; + output += SitTransform.ToString() + "\n"; + output += SitObject.ToString() + "\n"; return output; } - + } - - /// CameraConstraint packet + + /// CameraConstraint packet public class CameraConstraintPacket : Packet - { - /// CameraCollidePlane block + { + /// CameraCollidePlane block public class CameraCollidePlaneBlock - { - /// Plane field - public LLVector4 Plane; - - /// Length of this block serialized in bytes + { + /// Plane field + public LLVector4 Plane; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public CameraCollidePlaneBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public CameraCollidePlaneBlock() { } + /// Constructor for building the block from a byte array public CameraCollidePlaneBlock(byte[] bytes, ref int i) - { + { try - { - Plane = new LLVector4(bytes, i); i += 16; + { + Plane = new LLVector4(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(Plane == null) { Console.WriteLine("Warning: Plane is null, in " + this.GetType()); } - Array.Copy(Plane.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(Plane == null) { Console.WriteLine("Warning: Plane is null, in " + this.GetType()); } + Array.Copy(Plane.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- CameraCollidePlane --\n"; - output += "Plane: " + Plane.ToString() + "\n"; + { + string output = "-- CameraCollidePlane --\n"; + output += "Plane: " + Plane.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.CameraConstraint - public override PacketType Type { get { return PacketType.CameraConstraint; } } - /// CameraCollidePlane block - public CameraCollidePlaneBlock CameraCollidePlane; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.CameraConstraint + public override PacketType Type { get { return PacketType.CameraConstraint; } } + /// CameraCollidePlane block + public CameraCollidePlaneBlock CameraCollidePlane; + + /// Default constructor public CameraConstraintPacket() - { - Header = new HighHeader(); - Header.ID = 24; - Header.Reliable = true; - Header.Zerocoded = true; - CameraCollidePlane = new CameraCollidePlaneBlock(); + { + Header = new HighHeader(); + Header.ID = 24; + Header.Reliable = true; + Header.Zerocoded = true; + CameraCollidePlane = new CameraCollidePlaneBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public CameraConstraintPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new HighHeader(bytes, ref i, ref packetEnd); - CameraCollidePlane = new CameraCollidePlaneBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new HighHeader(bytes, ref i, ref packetEnd); + CameraCollidePlane = new CameraCollidePlaneBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public CameraConstraintPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - CameraCollidePlane = new CameraCollidePlaneBlock(bytes, ref i); + { + Header = head; + CameraCollidePlane = new CameraCollidePlaneBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 5; - length += CameraCollidePlane.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - CameraCollidePlane.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 5; + length += CameraCollidePlane.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + CameraCollidePlane.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- CameraConstraint ---\n"; - output += CameraCollidePlane.ToString() + "\n"; + { + string output = "--- CameraConstraint ---\n"; + output += CameraCollidePlane.ToString() + "\n"; return output; } - + } - - /// ParcelProperties packet + + /// ParcelProperties packet public class ParcelPropertiesPacket : Packet - { - /// ParcelData block + { + /// ParcelData block public class ParcelDataBlock - { - /// ReservedNewbie field - public bool ReservedNewbie; - /// GroupPrims field - public int GroupPrims; - /// SelectedPrims field - public int SelectedPrims; - /// MediaID field - public LLUUID MediaID; - /// UserLookAt field - public LLVector3 UserLookAt; - /// AABBMax field - public LLVector3 AABBMax; - /// AABBMin field - public LLVector3 AABBMin; - /// RequestResult field - public int RequestResult; - /// OwnerPrims field - public int OwnerPrims; - /// RegionPushOverride field - public bool RegionPushOverride; - /// RegionDenyAnonymous field - public bool RegionDenyAnonymous; - private byte[] _mediaurl; - /// MediaURL field + { + /// ReservedNewbie field + public bool ReservedNewbie; + /// GroupPrims field + public int GroupPrims; + /// SelectedPrims field + public int SelectedPrims; + /// MediaID field + public LLUUID MediaID; + /// UserLookAt field + public LLVector3 UserLookAt; + /// AABBMax field + public LLVector3 AABBMax; + /// AABBMin field + public LLVector3 AABBMin; + /// RequestResult field + public int RequestResult; + /// OwnerPrims field + public int OwnerPrims; + /// RegionPushOverride field + public bool RegionPushOverride; + /// RegionDenyAnonymous field + public bool RegionDenyAnonymous; + private byte[] _mediaurl; + /// MediaURL field public byte[] MediaURL - { - get { return _mediaurl; } + { + get { return _mediaurl; } set - { - if (value == null) { _mediaurl = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _mediaurl = new byte[value.Length]; Array.Copy(value, _mediaurl, value.Length); } + { + if (value == null) { _mediaurl = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _mediaurl = new byte[value.Length]; Array.Copy(value, _mediaurl, value.Length); } } - } - /// LocalID field - public int LocalID; - /// SimWideMaxPrims field - public int SimWideMaxPrims; - /// TotalPrims field - public int TotalPrims; - /// OtherCount field - public int OtherCount; - /// IsGroupOwned field - public bool IsGroupOwned; - /// UserLocation field - public LLVector3 UserLocation; - /// MaxPrims field - public int MaxPrims; - private byte[] _name; - /// Name field + } + /// LocalID field + public int LocalID; + /// SimWideMaxPrims field + public int SimWideMaxPrims; + /// TotalPrims field + public int TotalPrims; + /// OtherCount field + public int OtherCount; + /// IsGroupOwned field + public bool IsGroupOwned; + /// UserLocation field + public LLVector3 UserLocation; + /// MaxPrims field + public int MaxPrims; + private byte[] _name; + /// Name field public byte[] Name - { - get { return _name; } + { + get { return _name; } set - { - if (value == null) { _name = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } + { + if (value == null) { _name = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _name = new byte[value.Length]; Array.Copy(value, _name, value.Length); } } - } - /// OtherCleanTime field - public int OtherCleanTime; - private byte[] _desc; - /// Desc field + } + /// OtherCleanTime field + public int OtherCleanTime; + private byte[] _desc; + /// Desc field public byte[] Desc - { - get { return _desc; } + { + get { return _desc; } set - { - if (value == null) { _desc = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _desc = new byte[value.Length]; Array.Copy(value, _desc, value.Length); } + { + if (value == null) { _desc = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _desc = new byte[value.Length]; Array.Copy(value, _desc, value.Length); } } - } - /// Area field - public int Area; - /// OtherPrims field - public int OtherPrims; - /// RegionDenyIdentified field - public bool RegionDenyIdentified; - /// Category field - public byte Category; - /// PublicCount field - public int PublicCount; - /// GroupID field - public LLUUID GroupID; - /// SalePrice field - public int SalePrice; - /// OwnerID field - public LLUUID OwnerID; - /// SequenceID field - public int SequenceID; - /// RegionDenyTransacted field - public bool RegionDenyTransacted; - /// SelfCount field - public int SelfCount; - private byte[] _bitmap; - /// Bitmap field + } + /// Area field + public int Area; + /// OtherPrims field + public int OtherPrims; + /// RegionDenyIdentified field + public bool RegionDenyIdentified; + /// Category field + public byte Category; + /// PublicCount field + public int PublicCount; + /// GroupID field + public LLUUID GroupID; + /// SalePrice field + public int SalePrice; + /// OwnerID field + public LLUUID OwnerID; + /// SequenceID field + public int SequenceID; + /// RegionDenyTransacted field + public bool RegionDenyTransacted; + /// SelfCount field + public int SelfCount; + private byte[] _bitmap; + /// Bitmap field public byte[] Bitmap - { - get { return _bitmap; } + { + get { return _bitmap; } set - { - if (value == null) { _bitmap = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _bitmap = new byte[value.Length]; Array.Copy(value, _bitmap, value.Length); } + { + if (value == null) { _bitmap = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _bitmap = new byte[value.Length]; Array.Copy(value, _bitmap, value.Length); } } - } - /// Status field - public byte Status; - /// SnapshotID field - public LLUUID SnapshotID; - /// SnapSelection field - public bool SnapSelection; - /// LandingType field - public byte LandingType; - /// SimWideTotalPrims field - public int SimWideTotalPrims; - /// AuctionID field - public uint AuctionID; - /// AuthBuyerID field - public LLUUID AuthBuyerID; - /// PassHours field - public float PassHours; - /// ParcelFlags field - public uint ParcelFlags; - /// PassPrice field - public int PassPrice; - /// ClaimDate field - public int ClaimDate; - /// MediaAutoScale field - public byte MediaAutoScale; - private byte[] _musicurl; - /// MusicURL field + } + /// Status field + public byte Status; + /// SnapshotID field + public LLUUID SnapshotID; + /// SnapSelection field + public bool SnapSelection; + /// LandingType field + public byte LandingType; + /// SimWideTotalPrims field + public int SimWideTotalPrims; + /// AuctionID field + public uint AuctionID; + /// AuthBuyerID field + public LLUUID AuthBuyerID; + /// PassHours field + public float PassHours; + /// ParcelFlags field + public uint ParcelFlags; + /// PassPrice field + public int PassPrice; + /// ClaimDate field + public int ClaimDate; + /// MediaAutoScale field + public byte MediaAutoScale; + private byte[] _musicurl; + /// MusicURL field public byte[] MusicURL - { - get { return _musicurl; } + { + get { return _musicurl; } set - { - if (value == null) { _musicurl = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _musicurl = new byte[value.Length]; Array.Copy(value, _musicurl, value.Length); } + { + if (value == null) { _musicurl = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _musicurl = new byte[value.Length]; Array.Copy(value, _musicurl, value.Length); } } - } - /// ParcelPrimBonus field - public float ParcelPrimBonus; - /// ClaimPrice field - public int ClaimPrice; - /// RentPrice field - public int RentPrice; - - /// Length of this block serialized in bytes + } + /// ParcelPrimBonus field + public float ParcelPrimBonus; + /// ClaimPrice field + public int ClaimPrice; + /// RentPrice field + public int RentPrice; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 239; - if (MediaURL != null) { length += 1 + MediaURL.Length; } - if (Name != null) { length += 1 + Name.Length; } - if (Desc != null) { length += 1 + Desc.Length; } - if (Bitmap != null) { length += 2 + Bitmap.Length; } - if (MusicURL != null) { length += 1 + MusicURL.Length; } - return length; + { + int length = 239; + if (MediaURL != null) { length += 1 + MediaURL.Length; } + if (Name != null) { length += 1 + Name.Length; } + if (Desc != null) { length += 1 + Desc.Length; } + if (Bitmap != null) { length += 2 + Bitmap.Length; } + if (MusicURL != null) { length += 1 + MusicURL.Length; } + return length; } } - - /// Default constructor - public ParcelDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ParcelDataBlock() { } + /// Constructor for building the block from a byte array public ParcelDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - ReservedNewbie = (bytes[i++] != 0) ? (bool)true : (bool)false; - GroupPrims = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - SelectedPrims = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - MediaID = new LLUUID(bytes, i); i += 16; - UserLookAt = new LLVector3(bytes, i); i += 12; - AABBMax = new LLVector3(bytes, i); i += 12; - AABBMin = new LLVector3(bytes, i); i += 12; - RequestResult = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - OwnerPrims = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - RegionPushOverride = (bytes[i++] != 0) ? (bool)true : (bool)false; - RegionDenyAnonymous = (bytes[i++] != 0) ? (bool)true : (bool)false; - length = (ushort)bytes[i++]; - _mediaurl = new byte[length]; - Array.Copy(bytes, i, _mediaurl, 0, length); i += length; - LocalID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - SimWideMaxPrims = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - TotalPrims = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - OtherCount = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - IsGroupOwned = (bytes[i++] != 0) ? (bool)true : (bool)false; - UserLocation = new LLVector3(bytes, i); i += 12; - MaxPrims = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _name = new byte[length]; - Array.Copy(bytes, i, _name, 0, length); i += length; - OtherCleanTime = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)bytes[i++]; - _desc = new byte[length]; - Array.Copy(bytes, i, _desc, 0, length); i += length; - Area = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - OtherPrims = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - RegionDenyIdentified = (bytes[i++] != 0) ? (bool)true : (bool)false; - Category = (byte)bytes[i++]; - PublicCount = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - GroupID = new LLUUID(bytes, i); i += 16; - SalePrice = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - OwnerID = new LLUUID(bytes, i); i += 16; - SequenceID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - RegionDenyTransacted = (bytes[i++] != 0) ? (bool)true : (bool)false; - SelfCount = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _bitmap = new byte[length]; - Array.Copy(bytes, i, _bitmap, 0, length); i += length; - Status = (byte)bytes[i++]; - SnapshotID = new LLUUID(bytes, i); i += 16; - SnapSelection = (bytes[i++] != 0) ? (bool)true : (bool)false; - LandingType = (byte)bytes[i++]; - SimWideTotalPrims = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - AuctionID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - AuthBuyerID = new LLUUID(bytes, i); i += 16; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - PassHours = BitConverter.ToSingle(bytes, i); i += 4; - ParcelFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - PassPrice = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - ClaimDate = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - MediaAutoScale = (byte)bytes[i++]; - length = (ushort)bytes[i++]; - _musicurl = new byte[length]; - Array.Copy(bytes, i, _musicurl, 0, length); i += length; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - ParcelPrimBonus = BitConverter.ToSingle(bytes, i); i += 4; - ClaimPrice = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - RentPrice = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + ReservedNewbie = (bytes[i++] != 0) ? (bool)true : (bool)false; + GroupPrims = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + SelectedPrims = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + MediaID = new LLUUID(bytes, i); i += 16; + UserLookAt = new LLVector3(bytes, i); i += 12; + AABBMax = new LLVector3(bytes, i); i += 12; + AABBMin = new LLVector3(bytes, i); i += 12; + RequestResult = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + OwnerPrims = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + RegionPushOverride = (bytes[i++] != 0) ? (bool)true : (bool)false; + RegionDenyAnonymous = (bytes[i++] != 0) ? (bool)true : (bool)false; + length = (ushort)bytes[i++]; + _mediaurl = new byte[length]; + Array.Copy(bytes, i, _mediaurl, 0, length); i += length; + LocalID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + SimWideMaxPrims = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + TotalPrims = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + OtherCount = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + IsGroupOwned = (bytes[i++] != 0) ? (bool)true : (bool)false; + UserLocation = new LLVector3(bytes, i); i += 12; + MaxPrims = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _name = new byte[length]; + Array.Copy(bytes, i, _name, 0, length); i += length; + OtherCleanTime = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)bytes[i++]; + _desc = new byte[length]; + Array.Copy(bytes, i, _desc, 0, length); i += length; + Area = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + OtherPrims = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + RegionDenyIdentified = (bytes[i++] != 0) ? (bool)true : (bool)false; + Category = (byte)bytes[i++]; + PublicCount = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + GroupID = new LLUUID(bytes, i); i += 16; + SalePrice = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + OwnerID = new LLUUID(bytes, i); i += 16; + SequenceID = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + RegionDenyTransacted = (bytes[i++] != 0) ? (bool)true : (bool)false; + SelfCount = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _bitmap = new byte[length]; + Array.Copy(bytes, i, _bitmap, 0, length); i += length; + Status = (byte)bytes[i++]; + SnapshotID = new LLUUID(bytes, i); i += 16; + SnapSelection = (bytes[i++] != 0) ? (bool)true : (bool)false; + LandingType = (byte)bytes[i++]; + SimWideTotalPrims = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + AuctionID = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + AuthBuyerID = new LLUUID(bytes, i); i += 16; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + PassHours = BitConverter.ToSingle(bytes, i); i += 4; + ParcelFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + PassPrice = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + ClaimDate = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + MediaAutoScale = (byte)bytes[i++]; + length = (ushort)bytes[i++]; + _musicurl = new byte[length]; + Array.Copy(bytes, i, _musicurl, 0, length); i += length; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + ParcelPrimBonus = BitConverter.ToSingle(bytes, i); i += 4; + ClaimPrice = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + RentPrice = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; - bytes[i++] = (byte)((ReservedNewbie) ? 1 : 0); - bytes[i++] = (byte)(GroupPrims % 256); - bytes[i++] = (byte)((GroupPrims >> 8) % 256); - bytes[i++] = (byte)((GroupPrims >> 16) % 256); - bytes[i++] = (byte)((GroupPrims >> 24) % 256); - bytes[i++] = (byte)(SelectedPrims % 256); - bytes[i++] = (byte)((SelectedPrims >> 8) % 256); - bytes[i++] = (byte)((SelectedPrims >> 16) % 256); - bytes[i++] = (byte)((SelectedPrims >> 24) % 256); - if(MediaID == null) { Console.WriteLine("Warning: MediaID is null, in " + this.GetType()); } - Array.Copy(MediaID.GetBytes(), 0, bytes, i, 16); i += 16; - if(UserLookAt == null) { Console.WriteLine("Warning: UserLookAt is null, in " + this.GetType()); } - Array.Copy(UserLookAt.GetBytes(), 0, bytes, i, 12); i += 12; - if(AABBMax == null) { Console.WriteLine("Warning: AABBMax is null, in " + this.GetType()); } - Array.Copy(AABBMax.GetBytes(), 0, bytes, i, 12); i += 12; - if(AABBMin == null) { Console.WriteLine("Warning: AABBMin is null, in " + this.GetType()); } - Array.Copy(AABBMin.GetBytes(), 0, bytes, i, 12); i += 12; - bytes[i++] = (byte)(RequestResult % 256); - bytes[i++] = (byte)((RequestResult >> 8) % 256); - bytes[i++] = (byte)((RequestResult >> 16) % 256); - bytes[i++] = (byte)((RequestResult >> 24) % 256); - bytes[i++] = (byte)(OwnerPrims % 256); - bytes[i++] = (byte)((OwnerPrims >> 8) % 256); - bytes[i++] = (byte)((OwnerPrims >> 16) % 256); - bytes[i++] = (byte)((OwnerPrims >> 24) % 256); - bytes[i++] = (byte)((RegionPushOverride) ? 1 : 0); - bytes[i++] = (byte)((RegionDenyAnonymous) ? 1 : 0); - if(MediaURL == null) { Console.WriteLine("Warning: MediaURL is null, in " + this.GetType()); } - bytes[i++] = (byte)MediaURL.Length; - Array.Copy(MediaURL, 0, bytes, i, MediaURL.Length); i += MediaURL.Length; - bytes[i++] = (byte)(LocalID % 256); - bytes[i++] = (byte)((LocalID >> 8) % 256); - bytes[i++] = (byte)((LocalID >> 16) % 256); - bytes[i++] = (byte)((LocalID >> 24) % 256); - bytes[i++] = (byte)(SimWideMaxPrims % 256); - bytes[i++] = (byte)((SimWideMaxPrims >> 8) % 256); - bytes[i++] = (byte)((SimWideMaxPrims >> 16) % 256); - bytes[i++] = (byte)((SimWideMaxPrims >> 24) % 256); - bytes[i++] = (byte)(TotalPrims % 256); - bytes[i++] = (byte)((TotalPrims >> 8) % 256); - bytes[i++] = (byte)((TotalPrims >> 16) % 256); - bytes[i++] = (byte)((TotalPrims >> 24) % 256); - bytes[i++] = (byte)(OtherCount % 256); - bytes[i++] = (byte)((OtherCount >> 8) % 256); - bytes[i++] = (byte)((OtherCount >> 16) % 256); - bytes[i++] = (byte)((OtherCount >> 24) % 256); - bytes[i++] = (byte)((IsGroupOwned) ? 1 : 0); - if(UserLocation == null) { Console.WriteLine("Warning: UserLocation is null, in " + this.GetType()); } - Array.Copy(UserLocation.GetBytes(), 0, bytes, i, 12); i += 12; - bytes[i++] = (byte)(MaxPrims % 256); - bytes[i++] = (byte)((MaxPrims >> 8) % 256); - bytes[i++] = (byte)((MaxPrims >> 16) % 256); - bytes[i++] = (byte)((MaxPrims >> 24) % 256); - if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } - bytes[i++] = (byte)Name.Length; - Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; - bytes[i++] = (byte)(OtherCleanTime % 256); - bytes[i++] = (byte)((OtherCleanTime >> 8) % 256); - bytes[i++] = (byte)((OtherCleanTime >> 16) % 256); - bytes[i++] = (byte)((OtherCleanTime >> 24) % 256); - if(Desc == null) { Console.WriteLine("Warning: Desc is null, in " + this.GetType()); } - bytes[i++] = (byte)Desc.Length; - Array.Copy(Desc, 0, bytes, i, Desc.Length); i += Desc.Length; - bytes[i++] = (byte)(Area % 256); - bytes[i++] = (byte)((Area >> 8) % 256); - bytes[i++] = (byte)((Area >> 16) % 256); - bytes[i++] = (byte)((Area >> 24) % 256); - bytes[i++] = (byte)(OtherPrims % 256); - bytes[i++] = (byte)((OtherPrims >> 8) % 256); - bytes[i++] = (byte)((OtherPrims >> 16) % 256); - bytes[i++] = (byte)((OtherPrims >> 24) % 256); - bytes[i++] = (byte)((RegionDenyIdentified) ? 1 : 0); - bytes[i++] = Category; - bytes[i++] = (byte)(PublicCount % 256); - bytes[i++] = (byte)((PublicCount >> 8) % 256); - bytes[i++] = (byte)((PublicCount >> 16) % 256); - bytes[i++] = (byte)((PublicCount >> 24) % 256); - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(SalePrice % 256); - bytes[i++] = (byte)((SalePrice >> 8) % 256); - bytes[i++] = (byte)((SalePrice >> 16) % 256); - bytes[i++] = (byte)((SalePrice >> 24) % 256); - if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } - Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(SequenceID % 256); - bytes[i++] = (byte)((SequenceID >> 8) % 256); - bytes[i++] = (byte)((SequenceID >> 16) % 256); - bytes[i++] = (byte)((SequenceID >> 24) % 256); - bytes[i++] = (byte)((RegionDenyTransacted) ? 1 : 0); - bytes[i++] = (byte)(SelfCount % 256); - bytes[i++] = (byte)((SelfCount >> 8) % 256); - bytes[i++] = (byte)((SelfCount >> 16) % 256); - bytes[i++] = (byte)((SelfCount >> 24) % 256); - if(Bitmap == null) { Console.WriteLine("Warning: Bitmap is null, in " + this.GetType()); } - bytes[i++] = (byte)(Bitmap.Length % 256); - bytes[i++] = (byte)((Bitmap.Length >> 8) % 256); - Array.Copy(Bitmap, 0, bytes, i, Bitmap.Length); i += Bitmap.Length; - bytes[i++] = Status; - if(SnapshotID == null) { Console.WriteLine("Warning: SnapshotID is null, in " + this.GetType()); } - Array.Copy(SnapshotID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((SnapSelection) ? 1 : 0); - bytes[i++] = LandingType; - bytes[i++] = (byte)(SimWideTotalPrims % 256); - bytes[i++] = (byte)((SimWideTotalPrims >> 8) % 256); - bytes[i++] = (byte)((SimWideTotalPrims >> 16) % 256); - bytes[i++] = (byte)((SimWideTotalPrims >> 24) % 256); - bytes[i++] = (byte)(AuctionID % 256); - bytes[i++] = (byte)((AuctionID >> 8) % 256); - bytes[i++] = (byte)((AuctionID >> 16) % 256); - bytes[i++] = (byte)((AuctionID >> 24) % 256); - if(AuthBuyerID == null) { Console.WriteLine("Warning: AuthBuyerID is null, in " + this.GetType()); } - Array.Copy(AuthBuyerID.GetBytes(), 0, bytes, i, 16); i += 16; + { + byte[] ba; + bytes[i++] = (byte)((ReservedNewbie) ? 1 : 0); + bytes[i++] = (byte)(GroupPrims % 256); + bytes[i++] = (byte)((GroupPrims >> 8) % 256); + bytes[i++] = (byte)((GroupPrims >> 16) % 256); + bytes[i++] = (byte)((GroupPrims >> 24) % 256); + bytes[i++] = (byte)(SelectedPrims % 256); + bytes[i++] = (byte)((SelectedPrims >> 8) % 256); + bytes[i++] = (byte)((SelectedPrims >> 16) % 256); + bytes[i++] = (byte)((SelectedPrims >> 24) % 256); + if(MediaID == null) { Console.WriteLine("Warning: MediaID is null, in " + this.GetType()); } + Array.Copy(MediaID.GetBytes(), 0, bytes, i, 16); i += 16; + if(UserLookAt == null) { Console.WriteLine("Warning: UserLookAt is null, in " + this.GetType()); } + Array.Copy(UserLookAt.GetBytes(), 0, bytes, i, 12); i += 12; + if(AABBMax == null) { Console.WriteLine("Warning: AABBMax is null, in " + this.GetType()); } + Array.Copy(AABBMax.GetBytes(), 0, bytes, i, 12); i += 12; + if(AABBMin == null) { Console.WriteLine("Warning: AABBMin is null, in " + this.GetType()); } + Array.Copy(AABBMin.GetBytes(), 0, bytes, i, 12); i += 12; + bytes[i++] = (byte)(RequestResult % 256); + bytes[i++] = (byte)((RequestResult >> 8) % 256); + bytes[i++] = (byte)((RequestResult >> 16) % 256); + bytes[i++] = (byte)((RequestResult >> 24) % 256); + bytes[i++] = (byte)(OwnerPrims % 256); + bytes[i++] = (byte)((OwnerPrims >> 8) % 256); + bytes[i++] = (byte)((OwnerPrims >> 16) % 256); + bytes[i++] = (byte)((OwnerPrims >> 24) % 256); + bytes[i++] = (byte)((RegionPushOverride) ? 1 : 0); + bytes[i++] = (byte)((RegionDenyAnonymous) ? 1 : 0); + if(MediaURL == null) { Console.WriteLine("Warning: MediaURL is null, in " + this.GetType()); } + bytes[i++] = (byte)MediaURL.Length; + Array.Copy(MediaURL, 0, bytes, i, MediaURL.Length); i += MediaURL.Length; + bytes[i++] = (byte)(LocalID % 256); + bytes[i++] = (byte)((LocalID >> 8) % 256); + bytes[i++] = (byte)((LocalID >> 16) % 256); + bytes[i++] = (byte)((LocalID >> 24) % 256); + bytes[i++] = (byte)(SimWideMaxPrims % 256); + bytes[i++] = (byte)((SimWideMaxPrims >> 8) % 256); + bytes[i++] = (byte)((SimWideMaxPrims >> 16) % 256); + bytes[i++] = (byte)((SimWideMaxPrims >> 24) % 256); + bytes[i++] = (byte)(TotalPrims % 256); + bytes[i++] = (byte)((TotalPrims >> 8) % 256); + bytes[i++] = (byte)((TotalPrims >> 16) % 256); + bytes[i++] = (byte)((TotalPrims >> 24) % 256); + bytes[i++] = (byte)(OtherCount % 256); + bytes[i++] = (byte)((OtherCount >> 8) % 256); + bytes[i++] = (byte)((OtherCount >> 16) % 256); + bytes[i++] = (byte)((OtherCount >> 24) % 256); + bytes[i++] = (byte)((IsGroupOwned) ? 1 : 0); + if(UserLocation == null) { Console.WriteLine("Warning: UserLocation is null, in " + this.GetType()); } + Array.Copy(UserLocation.GetBytes(), 0, bytes, i, 12); i += 12; + bytes[i++] = (byte)(MaxPrims % 256); + bytes[i++] = (byte)((MaxPrims >> 8) % 256); + bytes[i++] = (byte)((MaxPrims >> 16) % 256); + bytes[i++] = (byte)((MaxPrims >> 24) % 256); + if(Name == null) { Console.WriteLine("Warning: Name is null, in " + this.GetType()); } + bytes[i++] = (byte)Name.Length; + Array.Copy(Name, 0, bytes, i, Name.Length); i += Name.Length; + bytes[i++] = (byte)(OtherCleanTime % 256); + bytes[i++] = (byte)((OtherCleanTime >> 8) % 256); + bytes[i++] = (byte)((OtherCleanTime >> 16) % 256); + bytes[i++] = (byte)((OtherCleanTime >> 24) % 256); + if(Desc == null) { Console.WriteLine("Warning: Desc is null, in " + this.GetType()); } + bytes[i++] = (byte)Desc.Length; + Array.Copy(Desc, 0, bytes, i, Desc.Length); i += Desc.Length; + bytes[i++] = (byte)(Area % 256); + bytes[i++] = (byte)((Area >> 8) % 256); + bytes[i++] = (byte)((Area >> 16) % 256); + bytes[i++] = (byte)((Area >> 24) % 256); + bytes[i++] = (byte)(OtherPrims % 256); + bytes[i++] = (byte)((OtherPrims >> 8) % 256); + bytes[i++] = (byte)((OtherPrims >> 16) % 256); + bytes[i++] = (byte)((OtherPrims >> 24) % 256); + bytes[i++] = (byte)((RegionDenyIdentified) ? 1 : 0); + bytes[i++] = Category; + bytes[i++] = (byte)(PublicCount % 256); + bytes[i++] = (byte)((PublicCount >> 8) % 256); + bytes[i++] = (byte)((PublicCount >> 16) % 256); + bytes[i++] = (byte)((PublicCount >> 24) % 256); + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(SalePrice % 256); + bytes[i++] = (byte)((SalePrice >> 8) % 256); + bytes[i++] = (byte)((SalePrice >> 16) % 256); + bytes[i++] = (byte)((SalePrice >> 24) % 256); + if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } + Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(SequenceID % 256); + bytes[i++] = (byte)((SequenceID >> 8) % 256); + bytes[i++] = (byte)((SequenceID >> 16) % 256); + bytes[i++] = (byte)((SequenceID >> 24) % 256); + bytes[i++] = (byte)((RegionDenyTransacted) ? 1 : 0); + bytes[i++] = (byte)(SelfCount % 256); + bytes[i++] = (byte)((SelfCount >> 8) % 256); + bytes[i++] = (byte)((SelfCount >> 16) % 256); + bytes[i++] = (byte)((SelfCount >> 24) % 256); + if(Bitmap == null) { Console.WriteLine("Warning: Bitmap is null, in " + this.GetType()); } + bytes[i++] = (byte)(Bitmap.Length % 256); + bytes[i++] = (byte)((Bitmap.Length >> 8) % 256); + Array.Copy(Bitmap, 0, bytes, i, Bitmap.Length); i += Bitmap.Length; + bytes[i++] = Status; + if(SnapshotID == null) { Console.WriteLine("Warning: SnapshotID is null, in " + this.GetType()); } + Array.Copy(SnapshotID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((SnapSelection) ? 1 : 0); + bytes[i++] = LandingType; + bytes[i++] = (byte)(SimWideTotalPrims % 256); + bytes[i++] = (byte)((SimWideTotalPrims >> 8) % 256); + bytes[i++] = (byte)((SimWideTotalPrims >> 16) % 256); + bytes[i++] = (byte)((SimWideTotalPrims >> 24) % 256); + bytes[i++] = (byte)(AuctionID % 256); + bytes[i++] = (byte)((AuctionID >> 8) % 256); + bytes[i++] = (byte)((AuctionID >> 16) % 256); + bytes[i++] = (byte)((AuctionID >> 24) % 256); + if(AuthBuyerID == null) { Console.WriteLine("Warning: AuthBuyerID is null, in " + this.GetType()); } + Array.Copy(AuthBuyerID.GetBytes(), 0, bytes, i, 16); i += 16; ba = BitConverter.GetBytes(PassHours); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - bytes[i++] = (byte)(ParcelFlags % 256); - bytes[i++] = (byte)((ParcelFlags >> 8) % 256); - bytes[i++] = (byte)((ParcelFlags >> 16) % 256); - bytes[i++] = (byte)((ParcelFlags >> 24) % 256); - bytes[i++] = (byte)(PassPrice % 256); - bytes[i++] = (byte)((PassPrice >> 8) % 256); - bytes[i++] = (byte)((PassPrice >> 16) % 256); - bytes[i++] = (byte)((PassPrice >> 24) % 256); - bytes[i++] = (byte)(ClaimDate % 256); - bytes[i++] = (byte)((ClaimDate >> 8) % 256); - bytes[i++] = (byte)((ClaimDate >> 16) % 256); - bytes[i++] = (byte)((ClaimDate >> 24) % 256); - bytes[i++] = MediaAutoScale; - if(MusicURL == null) { Console.WriteLine("Warning: MusicURL is null, in " + this.GetType()); } - bytes[i++] = (byte)MusicURL.Length; - Array.Copy(MusicURL, 0, bytes, i, MusicURL.Length); i += MusicURL.Length; + Array.Copy(ba, 0, bytes, i, 4); i += 4; + bytes[i++] = (byte)(ParcelFlags % 256); + bytes[i++] = (byte)((ParcelFlags >> 8) % 256); + bytes[i++] = (byte)((ParcelFlags >> 16) % 256); + bytes[i++] = (byte)((ParcelFlags >> 24) % 256); + bytes[i++] = (byte)(PassPrice % 256); + bytes[i++] = (byte)((PassPrice >> 8) % 256); + bytes[i++] = (byte)((PassPrice >> 16) % 256); + bytes[i++] = (byte)((PassPrice >> 24) % 256); + bytes[i++] = (byte)(ClaimDate % 256); + bytes[i++] = (byte)((ClaimDate >> 8) % 256); + bytes[i++] = (byte)((ClaimDate >> 16) % 256); + bytes[i++] = (byte)((ClaimDate >> 24) % 256); + bytes[i++] = MediaAutoScale; + if(MusicURL == null) { Console.WriteLine("Warning: MusicURL is null, in " + this.GetType()); } + bytes[i++] = (byte)MusicURL.Length; + Array.Copy(MusicURL, 0, bytes, i, MusicURL.Length); i += MusicURL.Length; ba = BitConverter.GetBytes(ParcelPrimBonus); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - bytes[i++] = (byte)(ClaimPrice % 256); - bytes[i++] = (byte)((ClaimPrice >> 8) % 256); - bytes[i++] = (byte)((ClaimPrice >> 16) % 256); - bytes[i++] = (byte)((ClaimPrice >> 24) % 256); - bytes[i++] = (byte)(RentPrice % 256); - bytes[i++] = (byte)((RentPrice >> 8) % 256); - bytes[i++] = (byte)((RentPrice >> 16) % 256); - bytes[i++] = (byte)((RentPrice >> 24) % 256); + Array.Copy(ba, 0, bytes, i, 4); i += 4; + bytes[i++] = (byte)(ClaimPrice % 256); + bytes[i++] = (byte)((ClaimPrice >> 8) % 256); + bytes[i++] = (byte)((ClaimPrice >> 16) % 256); + bytes[i++] = (byte)((ClaimPrice >> 24) % 256); + bytes[i++] = (byte)(RentPrice % 256); + bytes[i++] = (byte)((RentPrice >> 8) % 256); + bytes[i++] = (byte)((RentPrice >> 16) % 256); + bytes[i++] = (byte)((RentPrice >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ParcelData --\n"; - output += "ReservedNewbie: " + ReservedNewbie.ToString() + "\n"; - output += "GroupPrims: " + GroupPrims.ToString() + "\n"; - output += "SelectedPrims: " + SelectedPrims.ToString() + "\n"; - output += "MediaID: " + MediaID.ToString() + "\n"; - output += "UserLookAt: " + UserLookAt.ToString() + "\n"; - output += "AABBMax: " + AABBMax.ToString() + "\n"; - output += "AABBMin: " + AABBMin.ToString() + "\n"; - output += "RequestResult: " + RequestResult.ToString() + "\n"; - output += "OwnerPrims: " + OwnerPrims.ToString() + "\n"; - output += "RegionPushOverride: " + RegionPushOverride.ToString() + "\n"; - output += "RegionDenyAnonymous: " + RegionDenyAnonymous.ToString() + "\n"; - output += Helpers.FieldToString(MediaURL, "MediaURL") + "\n"; - output += "LocalID: " + LocalID.ToString() + "\n"; - output += "SimWideMaxPrims: " + SimWideMaxPrims.ToString() + "\n"; - output += "TotalPrims: " + TotalPrims.ToString() + "\n"; - output += "OtherCount: " + OtherCount.ToString() + "\n"; - output += "IsGroupOwned: " + IsGroupOwned.ToString() + "\n"; - output += "UserLocation: " + UserLocation.ToString() + "\n"; - output += "MaxPrims: " + MaxPrims.ToString() + "\n"; - output += Helpers.FieldToString(Name, "Name") + "\n"; - output += "OtherCleanTime: " + OtherCleanTime.ToString() + "\n"; - output += Helpers.FieldToString(Desc, "Desc") + "\n"; - output += "Area: " + Area.ToString() + "\n"; - output += "OtherPrims: " + OtherPrims.ToString() + "\n"; - output += "RegionDenyIdentified: " + RegionDenyIdentified.ToString() + "\n"; - output += "Category: " + Category.ToString() + "\n"; - output += "PublicCount: " + PublicCount.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; - output += "SalePrice: " + SalePrice.ToString() + "\n"; - output += "OwnerID: " + OwnerID.ToString() + "\n"; - output += "SequenceID: " + SequenceID.ToString() + "\n"; - output += "RegionDenyTransacted: " + RegionDenyTransacted.ToString() + "\n"; - output += "SelfCount: " + SelfCount.ToString() + "\n"; - output += Helpers.FieldToString(Bitmap, "Bitmap") + "\n"; - output += "Status: " + Status.ToString() + "\n"; - output += "SnapshotID: " + SnapshotID.ToString() + "\n"; - output += "SnapSelection: " + SnapSelection.ToString() + "\n"; - output += "LandingType: " + LandingType.ToString() + "\n"; - output += "SimWideTotalPrims: " + SimWideTotalPrims.ToString() + "\n"; - output += "AuctionID: " + AuctionID.ToString() + "\n"; - output += "AuthBuyerID: " + AuthBuyerID.ToString() + "\n"; - output += "PassHours: " + PassHours.ToString() + "\n"; - output += "ParcelFlags: " + ParcelFlags.ToString() + "\n"; - output += "PassPrice: " + PassPrice.ToString() + "\n"; - output += "ClaimDate: " + ClaimDate.ToString() + "\n"; - output += "MediaAutoScale: " + MediaAutoScale.ToString() + "\n"; - output += Helpers.FieldToString(MusicURL, "MusicURL") + "\n"; - output += "ParcelPrimBonus: " + ParcelPrimBonus.ToString() + "\n"; - output += "ClaimPrice: " + ClaimPrice.ToString() + "\n"; - output += "RentPrice: " + RentPrice.ToString() + "\n"; + { + string output = "-- ParcelData --\n"; + output += "ReservedNewbie: " + ReservedNewbie.ToString() + "\n"; + output += "GroupPrims: " + GroupPrims.ToString() + "\n"; + output += "SelectedPrims: " + SelectedPrims.ToString() + "\n"; + output += "MediaID: " + MediaID.ToString() + "\n"; + output += "UserLookAt: " + UserLookAt.ToString() + "\n"; + output += "AABBMax: " + AABBMax.ToString() + "\n"; + output += "AABBMin: " + AABBMin.ToString() + "\n"; + output += "RequestResult: " + RequestResult.ToString() + "\n"; + output += "OwnerPrims: " + OwnerPrims.ToString() + "\n"; + output += "RegionPushOverride: " + RegionPushOverride.ToString() + "\n"; + output += "RegionDenyAnonymous: " + RegionDenyAnonymous.ToString() + "\n"; + output += Helpers.FieldToString(MediaURL, "MediaURL") + "\n"; + output += "LocalID: " + LocalID.ToString() + "\n"; + output += "SimWideMaxPrims: " + SimWideMaxPrims.ToString() + "\n"; + output += "TotalPrims: " + TotalPrims.ToString() + "\n"; + output += "OtherCount: " + OtherCount.ToString() + "\n"; + output += "IsGroupOwned: " + IsGroupOwned.ToString() + "\n"; + output += "UserLocation: " + UserLocation.ToString() + "\n"; + output += "MaxPrims: " + MaxPrims.ToString() + "\n"; + output += Helpers.FieldToString(Name, "Name") + "\n"; + output += "OtherCleanTime: " + OtherCleanTime.ToString() + "\n"; + output += Helpers.FieldToString(Desc, "Desc") + "\n"; + output += "Area: " + Area.ToString() + "\n"; + output += "OtherPrims: " + OtherPrims.ToString() + "\n"; + output += "RegionDenyIdentified: " + RegionDenyIdentified.ToString() + "\n"; + output += "Category: " + Category.ToString() + "\n"; + output += "PublicCount: " + PublicCount.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; + output += "SalePrice: " + SalePrice.ToString() + "\n"; + output += "OwnerID: " + OwnerID.ToString() + "\n"; + output += "SequenceID: " + SequenceID.ToString() + "\n"; + output += "RegionDenyTransacted: " + RegionDenyTransacted.ToString() + "\n"; + output += "SelfCount: " + SelfCount.ToString() + "\n"; + output += Helpers.FieldToString(Bitmap, "Bitmap") + "\n"; + output += "Status: " + Status.ToString() + "\n"; + output += "SnapshotID: " + SnapshotID.ToString() + "\n"; + output += "SnapSelection: " + SnapSelection.ToString() + "\n"; + output += "LandingType: " + LandingType.ToString() + "\n"; + output += "SimWideTotalPrims: " + SimWideTotalPrims.ToString() + "\n"; + output += "AuctionID: " + AuctionID.ToString() + "\n"; + output += "AuthBuyerID: " + AuthBuyerID.ToString() + "\n"; + output += "PassHours: " + PassHours.ToString() + "\n"; + output += "ParcelFlags: " + ParcelFlags.ToString() + "\n"; + output += "PassPrice: " + PassPrice.ToString() + "\n"; + output += "ClaimDate: " + ClaimDate.ToString() + "\n"; + output += "MediaAutoScale: " + MediaAutoScale.ToString() + "\n"; + output += Helpers.FieldToString(MusicURL, "MusicURL") + "\n"; + output += "ParcelPrimBonus: " + ParcelPrimBonus.ToString() + "\n"; + output += "ClaimPrice: " + ClaimPrice.ToString() + "\n"; + output += "RentPrice: " + RentPrice.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ParcelProperties - public override PacketType Type { get { return PacketType.ParcelProperties; } } - /// ParcelData block - public ParcelDataBlock ParcelData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ParcelProperties + public override PacketType Type { get { return PacketType.ParcelProperties; } } + /// ParcelData block + public ParcelDataBlock ParcelData; + + /// Default constructor public ParcelPropertiesPacket() - { - Header = new HighHeader(); - Header.ID = 25; - Header.Reliable = true; - Header.Zerocoded = true; - ParcelData = new ParcelDataBlock(); + { + Header = new HighHeader(); + Header.ID = 25; + Header.Reliable = true; + Header.Zerocoded = true; + ParcelData = new ParcelDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ParcelPropertiesPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new HighHeader(bytes, ref i, ref packetEnd); - ParcelData = new ParcelDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new HighHeader(bytes, ref i, ref packetEnd); + ParcelData = new ParcelDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ParcelPropertiesPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - ParcelData = new ParcelDataBlock(bytes, ref i); + { + Header = head; + ParcelData = new ParcelDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 5; - length += ParcelData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - ParcelData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 5; + length += ParcelData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + ParcelData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ParcelProperties ---\n"; - output += ParcelData.ToString() + "\n"; + { + string output = "--- ParcelProperties ---\n"; + output += ParcelData.ToString() + "\n"; return output; } - + } - - /// EdgeDataPacket packet + + /// EdgeDataPacket packet public class EdgeDataPacketPacket : Packet - { - /// EdgeData block + { + /// EdgeData block public class EdgeDataBlock - { - /// LayerType field - public byte LayerType; - /// Direction field - public byte Direction; - private byte[] _layerdata; - /// LayerData field + { + /// LayerType field + public byte LayerType; + /// Direction field + public byte Direction; + private byte[] _layerdata; + /// LayerData field public byte[] LayerData - { - get { return _layerdata; } + { + get { return _layerdata; } set - { - if (value == null) { _layerdata = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _layerdata = new byte[value.Length]; Array.Copy(value, _layerdata, value.Length); } + { + if (value == null) { _layerdata = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _layerdata = new byte[value.Length]; Array.Copy(value, _layerdata, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 2; - if (LayerData != null) { length += 2 + LayerData.Length; } - return length; + { + int length = 2; + if (LayerData != null) { length += 2 + LayerData.Length; } + return length; } } - - /// Default constructor - public EdgeDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public EdgeDataBlock() { } + /// Constructor for building the block from a byte array public EdgeDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - LayerType = (byte)bytes[i++]; - Direction = (byte)bytes[i++]; - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _layerdata = new byte[length]; - Array.Copy(bytes, i, _layerdata, 0, length); i += length; + { + LayerType = (byte)bytes[i++]; + Direction = (byte)bytes[i++]; + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _layerdata = new byte[length]; + Array.Copy(bytes, i, _layerdata, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = LayerType; - bytes[i++] = Direction; - if(LayerData == null) { Console.WriteLine("Warning: LayerData is null, in " + this.GetType()); } - bytes[i++] = (byte)(LayerData.Length % 256); - bytes[i++] = (byte)((LayerData.Length >> 8) % 256); - Array.Copy(LayerData, 0, bytes, i, LayerData.Length); i += LayerData.Length; + { + bytes[i++] = LayerType; + bytes[i++] = Direction; + if(LayerData == null) { Console.WriteLine("Warning: LayerData is null, in " + this.GetType()); } + bytes[i++] = (byte)(LayerData.Length % 256); + bytes[i++] = (byte)((LayerData.Length >> 8) % 256); + Array.Copy(LayerData, 0, bytes, i, LayerData.Length); i += LayerData.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- EdgeData --\n"; - output += "LayerType: " + LayerType.ToString() + "\n"; - output += "Direction: " + Direction.ToString() + "\n"; - output += Helpers.FieldToString(LayerData, "LayerData") + "\n"; + { + string output = "-- EdgeData --\n"; + output += "LayerType: " + LayerType.ToString() + "\n"; + output += "Direction: " + Direction.ToString() + "\n"; + output += Helpers.FieldToString(LayerData, "LayerData") + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.EdgeDataPacket - public override PacketType Type { get { return PacketType.EdgeDataPacket; } } - /// EdgeData block - public EdgeDataBlock EdgeData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.EdgeDataPacket + public override PacketType Type { get { return PacketType.EdgeDataPacket; } } + /// EdgeData block + public EdgeDataBlock EdgeData; + + /// Default constructor public EdgeDataPacketPacket() - { - Header = new HighHeader(); - Header.ID = 26; - Header.Reliable = true; - Header.Zerocoded = true; - EdgeData = new EdgeDataBlock(); + { + Header = new HighHeader(); + Header.ID = 26; + Header.Reliable = true; + Header.Zerocoded = true; + EdgeData = new EdgeDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public EdgeDataPacketPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new HighHeader(bytes, ref i, ref packetEnd); - EdgeData = new EdgeDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new HighHeader(bytes, ref i, ref packetEnd); + EdgeData = new EdgeDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public EdgeDataPacketPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - EdgeData = new EdgeDataBlock(bytes, ref i); + { + Header = head; + EdgeData = new EdgeDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 5; - length += EdgeData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - EdgeData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 5; + length += EdgeData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + EdgeData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- EdgeDataPacket ---\n"; - output += EdgeData.ToString() + "\n"; + { + string output = "--- EdgeDataPacket ---\n"; + output += EdgeData.ToString() + "\n"; return output; } - + } - - /// ChildAgentUpdate packet + + /// ChildAgentUpdate packet public class ChildAgentUpdatePacket : Packet - { - /// VisualParam block + { + /// VisualParam block public class VisualParamBlock - { - /// ParamValue field - public byte ParamValue; - - /// Length of this block serialized in bytes + { + /// ParamValue field + public byte ParamValue; + + /// Length of this block serialized in bytes public int Length { get - { - return 1; + { + return 1; } } - - /// Default constructor - public VisualParamBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public VisualParamBlock() { } + /// Constructor for building the block from a byte array public VisualParamBlock(byte[] bytes, ref int i) - { + { try - { - ParamValue = (byte)bytes[i++]; + { + ParamValue = (byte)bytes[i++]; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = ParamValue; + { + bytes[i++] = ParamValue; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- VisualParam --\n"; - output += "ParamValue: " + ParamValue.ToString() + "\n"; + { + string output = "-- VisualParam --\n"; + output += "ParamValue: " + ParamValue.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// GranterBlock block + + /// GranterBlock block public class GranterBlockBlock - { - /// GranterID field - public LLUUID GranterID; - - /// Length of this block serialized in bytes + { + /// GranterID field + public LLUUID GranterID; + + /// Length of this block serialized in bytes public int Length { get - { - return 16; + { + return 16; } } - - /// Default constructor - public GranterBlockBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public GranterBlockBlock() { } + /// Constructor for building the block from a byte array public GranterBlockBlock(byte[] bytes, ref int i) - { + { try - { - GranterID = new LLUUID(bytes, i); i += 16; + { + GranterID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(GranterID == null) { Console.WriteLine("Warning: GranterID is null, in " + this.GetType()); } - Array.Copy(GranterID.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(GranterID == null) { Console.WriteLine("Warning: GranterID is null, in " + this.GetType()); } + Array.Copy(GranterID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- GranterBlock --\n"; - output += "GranterID: " + GranterID.ToString() + "\n"; + { + string output = "-- GranterBlock --\n"; + output += "GranterID: " + GranterID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AnimationData block + + /// AnimationData block public class AnimationDataBlock - { - /// ObjectID field - public LLUUID ObjectID; - /// Animation field - public LLUUID Animation; - - /// Length of this block serialized in bytes + { + /// ObjectID field + public LLUUID ObjectID; + /// Animation field + public LLUUID Animation; + + /// Length of this block serialized in bytes public int Length { get - { - return 32; + { + return 32; } } - - /// Default constructor - public AnimationDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AnimationDataBlock() { } + /// Constructor for building the block from a byte array public AnimationDataBlock(byte[] bytes, ref int i) - { + { try - { - ObjectID = new LLUUID(bytes, i); i += 16; - Animation = new LLUUID(bytes, i); i += 16; + { + ObjectID = new LLUUID(bytes, i); i += 16; + Animation = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } - Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; - if(Animation == null) { Console.WriteLine("Warning: Animation is null, in " + this.GetType()); } - Array.Copy(Animation.GetBytes(), 0, bytes, i, 16); i += 16; + { + if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } + Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; + if(Animation == null) { Console.WriteLine("Warning: Animation is null, in " + this.GetType()); } + Array.Copy(Animation.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AnimationData --\n"; - output += "ObjectID: " + ObjectID.ToString() + "\n"; - output += "Animation: " + Animation.ToString() + "\n"; + { + string output = "-- AnimationData --\n"; + output += "ObjectID: " + ObjectID.ToString() + "\n"; + output += "Animation: " + Animation.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// AgentData block + + /// AgentData block public class AgentDataBlock - { - /// ViewerCircuitCode field - public uint ViewerCircuitCode; - /// ControlFlags field - public uint ControlFlags; - /// Far field - public float Far; - /// AgentID field - public LLUUID AgentID; - /// ChangedGrid field - public bool ChangedGrid; - /// HeadRotation field - public LLQuaternion HeadRotation; - /// SessionID field - public LLUUID SessionID; - /// LeftAxis field - public LLVector3 LeftAxis; - /// Size field - public LLVector3 Size; - /// GodLevel field - public byte GodLevel; - /// RegionHandle field - public ulong RegionHandle; - /// AgentAccess field - public byte AgentAccess; - /// AgentVel field - public LLVector3 AgentVel; - /// AgentPos field - public LLVector3 AgentPos; - /// PreyAgent field - public LLUUID PreyAgent; - private byte[] _throttles; - /// Throttles field + { + /// ViewerCircuitCode field + public uint ViewerCircuitCode; + /// ControlFlags field + public uint ControlFlags; + /// Far field + public float Far; + /// AgentID field + public LLUUID AgentID; + /// ChangedGrid field + public bool ChangedGrid; + /// HeadRotation field + public LLQuaternion HeadRotation; + /// SessionID field + public LLUUID SessionID; + /// LeftAxis field + public LLVector3 LeftAxis; + /// Size field + public LLVector3 Size; + /// GodLevel field + public byte GodLevel; + /// RegionHandle field + public ulong RegionHandle; + /// AgentAccess field + public byte AgentAccess; + /// AgentVel field + public LLVector3 AgentVel; + /// AgentPos field + public LLVector3 AgentPos; + /// PreyAgent field + public LLUUID PreyAgent; + private byte[] _throttles; + /// Throttles field public byte[] Throttles - { - get { return _throttles; } + { + get { return _throttles; } set - { - if (value == null) { _throttles = null; return; } - if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } - else { _throttles = new byte[value.Length]; Array.Copy(value, _throttles, value.Length); } + { + if (value == null) { _throttles = null; return; } + if (value.Length > 255) { throw new OverflowException("Value exceeds 255 characters"); } + else { _throttles = new byte[value.Length]; Array.Copy(value, _throttles, value.Length); } } - } - /// UpAxis field - public LLVector3 UpAxis; - private byte[] _agenttextures; - /// AgentTextures field + } + /// UpAxis field + public LLVector3 UpAxis; + private byte[] _agenttextures; + /// AgentTextures field public byte[] AgentTextures - { - get { return _agenttextures; } + { + get { return _agenttextures; } set - { - if (value == null) { _agenttextures = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _agenttextures = new byte[value.Length]; Array.Copy(value, _agenttextures, value.Length); } + { + if (value == null) { _agenttextures = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _agenttextures = new byte[value.Length]; Array.Copy(value, _agenttextures, value.Length); } } - } - /// AtAxis field - public LLVector3 AtAxis; - /// Center field - public LLVector3 Center; - /// BodyRotation field - public LLQuaternion BodyRotation; - /// Aspect field - public float Aspect; - /// AlwaysRun field - public bool AlwaysRun; - /// EnergyLevel field - public float EnergyLevel; - /// LocomotionState field - public uint LocomotionState; - /// ActiveGroupID field - public LLUUID ActiveGroupID; - - /// Length of this block serialized in bytes + } + /// AtAxis field + public LLVector3 AtAxis; + /// Center field + public LLVector3 Center; + /// BodyRotation field + public LLQuaternion BodyRotation; + /// Aspect field + public float Aspect; + /// AlwaysRun field + public bool AlwaysRun; + /// EnergyLevel field + public float EnergyLevel; + /// LocomotionState field + public uint LocomotionState; + /// ActiveGroupID field + public LLUUID ActiveGroupID; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 208; - if (Throttles != null) { length += 1 + Throttles.Length; } - if (AgentTextures != null) { length += 2 + AgentTextures.Length; } - return length; + { + int length = 208; + if (Throttles != null) { length += 1 + Throttles.Length; } + if (AgentTextures != null) { length += 2 + AgentTextures.Length; } + return length; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - ViewerCircuitCode = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - ControlFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - Far = BitConverter.ToSingle(bytes, i); i += 4; - AgentID = new LLUUID(bytes, i); i += 16; - ChangedGrid = (bytes[i++] != 0) ? (bool)true : (bool)false; - HeadRotation = new LLQuaternion(bytes, i, true); i += 12; - SessionID = new LLUUID(bytes, i); i += 16; - LeftAxis = new LLVector3(bytes, i); i += 12; - Size = new LLVector3(bytes, i); i += 12; - GodLevel = (byte)bytes[i++]; - RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); - AgentAccess = (byte)bytes[i++]; - AgentVel = new LLVector3(bytes, i); i += 12; - AgentPos = new LLVector3(bytes, i); i += 12; - PreyAgent = new LLUUID(bytes, i); i += 16; - length = (ushort)bytes[i++]; - _throttles = new byte[length]; - Array.Copy(bytes, i, _throttles, 0, length); i += length; - UpAxis = new LLVector3(bytes, i); i += 12; - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _agenttextures = new byte[length]; - Array.Copy(bytes, i, _agenttextures, 0, length); i += length; - AtAxis = new LLVector3(bytes, i); i += 12; - Center = new LLVector3(bytes, i); i += 12; - BodyRotation = new LLQuaternion(bytes, i, true); i += 12; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - Aspect = BitConverter.ToSingle(bytes, i); i += 4; - AlwaysRun = (bytes[i++] != 0) ? (bool)true : (bool)false; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - EnergyLevel = BitConverter.ToSingle(bytes, i); i += 4; - LocomotionState = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - ActiveGroupID = new LLUUID(bytes, i); i += 16; + { + ViewerCircuitCode = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + ControlFlags = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + Far = BitConverter.ToSingle(bytes, i); i += 4; + AgentID = new LLUUID(bytes, i); i += 16; + ChangedGrid = (bytes[i++] != 0) ? (bool)true : (bool)false; + HeadRotation = new LLQuaternion(bytes, i, true); i += 12; + SessionID = new LLUUID(bytes, i); i += 16; + LeftAxis = new LLVector3(bytes, i); i += 12; + Size = new LLVector3(bytes, i); i += 12; + GodLevel = (byte)bytes[i++]; + RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + AgentAccess = (byte)bytes[i++]; + AgentVel = new LLVector3(bytes, i); i += 12; + AgentPos = new LLVector3(bytes, i); i += 12; + PreyAgent = new LLUUID(bytes, i); i += 16; + length = (ushort)bytes[i++]; + _throttles = new byte[length]; + Array.Copy(bytes, i, _throttles, 0, length); i += length; + UpAxis = new LLVector3(bytes, i); i += 12; + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _agenttextures = new byte[length]; + Array.Copy(bytes, i, _agenttextures, 0, length); i += length; + AtAxis = new LLVector3(bytes, i); i += 12; + Center = new LLVector3(bytes, i); i += 12; + BodyRotation = new LLQuaternion(bytes, i, true); i += 12; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + Aspect = BitConverter.ToSingle(bytes, i); i += 4; + AlwaysRun = (bytes[i++] != 0) ? (bool)true : (bool)false; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + EnergyLevel = BitConverter.ToSingle(bytes, i); i += 4; + LocomotionState = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + ActiveGroupID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; - bytes[i++] = (byte)(ViewerCircuitCode % 256); - bytes[i++] = (byte)((ViewerCircuitCode >> 8) % 256); - bytes[i++] = (byte)((ViewerCircuitCode >> 16) % 256); - bytes[i++] = (byte)((ViewerCircuitCode >> 24) % 256); - bytes[i++] = (byte)(ControlFlags % 256); - bytes[i++] = (byte)((ControlFlags >> 8) % 256); - bytes[i++] = (byte)((ControlFlags >> 16) % 256); - bytes[i++] = (byte)((ControlFlags >> 24) % 256); + { + byte[] ba; + bytes[i++] = (byte)(ViewerCircuitCode % 256); + bytes[i++] = (byte)((ViewerCircuitCode >> 8) % 256); + bytes[i++] = (byte)((ViewerCircuitCode >> 16) % 256); + bytes[i++] = (byte)((ViewerCircuitCode >> 24) % 256); + bytes[i++] = (byte)(ControlFlags % 256); + bytes[i++] = (byte)((ControlFlags >> 8) % 256); + bytes[i++] = (byte)((ControlFlags >> 16) % 256); + bytes[i++] = (byte)((ControlFlags >> 24) % 256); ba = BitConverter.GetBytes(Far); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((ChangedGrid) ? 1 : 0); - if(HeadRotation == null) { Console.WriteLine("Warning: HeadRotation is null, in " + this.GetType()); } - Array.Copy(HeadRotation.GetBytes(), 0, bytes, i, 12); i += 12; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - if(LeftAxis == null) { Console.WriteLine("Warning: LeftAxis is null, in " + this.GetType()); } - Array.Copy(LeftAxis.GetBytes(), 0, bytes, i, 12); i += 12; - if(Size == null) { Console.WriteLine("Warning: Size is null, in " + this.GetType()); } - Array.Copy(Size.GetBytes(), 0, bytes, i, 12); i += 12; - bytes[i++] = GodLevel; - bytes[i++] = (byte)(RegionHandle % 256); - bytes[i++] = (byte)((RegionHandle >> 8) % 256); - bytes[i++] = (byte)((RegionHandle >> 16) % 256); - bytes[i++] = (byte)((RegionHandle >> 24) % 256); - bytes[i++] = (byte)((RegionHandle >> 32) % 256); - bytes[i++] = (byte)((RegionHandle >> 40) % 256); - bytes[i++] = (byte)((RegionHandle >> 48) % 256); - bytes[i++] = (byte)((RegionHandle >> 56) % 256); - bytes[i++] = AgentAccess; - if(AgentVel == null) { Console.WriteLine("Warning: AgentVel is null, in " + this.GetType()); } - Array.Copy(AgentVel.GetBytes(), 0, bytes, i, 12); i += 12; - if(AgentPos == null) { Console.WriteLine("Warning: AgentPos is null, in " + this.GetType()); } - Array.Copy(AgentPos.GetBytes(), 0, bytes, i, 12); i += 12; - if(PreyAgent == null) { Console.WriteLine("Warning: PreyAgent is null, in " + this.GetType()); } - Array.Copy(PreyAgent.GetBytes(), 0, bytes, i, 16); i += 16; - if(Throttles == null) { Console.WriteLine("Warning: Throttles is null, in " + this.GetType()); } - bytes[i++] = (byte)Throttles.Length; - Array.Copy(Throttles, 0, bytes, i, Throttles.Length); i += Throttles.Length; - if(UpAxis == null) { Console.WriteLine("Warning: UpAxis is null, in " + this.GetType()); } - Array.Copy(UpAxis.GetBytes(), 0, bytes, i, 12); i += 12; - if(AgentTextures == null) { Console.WriteLine("Warning: AgentTextures is null, in " + this.GetType()); } - bytes[i++] = (byte)(AgentTextures.Length % 256); - bytes[i++] = (byte)((AgentTextures.Length >> 8) % 256); - Array.Copy(AgentTextures, 0, bytes, i, AgentTextures.Length); i += AgentTextures.Length; - if(AtAxis == null) { Console.WriteLine("Warning: AtAxis is null, in " + this.GetType()); } - Array.Copy(AtAxis.GetBytes(), 0, bytes, i, 12); i += 12; - if(Center == null) { Console.WriteLine("Warning: Center is null, in " + this.GetType()); } - Array.Copy(Center.GetBytes(), 0, bytes, i, 12); i += 12; - if(BodyRotation == null) { Console.WriteLine("Warning: BodyRotation is null, in " + this.GetType()); } - Array.Copy(BodyRotation.GetBytes(), 0, bytes, i, 12); i += 12; + Array.Copy(ba, 0, bytes, i, 4); i += 4; + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((ChangedGrid) ? 1 : 0); + if(HeadRotation == null) { Console.WriteLine("Warning: HeadRotation is null, in " + this.GetType()); } + Array.Copy(HeadRotation.GetBytes(), 0, bytes, i, 12); i += 12; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + if(LeftAxis == null) { Console.WriteLine("Warning: LeftAxis is null, in " + this.GetType()); } + Array.Copy(LeftAxis.GetBytes(), 0, bytes, i, 12); i += 12; + if(Size == null) { Console.WriteLine("Warning: Size is null, in " + this.GetType()); } + Array.Copy(Size.GetBytes(), 0, bytes, i, 12); i += 12; + bytes[i++] = GodLevel; + bytes[i++] = (byte)(RegionHandle % 256); + bytes[i++] = (byte)((RegionHandle >> 8) % 256); + bytes[i++] = (byte)((RegionHandle >> 16) % 256); + bytes[i++] = (byte)((RegionHandle >> 24) % 256); + bytes[i++] = (byte)((RegionHandle >> 32) % 256); + bytes[i++] = (byte)((RegionHandle >> 40) % 256); + bytes[i++] = (byte)((RegionHandle >> 48) % 256); + bytes[i++] = (byte)((RegionHandle >> 56) % 256); + bytes[i++] = AgentAccess; + if(AgentVel == null) { Console.WriteLine("Warning: AgentVel is null, in " + this.GetType()); } + Array.Copy(AgentVel.GetBytes(), 0, bytes, i, 12); i += 12; + if(AgentPos == null) { Console.WriteLine("Warning: AgentPos is null, in " + this.GetType()); } + Array.Copy(AgentPos.GetBytes(), 0, bytes, i, 12); i += 12; + if(PreyAgent == null) { Console.WriteLine("Warning: PreyAgent is null, in " + this.GetType()); } + Array.Copy(PreyAgent.GetBytes(), 0, bytes, i, 16); i += 16; + if(Throttles == null) { Console.WriteLine("Warning: Throttles is null, in " + this.GetType()); } + bytes[i++] = (byte)Throttles.Length; + Array.Copy(Throttles, 0, bytes, i, Throttles.Length); i += Throttles.Length; + if(UpAxis == null) { Console.WriteLine("Warning: UpAxis is null, in " + this.GetType()); } + Array.Copy(UpAxis.GetBytes(), 0, bytes, i, 12); i += 12; + if(AgentTextures == null) { Console.WriteLine("Warning: AgentTextures is null, in " + this.GetType()); } + bytes[i++] = (byte)(AgentTextures.Length % 256); + bytes[i++] = (byte)((AgentTextures.Length >> 8) % 256); + Array.Copy(AgentTextures, 0, bytes, i, AgentTextures.Length); i += AgentTextures.Length; + if(AtAxis == null) { Console.WriteLine("Warning: AtAxis is null, in " + this.GetType()); } + Array.Copy(AtAxis.GetBytes(), 0, bytes, i, 12); i += 12; + if(Center == null) { Console.WriteLine("Warning: Center is null, in " + this.GetType()); } + Array.Copy(Center.GetBytes(), 0, bytes, i, 12); i += 12; + if(BodyRotation == null) { Console.WriteLine("Warning: BodyRotation is null, in " + this.GetType()); } + Array.Copy(BodyRotation.GetBytes(), 0, bytes, i, 12); i += 12; ba = BitConverter.GetBytes(Aspect); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - bytes[i++] = (byte)((AlwaysRun) ? 1 : 0); + Array.Copy(ba, 0, bytes, i, 4); i += 4; + bytes[i++] = (byte)((AlwaysRun) ? 1 : 0); ba = BitConverter.GetBytes(EnergyLevel); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - bytes[i++] = (byte)(LocomotionState % 256); - bytes[i++] = (byte)((LocomotionState >> 8) % 256); - bytes[i++] = (byte)((LocomotionState >> 16) % 256); - bytes[i++] = (byte)((LocomotionState >> 24) % 256); - if(ActiveGroupID == null) { Console.WriteLine("Warning: ActiveGroupID is null, in " + this.GetType()); } - Array.Copy(ActiveGroupID.GetBytes(), 0, bytes, i, 16); i += 16; + Array.Copy(ba, 0, bytes, i, 4); i += 4; + bytes[i++] = (byte)(LocomotionState % 256); + bytes[i++] = (byte)((LocomotionState >> 8) % 256); + bytes[i++] = (byte)((LocomotionState >> 16) % 256); + bytes[i++] = (byte)((LocomotionState >> 24) % 256); + if(ActiveGroupID == null) { Console.WriteLine("Warning: ActiveGroupID is null, in " + this.GetType()); } + Array.Copy(ActiveGroupID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "ViewerCircuitCode: " + ViewerCircuitCode.ToString() + "\n"; - output += "ControlFlags: " + ControlFlags.ToString() + "\n"; - output += "Far: " + Far.ToString() + "\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "ChangedGrid: " + ChangedGrid.ToString() + "\n"; - output += "HeadRotation: " + HeadRotation.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "LeftAxis: " + LeftAxis.ToString() + "\n"; - output += "Size: " + Size.ToString() + "\n"; - output += "GodLevel: " + GodLevel.ToString() + "\n"; - output += "RegionHandle: " + RegionHandle.ToString() + "\n"; - output += "AgentAccess: " + AgentAccess.ToString() + "\n"; - output += "AgentVel: " + AgentVel.ToString() + "\n"; - output += "AgentPos: " + AgentPos.ToString() + "\n"; - output += "PreyAgent: " + PreyAgent.ToString() + "\n"; - output += Helpers.FieldToString(Throttles, "Throttles") + "\n"; - output += "UpAxis: " + UpAxis.ToString() + "\n"; - output += Helpers.FieldToString(AgentTextures, "AgentTextures") + "\n"; - output += "AtAxis: " + AtAxis.ToString() + "\n"; - output += "Center: " + Center.ToString() + "\n"; - output += "BodyRotation: " + BodyRotation.ToString() + "\n"; - output += "Aspect: " + Aspect.ToString() + "\n"; - output += "AlwaysRun: " + AlwaysRun.ToString() + "\n"; - output += "EnergyLevel: " + EnergyLevel.ToString() + "\n"; - output += "LocomotionState: " + LocomotionState.ToString() + "\n"; - output += "ActiveGroupID: " + ActiveGroupID.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "ViewerCircuitCode: " + ViewerCircuitCode.ToString() + "\n"; + output += "ControlFlags: " + ControlFlags.ToString() + "\n"; + output += "Far: " + Far.ToString() + "\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "ChangedGrid: " + ChangedGrid.ToString() + "\n"; + output += "HeadRotation: " + HeadRotation.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "LeftAxis: " + LeftAxis.ToString() + "\n"; + output += "Size: " + Size.ToString() + "\n"; + output += "GodLevel: " + GodLevel.ToString() + "\n"; + output += "RegionHandle: " + RegionHandle.ToString() + "\n"; + output += "AgentAccess: " + AgentAccess.ToString() + "\n"; + output += "AgentVel: " + AgentVel.ToString() + "\n"; + output += "AgentPos: " + AgentPos.ToString() + "\n"; + output += "PreyAgent: " + PreyAgent.ToString() + "\n"; + output += Helpers.FieldToString(Throttles, "Throttles") + "\n"; + output += "UpAxis: " + UpAxis.ToString() + "\n"; + output += Helpers.FieldToString(AgentTextures, "AgentTextures") + "\n"; + output += "AtAxis: " + AtAxis.ToString() + "\n"; + output += "Center: " + Center.ToString() + "\n"; + output += "BodyRotation: " + BodyRotation.ToString() + "\n"; + output += "Aspect: " + Aspect.ToString() + "\n"; + output += "AlwaysRun: " + AlwaysRun.ToString() + "\n"; + output += "EnergyLevel: " + EnergyLevel.ToString() + "\n"; + output += "LocomotionState: " + LocomotionState.ToString() + "\n"; + output += "ActiveGroupID: " + ActiveGroupID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// GroupData block + + /// GroupData block public class GroupDataBlock - { - /// GroupPowers field - public ulong GroupPowers; - /// GroupID field - public LLUUID GroupID; - /// AcceptNotices field - public bool AcceptNotices; - - /// Length of this block serialized in bytes + { + /// GroupPowers field + public ulong GroupPowers; + /// GroupID field + public LLUUID GroupID; + /// AcceptNotices field + public bool AcceptNotices; + + /// Length of this block serialized in bytes public int Length { get - { - return 25; + { + return 25; } } - - /// Default constructor - public GroupDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public GroupDataBlock() { } + /// Constructor for building the block from a byte array public GroupDataBlock(byte[] bytes, ref int i) - { + { try - { - GroupPowers = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); - GroupID = new LLUUID(bytes, i); i += 16; - AcceptNotices = (bytes[i++] != 0) ? (bool)true : (bool)false; + { + GroupPowers = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + GroupID = new LLUUID(bytes, i); i += 16; + AcceptNotices = (bytes[i++] != 0) ? (bool)true : (bool)false; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(GroupPowers % 256); - bytes[i++] = (byte)((GroupPowers >> 8) % 256); - bytes[i++] = (byte)((GroupPowers >> 16) % 256); - bytes[i++] = (byte)((GroupPowers >> 24) % 256); - bytes[i++] = (byte)((GroupPowers >> 32) % 256); - bytes[i++] = (byte)((GroupPowers >> 40) % 256); - bytes[i++] = (byte)((GroupPowers >> 48) % 256); - bytes[i++] = (byte)((GroupPowers >> 56) % 256); - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((AcceptNotices) ? 1 : 0); + { + bytes[i++] = (byte)(GroupPowers % 256); + bytes[i++] = (byte)((GroupPowers >> 8) % 256); + bytes[i++] = (byte)((GroupPowers >> 16) % 256); + bytes[i++] = (byte)((GroupPowers >> 24) % 256); + bytes[i++] = (byte)((GroupPowers >> 32) % 256); + bytes[i++] = (byte)((GroupPowers >> 40) % 256); + bytes[i++] = (byte)((GroupPowers >> 48) % 256); + bytes[i++] = (byte)((GroupPowers >> 56) % 256); + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((AcceptNotices) ? 1 : 0); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- GroupData --\n"; - output += "GroupPowers: " + GroupPowers.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; - output += "AcceptNotices: " + AcceptNotices.ToString() + "\n"; + { + string output = "-- GroupData --\n"; + output += "GroupPowers: " + GroupPowers.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; + output += "AcceptNotices: " + AcceptNotices.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// NVPairData block + + /// NVPairData block public class NVPairDataBlock - { - private byte[] _nvpairs; - /// NVPairs field + { + private byte[] _nvpairs; + /// NVPairs field public byte[] NVPairs - { - get { return _nvpairs; } + { + get { return _nvpairs; } set - { - if (value == null) { _nvpairs = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _nvpairs = new byte[value.Length]; Array.Copy(value, _nvpairs, value.Length); } + { + if (value == null) { _nvpairs = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _nvpairs = new byte[value.Length]; Array.Copy(value, _nvpairs, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 0; - if (NVPairs != null) { length += 2 + NVPairs.Length; } - return length; + { + int length = 0; + if (NVPairs != null) { length += 2 + NVPairs.Length; } + return length; } } - - /// Default constructor - public NVPairDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public NVPairDataBlock() { } + /// Constructor for building the block from a byte array public NVPairDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _nvpairs = new byte[length]; - Array.Copy(bytes, i, _nvpairs, 0, length); i += length; + { + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _nvpairs = new byte[length]; + Array.Copy(bytes, i, _nvpairs, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(NVPairs == null) { Console.WriteLine("Warning: NVPairs is null, in " + this.GetType()); } - bytes[i++] = (byte)(NVPairs.Length % 256); - bytes[i++] = (byte)((NVPairs.Length >> 8) % 256); - Array.Copy(NVPairs, 0, bytes, i, NVPairs.Length); i += NVPairs.Length; + { + if(NVPairs == null) { Console.WriteLine("Warning: NVPairs is null, in " + this.GetType()); } + bytes[i++] = (byte)(NVPairs.Length % 256); + bytes[i++] = (byte)((NVPairs.Length >> 8) % 256); + Array.Copy(NVPairs, 0, bytes, i, NVPairs.Length); i += NVPairs.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- NVPairData --\n"; - output += Helpers.FieldToString(NVPairs, "NVPairs") + "\n"; + { + string output = "-- NVPairData --\n"; + output += Helpers.FieldToString(NVPairs, "NVPairs") + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ChildAgentUpdate - public override PacketType Type { get { return PacketType.ChildAgentUpdate; } } - /// VisualParam block - public VisualParamBlock[] VisualParam; - /// GranterBlock block - public GranterBlockBlock[] GranterBlock; - /// AnimationData block - public AnimationDataBlock[] AnimationData; - /// AgentData block - public AgentDataBlock AgentData; - /// GroupData block - public GroupDataBlock[] GroupData; - /// NVPairData block - public NVPairDataBlock[] NVPairData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ChildAgentUpdate + public override PacketType Type { get { return PacketType.ChildAgentUpdate; } } + /// VisualParam block + public VisualParamBlock[] VisualParam; + /// GranterBlock block + public GranterBlockBlock[] GranterBlock; + /// AnimationData block + public AnimationDataBlock[] AnimationData; + /// AgentData block + public AgentDataBlock AgentData; + /// GroupData block + public GroupDataBlock[] GroupData; + /// NVPairData block + public NVPairDataBlock[] NVPairData; + + /// Default constructor public ChildAgentUpdatePacket() - { - Header = new HighHeader(); - Header.ID = 27; - Header.Reliable = true; - Header.Zerocoded = true; - VisualParam = new VisualParamBlock[0]; - GranterBlock = new GranterBlockBlock[0]; - AnimationData = new AnimationDataBlock[0]; - AgentData = new AgentDataBlock(); - GroupData = new GroupDataBlock[0]; - NVPairData = new NVPairDataBlock[0]; + { + Header = new HighHeader(); + Header.ID = 27; + Header.Reliable = true; + Header.Zerocoded = true; + VisualParam = new VisualParamBlock[0]; + GranterBlock = new GranterBlockBlock[0]; + AnimationData = new AnimationDataBlock[0]; + AgentData = new AgentDataBlock(); + GroupData = new GroupDataBlock[0]; + NVPairData = new NVPairDataBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ChildAgentUpdatePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new HighHeader(bytes, ref i, ref packetEnd); - int count = (int)bytes[i++]; - VisualParam = new VisualParamBlock[count]; - for (int j = 0; j < count; j++) - { VisualParam[j] = new VisualParamBlock(bytes, ref i); } - count = (int)bytes[i++]; - GranterBlock = new GranterBlockBlock[count]; - for (int j = 0; j < count; j++) - { GranterBlock[j] = new GranterBlockBlock(bytes, ref i); } - count = (int)bytes[i++]; - AnimationData = new AnimationDataBlock[count]; - for (int j = 0; j < count; j++) - { AnimationData[j] = new AnimationDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); - count = (int)bytes[i++]; - GroupData = new GroupDataBlock[count]; - for (int j = 0; j < count; j++) - { GroupData[j] = new GroupDataBlock(bytes, ref i); } - count = (int)bytes[i++]; - NVPairData = new NVPairDataBlock[count]; - for (int j = 0; j < count; j++) - { NVPairData[j] = new NVPairDataBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new HighHeader(bytes, ref i, ref packetEnd); + int count = (int)bytes[i++]; + VisualParam = new VisualParamBlock[count]; + for (int j = 0; j < count; j++) + { VisualParam[j] = new VisualParamBlock(bytes, ref i); } + count = (int)bytes[i++]; + GranterBlock = new GranterBlockBlock[count]; + for (int j = 0; j < count; j++) + { GranterBlock[j] = new GranterBlockBlock(bytes, ref i); } + count = (int)bytes[i++]; + AnimationData = new AnimationDataBlock[count]; + for (int j = 0; j < count; j++) + { AnimationData[j] = new AnimationDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); + count = (int)bytes[i++]; + GroupData = new GroupDataBlock[count]; + for (int j = 0; j < count; j++) + { GroupData[j] = new GroupDataBlock(bytes, ref i); } + count = (int)bytes[i++]; + NVPairData = new NVPairDataBlock[count]; + for (int j = 0; j < count; j++) + { NVPairData[j] = new NVPairDataBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ChildAgentUpdatePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - int count = (int)bytes[i++]; - VisualParam = new VisualParamBlock[count]; - for (int j = 0; j < count; j++) - { VisualParam[j] = new VisualParamBlock(bytes, ref i); } - count = (int)bytes[i++]; - GranterBlock = new GranterBlockBlock[count]; - for (int j = 0; j < count; j++) - { GranterBlock[j] = new GranterBlockBlock(bytes, ref i); } - count = (int)bytes[i++]; - AnimationData = new AnimationDataBlock[count]; - for (int j = 0; j < count; j++) - { AnimationData[j] = new AnimationDataBlock(bytes, ref i); } - AgentData = new AgentDataBlock(bytes, ref i); - count = (int)bytes[i++]; - GroupData = new GroupDataBlock[count]; - for (int j = 0; j < count; j++) - { GroupData[j] = new GroupDataBlock(bytes, ref i); } - count = (int)bytes[i++]; - NVPairData = new NVPairDataBlock[count]; - for (int j = 0; j < count; j++) - { NVPairData[j] = new NVPairDataBlock(bytes, ref i); } + { + Header = head; + int count = (int)bytes[i++]; + VisualParam = new VisualParamBlock[count]; + for (int j = 0; j < count; j++) + { VisualParam[j] = new VisualParamBlock(bytes, ref i); } + count = (int)bytes[i++]; + GranterBlock = new GranterBlockBlock[count]; + for (int j = 0; j < count; j++) + { GranterBlock[j] = new GranterBlockBlock(bytes, ref i); } + count = (int)bytes[i++]; + AnimationData = new AnimationDataBlock[count]; + for (int j = 0; j < count; j++) + { AnimationData[j] = new AnimationDataBlock(bytes, ref i); } + AgentData = new AgentDataBlock(bytes, ref i); + count = (int)bytes[i++]; + GroupData = new GroupDataBlock[count]; + for (int j = 0; j < count; j++) + { GroupData[j] = new GroupDataBlock(bytes, ref i); } + count = (int)bytes[i++]; + NVPairData = new NVPairDataBlock[count]; + for (int j = 0; j < count; j++) + { NVPairData[j] = new NVPairDataBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 5; - length += AgentData.Length;; - length++; - for (int j = 0; j < VisualParam.Length; j++) { length += VisualParam[j].Length; } - length++; - for (int j = 0; j < GranterBlock.Length; j++) { length += GranterBlock[j].Length; } - length++; - for (int j = 0; j < AnimationData.Length; j++) { length += AnimationData[j].Length; } - length++; - for (int j = 0; j < GroupData.Length; j++) { length += GroupData[j].Length; } - length++; - for (int j = 0; j < NVPairData.Length; j++) { length += NVPairData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - bytes[i++] = (byte)VisualParam.Length; - for (int j = 0; j < VisualParam.Length; j++) { VisualParam[j].ToBytes(bytes, ref i); } - bytes[i++] = (byte)GranterBlock.Length; - for (int j = 0; j < GranterBlock.Length; j++) { GranterBlock[j].ToBytes(bytes, ref i); } - bytes[i++] = (byte)AnimationData.Length; - for (int j = 0; j < AnimationData.Length; j++) { AnimationData[j].ToBytes(bytes, ref i); } - AgentData.ToBytes(bytes, ref i); - bytes[i++] = (byte)GroupData.Length; - for (int j = 0; j < GroupData.Length; j++) { GroupData[j].ToBytes(bytes, ref i); } - bytes[i++] = (byte)NVPairData.Length; - for (int j = 0; j < NVPairData.Length; j++) { NVPairData[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 5; + length += AgentData.Length;; + length++; + for (int j = 0; j < VisualParam.Length; j++) { length += VisualParam[j].Length; } + length++; + for (int j = 0; j < GranterBlock.Length; j++) { length += GranterBlock[j].Length; } + length++; + for (int j = 0; j < AnimationData.Length; j++) { length += AnimationData[j].Length; } + length++; + for (int j = 0; j < GroupData.Length; j++) { length += GroupData[j].Length; } + length++; + for (int j = 0; j < NVPairData.Length; j++) { length += NVPairData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + bytes[i++] = (byte)VisualParam.Length; + for (int j = 0; j < VisualParam.Length; j++) { VisualParam[j].ToBytes(bytes, ref i); } + bytes[i++] = (byte)GranterBlock.Length; + for (int j = 0; j < GranterBlock.Length; j++) { GranterBlock[j].ToBytes(bytes, ref i); } + bytes[i++] = (byte)AnimationData.Length; + for (int j = 0; j < AnimationData.Length; j++) { AnimationData[j].ToBytes(bytes, ref i); } + AgentData.ToBytes(bytes, ref i); + bytes[i++] = (byte)GroupData.Length; + for (int j = 0; j < GroupData.Length; j++) { GroupData[j].ToBytes(bytes, ref i); } + bytes[i++] = (byte)NVPairData.Length; + for (int j = 0; j < NVPairData.Length; j++) { NVPairData[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ChildAgentUpdate ---\n"; + { + string output = "--- ChildAgentUpdate ---\n"; for (int j = 0; j < VisualParam.Length; j++) - { + { output += VisualParam[j].ToString() + "\n"; - } + } for (int j = 0; j < GranterBlock.Length; j++) - { + { output += GranterBlock[j].ToString() + "\n"; - } + } for (int j = 0; j < AnimationData.Length; j++) - { + { output += AnimationData[j].ToString() + "\n"; - } - output += AgentData.ToString() + "\n"; + } + output += AgentData.ToString() + "\n"; for (int j = 0; j < GroupData.Length; j++) - { + { output += GroupData[j].ToString() + "\n"; - } + } for (int j = 0; j < NVPairData.Length; j++) - { + { output += NVPairData[j].ToString() + "\n"; - } + } return output; } - + } - - /// ChildAgentAlive packet + + /// ChildAgentAlive packet public class ChildAgentAlivePacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// ViewerCircuitCode field - public uint ViewerCircuitCode; - /// AgentID field - public LLUUID AgentID; - /// SessionID field - public LLUUID SessionID; - /// RegionHandle field - public ulong RegionHandle; - - /// Length of this block serialized in bytes + { + /// ViewerCircuitCode field + public uint ViewerCircuitCode; + /// AgentID field + public LLUUID AgentID; + /// SessionID field + public LLUUID SessionID; + /// RegionHandle field + public ulong RegionHandle; + + /// Length of this block serialized in bytes public int Length { get - { - return 44; + { + return 44; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - ViewerCircuitCode = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - AgentID = new LLUUID(bytes, i); i += 16; - SessionID = new LLUUID(bytes, i); i += 16; - RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + { + ViewerCircuitCode = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + AgentID = new LLUUID(bytes, i); i += 16; + SessionID = new LLUUID(bytes, i); i += 16; + RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(ViewerCircuitCode % 256); - bytes[i++] = (byte)((ViewerCircuitCode >> 8) % 256); - bytes[i++] = (byte)((ViewerCircuitCode >> 16) % 256); - bytes[i++] = (byte)((ViewerCircuitCode >> 24) % 256); - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(RegionHandle % 256); - bytes[i++] = (byte)((RegionHandle >> 8) % 256); - bytes[i++] = (byte)((RegionHandle >> 16) % 256); - bytes[i++] = (byte)((RegionHandle >> 24) % 256); - bytes[i++] = (byte)((RegionHandle >> 32) % 256); - bytes[i++] = (byte)((RegionHandle >> 40) % 256); - bytes[i++] = (byte)((RegionHandle >> 48) % 256); - bytes[i++] = (byte)((RegionHandle >> 56) % 256); + { + bytes[i++] = (byte)(ViewerCircuitCode % 256); + bytes[i++] = (byte)((ViewerCircuitCode >> 8) % 256); + bytes[i++] = (byte)((ViewerCircuitCode >> 16) % 256); + bytes[i++] = (byte)((ViewerCircuitCode >> 24) % 256); + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(RegionHandle % 256); + bytes[i++] = (byte)((RegionHandle >> 8) % 256); + bytes[i++] = (byte)((RegionHandle >> 16) % 256); + bytes[i++] = (byte)((RegionHandle >> 24) % 256); + bytes[i++] = (byte)((RegionHandle >> 32) % 256); + bytes[i++] = (byte)((RegionHandle >> 40) % 256); + bytes[i++] = (byte)((RegionHandle >> 48) % 256); + bytes[i++] = (byte)((RegionHandle >> 56) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "ViewerCircuitCode: " + ViewerCircuitCode.ToString() + "\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "RegionHandle: " + RegionHandle.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "ViewerCircuitCode: " + ViewerCircuitCode.ToString() + "\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "RegionHandle: " + RegionHandle.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ChildAgentAlive - public override PacketType Type { get { return PacketType.ChildAgentAlive; } } - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ChildAgentAlive + public override PacketType Type { get { return PacketType.ChildAgentAlive; } } + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ChildAgentAlivePacket() - { - Header = new HighHeader(); - Header.ID = 28; - Header.Reliable = true; - AgentData = new AgentDataBlock(); + { + Header = new HighHeader(); + Header.ID = 28; + Header.Reliable = true; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ChildAgentAlivePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new HighHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new HighHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ChildAgentAlivePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 5; - length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 5; + length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ChildAgentAlive ---\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- ChildAgentAlive ---\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// ChildAgentPositionUpdate packet + + /// ChildAgentPositionUpdate packet public class ChildAgentPositionUpdatePacket : Packet - { - /// AgentData block + { + /// AgentData block public class AgentDataBlock - { - /// ViewerCircuitCode field - public uint ViewerCircuitCode; - /// AgentID field - public LLUUID AgentID; - /// ChangedGrid field - public bool ChangedGrid; - /// SessionID field - public LLUUID SessionID; - /// LeftAxis field - public LLVector3 LeftAxis; - /// Size field - public LLVector3 Size; - /// RegionHandle field - public ulong RegionHandle; - /// AgentVel field - public LLVector3 AgentVel; - /// AgentPos field - public LLVector3 AgentPos; - /// UpAxis field - public LLVector3 UpAxis; - /// AtAxis field - public LLVector3 AtAxis; - /// Center field - public LLVector3 Center; - - /// Length of this block serialized in bytes + { + /// ViewerCircuitCode field + public uint ViewerCircuitCode; + /// AgentID field + public LLUUID AgentID; + /// ChangedGrid field + public bool ChangedGrid; + /// SessionID field + public LLUUID SessionID; + /// LeftAxis field + public LLVector3 LeftAxis; + /// Size field + public LLVector3 Size; + /// RegionHandle field + public ulong RegionHandle; + /// AgentVel field + public LLVector3 AgentVel; + /// AgentPos field + public LLVector3 AgentPos; + /// UpAxis field + public LLVector3 UpAxis; + /// AtAxis field + public LLVector3 AtAxis; + /// Center field + public LLVector3 Center; + + /// Length of this block serialized in bytes public int Length { get - { - return 129; + { + return 129; } } - - /// Default constructor - public AgentDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public AgentDataBlock() { } + /// Constructor for building the block from a byte array public AgentDataBlock(byte[] bytes, ref int i) - { + { try - { - ViewerCircuitCode = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - AgentID = new LLUUID(bytes, i); i += 16; - ChangedGrid = (bytes[i++] != 0) ? (bool)true : (bool)false; - SessionID = new LLUUID(bytes, i); i += 16; - LeftAxis = new LLVector3(bytes, i); i += 12; - Size = new LLVector3(bytes, i); i += 12; - RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); - AgentVel = new LLVector3(bytes, i); i += 12; - AgentPos = new LLVector3(bytes, i); i += 12; - UpAxis = new LLVector3(bytes, i); i += 12; - AtAxis = new LLVector3(bytes, i); i += 12; - Center = new LLVector3(bytes, i); i += 12; + { + ViewerCircuitCode = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + AgentID = new LLUUID(bytes, i); i += 16; + ChangedGrid = (bytes[i++] != 0) ? (bool)true : (bool)false; + SessionID = new LLUUID(bytes, i); i += 16; + LeftAxis = new LLVector3(bytes, i); i += 12; + Size = new LLVector3(bytes, i); i += 12; + RegionHandle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + AgentVel = new LLVector3(bytes, i); i += 12; + AgentPos = new LLVector3(bytes, i); i += 12; + UpAxis = new LLVector3(bytes, i); i += 12; + AtAxis = new LLVector3(bytes, i); i += 12; + Center = new LLVector3(bytes, i); i += 12; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)(ViewerCircuitCode % 256); - bytes[i++] = (byte)((ViewerCircuitCode >> 8) % 256); - bytes[i++] = (byte)((ViewerCircuitCode >> 16) % 256); - bytes[i++] = (byte)((ViewerCircuitCode >> 24) % 256); - if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } - Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((ChangedGrid) ? 1 : 0); - if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } - Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; - if(LeftAxis == null) { Console.WriteLine("Warning: LeftAxis is null, in " + this.GetType()); } - Array.Copy(LeftAxis.GetBytes(), 0, bytes, i, 12); i += 12; - if(Size == null) { Console.WriteLine("Warning: Size is null, in " + this.GetType()); } - Array.Copy(Size.GetBytes(), 0, bytes, i, 12); i += 12; - bytes[i++] = (byte)(RegionHandle % 256); - bytes[i++] = (byte)((RegionHandle >> 8) % 256); - bytes[i++] = (byte)((RegionHandle >> 16) % 256); - bytes[i++] = (byte)((RegionHandle >> 24) % 256); - bytes[i++] = (byte)((RegionHandle >> 32) % 256); - bytes[i++] = (byte)((RegionHandle >> 40) % 256); - bytes[i++] = (byte)((RegionHandle >> 48) % 256); - bytes[i++] = (byte)((RegionHandle >> 56) % 256); - if(AgentVel == null) { Console.WriteLine("Warning: AgentVel is null, in " + this.GetType()); } - Array.Copy(AgentVel.GetBytes(), 0, bytes, i, 12); i += 12; - if(AgentPos == null) { Console.WriteLine("Warning: AgentPos is null, in " + this.GetType()); } - Array.Copy(AgentPos.GetBytes(), 0, bytes, i, 12); i += 12; - if(UpAxis == null) { Console.WriteLine("Warning: UpAxis is null, in " + this.GetType()); } - Array.Copy(UpAxis.GetBytes(), 0, bytes, i, 12); i += 12; - if(AtAxis == null) { Console.WriteLine("Warning: AtAxis is null, in " + this.GetType()); } - Array.Copy(AtAxis.GetBytes(), 0, bytes, i, 12); i += 12; - if(Center == null) { Console.WriteLine("Warning: Center is null, in " + this.GetType()); } - Array.Copy(Center.GetBytes(), 0, bytes, i, 12); i += 12; + { + bytes[i++] = (byte)(ViewerCircuitCode % 256); + bytes[i++] = (byte)((ViewerCircuitCode >> 8) % 256); + bytes[i++] = (byte)((ViewerCircuitCode >> 16) % 256); + bytes[i++] = (byte)((ViewerCircuitCode >> 24) % 256); + if(AgentID == null) { Console.WriteLine("Warning: AgentID is null, in " + this.GetType()); } + Array.Copy(AgentID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((ChangedGrid) ? 1 : 0); + if(SessionID == null) { Console.WriteLine("Warning: SessionID is null, in " + this.GetType()); } + Array.Copy(SessionID.GetBytes(), 0, bytes, i, 16); i += 16; + if(LeftAxis == null) { Console.WriteLine("Warning: LeftAxis is null, in " + this.GetType()); } + Array.Copy(LeftAxis.GetBytes(), 0, bytes, i, 12); i += 12; + if(Size == null) { Console.WriteLine("Warning: Size is null, in " + this.GetType()); } + Array.Copy(Size.GetBytes(), 0, bytes, i, 12); i += 12; + bytes[i++] = (byte)(RegionHandle % 256); + bytes[i++] = (byte)((RegionHandle >> 8) % 256); + bytes[i++] = (byte)((RegionHandle >> 16) % 256); + bytes[i++] = (byte)((RegionHandle >> 24) % 256); + bytes[i++] = (byte)((RegionHandle >> 32) % 256); + bytes[i++] = (byte)((RegionHandle >> 40) % 256); + bytes[i++] = (byte)((RegionHandle >> 48) % 256); + bytes[i++] = (byte)((RegionHandle >> 56) % 256); + if(AgentVel == null) { Console.WriteLine("Warning: AgentVel is null, in " + this.GetType()); } + Array.Copy(AgentVel.GetBytes(), 0, bytes, i, 12); i += 12; + if(AgentPos == null) { Console.WriteLine("Warning: AgentPos is null, in " + this.GetType()); } + Array.Copy(AgentPos.GetBytes(), 0, bytes, i, 12); i += 12; + if(UpAxis == null) { Console.WriteLine("Warning: UpAxis is null, in " + this.GetType()); } + Array.Copy(UpAxis.GetBytes(), 0, bytes, i, 12); i += 12; + if(AtAxis == null) { Console.WriteLine("Warning: AtAxis is null, in " + this.GetType()); } + Array.Copy(AtAxis.GetBytes(), 0, bytes, i, 12); i += 12; + if(Center == null) { Console.WriteLine("Warning: Center is null, in " + this.GetType()); } + Array.Copy(Center.GetBytes(), 0, bytes, i, 12); i += 12; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- AgentData --\n"; - output += "ViewerCircuitCode: " + ViewerCircuitCode.ToString() + "\n"; - output += "AgentID: " + AgentID.ToString() + "\n"; - output += "ChangedGrid: " + ChangedGrid.ToString() + "\n"; - output += "SessionID: " + SessionID.ToString() + "\n"; - output += "LeftAxis: " + LeftAxis.ToString() + "\n"; - output += "Size: " + Size.ToString() + "\n"; - output += "RegionHandle: " + RegionHandle.ToString() + "\n"; - output += "AgentVel: " + AgentVel.ToString() + "\n"; - output += "AgentPos: " + AgentPos.ToString() + "\n"; - output += "UpAxis: " + UpAxis.ToString() + "\n"; - output += "AtAxis: " + AtAxis.ToString() + "\n"; - output += "Center: " + Center.ToString() + "\n"; + { + string output = "-- AgentData --\n"; + output += "ViewerCircuitCode: " + ViewerCircuitCode.ToString() + "\n"; + output += "AgentID: " + AgentID.ToString() + "\n"; + output += "ChangedGrid: " + ChangedGrid.ToString() + "\n"; + output += "SessionID: " + SessionID.ToString() + "\n"; + output += "LeftAxis: " + LeftAxis.ToString() + "\n"; + output += "Size: " + Size.ToString() + "\n"; + output += "RegionHandle: " + RegionHandle.ToString() + "\n"; + output += "AgentVel: " + AgentVel.ToString() + "\n"; + output += "AgentPos: " + AgentPos.ToString() + "\n"; + output += "UpAxis: " + UpAxis.ToString() + "\n"; + output += "AtAxis: " + AtAxis.ToString() + "\n"; + output += "Center: " + Center.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.ChildAgentPositionUpdate - public override PacketType Type { get { return PacketType.ChildAgentPositionUpdate; } } - /// AgentData block - public AgentDataBlock AgentData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.ChildAgentPositionUpdate + public override PacketType Type { get { return PacketType.ChildAgentPositionUpdate; } } + /// AgentData block + public AgentDataBlock AgentData; + + /// Default constructor public ChildAgentPositionUpdatePacket() - { - Header = new HighHeader(); - Header.ID = 29; - Header.Reliable = true; - AgentData = new AgentDataBlock(); + { + Header = new HighHeader(); + Header.ID = 29; + Header.Reliable = true; + AgentData = new AgentDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public ChildAgentPositionUpdatePacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new HighHeader(bytes, ref i, ref packetEnd); - AgentData = new AgentDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new HighHeader(bytes, ref i, ref packetEnd); + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public ChildAgentPositionUpdatePacket(Header head, byte[] bytes, ref int i) - { - Header = head; - AgentData = new AgentDataBlock(bytes, ref i); + { + Header = head; + AgentData = new AgentDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 5; - length += AgentData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - AgentData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 5; + length += AgentData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + AgentData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- ChildAgentPositionUpdate ---\n"; - output += AgentData.ToString() + "\n"; + { + string output = "--- ChildAgentPositionUpdate ---\n"; + output += AgentData.ToString() + "\n"; return output; } - + } - - /// PassObject packet + + /// PassObject packet public class PassObjectPacket : Packet - { - /// ObjectData block + { + /// ObjectData block public class ObjectDataBlock - { - /// ID field - public LLUUID ID; - /// GroupOwned field - public bool GroupOwned; - /// PathTwistBegin field - public sbyte PathTwistBegin; - /// PathEnd field - public byte PathEnd; - /// AngVelX field - public short AngVelX; - /// AngVelY field - public short AngVelY; - /// AngVelZ field - public short AngVelZ; - /// BaseMask field - public uint BaseMask; - /// ProfileBegin field - public byte ProfileBegin; - /// SubType field - public short SubType; - /// PathRadiusOffset field - public sbyte PathRadiusOffset; - /// VelX field - public short VelX; - /// PathSkew field - public sbyte PathSkew; - /// VelY field - public short VelY; - /// VelZ field - public short VelZ; - private byte[] _data; - /// Data field + { + /// ID field + public LLUUID ID; + /// GroupOwned field + public bool GroupOwned; + /// PathTwistBegin field + public sbyte PathTwistBegin; + /// PathEnd field + public byte PathEnd; + /// AngVelX field + public short AngVelX; + /// AngVelY field + public short AngVelY; + /// AngVelZ field + public short AngVelZ; + /// BaseMask field + public uint BaseMask; + /// ProfileBegin field + public byte ProfileBegin; + /// SubType field + public short SubType; + /// PathRadiusOffset field + public sbyte PathRadiusOffset; + /// VelX field + public short VelX; + /// PathSkew field + public sbyte PathSkew; + /// VelY field + public short VelY; + /// VelZ field + public short VelZ; + private byte[] _data; + /// Data field public byte[] Data - { - get { return _data; } + { + get { return _data; } set - { - if (value == null) { _data = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _data = new byte[value.Length]; Array.Copy(value, _data, value.Length); } + { + if (value == null) { _data = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _data = new byte[value.Length]; Array.Copy(value, _data, value.Length); } } - } - /// ParentID field - public LLUUID ParentID; - /// PosX field - public short PosX; - /// PosY field - public short PosY; - /// PosZ field - public short PosZ; - /// ProfileCurve field - public byte ProfileCurve; - /// PathScaleX field - public byte PathScaleX; - /// PathScaleY field - public byte PathScaleY; - /// GroupID field - public LLUUID GroupID; - /// Material field - public byte Material; - /// OwnerID field - public LLUUID OwnerID; - /// CreatorID field - public LLUUID CreatorID; - /// PathShearX field - public byte PathShearX; - /// PathShearY field - public byte PathShearY; - /// PathTaperX field - public sbyte PathTaperX; - /// PathTaperY field - public sbyte PathTaperY; - /// ProfileEnd field - public byte ProfileEnd; - /// UsePhysics field - public byte UsePhysics; - /// PathBegin field - public byte PathBegin; - /// Active field - public byte Active; - /// PCode field - public byte PCode; - /// PathCurve field - public byte PathCurve; - /// EveryoneMask field - public uint EveryoneMask; - /// Scale field - public LLVector3 Scale; - /// State field - public byte State; - /// PathTwist field - public sbyte PathTwist; - private byte[] _textureentry; - /// TextureEntry field + } + /// ParentID field + public LLUUID ParentID; + /// PosX field + public short PosX; + /// PosY field + public short PosY; + /// PosZ field + public short PosZ; + /// ProfileCurve field + public byte ProfileCurve; + /// PathScaleX field + public byte PathScaleX; + /// PathScaleY field + public byte PathScaleY; + /// GroupID field + public LLUUID GroupID; + /// Material field + public byte Material; + /// OwnerID field + public LLUUID OwnerID; + /// CreatorID field + public LLUUID CreatorID; + /// PathShearX field + public byte PathShearX; + /// PathShearY field + public byte PathShearY; + /// PathTaperX field + public sbyte PathTaperX; + /// PathTaperY field + public sbyte PathTaperY; + /// ProfileEnd field + public byte ProfileEnd; + /// UsePhysics field + public byte UsePhysics; + /// PathBegin field + public byte PathBegin; + /// Active field + public byte Active; + /// PCode field + public byte PCode; + /// PathCurve field + public byte PathCurve; + /// EveryoneMask field + public uint EveryoneMask; + /// Scale field + public LLVector3 Scale; + /// State field + public byte State; + /// PathTwist field + public sbyte PathTwist; + private byte[] _textureentry; + /// TextureEntry field public byte[] TextureEntry - { - get { return _textureentry; } + { + get { return _textureentry; } set - { - if (value == null) { _textureentry = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _textureentry = new byte[value.Length]; Array.Copy(value, _textureentry, value.Length); } + { + if (value == null) { _textureentry = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _textureentry = new byte[value.Length]; Array.Copy(value, _textureentry, value.Length); } } - } - /// ProfileHollow field - public byte ProfileHollow; - /// PathRevolutions field - public byte PathRevolutions; - /// Rotation field - public LLQuaternion Rotation; - /// NextOwnerMask field - public uint NextOwnerMask; - /// GroupMask field - public uint GroupMask; - /// OwnerMask field - public uint OwnerMask; - - /// Length of this block serialized in bytes + } + /// ProfileHollow field + public byte ProfileHollow; + /// PathRevolutions field + public byte PathRevolutions; + /// Rotation field + public LLQuaternion Rotation; + /// NextOwnerMask field + public uint NextOwnerMask; + /// GroupMask field + public uint GroupMask; + /// OwnerMask field + public uint OwnerMask; + + /// Length of this block serialized in bytes public int Length { get - { - int length = 168; - if (Data != null) { length += 2 + Data.Length; } - if (TextureEntry != null) { length += 2 + TextureEntry.Length; } - return length; + { + int length = 168; + if (Data != null) { length += 2 + Data.Length; } + if (TextureEntry != null) { length += 2 + TextureEntry.Length; } + return length; } } - - /// Default constructor - public ObjectDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public ObjectDataBlock() { } + /// Constructor for building the block from a byte array public ObjectDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - ID = new LLUUID(bytes, i); i += 16; - GroupOwned = (bytes[i++] != 0) ? (bool)true : (bool)false; - PathTwistBegin = (sbyte)bytes[i++]; - PathEnd = (byte)bytes[i++]; - AngVelX = (short)(bytes[i++] + (bytes[i++] << 8)); - AngVelY = (short)(bytes[i++] + (bytes[i++] << 8)); - AngVelZ = (short)(bytes[i++] + (bytes[i++] << 8)); - BaseMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - ProfileBegin = (byte)bytes[i++]; - SubType = (short)(bytes[i++] + (bytes[i++] << 8)); - PathRadiusOffset = (sbyte)bytes[i++]; - VelX = (short)(bytes[i++] + (bytes[i++] << 8)); - PathSkew = (sbyte)bytes[i++]; - VelY = (short)(bytes[i++] + (bytes[i++] << 8)); - VelZ = (short)(bytes[i++] + (bytes[i++] << 8)); - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _data = new byte[length]; - Array.Copy(bytes, i, _data, 0, length); i += length; - ParentID = new LLUUID(bytes, i); i += 16; - PosX = (short)(bytes[i++] + (bytes[i++] << 8)); - PosY = (short)(bytes[i++] + (bytes[i++] << 8)); - PosZ = (short)(bytes[i++] + (bytes[i++] << 8)); - ProfileCurve = (byte)bytes[i++]; - PathScaleX = (byte)bytes[i++]; - PathScaleY = (byte)bytes[i++]; - GroupID = new LLUUID(bytes, i); i += 16; - Material = (byte)bytes[i++]; - OwnerID = new LLUUID(bytes, i); i += 16; - CreatorID = new LLUUID(bytes, i); i += 16; - PathShearX = (byte)bytes[i++]; - PathShearY = (byte)bytes[i++]; - PathTaperX = (sbyte)bytes[i++]; - PathTaperY = (sbyte)bytes[i++]; - ProfileEnd = (byte)bytes[i++]; - UsePhysics = (byte)bytes[i++]; - PathBegin = (byte)bytes[i++]; - Active = (byte)bytes[i++]; - PCode = (byte)bytes[i++]; - PathCurve = (byte)bytes[i++]; - EveryoneMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - Scale = new LLVector3(bytes, i); i += 12; - State = (byte)bytes[i++]; - PathTwist = (sbyte)bytes[i++]; - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _textureentry = new byte[length]; - Array.Copy(bytes, i, _textureentry, 0, length); i += length; - ProfileHollow = (byte)bytes[i++]; - PathRevolutions = (byte)bytes[i++]; - Rotation = new LLQuaternion(bytes, i, true); i += 12; - NextOwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - GroupMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); - OwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + { + ID = new LLUUID(bytes, i); i += 16; + GroupOwned = (bytes[i++] != 0) ? (bool)true : (bool)false; + PathTwistBegin = (sbyte)bytes[i++]; + PathEnd = (byte)bytes[i++]; + AngVelX = (short)(bytes[i++] + (bytes[i++] << 8)); + AngVelY = (short)(bytes[i++] + (bytes[i++] << 8)); + AngVelZ = (short)(bytes[i++] + (bytes[i++] << 8)); + BaseMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + ProfileBegin = (byte)bytes[i++]; + SubType = (short)(bytes[i++] + (bytes[i++] << 8)); + PathRadiusOffset = (sbyte)bytes[i++]; + VelX = (short)(bytes[i++] + (bytes[i++] << 8)); + PathSkew = (sbyte)bytes[i++]; + VelY = (short)(bytes[i++] + (bytes[i++] << 8)); + VelZ = (short)(bytes[i++] + (bytes[i++] << 8)); + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _data = new byte[length]; + Array.Copy(bytes, i, _data, 0, length); i += length; + ParentID = new LLUUID(bytes, i); i += 16; + PosX = (short)(bytes[i++] + (bytes[i++] << 8)); + PosY = (short)(bytes[i++] + (bytes[i++] << 8)); + PosZ = (short)(bytes[i++] + (bytes[i++] << 8)); + ProfileCurve = (byte)bytes[i++]; + PathScaleX = (byte)bytes[i++]; + PathScaleY = (byte)bytes[i++]; + GroupID = new LLUUID(bytes, i); i += 16; + Material = (byte)bytes[i++]; + OwnerID = new LLUUID(bytes, i); i += 16; + CreatorID = new LLUUID(bytes, i); i += 16; + PathShearX = (byte)bytes[i++]; + PathShearY = (byte)bytes[i++]; + PathTaperX = (sbyte)bytes[i++]; + PathTaperY = (sbyte)bytes[i++]; + ProfileEnd = (byte)bytes[i++]; + UsePhysics = (byte)bytes[i++]; + PathBegin = (byte)bytes[i++]; + Active = (byte)bytes[i++]; + PCode = (byte)bytes[i++]; + PathCurve = (byte)bytes[i++]; + EveryoneMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + Scale = new LLVector3(bytes, i); i += 12; + State = (byte)bytes[i++]; + PathTwist = (sbyte)bytes[i++]; + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _textureentry = new byte[length]; + Array.Copy(bytes, i, _textureentry, 0, length); i += length; + ProfileHollow = (byte)bytes[i++]; + PathRevolutions = (byte)bytes[i++]; + Rotation = new LLQuaternion(bytes, i, true); i += 12; + NextOwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + GroupMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); + OwnerMask = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24)); } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } - Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)((GroupOwned) ? 1 : 0); - bytes[i++] = (byte)PathTwistBegin; - bytes[i++] = PathEnd; - bytes[i++] = (byte)(AngVelX % 256); - bytes[i++] = (byte)((AngVelX >> 8) % 256); - bytes[i++] = (byte)(AngVelY % 256); - bytes[i++] = (byte)((AngVelY >> 8) % 256); - bytes[i++] = (byte)(AngVelZ % 256); - bytes[i++] = (byte)((AngVelZ >> 8) % 256); - bytes[i++] = (byte)(BaseMask % 256); - bytes[i++] = (byte)((BaseMask >> 8) % 256); - bytes[i++] = (byte)((BaseMask >> 16) % 256); - bytes[i++] = (byte)((BaseMask >> 24) % 256); - bytes[i++] = ProfileBegin; - bytes[i++] = (byte)(SubType % 256); - bytes[i++] = (byte)((SubType >> 8) % 256); - bytes[i++] = (byte)PathRadiusOffset; - bytes[i++] = (byte)(VelX % 256); - bytes[i++] = (byte)((VelX >> 8) % 256); - bytes[i++] = (byte)PathSkew; - bytes[i++] = (byte)(VelY % 256); - bytes[i++] = (byte)((VelY >> 8) % 256); - bytes[i++] = (byte)(VelZ % 256); - bytes[i++] = (byte)((VelZ >> 8) % 256); - if(Data == null) { Console.WriteLine("Warning: Data is null, in " + this.GetType()); } - bytes[i++] = (byte)(Data.Length % 256); - bytes[i++] = (byte)((Data.Length >> 8) % 256); - Array.Copy(Data, 0, bytes, i, Data.Length); i += Data.Length; - if(ParentID == null) { Console.WriteLine("Warning: ParentID is null, in " + this.GetType()); } - Array.Copy(ParentID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(PosX % 256); - bytes[i++] = (byte)((PosX >> 8) % 256); - bytes[i++] = (byte)(PosY % 256); - bytes[i++] = (byte)((PosY >> 8) % 256); - bytes[i++] = (byte)(PosZ % 256); - bytes[i++] = (byte)((PosZ >> 8) % 256); - bytes[i++] = ProfileCurve; - bytes[i++] = PathScaleX; - bytes[i++] = PathScaleY; - if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } - Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = Material; - if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } - Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; - if(CreatorID == null) { Console.WriteLine("Warning: CreatorID is null, in " + this.GetType()); } - Array.Copy(CreatorID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = PathShearX; - bytes[i++] = PathShearY; - bytes[i++] = (byte)PathTaperX; - bytes[i++] = (byte)PathTaperY; - bytes[i++] = ProfileEnd; - bytes[i++] = UsePhysics; - bytes[i++] = PathBegin; - bytes[i++] = Active; - bytes[i++] = PCode; - bytes[i++] = PathCurve; - bytes[i++] = (byte)(EveryoneMask % 256); - bytes[i++] = (byte)((EveryoneMask >> 8) % 256); - bytes[i++] = (byte)((EveryoneMask >> 16) % 256); - bytes[i++] = (byte)((EveryoneMask >> 24) % 256); - if(Scale == null) { Console.WriteLine("Warning: Scale is null, in " + this.GetType()); } - Array.Copy(Scale.GetBytes(), 0, bytes, i, 12); i += 12; - bytes[i++] = State; - bytes[i++] = (byte)PathTwist; - if(TextureEntry == null) { Console.WriteLine("Warning: TextureEntry is null, in " + this.GetType()); } - bytes[i++] = (byte)(TextureEntry.Length % 256); - bytes[i++] = (byte)((TextureEntry.Length >> 8) % 256); - Array.Copy(TextureEntry, 0, bytes, i, TextureEntry.Length); i += TextureEntry.Length; - bytes[i++] = ProfileHollow; - bytes[i++] = PathRevolutions; - if(Rotation == null) { Console.WriteLine("Warning: Rotation is null, in " + this.GetType()); } - Array.Copy(Rotation.GetBytes(), 0, bytes, i, 12); i += 12; - bytes[i++] = (byte)(NextOwnerMask % 256); - bytes[i++] = (byte)((NextOwnerMask >> 8) % 256); - bytes[i++] = (byte)((NextOwnerMask >> 16) % 256); - bytes[i++] = (byte)((NextOwnerMask >> 24) % 256); - bytes[i++] = (byte)(GroupMask % 256); - bytes[i++] = (byte)((GroupMask >> 8) % 256); - bytes[i++] = (byte)((GroupMask >> 16) % 256); - bytes[i++] = (byte)((GroupMask >> 24) % 256); - bytes[i++] = (byte)(OwnerMask % 256); - bytes[i++] = (byte)((OwnerMask >> 8) % 256); - bytes[i++] = (byte)((OwnerMask >> 16) % 256); - bytes[i++] = (byte)((OwnerMask >> 24) % 256); + { + if(ID == null) { Console.WriteLine("Warning: ID is null, in " + this.GetType()); } + Array.Copy(ID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)((GroupOwned) ? 1 : 0); + bytes[i++] = (byte)PathTwistBegin; + bytes[i++] = PathEnd; + bytes[i++] = (byte)(AngVelX % 256); + bytes[i++] = (byte)((AngVelX >> 8) % 256); + bytes[i++] = (byte)(AngVelY % 256); + bytes[i++] = (byte)((AngVelY >> 8) % 256); + bytes[i++] = (byte)(AngVelZ % 256); + bytes[i++] = (byte)((AngVelZ >> 8) % 256); + bytes[i++] = (byte)(BaseMask % 256); + bytes[i++] = (byte)((BaseMask >> 8) % 256); + bytes[i++] = (byte)((BaseMask >> 16) % 256); + bytes[i++] = (byte)((BaseMask >> 24) % 256); + bytes[i++] = ProfileBegin; + bytes[i++] = (byte)(SubType % 256); + bytes[i++] = (byte)((SubType >> 8) % 256); + bytes[i++] = (byte)PathRadiusOffset; + bytes[i++] = (byte)(VelX % 256); + bytes[i++] = (byte)((VelX >> 8) % 256); + bytes[i++] = (byte)PathSkew; + bytes[i++] = (byte)(VelY % 256); + bytes[i++] = (byte)((VelY >> 8) % 256); + bytes[i++] = (byte)(VelZ % 256); + bytes[i++] = (byte)((VelZ >> 8) % 256); + if(Data == null) { Console.WriteLine("Warning: Data is null, in " + this.GetType()); } + bytes[i++] = (byte)(Data.Length % 256); + bytes[i++] = (byte)((Data.Length >> 8) % 256); + Array.Copy(Data, 0, bytes, i, Data.Length); i += Data.Length; + if(ParentID == null) { Console.WriteLine("Warning: ParentID is null, in " + this.GetType()); } + Array.Copy(ParentID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(PosX % 256); + bytes[i++] = (byte)((PosX >> 8) % 256); + bytes[i++] = (byte)(PosY % 256); + bytes[i++] = (byte)((PosY >> 8) % 256); + bytes[i++] = (byte)(PosZ % 256); + bytes[i++] = (byte)((PosZ >> 8) % 256); + bytes[i++] = ProfileCurve; + bytes[i++] = PathScaleX; + bytes[i++] = PathScaleY; + if(GroupID == null) { Console.WriteLine("Warning: GroupID is null, in " + this.GetType()); } + Array.Copy(GroupID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = Material; + if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } + Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; + if(CreatorID == null) { Console.WriteLine("Warning: CreatorID is null, in " + this.GetType()); } + Array.Copy(CreatorID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = PathShearX; + bytes[i++] = PathShearY; + bytes[i++] = (byte)PathTaperX; + bytes[i++] = (byte)PathTaperY; + bytes[i++] = ProfileEnd; + bytes[i++] = UsePhysics; + bytes[i++] = PathBegin; + bytes[i++] = Active; + bytes[i++] = PCode; + bytes[i++] = PathCurve; + bytes[i++] = (byte)(EveryoneMask % 256); + bytes[i++] = (byte)((EveryoneMask >> 8) % 256); + bytes[i++] = (byte)((EveryoneMask >> 16) % 256); + bytes[i++] = (byte)((EveryoneMask >> 24) % 256); + if(Scale == null) { Console.WriteLine("Warning: Scale is null, in " + this.GetType()); } + Array.Copy(Scale.GetBytes(), 0, bytes, i, 12); i += 12; + bytes[i++] = State; + bytes[i++] = (byte)PathTwist; + if(TextureEntry == null) { Console.WriteLine("Warning: TextureEntry is null, in " + this.GetType()); } + bytes[i++] = (byte)(TextureEntry.Length % 256); + bytes[i++] = (byte)((TextureEntry.Length >> 8) % 256); + Array.Copy(TextureEntry, 0, bytes, i, TextureEntry.Length); i += TextureEntry.Length; + bytes[i++] = ProfileHollow; + bytes[i++] = PathRevolutions; + if(Rotation == null) { Console.WriteLine("Warning: Rotation is null, in " + this.GetType()); } + Array.Copy(Rotation.GetBytes(), 0, bytes, i, 12); i += 12; + bytes[i++] = (byte)(NextOwnerMask % 256); + bytes[i++] = (byte)((NextOwnerMask >> 8) % 256); + bytes[i++] = (byte)((NextOwnerMask >> 16) % 256); + bytes[i++] = (byte)((NextOwnerMask >> 24) % 256); + bytes[i++] = (byte)(GroupMask % 256); + bytes[i++] = (byte)((GroupMask >> 8) % 256); + bytes[i++] = (byte)((GroupMask >> 16) % 256); + bytes[i++] = (byte)((GroupMask >> 24) % 256); + bytes[i++] = (byte)(OwnerMask % 256); + bytes[i++] = (byte)((OwnerMask >> 8) % 256); + bytes[i++] = (byte)((OwnerMask >> 16) % 256); + bytes[i++] = (byte)((OwnerMask >> 24) % 256); } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- ObjectData --\n"; - output += "ID: " + ID.ToString() + "\n"; - output += "GroupOwned: " + GroupOwned.ToString() + "\n"; - output += "PathTwistBegin: " + PathTwistBegin.ToString() + "\n"; - output += "PathEnd: " + PathEnd.ToString() + "\n"; - output += "AngVelX: " + AngVelX.ToString() + "\n"; - output += "AngVelY: " + AngVelY.ToString() + "\n"; - output += "AngVelZ: " + AngVelZ.ToString() + "\n"; - output += "BaseMask: " + BaseMask.ToString() + "\n"; - output += "ProfileBegin: " + ProfileBegin.ToString() + "\n"; - output += "SubType: " + SubType.ToString() + "\n"; - output += "PathRadiusOffset: " + PathRadiusOffset.ToString() + "\n"; - output += "VelX: " + VelX.ToString() + "\n"; - output += "PathSkew: " + PathSkew.ToString() + "\n"; - output += "VelY: " + VelY.ToString() + "\n"; - output += "VelZ: " + VelZ.ToString() + "\n"; - output += Helpers.FieldToString(Data, "Data") + "\n"; - output += "ParentID: " + ParentID.ToString() + "\n"; - output += "PosX: " + PosX.ToString() + "\n"; - output += "PosY: " + PosY.ToString() + "\n"; - output += "PosZ: " + PosZ.ToString() + "\n"; - output += "ProfileCurve: " + ProfileCurve.ToString() + "\n"; - output += "PathScaleX: " + PathScaleX.ToString() + "\n"; - output += "PathScaleY: " + PathScaleY.ToString() + "\n"; - output += "GroupID: " + GroupID.ToString() + "\n"; - output += "Material: " + Material.ToString() + "\n"; - output += "OwnerID: " + OwnerID.ToString() + "\n"; - output += "CreatorID: " + CreatorID.ToString() + "\n"; - output += "PathShearX: " + PathShearX.ToString() + "\n"; - output += "PathShearY: " + PathShearY.ToString() + "\n"; - output += "PathTaperX: " + PathTaperX.ToString() + "\n"; - output += "PathTaperY: " + PathTaperY.ToString() + "\n"; - output += "ProfileEnd: " + ProfileEnd.ToString() + "\n"; - output += "UsePhysics: " + UsePhysics.ToString() + "\n"; - output += "PathBegin: " + PathBegin.ToString() + "\n"; - output += "Active: " + Active.ToString() + "\n"; - output += "PCode: " + PCode.ToString() + "\n"; - output += "PathCurve: " + PathCurve.ToString() + "\n"; - output += "EveryoneMask: " + EveryoneMask.ToString() + "\n"; - output += "Scale: " + Scale.ToString() + "\n"; - output += "State: " + State.ToString() + "\n"; - output += "PathTwist: " + PathTwist.ToString() + "\n"; - output += Helpers.FieldToString(TextureEntry, "TextureEntry") + "\n"; - output += "ProfileHollow: " + ProfileHollow.ToString() + "\n"; - output += "PathRevolutions: " + PathRevolutions.ToString() + "\n"; - output += "Rotation: " + Rotation.ToString() + "\n"; - output += "NextOwnerMask: " + NextOwnerMask.ToString() + "\n"; - output += "GroupMask: " + GroupMask.ToString() + "\n"; - output += "OwnerMask: " + OwnerMask.ToString() + "\n"; + { + string output = "-- ObjectData --\n"; + output += "ID: " + ID.ToString() + "\n"; + output += "GroupOwned: " + GroupOwned.ToString() + "\n"; + output += "PathTwistBegin: " + PathTwistBegin.ToString() + "\n"; + output += "PathEnd: " + PathEnd.ToString() + "\n"; + output += "AngVelX: " + AngVelX.ToString() + "\n"; + output += "AngVelY: " + AngVelY.ToString() + "\n"; + output += "AngVelZ: " + AngVelZ.ToString() + "\n"; + output += "BaseMask: " + BaseMask.ToString() + "\n"; + output += "ProfileBegin: " + ProfileBegin.ToString() + "\n"; + output += "SubType: " + SubType.ToString() + "\n"; + output += "PathRadiusOffset: " + PathRadiusOffset.ToString() + "\n"; + output += "VelX: " + VelX.ToString() + "\n"; + output += "PathSkew: " + PathSkew.ToString() + "\n"; + output += "VelY: " + VelY.ToString() + "\n"; + output += "VelZ: " + VelZ.ToString() + "\n"; + output += Helpers.FieldToString(Data, "Data") + "\n"; + output += "ParentID: " + ParentID.ToString() + "\n"; + output += "PosX: " + PosX.ToString() + "\n"; + output += "PosY: " + PosY.ToString() + "\n"; + output += "PosZ: " + PosZ.ToString() + "\n"; + output += "ProfileCurve: " + ProfileCurve.ToString() + "\n"; + output += "PathScaleX: " + PathScaleX.ToString() + "\n"; + output += "PathScaleY: " + PathScaleY.ToString() + "\n"; + output += "GroupID: " + GroupID.ToString() + "\n"; + output += "Material: " + Material.ToString() + "\n"; + output += "OwnerID: " + OwnerID.ToString() + "\n"; + output += "CreatorID: " + CreatorID.ToString() + "\n"; + output += "PathShearX: " + PathShearX.ToString() + "\n"; + output += "PathShearY: " + PathShearY.ToString() + "\n"; + output += "PathTaperX: " + PathTaperX.ToString() + "\n"; + output += "PathTaperY: " + PathTaperY.ToString() + "\n"; + output += "ProfileEnd: " + ProfileEnd.ToString() + "\n"; + output += "UsePhysics: " + UsePhysics.ToString() + "\n"; + output += "PathBegin: " + PathBegin.ToString() + "\n"; + output += "Active: " + Active.ToString() + "\n"; + output += "PCode: " + PCode.ToString() + "\n"; + output += "PathCurve: " + PathCurve.ToString() + "\n"; + output += "EveryoneMask: " + EveryoneMask.ToString() + "\n"; + output += "Scale: " + Scale.ToString() + "\n"; + output += "State: " + State.ToString() + "\n"; + output += "PathTwist: " + PathTwist.ToString() + "\n"; + output += Helpers.FieldToString(TextureEntry, "TextureEntry") + "\n"; + output += "ProfileHollow: " + ProfileHollow.ToString() + "\n"; + output += "PathRevolutions: " + PathRevolutions.ToString() + "\n"; + output += "Rotation: " + Rotation.ToString() + "\n"; + output += "NextOwnerMask: " + NextOwnerMask.ToString() + "\n"; + output += "GroupMask: " + GroupMask.ToString() + "\n"; + output += "OwnerMask: " + OwnerMask.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - /// NVPairData block + + /// NVPairData block public class NVPairDataBlock - { - private byte[] _nvpairs; - /// NVPairs field + { + private byte[] _nvpairs; + /// NVPairs field public byte[] NVPairs - { - get { return _nvpairs; } + { + get { return _nvpairs; } set - { - if (value == null) { _nvpairs = null; return; } - if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } - else { _nvpairs = new byte[value.Length]; Array.Copy(value, _nvpairs, value.Length); } + { + if (value == null) { _nvpairs = null; return; } + if (value.Length > 1024) { throw new OverflowException("Value exceeds 1024 characters"); } + else { _nvpairs = new byte[value.Length]; Array.Copy(value, _nvpairs, value.Length); } } - } - - /// Length of this block serialized in bytes + } + + /// Length of this block serialized in bytes public int Length { get - { - int length = 0; - if (NVPairs != null) { length += 2 + NVPairs.Length; } - return length; + { + int length = 0; + if (NVPairs != null) { length += 2 + NVPairs.Length; } + return length; } } - - /// Default constructor - public NVPairDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public NVPairDataBlock() { } + /// Constructor for building the block from a byte array public NVPairDataBlock(byte[] bytes, ref int i) - { - int length; + { + int length; try - { - length = (ushort)(bytes[i++] + (bytes[i++] << 8)); - _nvpairs = new byte[length]; - Array.Copy(bytes, i, _nvpairs, 0, length); i += length; + { + length = (ushort)(bytes[i++] + (bytes[i++] << 8)); + _nvpairs = new byte[length]; + Array.Copy(bytes, i, _nvpairs, 0, length); i += length; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - if(NVPairs == null) { Console.WriteLine("Warning: NVPairs is null, in " + this.GetType()); } - bytes[i++] = (byte)(NVPairs.Length % 256); - bytes[i++] = (byte)((NVPairs.Length >> 8) % 256); - Array.Copy(NVPairs, 0, bytes, i, NVPairs.Length); i += NVPairs.Length; + { + if(NVPairs == null) { Console.WriteLine("Warning: NVPairs is null, in " + this.GetType()); } + bytes[i++] = (byte)(NVPairs.Length % 256); + bytes[i++] = (byte)((NVPairs.Length >> 8) % 256); + Array.Copy(NVPairs, 0, bytes, i, NVPairs.Length); i += NVPairs.Length; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- NVPairData --\n"; - output += Helpers.FieldToString(NVPairs, "NVPairs") + "\n"; + { + string output = "-- NVPairData --\n"; + output += Helpers.FieldToString(NVPairs, "NVPairs") + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.PassObject - public override PacketType Type { get { return PacketType.PassObject; } } - /// ObjectData block - public ObjectDataBlock ObjectData; - /// NVPairData block - public NVPairDataBlock[] NVPairData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.PassObject + public override PacketType Type { get { return PacketType.PassObject; } } + /// ObjectData block + public ObjectDataBlock ObjectData; + /// NVPairData block + public NVPairDataBlock[] NVPairData; + + /// Default constructor public PassObjectPacket() - { - Header = new HighHeader(); - Header.ID = 30; - Header.Reliable = true; - Header.Zerocoded = true; - ObjectData = new ObjectDataBlock(); - NVPairData = new NVPairDataBlock[0]; + { + Header = new HighHeader(); + Header.ID = 30; + Header.Reliable = true; + Header.Zerocoded = true; + ObjectData = new ObjectDataBlock(); + NVPairData = new NVPairDataBlock[0]; } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public PassObjectPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new HighHeader(bytes, ref i, ref packetEnd); - ObjectData = new ObjectDataBlock(bytes, ref i); - int count = (int)bytes[i++]; - NVPairData = new NVPairDataBlock[count]; - for (int j = 0; j < count; j++) - { NVPairData[j] = new NVPairDataBlock(bytes, ref i); } + { + int packetEnd = bytes.Length - 1; + Header = new HighHeader(bytes, ref i, ref packetEnd); + ObjectData = new ObjectDataBlock(bytes, ref i); + int count = (int)bytes[i++]; + NVPairData = new NVPairDataBlock[count]; + for (int j = 0; j < count; j++) + { NVPairData[j] = new NVPairDataBlock(bytes, ref i); } } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public PassObjectPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - ObjectData = new ObjectDataBlock(bytes, ref i); - int count = (int)bytes[i++]; - NVPairData = new NVPairDataBlock[count]; - for (int j = 0; j < count; j++) - { NVPairData[j] = new NVPairDataBlock(bytes, ref i); } + { + Header = head; + ObjectData = new ObjectDataBlock(bytes, ref i); + int count = (int)bytes[i++]; + NVPairData = new NVPairDataBlock[count]; + for (int j = 0; j < count; j++) + { NVPairData[j] = new NVPairDataBlock(bytes, ref i); } } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 5; - length += ObjectData.Length;; - length++; - for (int j = 0; j < NVPairData.Length; j++) { length += NVPairData[j].Length; } - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - ObjectData.ToBytes(bytes, ref i); - bytes[i++] = (byte)NVPairData.Length; - for (int j = 0; j < NVPairData.Length; j++) { NVPairData[j].ToBytes(bytes, ref i); } - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 5; + length += ObjectData.Length;; + length++; + for (int j = 0; j < NVPairData.Length; j++) { length += NVPairData[j].Length; } + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + ObjectData.ToBytes(bytes, ref i); + bytes[i++] = (byte)NVPairData.Length; + for (int j = 0; j < NVPairData.Length; j++) { NVPairData[j].ToBytes(bytes, ref i); } + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- PassObject ---\n"; - output += ObjectData.ToString() + "\n"; + { + string output = "--- PassObject ---\n"; + output += ObjectData.ToString() + "\n"; for (int j = 0; j < NVPairData.Length; j++) - { + { output += NVPairData[j].ToString() + "\n"; - } + } return output; } - + } - - /// AtomicPassObject packet + + /// AtomicPassObject packet public class AtomicPassObjectPacket : Packet - { - /// TaskData block + { + /// TaskData block public class TaskDataBlock - { - /// AttachmentNeedsSave field - public bool AttachmentNeedsSave; - /// TaskID field - public LLUUID TaskID; - - /// Length of this block serialized in bytes + { + /// AttachmentNeedsSave field + public bool AttachmentNeedsSave; + /// TaskID field + public LLUUID TaskID; + + /// Length of this block serialized in bytes public int Length { get - { - return 17; + { + return 17; } } - - /// Default constructor - public TaskDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public TaskDataBlock() { } + /// Constructor for building the block from a byte array public TaskDataBlock(byte[] bytes, ref int i) - { + { try - { - AttachmentNeedsSave = (bytes[i++] != 0) ? (bool)true : (bool)false; - TaskID = new LLUUID(bytes, i); i += 16; + { + AttachmentNeedsSave = (bytes[i++] != 0) ? (bool)true : (bool)false; + TaskID = new LLUUID(bytes, i); i += 16; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - bytes[i++] = (byte)((AttachmentNeedsSave) ? 1 : 0); - if(TaskID == null) { Console.WriteLine("Warning: TaskID is null, in " + this.GetType()); } - Array.Copy(TaskID.GetBytes(), 0, bytes, i, 16); i += 16; + { + bytes[i++] = (byte)((AttachmentNeedsSave) ? 1 : 0); + if(TaskID == null) { Console.WriteLine("Warning: TaskID is null, in " + this.GetType()); } + Array.Copy(TaskID.GetBytes(), 0, bytes, i, 16); i += 16; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- TaskData --\n"; - output += "AttachmentNeedsSave: " + AttachmentNeedsSave.ToString() + "\n"; - output += "TaskID: " + TaskID.ToString() + "\n"; + { + string output = "-- TaskData --\n"; + output += "AttachmentNeedsSave: " + AttachmentNeedsSave.ToString() + "\n"; + output += "TaskID: " + TaskID.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.AtomicPassObject - public override PacketType Type { get { return PacketType.AtomicPassObject; } } - /// TaskData block - public TaskDataBlock TaskData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.AtomicPassObject + public override PacketType Type { get { return PacketType.AtomicPassObject; } } + /// TaskData block + public TaskDataBlock TaskData; + + /// Default constructor public AtomicPassObjectPacket() - { - Header = new HighHeader(); - Header.ID = 31; - Header.Reliable = true; - TaskData = new TaskDataBlock(); + { + Header = new HighHeader(); + Header.ID = 31; + Header.Reliable = true; + TaskData = new TaskDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public AtomicPassObjectPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new HighHeader(bytes, ref i, ref packetEnd); - TaskData = new TaskDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new HighHeader(bytes, ref i, ref packetEnd); + TaskData = new TaskDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public AtomicPassObjectPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - TaskData = new TaskDataBlock(bytes, ref i); + { + Header = head; + TaskData = new TaskDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 5; - length += TaskData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - TaskData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 5; + length += TaskData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + TaskData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- AtomicPassObject ---\n"; - output += TaskData.ToString() + "\n"; + { + string output = "--- AtomicPassObject ---\n"; + output += TaskData.ToString() + "\n"; return output; } - + } - - /// SoundTrigger packet + + /// SoundTrigger packet public class SoundTriggerPacket : Packet - { - /// SoundData block + { + /// SoundData block public class SoundDataBlock - { - /// ObjectID field - public LLUUID ObjectID; - /// Gain field - public float Gain; - /// ParentID field - public LLUUID ParentID; - /// SoundID field - public LLUUID SoundID; - /// OwnerID field - public LLUUID OwnerID; - /// Handle field - public ulong Handle; - /// Position field - public LLVector3 Position; - - /// Length of this block serialized in bytes + { + /// ObjectID field + public LLUUID ObjectID; + /// Gain field + public float Gain; + /// ParentID field + public LLUUID ParentID; + /// SoundID field + public LLUUID SoundID; + /// OwnerID field + public LLUUID OwnerID; + /// Handle field + public ulong Handle; + /// Position field + public LLVector3 Position; + + /// Length of this block serialized in bytes public int Length { get - { - return 88; + { + return 88; } } - - /// Default constructor - public SoundDataBlock() { } - /// Constructor for building the block from a byte array + + /// Default constructor + public SoundDataBlock() { } + /// Constructor for building the block from a byte array public SoundDataBlock(byte[] bytes, ref int i) - { + { try - { - ObjectID = new LLUUID(bytes, i); i += 16; - if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); - Gain = BitConverter.ToSingle(bytes, i); i += 4; - ParentID = new LLUUID(bytes, i); i += 16; - SoundID = new LLUUID(bytes, i); i += 16; - OwnerID = new LLUUID(bytes, i); i += 16; - Handle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); - Position = new LLVector3(bytes, i); i += 12; + { + ObjectID = new LLUUID(bytes, i); i += 16; + if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4); + Gain = BitConverter.ToSingle(bytes, i); i += 4; + ParentID = new LLUUID(bytes, i); i += 16; + SoundID = new LLUUID(bytes, i); i += 16; + OwnerID = new LLUUID(bytes, i); i += 16; + Handle = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + ((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + ((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + ((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56)); + Position = new LLVector3(bytes, i); i += 12; } catch (Exception) { throw new MalformedDataException(); } } - - /// Serialize this block to a byte array + + /// Serialize this block to a byte array public void ToBytes(byte[] bytes, ref int i) - { - byte[] ba; - if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } - Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; + { + byte[] ba; + if(ObjectID == null) { Console.WriteLine("Warning: ObjectID is null, in " + this.GetType()); } + Array.Copy(ObjectID.GetBytes(), 0, bytes, i, 16); i += 16; ba = BitConverter.GetBytes(Gain); if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); } - Array.Copy(ba, 0, bytes, i, 4); i += 4; - if(ParentID == null) { Console.WriteLine("Warning: ParentID is null, in " + this.GetType()); } - Array.Copy(ParentID.GetBytes(), 0, bytes, i, 16); i += 16; - if(SoundID == null) { Console.WriteLine("Warning: SoundID is null, in " + this.GetType()); } - Array.Copy(SoundID.GetBytes(), 0, bytes, i, 16); i += 16; - if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } - Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; - bytes[i++] = (byte)(Handle % 256); - bytes[i++] = (byte)((Handle >> 8) % 256); - bytes[i++] = (byte)((Handle >> 16) % 256); - bytes[i++] = (byte)((Handle >> 24) % 256); - bytes[i++] = (byte)((Handle >> 32) % 256); - bytes[i++] = (byte)((Handle >> 40) % 256); - bytes[i++] = (byte)((Handle >> 48) % 256); - bytes[i++] = (byte)((Handle >> 56) % 256); - if(Position == null) { Console.WriteLine("Warning: Position is null, in " + this.GetType()); } - Array.Copy(Position.GetBytes(), 0, bytes, i, 12); i += 12; + Array.Copy(ba, 0, bytes, i, 4); i += 4; + if(ParentID == null) { Console.WriteLine("Warning: ParentID is null, in " + this.GetType()); } + Array.Copy(ParentID.GetBytes(), 0, bytes, i, 16); i += 16; + if(SoundID == null) { Console.WriteLine("Warning: SoundID is null, in " + this.GetType()); } + Array.Copy(SoundID.GetBytes(), 0, bytes, i, 16); i += 16; + if(OwnerID == null) { Console.WriteLine("Warning: OwnerID is null, in " + this.GetType()); } + Array.Copy(OwnerID.GetBytes(), 0, bytes, i, 16); i += 16; + bytes[i++] = (byte)(Handle % 256); + bytes[i++] = (byte)((Handle >> 8) % 256); + bytes[i++] = (byte)((Handle >> 16) % 256); + bytes[i++] = (byte)((Handle >> 24) % 256); + bytes[i++] = (byte)((Handle >> 32) % 256); + bytes[i++] = (byte)((Handle >> 40) % 256); + bytes[i++] = (byte)((Handle >> 48) % 256); + bytes[i++] = (byte)((Handle >> 56) % 256); + if(Position == null) { Console.WriteLine("Warning: Position is null, in " + this.GetType()); } + Array.Copy(Position.GetBytes(), 0, bytes, i, 12); i += 12; } - - /// Serialize this block to a stringA string containing the serialized block + + /// Serialize this block to a stringA string containing the serialized block public override string ToString() - { - string output = "-- SoundData --\n"; - output += "ObjectID: " + ObjectID.ToString() + "\n"; - output += "Gain: " + Gain.ToString() + "\n"; - output += "ParentID: " + ParentID.ToString() + "\n"; - output += "SoundID: " + SoundID.ToString() + "\n"; - output += "OwnerID: " + OwnerID.ToString() + "\n"; - output += "Handle: " + Handle.ToString() + "\n"; - output += "Position: " + Position.ToString() + "\n"; + { + string output = "-- SoundData --\n"; + output += "ObjectID: " + ObjectID.ToString() + "\n"; + output += "Gain: " + Gain.ToString() + "\n"; + output += "ParentID: " + ParentID.ToString() + "\n"; + output += "SoundID: " + SoundID.ToString() + "\n"; + output += "OwnerID: " + OwnerID.ToString() + "\n"; + output += "Handle: " + Handle.ToString() + "\n"; + output += "Position: " + Position.ToString() + "\n"; output = output.Trim(); return output; - } + } } - - private Header header; - /// The header for this packet - public override Header Header { get { return header; } set { header = value; } } - /// Will return PacketType.SoundTrigger - public override PacketType Type { get { return PacketType.SoundTrigger; } } - /// SoundData block - public SoundDataBlock SoundData; - - /// Default constructor + + private Header header; + /// The header for this packet + public override Header Header { get { return header; } set { header = value; } } + /// Will return PacketType.SoundTrigger + public override PacketType Type { get { return PacketType.SoundTrigger; } } + /// SoundData block + public SoundDataBlock SoundData; + + /// Default constructor public SoundTriggerPacket() - { - Header = new HighHeader(); - Header.ID = 32; - Header.Reliable = true; - SoundData = new SoundDataBlock(); + { + Header = new HighHeader(); + Header.ID = 32; + Header.Reliable = true; + SoundData = new SoundDataBlock(); } - - /// Constructor that takes a byte array and beginning position (no prebuilt header) + + /// Constructor that takes a byte array and beginning position (no prebuilt header) public SoundTriggerPacket(byte[] bytes, ref int i) - { - int packetEnd = bytes.Length - 1; - Header = new HighHeader(bytes, ref i, ref packetEnd); - SoundData = new SoundDataBlock(bytes, ref i); + { + int packetEnd = bytes.Length - 1; + Header = new HighHeader(bytes, ref i, ref packetEnd); + SoundData = new SoundDataBlock(bytes, ref i); } - - /// Constructor that takes a byte array and a prebuilt header + + /// Constructor that takes a byte array and a prebuilt header public SoundTriggerPacket(Header head, byte[] bytes, ref int i) - { - Header = head; - SoundData = new SoundDataBlock(bytes, ref i); + { + Header = head; + SoundData = new SoundDataBlock(bytes, ref i); } - - /// Serialize this packet to a byte arrayA byte array containing the serialized packet + + /// Serialize this packet to a byte arrayA byte array containing the serialized packet public override byte[] ToBytes() - { - int length = 5; - length += SoundData.Length;; - if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } - byte[] bytes = new byte[length]; - int i = 0; - header.ToBytes(bytes, ref i); - SoundData.ToBytes(bytes, ref i); - if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } + { + int length = 5; + length += SoundData.Length;; + if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; } + byte[] bytes = new byte[length]; + int i = 0; + header.ToBytes(bytes, ref i); + SoundData.ToBytes(bytes, ref i); + if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); } return bytes; } - - /// Serialize this packet to a stringA string containing the serialized packet + + /// Serialize this packet to a stringA string containing the serialized packet public override string ToString() - { - string output = "--- SoundTrigger ---\n"; - output += SoundData.ToString() + "\n"; + { + string output = "--- SoundTrigger ---\n"; + output += SoundData.ToString() + "\n"; return output; } - + } - -} + +} + diff --git a/libsecondlife-cs/examples/AnimationSample/AnimationSample.csproj b/libsecondlife-cs/examples/AnimationSample/AnimationSample.csproj index 66ebf1fc..20b08fa4 100644 --- a/libsecondlife-cs/examples/AnimationSample/AnimationSample.csproj +++ b/libsecondlife-cs/examples/AnimationSample/AnimationSample.csproj @@ -1,84 +1,84 @@ - - - Debug - AnyCPU - 8.0.50727 - 2.0 - {4EF98AD4-B3B3-42B0-9273-13A614A823F7} - WinExe - Properties - AnimationSample - AnimationSample - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - Form - - - Form1.cs - - - - - Designer - Form1.cs - - - ResXFileCodeGenerator - Resources.Designer.cs - Designer - - - True - Resources.resx - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - True - Settings.settings - True - - - - - {D9CDEDFB-8169-4B03-B57F-0DF638F044EC} - libsecondlife - - - - + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {4EF98AD4-B3B3-42B0-9273-13A614A823F7} + WinExe + Properties + AnimationSample + AnimationSample + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + Form + + + Form1.cs + + + + + Designer + Form1.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + {D9CDEDFB-8169-4B03-B57F-0DF638F044EC} + libsecondlife + + + + \ No newline at end of file diff --git a/libsecondlife-cs/examples/AnimationSample/Form1.Designer.cs b/libsecondlife-cs/examples/AnimationSample/Form1.Designer.cs index 6d697050..e8ed1376 100644 --- a/libsecondlife-cs/examples/AnimationSample/Form1.Designer.cs +++ b/libsecondlife-cs/examples/AnimationSample/Form1.Designer.cs @@ -1,152 +1,152 @@ -namespace AnimationSample -{ - partial class Form1 - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - try - { - client.Network.Logout(); - } - catch - { - //ignore - } - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.txtLast = new System.Windows.Forms.TextBox(); - this.txtFirst = new System.Windows.Forms.TextBox(); - this.txtPassword = new System.Windows.Forms.TextBox(); - this.label1 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.label3 = new System.Windows.Forms.Label(); - this.btnLogin = new System.Windows.Forms.Button(); - this.btnPlay = new System.Windows.Forms.Button(); - this.SuspendLayout(); - // - // txtLast - // - this.txtLast.Location = new System.Drawing.Point(162, 33); - this.txtLast.Name = "txtLast"; - this.txtLast.Size = new System.Drawing.Size(133, 20); - this.txtLast.TabIndex = 0; - this.txtLast.Text = "Malthus"; - // - // txtFirst - // - this.txtFirst.Location = new System.Drawing.Point(23, 33); - this.txtFirst.Name = "txtFirst"; - this.txtFirst.Size = new System.Drawing.Size(133, 20); - this.txtFirst.TabIndex = 0; - this.txtFirst.Text = "Jesse"; - // - // txtPassword - // - this.txtPassword.Location = new System.Drawing.Point(301, 33); - this.txtPassword.Name = "txtPassword"; - this.txtPassword.PasswordChar = '*'; - this.txtPassword.Size = new System.Drawing.Size(133, 20); - this.txtPassword.TabIndex = 0; - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(159, 17); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(58, 13); - this.label1.TabIndex = 1; - this.label1.Text = "Last Name"; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(20, 17); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(57, 13); - this.label2.TabIndex = 1; - this.label2.Text = "First Name"; - // - // label3 - // - this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(298, 17); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(53, 13); - this.label3.TabIndex = 1; - this.label3.Text = "Password"; - // - // btnLogin - // - this.btnLogin.Location = new System.Drawing.Point(305, 61); - this.btnLogin.Name = "btnLogin"; - this.btnLogin.Size = new System.Drawing.Size(128, 29); - this.btnLogin.TabIndex = 2; - this.btnLogin.Text = "Login"; - this.btnLogin.UseVisualStyleBackColor = true; - this.btnLogin.Click += new System.EventHandler(this.btnLogin_Click); - // - // btnPlay - // - this.btnPlay.Location = new System.Drawing.Point(162, 131); - this.btnPlay.Name = "btnPlay"; - this.btnPlay.Size = new System.Drawing.Size(133, 42); - this.btnPlay.TabIndex = 3; - this.btnPlay.Text = "Play \"dance1\" animation"; - this.btnPlay.UseVisualStyleBackColor = true; - this.btnPlay.Click += new System.EventHandler(this.btnPlay_Click); - // - // Form1 - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(464, 196); - this.Controls.Add(this.btnPlay); - this.Controls.Add(this.btnLogin); - this.Controls.Add(this.label2); - this.Controls.Add(this.label3); - this.Controls.Add(this.label1); - this.Controls.Add(this.txtPassword); - this.Controls.Add(this.txtFirst); - this.Controls.Add(this.txtLast); - this.Name = "Form1"; - this.Text = "LibSL Animation Example"; - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - private System.Windows.Forms.TextBox txtLast; - private System.Windows.Forms.TextBox txtFirst; - private System.Windows.Forms.TextBox txtPassword; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.Label label3; - private System.Windows.Forms.Button btnLogin; - private System.Windows.Forms.Button btnPlay; - } -} - +namespace AnimationSample +{ + partial class Form1 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + try + { + client.Network.Logout(); + } + catch + { + //ignore + } + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.txtLast = new System.Windows.Forms.TextBox(); + this.txtFirst = new System.Windows.Forms.TextBox(); + this.txtPassword = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.label3 = new System.Windows.Forms.Label(); + this.btnLogin = new System.Windows.Forms.Button(); + this.btnPlay = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // txtLast + // + this.txtLast.Location = new System.Drawing.Point(162, 33); + this.txtLast.Name = "txtLast"; + this.txtLast.Size = new System.Drawing.Size(133, 20); + this.txtLast.TabIndex = 0; + this.txtLast.Text = "Malthus"; + // + // txtFirst + // + this.txtFirst.Location = new System.Drawing.Point(23, 33); + this.txtFirst.Name = "txtFirst"; + this.txtFirst.Size = new System.Drawing.Size(133, 20); + this.txtFirst.TabIndex = 0; + this.txtFirst.Text = "Jesse"; + // + // txtPassword + // + this.txtPassword.Location = new System.Drawing.Point(301, 33); + this.txtPassword.Name = "txtPassword"; + this.txtPassword.PasswordChar = '*'; + this.txtPassword.Size = new System.Drawing.Size(133, 20); + this.txtPassword.TabIndex = 0; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(159, 17); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(58, 13); + this.label1.TabIndex = 1; + this.label1.Text = "Last Name"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(20, 17); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(57, 13); + this.label2.TabIndex = 1; + this.label2.Text = "First Name"; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(298, 17); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(53, 13); + this.label3.TabIndex = 1; + this.label3.Text = "Password"; + // + // btnLogin + // + this.btnLogin.Location = new System.Drawing.Point(305, 61); + this.btnLogin.Name = "btnLogin"; + this.btnLogin.Size = new System.Drawing.Size(128, 29); + this.btnLogin.TabIndex = 2; + this.btnLogin.Text = "Login"; + this.btnLogin.UseVisualStyleBackColor = true; + this.btnLogin.Click += new System.EventHandler(this.btnLogin_Click); + // + // btnPlay + // + this.btnPlay.Location = new System.Drawing.Point(162, 131); + this.btnPlay.Name = "btnPlay"; + this.btnPlay.Size = new System.Drawing.Size(133, 42); + this.btnPlay.TabIndex = 3; + this.btnPlay.Text = "Play \"dance1\" animation"; + this.btnPlay.UseVisualStyleBackColor = true; + this.btnPlay.Click += new System.EventHandler(this.btnPlay_Click); + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(464, 196); + this.Controls.Add(this.btnPlay); + this.Controls.Add(this.btnLogin); + this.Controls.Add(this.label2); + this.Controls.Add(this.label3); + this.Controls.Add(this.label1); + this.Controls.Add(this.txtPassword); + this.Controls.Add(this.txtFirst); + this.Controls.Add(this.txtLast); + this.Name = "Form1"; + this.Text = "LibSL Animation Example"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TextBox txtLast; + private System.Windows.Forms.TextBox txtFirst; + private System.Windows.Forms.TextBox txtPassword; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Button btnLogin; + private System.Windows.Forms.Button btnPlay; + } +} + diff --git a/libsecondlife-cs/examples/AnimationSample/Form1.cs b/libsecondlife-cs/examples/AnimationSample/Form1.cs index a0a4d6bd..945dd46b 100644 --- a/libsecondlife-cs/examples/AnimationSample/Form1.cs +++ b/libsecondlife-cs/examples/AnimationSample/Form1.cs @@ -1,71 +1,71 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Text; -using System.Windows.Forms; -using libsecondlife; -using libsecondlife.Packets; -using System.Collections; - -namespace AnimationSample -{ - public partial class Form1 : Form - { - SecondLife client; - public Form1() - { - InitializeComponent(); - //Create the SecondLife client object - client = new SecondLife(); - - } - - private void btnPlay_Click(object sender, EventArgs e) - { - //Build an animation packet - AgentAnimationPacket packet = new AgentAnimationPacket(); - - //create an AgentData block - AgentAnimationPacket.AgentDataBlock agentdata = new AgentAnimationPacket.AgentDataBlock(); - //Fill in its values - agentdata.AgentID = client.Avatar.ID; - agentdata.SessionID = client.Network.SessionID; - //Add it in the packet - packet.AgentData = agentdata; - - //Create an AnimationList block - AgentAnimationPacket.AnimationListBlock anims = new AgentAnimationPacket.AnimationListBlock(); - //Set the UUID of the animation to avatar_dance1.bvh, a standard animation - anims.AnimID = new LLUUID("b68a3d7c-de9e-fc87-eec8-543d787e5b0d"); - //Start the animation - anims.StartAnim = true; - //Add it to the packet. SInce it's a Variable number block, we have to construct an array. - packet.AnimationList = new AgentAnimationPacket.AnimationListBlock[] { anims }; - - //Send the packet - client.Network.SendPacket(packet); - } - - private void btnLogin_Click(object sender, EventArgs e) - { - //Login information - Hashtable loginParams = NetworkManager.DefaultLoginValues(txtFirst.Text, txtLast.Text, txtPassword.Text, "00:00:00:00:00:00", - "last", 1, 12, 12, 12, "Win", "0", "animationsample", "jessemalthus@gmail.com"); - Hashtable loginReply = new Hashtable(); - - // Login - if (!client.Network.Login(loginParams)) - { - // Login failed - MessageBox.Show("We're sorry, but login failed. Error: \n " + client.Network.LoginError); - - } - else - { - MessageBox.Show("Login succeded. You're at " + client.Avatar.Position + " on " + client.Network.CurrentSim.Region.Name); - } - } - } +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; +using libsecondlife; +using libsecondlife.Packets; +using System.Collections; + +namespace AnimationSample +{ + public partial class Form1 : Form + { + SecondLife client; + public Form1() + { + InitializeComponent(); + //Create the SecondLife client object + client = new SecondLife(); + + } + + private void btnPlay_Click(object sender, EventArgs e) + { + //Build an animation packet + AgentAnimationPacket packet = new AgentAnimationPacket(); + + //create an AgentData block + AgentAnimationPacket.AgentDataBlock agentdata = new AgentAnimationPacket.AgentDataBlock(); + //Fill in its values + agentdata.AgentID = client.Avatar.ID; + agentdata.SessionID = client.Network.SessionID; + //Add it in the packet + packet.AgentData = agentdata; + + //Create an AnimationList block + AgentAnimationPacket.AnimationListBlock anims = new AgentAnimationPacket.AnimationListBlock(); + //Set the UUID of the animation to avatar_dance1.bvh, a standard animation + anims.AnimID = new LLUUID("b68a3d7c-de9e-fc87-eec8-543d787e5b0d"); + //Start the animation + anims.StartAnim = true; + //Add it to the packet. SInce it's a Variable number block, we have to construct an array. + packet.AnimationList = new AgentAnimationPacket.AnimationListBlock[] { anims }; + + //Send the packet + client.Network.SendPacket(packet); + } + + private void btnLogin_Click(object sender, EventArgs e) + { + //Login information + Hashtable loginParams = NetworkManager.DefaultLoginValues(txtFirst.Text, txtLast.Text, txtPassword.Text, "00:00:00:00:00:00", + "last", 1, 12, 12, 12, "Win", "0", "animationsample", "jessemalthus@gmail.com"); + Hashtable loginReply = new Hashtable(); + + // Login + if (!client.Network.Login(loginParams)) + { + // Login failed + MessageBox.Show("We're sorry, but login failed. Error: \n " + client.Network.LoginError); + + } + else + { + MessageBox.Show("Login succeded. You're at " + client.Avatar.Position + " on " + client.Network.CurrentSim.Region.Name); + } + } + } } \ No newline at end of file diff --git a/libsecondlife-cs/examples/AnimationSample/Form1.resx b/libsecondlife-cs/examples/AnimationSample/Form1.resx index ff31a6db..19dc0dd8 100644 --- a/libsecondlife-cs/examples/AnimationSample/Form1.resx +++ b/libsecondlife-cs/examples/AnimationSample/Form1.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/libsecondlife-cs/examples/AnimationSample/Program.cs b/libsecondlife-cs/examples/AnimationSample/Program.cs index 3b2462fc..fbfdd771 100644 --- a/libsecondlife-cs/examples/AnimationSample/Program.cs +++ b/libsecondlife-cs/examples/AnimationSample/Program.cs @@ -1,20 +1,20 @@ -using System; -using System.Collections.Generic; -using System.Windows.Forms; - -namespace AnimationSample -{ - static class Program - { - /// - /// The main entry point for the application. - /// - [STAThread] - static void Main() - { - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new Form1()); - } - } +using System; +using System.Collections.Generic; +using System.Windows.Forms; + +namespace AnimationSample +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new Form1()); + } + } } \ No newline at end of file diff --git a/libsecondlife-cs/examples/AnimationSample/Properties/AssemblyInfo.cs b/libsecondlife-cs/examples/AnimationSample/Properties/AssemblyInfo.cs index d2215c14..ad4f6583 100644 --- a/libsecondlife-cs/examples/AnimationSample/Properties/AssemblyInfo.cs +++ b/libsecondlife-cs/examples/AnimationSample/Properties/AssemblyInfo.cs @@ -1,33 +1,33 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("AnimationSample")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Thearis Systems/RedWire Virtual")] -[assembly: AssemblyProduct("AnimationSample")] -[assembly: AssemblyCopyright("Copyright © Thearis Systems/RedWire Virtual 2006")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("e7a7971a-3841-436b-bfdc-d4c14ffa1fc6")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("AnimationSample")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Thearis Systems/RedWire Virtual")] +[assembly: AssemblyProduct("AnimationSample")] +[assembly: AssemblyCopyright("Copyright © Thearis Systems/RedWire Virtual 2006")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("e7a7971a-3841-436b-bfdc-d4c14ffa1fc6")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/libsecondlife-cs/examples/AnimationSample/Properties/Resources.Designer.cs b/libsecondlife-cs/examples/AnimationSample/Properties/Resources.Designer.cs index 86e6c716..b93709c1 100644 --- a/libsecondlife-cs/examples/AnimationSample/Properties/Resources.Designer.cs +++ b/libsecondlife-cs/examples/AnimationSample/Properties/Resources.Designer.cs @@ -1,71 +1,71 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.42 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace AnimationSample.Properties -{ - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources - { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() - { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager - { - get - { - if ((resourceMan == null)) - { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AnimationSample.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture - { - get - { - return resourceCulture; - } - set - { - resourceCulture = value; - } - } - } -} +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace AnimationSample.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AnimationSample.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/libsecondlife-cs/examples/AnimationSample/Properties/Resources.resx b/libsecondlife-cs/examples/AnimationSample/Properties/Resources.resx index ffecec85..af7dbebb 100644 --- a/libsecondlife-cs/examples/AnimationSample/Properties/Resources.resx +++ b/libsecondlife-cs/examples/AnimationSample/Properties/Resources.resx @@ -1,117 +1,117 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/libsecondlife-cs/examples/AnimationSample/Properties/Settings.Designer.cs b/libsecondlife-cs/examples/AnimationSample/Properties/Settings.Designer.cs index d7a4f5ff..3d7e1875 100644 --- a/libsecondlife-cs/examples/AnimationSample/Properties/Settings.Designer.cs +++ b/libsecondlife-cs/examples/AnimationSample/Properties/Settings.Designer.cs @@ -1,30 +1,30 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:2.0.50727.42 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace AnimationSample.Properties -{ - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase - { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default - { - get - { - return defaultInstance; - } - } - } -} +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace AnimationSample.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "8.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/libsecondlife-cs/examples/AnimationSample/Properties/Settings.settings b/libsecondlife-cs/examples/AnimationSample/Properties/Settings.settings index abf36c5d..39645652 100644 --- a/libsecondlife-cs/examples/AnimationSample/Properties/Settings.settings +++ b/libsecondlife-cs/examples/AnimationSample/Properties/Settings.settings @@ -1,7 +1,7 @@ - - - - - - - + + + + + + + diff --git a/libsecondlife-cs/examples/IA_ImageTool/IA_ImageTool.csproj b/libsecondlife-cs/examples/IA_ImageTool/IA_ImageTool.csproj index 93d3e240..6b25705f 100644 --- a/libsecondlife-cs/examples/IA_ImageTool/IA_ImageTool.csproj +++ b/libsecondlife-cs/examples/IA_ImageTool/IA_ImageTool.csproj @@ -1,59 +1,59 @@ - - - Debug - AnyCPU - 8.0.50727 - 2.0 - {8D2E5240-2247-42F5-AAAC-CF0CCCEE349A} - Exe - Properties - IA_ImageTool - ImageTool - IA_ImageTool.ImageTool - - - true - full - false - ..\..\bin\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - {E464B963-46E3-4E1A-A36F-9C640C880E68} - IA_SimpleInventory - - - {D9CDEDFB-8169-4B03-B57F-0DF638F044EC} - libsecondlife - - - - + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {8D2E5240-2247-42F5-AAAC-CF0CCCEE349A} + Exe + Properties + IA_ImageTool + ImageTool + IA_ImageTool.ImageTool + + + true + full + false + ..\..\bin\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + {E464B963-46E3-4E1A-A36F-9C640C880E68} + IA_SimpleInventory + + + {D9CDEDFB-8169-4B03-B57F-0DF638F044EC} + libsecondlife + + + + \ No newline at end of file diff --git a/libsecondlife-cs/examples/IA_ImageTool/ImageTool.cs b/libsecondlife-cs/examples/IA_ImageTool/ImageTool.cs index 015932e5..6daf99f9 100644 --- a/libsecondlife-cs/examples/IA_ImageTool/ImageTool.cs +++ b/libsecondlife-cs/examples/IA_ImageTool/ImageTool.cs @@ -1,126 +1,126 @@ -using System; -using System.Collections; -using System.IO; - -using IA_SimpleInventory; - -using libsecondlife; -using libsecondlife.InventorySystem; -using libsecondlife.AssetSystem; - -namespace IA_ImageTool -{ - /// - /// Summary description for Class1. - /// - class ImageTool : SimpleInventory - { - private LLUUID _ImageID; - private string _FileName; - private bool _Put; - - /// - /// Used to upload/download images. - /// - [STAThread] - static new void Main(string[] args) - { - if (KakaduWrap.Check4Tools() == false) - { - return; - } - - if (args.Length < 5) - { - ImageTool.Usage(); - return; - } - - - LLUUID id = null; - string filename = ""; - bool put = false; - if (args[3].ToLower().Equals("put")) - { - put = true; - filename = args[4]; - } - else - { - if (args.Length < 6) - { - ImageTool.Usage(); - return; - } - - id = new LLUUID(args[4]); - if (args.Length == 6) - { - filename = args[5]; - } - else if (!args[4].ToLower().EndsWith(".j2c")) - { - filename = args[4] + ".j2c"; - } - } - - ImageTool it = new ImageTool(id, filename, put); - it.Connect(args[0], args[1], args[2]); - it.doStuff(); - it.Disconnect(); - - System.Threading.Thread.Sleep(500); - - Console.WriteLine("Done logging out."); - } - - protected ImageTool(LLUUID imageID, string filename, bool put) - { - _ImageID = imageID; - _FileName = filename; - _Put = put; - } - - protected new void doStuff() - { - if (_Put) - { - Console.WriteLine("Reading: " + _FileName); - - byte[] j2cdata = KakaduWrap.ReadJ2CData(_FileName); - - Console.WriteLine("Connecting to your Texture folder..."); - InventoryFolder iFolder = AgentInventory.getFolder("Textures"); - - Console.WriteLine("Uploading Texture..."); - iFolder.NewImage(_FileName, "ImageTool Upload", j2cdata); - } - else - { - Console.WriteLine("Downloading: " + _ImageID); - - ImageManager im = new ImageManager(base.client); - byte[] j2cdata = im.RequestImage(_ImageID); - - Console.WriteLine("Writing to: " + _FileName + ".tif"); - KakaduWrap.WriteJ2CAsTiff(_FileName + ".tif", j2cdata); - - Console.WriteLine("Writing to: " + _FileName + ".bmp"); - KakaduWrap.WriteJ2CAsBmp(_FileName + ".bmp", j2cdata); - } - - Console.WriteLine("Done..."); - - } - - protected static void Usage() - { - Console.WriteLine("Usage: ImageTool [first] [last] [password] [get] [uuid] [(filename)]"); - Console.WriteLine("Usage: ImageTool [first] [last] [password] [put] [filename]"); - - Console.WriteLine(); - Console.WriteLine("Example: ImageTool John Doe Password get 0444bf21-f77e-7f63-89e9-b839ec66bc15 cloud.tif"); - Console.WriteLine("Example: ImageTool John Doe Password put Sample (this will output a bmp and a tiff)"); - } - } +using System; +using System.Collections; +using System.IO; + +using IA_SimpleInventory; + +using libsecondlife; +using libsecondlife.InventorySystem; +using libsecondlife.AssetSystem; + +namespace IA_ImageTool +{ + /// + /// Summary description for Class1. + /// + class ImageTool : SimpleInventory + { + private LLUUID _ImageID; + private string _FileName; + private bool _Put; + + /// + /// Used to upload/download images. + /// + [STAThread] + static new void Main(string[] args) + { + if (KakaduWrap.Check4Tools() == false) + { + return; + } + + if (args.Length < 5) + { + ImageTool.Usage(); + return; + } + + + LLUUID id = null; + string filename = ""; + bool put = false; + if (args[3].ToLower().Equals("put")) + { + put = true; + filename = args[4]; + } + else + { + if (args.Length < 6) + { + ImageTool.Usage(); + return; + } + + id = new LLUUID(args[4]); + if (args.Length == 6) + { + filename = args[5]; + } + else if (!args[4].ToLower().EndsWith(".j2c")) + { + filename = args[4] + ".j2c"; + } + } + + ImageTool it = new ImageTool(id, filename, put); + it.Connect(args[0], args[1], args[2]); + it.doStuff(); + it.Disconnect(); + + System.Threading.Thread.Sleep(500); + + Console.WriteLine("Done logging out."); + } + + protected ImageTool(LLUUID imageID, string filename, bool put) + { + _ImageID = imageID; + _FileName = filename; + _Put = put; + } + + protected new void doStuff() + { + if (_Put) + { + Console.WriteLine("Reading: " + _FileName); + + byte[] j2cdata = KakaduWrap.ReadJ2CData(_FileName); + + Console.WriteLine("Connecting to your Texture folder..."); + InventoryFolder iFolder = AgentInventory.getFolder("Textures"); + + Console.WriteLine("Uploading Texture..."); + iFolder.NewImage(_FileName, "ImageTool Upload", j2cdata); + } + else + { + Console.WriteLine("Downloading: " + _ImageID); + + ImageManager im = new ImageManager(base.client); + byte[] j2cdata = im.RequestImage(_ImageID); + + Console.WriteLine("Writing to: " + _FileName + ".tif"); + KakaduWrap.WriteJ2CAsTiff(_FileName + ".tif", j2cdata); + + Console.WriteLine("Writing to: " + _FileName + ".bmp"); + KakaduWrap.WriteJ2CAsBmp(_FileName + ".bmp", j2cdata); + } + + Console.WriteLine("Done..."); + + } + + protected static void Usage() + { + Console.WriteLine("Usage: ImageTool [first] [last] [password] [get] [uuid] [(filename)]"); + Console.WriteLine("Usage: ImageTool [first] [last] [password] [put] [filename]"); + + Console.WriteLine(); + Console.WriteLine("Example: ImageTool John Doe Password get 0444bf21-f77e-7f63-89e9-b839ec66bc15 cloud.tif"); + Console.WriteLine("Example: ImageTool John Doe Password put Sample (this will output a bmp and a tiff)"); + } + } } \ No newline at end of file diff --git a/libsecondlife-cs/examples/IA_ImageTool/KakaduWrap.cs b/libsecondlife-cs/examples/IA_ImageTool/KakaduWrap.cs index 788953c4..2015daf5 100644 --- a/libsecondlife-cs/examples/IA_ImageTool/KakaduWrap.cs +++ b/libsecondlife-cs/examples/IA_ImageTool/KakaduWrap.cs @@ -1,150 +1,150 @@ -using System; -using System.IO; -using System.Diagnostics; - -namespace IA_ImageTool -{ - /// - /// Summary description for ImageTools. - /// - public class KakaduWrap - { - private KakaduWrap() - { - } - - public static bool Check4Tools() - { - bool status = true; - if( File.Exists("kdu_expand.exe") == false ) - { - status = false; - Console.WriteLine("You need kdu_expand.exe to save SL images."); - } - - if( File.Exists("kdu_compress.exe") == false ) - { - status = false; - Console.WriteLine("You need kdu_compress.exe to load images into SL."); - } - - return status; - } - - public static void WriteJ2CToFile( string j2c_filename, byte[] J2CData ) - { - FileStream fs = System.IO.File.OpenWrite( j2c_filename ); - fs.Write(J2CData, 0, J2CData.Length); - fs.Close(); - } - - - public static void Convert2Tiff(string j2c_filename, string tif_filename) - { - if (File.Exists("kdu_expand.exe") == false) - { - throw new Exception("You must have kdu_expand.exe"); - } - - if (tif_filename.ToLower().EndsWith(".tif") == false) - { - tif_filename += ".tif"; - } - - string args = "-i " + j2c_filename + " -o " + tif_filename; - Console.WriteLine(args); - - Process p = new Process(); - p.StartInfo.UseShellExecute = false; - p.StartInfo.FileName = "kdu_expand.exe"; - p.StartInfo.Arguments = args; - p.Start(); - p.WaitForExit(); - } - - public static void Convert2Bmp(string j2c_filename, string bmp_filename) - { - if (File.Exists("kdu_expand.exe") == false) - { - throw new Exception("You must have kdu_expand.exe"); - } - - if (bmp_filename.ToLower().EndsWith(".bmp") == false) - { - bmp_filename += ".bmp"; - } - - string args = "-i " + j2c_filename + " -o " + bmp_filename; - Console.WriteLine(args); - - Process p = new Process(); - p.StartInfo.UseShellExecute = false; - p.StartInfo.FileName = "kdu_expand.exe"; - p.StartInfo.Arguments = args; - p.Start(); - p.WaitForExit(); - } - - public static void WriteJ2CAsTiff(string tif_filename, byte[] J2CData) - { - String tempname = tif_filename + ".j2c"; - WriteJ2CToFile( tempname, J2CData ); - Convert2Tiff( tempname, tif_filename ); - File.Delete( tempname ); - } - - public static void WriteJ2CAsBmp(string bmp_filename, byte[] J2CData) - { - String tempname = bmp_filename + ".j2c"; - WriteJ2CToFile(tempname, J2CData); - Convert2Bmp(tempname, bmp_filename); - File.Delete(tempname); - } - - /* - * kdu_compress -no_info -no_weights -no_palette -i TestTexture.tif -o TestTexture.J2C - */ - public static void Convert2J2C( string tif_filename, string j2c_filename ) - { - if( File.Exists("kdu_compress.exe") == false ) - { - throw new Exception("You must have kdu_compress.exe"); - } - - if( j2c_filename.ToLower().EndsWith(".j2c") == false ) - { - j2c_filename += ".j2c"; - } - - Process p = new Process(); - p.StartInfo.UseShellExecute = false; - p.StartInfo.FileName = "kdu_compress.exe"; - p.StartInfo.Arguments = "-no_info -no_weights -no_palette -i " + tif_filename + " -o " + j2c_filename; - p.Start(); - p.WaitForExit(); - } - - public static byte[] ReadJ2CData( string filename ) - { - if( (filename.ToLower().EndsWith(".j2c") == false) && (filename.ToLower().EndsWith(".tif") == true) ) - { - string tempname = filename + ".j2c"; - Convert2J2C( filename, tempname ); - filename = tempname; - } - - FileStream fs = File.OpenRead( filename ); - - byte[] data = new byte[fs.Length]; - - if( fs.Length > int.MaxValue ) - { - throw new Exception("AssetImage.cs: Bad stuff going to happen because length bigger then Max Integer"); - } - - fs.Read(data, 0, (int)fs.Length); - - return data; - } - } -} +using System; +using System.IO; +using System.Diagnostics; + +namespace IA_ImageTool +{ + /// + /// Summary description for ImageTools. + /// + public class KakaduWrap + { + private KakaduWrap() + { + } + + public static bool Check4Tools() + { + bool status = true; + if( File.Exists("kdu_expand.exe") == false ) + { + status = false; + Console.WriteLine("You need kdu_expand.exe to save SL images."); + } + + if( File.Exists("kdu_compress.exe") == false ) + { + status = false; + Console.WriteLine("You need kdu_compress.exe to load images into SL."); + } + + return status; + } + + public static void WriteJ2CToFile( string j2c_filename, byte[] J2CData ) + { + FileStream fs = System.IO.File.OpenWrite( j2c_filename ); + fs.Write(J2CData, 0, J2CData.Length); + fs.Close(); + } + + + public static void Convert2Tiff(string j2c_filename, string tif_filename) + { + if (File.Exists("kdu_expand.exe") == false) + { + throw new Exception("You must have kdu_expand.exe"); + } + + if (tif_filename.ToLower().EndsWith(".tif") == false) + { + tif_filename += ".tif"; + } + + string args = "-i " + j2c_filename + " -o " + tif_filename; + Console.WriteLine(args); + + Process p = new Process(); + p.StartInfo.UseShellExecute = false; + p.StartInfo.FileName = "kdu_expand.exe"; + p.StartInfo.Arguments = args; + p.Start(); + p.WaitForExit(); + } + + public static void Convert2Bmp(string j2c_filename, string bmp_filename) + { + if (File.Exists("kdu_expand.exe") == false) + { + throw new Exception("You must have kdu_expand.exe"); + } + + if (bmp_filename.ToLower().EndsWith(".bmp") == false) + { + bmp_filename += ".bmp"; + } + + string args = "-i " + j2c_filename + " -o " + bmp_filename; + Console.WriteLine(args); + + Process p = new Process(); + p.StartInfo.UseShellExecute = false; + p.StartInfo.FileName = "kdu_expand.exe"; + p.StartInfo.Arguments = args; + p.Start(); + p.WaitForExit(); + } + + public static void WriteJ2CAsTiff(string tif_filename, byte[] J2CData) + { + String tempname = tif_filename + ".j2c"; + WriteJ2CToFile( tempname, J2CData ); + Convert2Tiff( tempname, tif_filename ); + File.Delete( tempname ); + } + + public static void WriteJ2CAsBmp(string bmp_filename, byte[] J2CData) + { + String tempname = bmp_filename + ".j2c"; + WriteJ2CToFile(tempname, J2CData); + Convert2Bmp(tempname, bmp_filename); + File.Delete(tempname); + } + + /* + * kdu_compress -no_info -no_weights -no_palette -i TestTexture.tif -o TestTexture.J2C + */ + public static void Convert2J2C( string tif_filename, string j2c_filename ) + { + if( File.Exists("kdu_compress.exe") == false ) + { + throw new Exception("You must have kdu_compress.exe"); + } + + if( j2c_filename.ToLower().EndsWith(".j2c") == false ) + { + j2c_filename += ".j2c"; + } + + Process p = new Process(); + p.StartInfo.UseShellExecute = false; + p.StartInfo.FileName = "kdu_compress.exe"; + p.StartInfo.Arguments = "-no_info -no_weights -no_palette -i " + tif_filename + " -o " + j2c_filename; + p.Start(); + p.WaitForExit(); + } + + public static byte[] ReadJ2CData( string filename ) + { + if( (filename.ToLower().EndsWith(".j2c") == false) && (filename.ToLower().EndsWith(".tif") == true) ) + { + string tempname = filename + ".j2c"; + Convert2J2C( filename, tempname ); + filename = tempname; + } + + FileStream fs = File.OpenRead( filename ); + + byte[] data = new byte[fs.Length]; + + if( fs.Length > int.MaxValue ) + { + throw new Exception("AssetImage.cs: Bad stuff going to happen because length bigger then Max Integer"); + } + + fs.Read(data, 0, (int)fs.Length); + + return data; + } + } +} diff --git a/libsecondlife-cs/examples/IA_ImageTool/Properties/AssemblyInfo.cs b/libsecondlife-cs/examples/IA_ImageTool/Properties/AssemblyInfo.cs index 8a703faa..4760de8b 100644 --- a/libsecondlife-cs/examples/IA_ImageTool/Properties/AssemblyInfo.cs +++ b/libsecondlife-cs/examples/IA_ImageTool/Properties/AssemblyInfo.cs @@ -1,33 +1,33 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("ImageTool")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("ImageTool")] -[assembly: AssemblyCopyright("Copyright © 2006")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("e01867f5-7ab0-4b1a-aca6-19c7bd764a7b")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("ImageTool")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ImageTool")] +[assembly: AssemblyCopyright("Copyright © 2006")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("e01867f5-7ab0-4b1a-aca6-19c7bd764a7b")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/libsecondlife-cs/examples/IA_InventoryManager/IA_InventoryManager.csproj b/libsecondlife-cs/examples/IA_InventoryManager/IA_InventoryManager.csproj index 2191219a..0f61d276 100644 --- a/libsecondlife-cs/examples/IA_InventoryManager/IA_InventoryManager.csproj +++ b/libsecondlife-cs/examples/IA_InventoryManager/IA_InventoryManager.csproj @@ -1,58 +1,58 @@ - - - Debug - AnyCPU - 8.0.50727 - 2.0 - {D6D1D020-D8D8-4D7E-B7AC-5913A903D6E7} - Exe - Properties - IA_InventoryManager - iManager - IA_InventoryManager.iManager - - - true - full - false - ..\..\bin\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - {E464B963-46E3-4E1A-A36F-9C640C880E68} - IA_SimpleInventory - - - {D9CDEDFB-8169-4B03-B57F-0DF638F044EC} - libsecondlife - - - - + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {D6D1D020-D8D8-4D7E-B7AC-5913A903D6E7} + Exe + Properties + IA_InventoryManager + iManager + IA_InventoryManager.iManager + + + true + full + false + ..\..\bin\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + {E464B963-46E3-4E1A-A36F-9C640C880E68} + IA_SimpleInventory + + + {D9CDEDFB-8169-4B03-B57F-0DF638F044EC} + libsecondlife + + + + \ No newline at end of file diff --git a/libsecondlife-cs/examples/IA_InventoryManager/Properties/AssemblyInfo.cs b/libsecondlife-cs/examples/IA_InventoryManager/Properties/AssemblyInfo.cs index f286b799..4bd1e388 100644 --- a/libsecondlife-cs/examples/IA_InventoryManager/Properties/AssemblyInfo.cs +++ b/libsecondlife-cs/examples/IA_InventoryManager/Properties/AssemblyInfo.cs @@ -1,33 +1,33 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("IA_InventoryManager")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("IA_InventoryManager")] -[assembly: AssemblyCopyright("Copyright © 2006")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("f9eee737-3447-445a-9ff3-c1235c6f91d0")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("IA_InventoryManager")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("IA_InventoryManager")] +[assembly: AssemblyCopyright("Copyright © 2006")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("f9eee737-3447-445a-9ff3-c1235c6f91d0")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/libsecondlife-cs/examples/IA_InventoryManager/iManager.cs b/libsecondlife-cs/examples/IA_InventoryManager/iManager.cs index 92001b3c..012f435a 100644 --- a/libsecondlife-cs/examples/IA_InventoryManager/iManager.cs +++ b/libsecondlife-cs/examples/IA_InventoryManager/iManager.cs @@ -1,261 +1,261 @@ -using System; -using System.Collections.Generic; -using System.Text; - -using IA_SimpleInventory; -using libsecondlife; -using libsecondlife.InventorySystem; - -namespace IA_InventoryManager -{ - /// - /// Todo: - /// * TYPE or VIEW (for notecards, landmarks, etc) - /// * RENAME - /// * DOWNLOAD - /// * COPY - /// * MOVE - /// * GIVE - /// - class iManager : SimpleInventory - { - private char[] cmdSeperators = { ' ' }; - private string curDirectory = "/"; - - private string TYPE_DIR = " "; - private string TYPE_ITEM = " "; - - - static new void Main(string[] args) - { - if (args.Length < 3) - { - Console.WriteLine("Usage: Inventory [first] [last] [password]"); - return; - } - - iManager it = new iManager(); - it.Connect(args[0], args[1], args[2]); - it.doStuff(); - it.Disconnect(); - - System.Threading.Thread.Sleep(500); - - } - - private new void doStuff() - { - System.Threading.Thread.Sleep(1000); - - Console.WriteLine("=================================================================="); - Console.WriteLine("The Inventory Manager program provides a simple shell for working with your Second Life[tm] Avatar's Inventory."); - Console.WriteLine(); - Console.WriteLine("Type HELP for a list of available commands."); - Console.WriteLine("-------------------------------------------"); - - bool shutdown = false; - - - do - { - Console.WriteLine(); - Console.Write( curDirectory + "> "); - - string curCmd = Console.ReadLine(); - string[] curCmdLine = curCmd.Split(cmdSeperators); - - switch (curCmdLine[0].ToLower()) - { - case "quit": - case "exit": - case "q": - shutdown = true; - break; - - case "help": - help(); - break; - - case "ls": - case "dir": - ls( curCmdLine ); - break; - - case "cd": - cd(curCmdLine); - break; - - case "mkdir": - mkdir(curCmdLine); - break; - - case "rmdir": - rmdir(curCmdLine); - break; - - default: - Console.WriteLine("Unknown command '" + curCmdLine[0] + "'."); - Console.WriteLine("Type HELP for a list of available commands."); - break; - } - - } while (shutdown == false); - - } - - private void help() - { - Console.WriteLine("Currently available commands are: "); - Console.WriteLine("LS - List contents of the current directory."); - Console.WriteLine("CD [dir] - Change directory."); - Console.WriteLine("MKDIR [dir] - Make a new directory."); - Console.WriteLine("RMDIR [dir] - Remove directory."); - Console.WriteLine("QUIT - Exit the Inventory Manager."); - } - - private void rmdir(string[] cmdLine) - { - if (cmdLine.Length < 2) - { - Console.WriteLine("Usage: rmdir [directory]"); - Console.WriteLine("Example: rmdir SubDir"); - return; - } - - string targetDir = ""; - if (!curDirectory.Equals("/")) - { - targetDir = curDirectory + "/"; - - } - targetDir += combineCmdArg(cmdLine); - - InventoryFolder iFolder = AgentInventory.getFolder(targetDir); - if (iFolder == null) - { - Console.WriteLine("Could not find directory: " + targetDir); - return; - } - else - { - iFolder.Delete(); - } - } - - private void mkdir(string[] cmdLine) - { - if (cmdLine.Length < 2) - { - Console.WriteLine("Usage: mkdir [directory]"); - Console.WriteLine("Example: mkdir SubDir"); - return; - } - - string targetDir = combineCmdArg(cmdLine); - - InventoryFolder iFolder = AgentInventory.getFolder(curDirectory); - - InventoryFolder newFolder = iFolder.CreateFolder(targetDir); - - if (newFolder != null) - { - Console.WriteLine("Directory created: " + targetDir); - } - else - { - Console.WriteLine("Error creating directory: " + targetDir); - } - } - - private void cd(string[] cmdLine) - { - if( cmdLine.Length < 2 ) - { - Console.WriteLine("Usage: cd [directory]"); - Console.WriteLine("Example: cd /Notecards"); - return; - } - - string targetDir = ""; - - if (cmdLine[1].Equals("..")) - { - targetDir = curDirectory.Substring(0, curDirectory.LastIndexOf("/")); - } - else if (cmdLine[1].StartsWith("/")) - { - targetDir += combineCmdArg(cmdLine); - } - else - { - if (!curDirectory.Equals("/")) - { - targetDir = curDirectory + "/"; - - } - - targetDir += combineCmdArg(cmdLine); - } - Console.WriteLine("Changing directory to: " + targetDir ); - - - InventoryFolder iFolder = AgentInventory.getFolder(targetDir); - - if (iFolder == null) - { - Console.WriteLine("Could not find directory: " + targetDir); - return; - } - else - { - if (targetDir.StartsWith("/")) - { - curDirectory = targetDir; - } - else - { - curDirectory = "/" + targetDir; - } - } - } - - private void ls(string[] cmdLine) - { - Console.WriteLine("Contents of: " + curDirectory); - Console.WriteLine("--------------------------------------------------"); - if (!curDirectory.Equals("/")) - { - Console.WriteLine(".."); - } - - InventoryFolder iFolder = AgentInventory.getFolder(curDirectory); - foreach (InventoryBase ib in iFolder.alContents) - { - if (ib is InventoryFolder) - { - InventoryFolder folder = (InventoryFolder)ib; - Console.WriteLine(TYPE_DIR + folder.Name); - } - else - { - InventoryItem item = (InventoryItem)ib; - Console.WriteLine(TYPE_ITEM + item.Name); - } - } - } - - private string combineCmdArg( string[] cmdLine ) - { - return combineString( cmdLine, 1 ); - } - private string combineString( string[] parts, int start ) - { - string rtn = ""; - for (int i = start; i < parts.Length; i++) - { - rtn += " " + parts[i]; - } - return rtn.Trim(); - } - } -} +using System; +using System.Collections.Generic; +using System.Text; + +using IA_SimpleInventory; +using libsecondlife; +using libsecondlife.InventorySystem; + +namespace IA_InventoryManager +{ + /// + /// Todo: + /// * TYPE or VIEW (for notecards, landmarks, etc) + /// * RENAME + /// * DOWNLOAD + /// * COPY + /// * MOVE + /// * GIVE + /// + class iManager : SimpleInventory + { + private char[] cmdSeperators = { ' ' }; + private string curDirectory = "/"; + + private string TYPE_DIR = " "; + private string TYPE_ITEM = " "; + + + static new void Main(string[] args) + { + if (args.Length < 3) + { + Console.WriteLine("Usage: Inventory [first] [last] [password]"); + return; + } + + iManager it = new iManager(); + it.Connect(args[0], args[1], args[2]); + it.doStuff(); + it.Disconnect(); + + System.Threading.Thread.Sleep(500); + + } + + private new void doStuff() + { + System.Threading.Thread.Sleep(1000); + + Console.WriteLine("=================================================================="); + Console.WriteLine("The Inventory Manager program provides a simple shell for working with your Second Life[tm] Avatar's Inventory."); + Console.WriteLine(); + Console.WriteLine("Type HELP for a list of available commands."); + Console.WriteLine("-------------------------------------------"); + + bool shutdown = false; + + + do + { + Console.WriteLine(); + Console.Write( curDirectory + "> "); + + string curCmd = Console.ReadLine(); + string[] curCmdLine = curCmd.Split(cmdSeperators); + + switch (curCmdLine[0].ToLower()) + { + case "quit": + case "exit": + case "q": + shutdown = true; + break; + + case "help": + help(); + break; + + case "ls": + case "dir": + ls( curCmdLine ); + break; + + case "cd": + cd(curCmdLine); + break; + + case "mkdir": + mkdir(curCmdLine); + break; + + case "rmdir": + rmdir(curCmdLine); + break; + + default: + Console.WriteLine("Unknown command '" + curCmdLine[0] + "'."); + Console.WriteLine("Type HELP for a list of available commands."); + break; + } + + } while (shutdown == false); + + } + + private void help() + { + Console.WriteLine("Currently available commands are: "); + Console.WriteLine("LS - List contents of the current directory."); + Console.WriteLine("CD [dir] - Change directory."); + Console.WriteLine("MKDIR [dir] - Make a new directory."); + Console.WriteLine("RMDIR [dir] - Remove directory."); + Console.WriteLine("QUIT - Exit the Inventory Manager."); + } + + private void rmdir(string[] cmdLine) + { + if (cmdLine.Length < 2) + { + Console.WriteLine("Usage: rmdir [directory]"); + Console.WriteLine("Example: rmdir SubDir"); + return; + } + + string targetDir = ""; + if (!curDirectory.Equals("/")) + { + targetDir = curDirectory + "/"; + + } + targetDir += combineCmdArg(cmdLine); + + InventoryFolder iFolder = AgentInventory.getFolder(targetDir); + if (iFolder == null) + { + Console.WriteLine("Could not find directory: " + targetDir); + return; + } + else + { + iFolder.Delete(); + } + } + + private void mkdir(string[] cmdLine) + { + if (cmdLine.Length < 2) + { + Console.WriteLine("Usage: mkdir [directory]"); + Console.WriteLine("Example: mkdir SubDir"); + return; + } + + string targetDir = combineCmdArg(cmdLine); + + InventoryFolder iFolder = AgentInventory.getFolder(curDirectory); + + InventoryFolder newFolder = iFolder.CreateFolder(targetDir); + + if (newFolder != null) + { + Console.WriteLine("Directory created: " + targetDir); + } + else + { + Console.WriteLine("Error creating directory: " + targetDir); + } + } + + private void cd(string[] cmdLine) + { + if( cmdLine.Length < 2 ) + { + Console.WriteLine("Usage: cd [directory]"); + Console.WriteLine("Example: cd /Notecards"); + return; + } + + string targetDir = ""; + + if (cmdLine[1].Equals("..")) + { + targetDir = curDirectory.Substring(0, curDirectory.LastIndexOf("/")); + } + else if (cmdLine[1].StartsWith("/")) + { + targetDir += combineCmdArg(cmdLine); + } + else + { + if (!curDirectory.Equals("/")) + { + targetDir = curDirectory + "/"; + + } + + targetDir += combineCmdArg(cmdLine); + } + Console.WriteLine("Changing directory to: " + targetDir ); + + + InventoryFolder iFolder = AgentInventory.getFolder(targetDir); + + if (iFolder == null) + { + Console.WriteLine("Could not find directory: " + targetDir); + return; + } + else + { + if (targetDir.StartsWith("/")) + { + curDirectory = targetDir; + } + else + { + curDirectory = "/" + targetDir; + } + } + } + + private void ls(string[] cmdLine) + { + Console.WriteLine("Contents of: " + curDirectory); + Console.WriteLine("--------------------------------------------------"); + if (!curDirectory.Equals("/")) + { + Console.WriteLine(".."); + } + + InventoryFolder iFolder = AgentInventory.getFolder(curDirectory); + foreach (InventoryBase ib in iFolder.alContents) + { + if (ib is InventoryFolder) + { + InventoryFolder folder = (InventoryFolder)ib; + Console.WriteLine(TYPE_DIR + folder.Name); + } + else + { + InventoryItem item = (InventoryItem)ib; + Console.WriteLine(TYPE_ITEM + item.Name); + } + } + } + + private string combineCmdArg( string[] cmdLine ) + { + return combineString( cmdLine, 1 ); + } + private string combineString( string[] parts, int start ) + { + string rtn = ""; + for (int i = start; i < parts.Length; i++) + { + rtn += " " + parts[i]; + } + return rtn.Trim(); + } + } +} diff --git a/libsecondlife-cs/examples/IA_NotecardTool/IA_NotecardTool.csproj b/libsecondlife-cs/examples/IA_NotecardTool/IA_NotecardTool.csproj index 1c85dd17..af465216 100644 --- a/libsecondlife-cs/examples/IA_NotecardTool/IA_NotecardTool.csproj +++ b/libsecondlife-cs/examples/IA_NotecardTool/IA_NotecardTool.csproj @@ -1,58 +1,58 @@ - - - Debug - AnyCPU - 8.0.50727 - 2.0 - {E185E4E1-62D2-430C-A94C-E8E38190805B} - Exe - Properties - IA_NotecardTool - NotecardTool - IA_NotecardTool.NotecardTool - - - true - full - false - ..\..\..\bin\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - {D9CDEDFB-8169-4B03-B57F-0DF638F044EC} - libsecondlife - - - {E464B963-46E3-4E1A-A36F-9C640C880E68} - IA_SimpleInventory - - - - + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {E185E4E1-62D2-430C-A94C-E8E38190805B} + Exe + Properties + IA_NotecardTool + NotecardTool + IA_NotecardTool.NotecardTool + + + true + full + false + ..\..\..\bin\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + {D9CDEDFB-8169-4B03-B57F-0DF638F044EC} + libsecondlife + + + {E464B963-46E3-4E1A-A36F-9C640C880E68} + IA_SimpleInventory + + + + \ No newline at end of file diff --git a/libsecondlife-cs/examples/IA_NotecardTool/NotecardTool.cs b/libsecondlife-cs/examples/IA_NotecardTool/NotecardTool.cs index fd2a3b42..e8424bac 100644 --- a/libsecondlife-cs/examples/IA_NotecardTool/NotecardTool.cs +++ b/libsecondlife-cs/examples/IA_NotecardTool/NotecardTool.cs @@ -1,85 +1,85 @@ -/* - * Copyright (c) 2006, Second Life Reverse Engineering Team - * All rights reserved. - * - * - Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - Neither the name of the Second Life Reverse Engineering Team nor the names - * of its contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; - -using IA_SimpleInventory; -using libsecondlife; -using libsecondlife.InventorySystem; - -namespace IA_NotecardTool -{ - class NotecardTool : SimpleInventory - { - private string FileName; - private string NotecardName; - - static new void Main(string[] args) - { - if (args.Length < 6) - { - Console.WriteLine("Usage: NotecardTool [first] [last] [password] [put] [name] [notecard.txt] "); - return; - } - - if( !File.Exists(args[5]) ) - { - Console.WriteLine("Cannot find file: " + args[5]); - return; - } - - NotecardTool tool = new NotecardTool(); - tool.NotecardName = args[4] + " : " + Helpers.GetUnixTime(); - tool.FileName = args[5]; - - tool.Connect(args[0], args[1], args[2]); - tool.doStuff(); - tool.Disconnect(); - - System.Threading.Thread.Sleep(500); - - } - - private new void doStuff() - { - Console.WriteLine("Reading " + FileName); - StreamReader sr = File.OpenText(FileName); - string Body = sr.ReadToEnd(); - - Console.WriteLine("Getting Notecard Folder"); - InventoryFolder iFolder = base.AgentInventory.getFolder("Notecards"); - - - Console.WriteLine("Creating Notecard"); - iFolder.NewNotecard(NotecardName, "Imported by libsl Notecard Tool", Body); - - Console.WriteLine("Done."); - } - } -} +/* + * Copyright (c) 2006, Second Life Reverse Engineering Team + * All rights reserved. + * + * - Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Neither the name of the Second Life Reverse Engineering Team nor the names + * of its contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; + +using IA_SimpleInventory; +using libsecondlife; +using libsecondlife.InventorySystem; + +namespace IA_NotecardTool +{ + class NotecardTool : SimpleInventory + { + private string FileName; + private string NotecardName; + + static new void Main(string[] args) + { + if (args.Length < 6) + { + Console.WriteLine("Usage: NotecardTool [first] [last] [password] [put] [name] [notecard.txt] "); + return; + } + + if( !File.Exists(args[5]) ) + { + Console.WriteLine("Cannot find file: " + args[5]); + return; + } + + NotecardTool tool = new NotecardTool(); + tool.NotecardName = args[4] + " : " + Helpers.GetUnixTime(); + tool.FileName = args[5]; + + tool.Connect(args[0], args[1], args[2]); + tool.doStuff(); + tool.Disconnect(); + + System.Threading.Thread.Sleep(500); + + } + + private new void doStuff() + { + Console.WriteLine("Reading " + FileName); + StreamReader sr = File.OpenText(FileName); + string Body = sr.ReadToEnd(); + + Console.WriteLine("Getting Notecard Folder"); + InventoryFolder iFolder = base.AgentInventory.getFolder("Notecards"); + + + Console.WriteLine("Creating Notecard"); + iFolder.NewNotecard(NotecardName, "Imported by libsl Notecard Tool", Body); + + Console.WriteLine("Done."); + } + } +} diff --git a/libsecondlife-cs/examples/IA_NotecardTool/Properties/AssemblyInfo.cs b/libsecondlife-cs/examples/IA_NotecardTool/Properties/AssemblyInfo.cs index 2b4eee51..f4f4e181 100644 --- a/libsecondlife-cs/examples/IA_NotecardTool/Properties/AssemblyInfo.cs +++ b/libsecondlife-cs/examples/IA_NotecardTool/Properties/AssemblyInfo.cs @@ -1,33 +1,33 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("IA_NotecardTool")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("IA_NotecardTool")] -[assembly: AssemblyCopyright("Copyright © 2006")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("2f12f3fd-adb3-408b-9f70-ed6e9fa25cff")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("IA_NotecardTool")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("IA_NotecardTool")] +[assembly: AssemblyCopyright("Copyright © 2006")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("2f12f3fd-adb3-408b-9f70-ed6e9fa25cff")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/libsecondlife-cs/examples/IA_SimpleInventory/IA_SimpleInventory.cs b/libsecondlife-cs/examples/IA_SimpleInventory/IA_SimpleInventory.cs index c9e34f23..04b58af8 100644 --- a/libsecondlife-cs/examples/IA_SimpleInventory/IA_SimpleInventory.cs +++ b/libsecondlife-cs/examples/IA_SimpleInventory/IA_SimpleInventory.cs @@ -1,129 +1,129 @@ -/* - * Copyright (c) 2006, Second Life Reverse Engineering Team - * All rights reserved. - * - * - Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - Neither the name of the Second Life Reverse Engineering Team nor the names - * of its contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections; - -using libsecondlife; -using libsecondlife.InventorySystem; - -namespace IA_SimpleInventory -{ - /// - /// A simple base application for building console applications that access SL Inventory - /// - public class SimpleInventory - { - protected SecondLife client; - protected InventoryManager AgentInventory; - - protected bool DownloadInventoryOnConnect = true; - - public static void Main( string[] args ) - { - - if (args.Length < 3) - { - Console.WriteLine("Usage: SimpleInventory [loginfirstname] [loginlastname] [password]"); - return; - } - - SimpleInventory simple = new SimpleInventory(); - simple.Connect(args[0], args[1], args[2]); - simple.doStuff(); - simple.Disconnect(); - } - - protected SimpleInventory() - { - try - { - client = new SecondLife(); - } - catch (Exception e) - { - // Error initializing the client - Console.WriteLine(); - Console.WriteLine(e.ToString()); - } - } - - protected void Connect(string FirstName, string LastName, string Password) - { - Console.WriteLine("Attempting to connect and login to SecondLife."); - - // Setup Login to Second Life - Hashtable loginParams = NetworkManager.DefaultLoginValues(FirstName, LastName, Password, "00:00:00:00:00:00", - "last", "Win", "0", "createnotecard", "static.sprocket@gmail.com"); - Hashtable loginReply = new Hashtable(); - - // Login - if (!client.Network.Login(loginParams)) - { - // Login failed - Console.WriteLine("Error logging in: " + client.Network.LoginError); - return; - } - - // Login was successful - Console.WriteLine("Login was successful."); - Console.WriteLine("AgentID: " + client.Network.AgentID); - Console.WriteLine("SessionID: " + client.Network.SessionID); - - // Get Root Inventory Folder UUID - Console.WriteLine("Pulling root folder UUID from login data."); - ArrayList alInventoryRoot = (ArrayList)client.Network.LoginValues["inventory-root"]; - Hashtable htInventoryRoot = (Hashtable)alInventoryRoot[0]; - LLUUID agentRootFolderID = new LLUUID( (string)htInventoryRoot["folder_id"] ); - - // Initialize Inventory Manager object - Console.WriteLine("Initializing Inventory Manager."); - AgentInventory = new InventoryManager(client, agentRootFolderID); - - if( DownloadInventoryOnConnect ) - { - // and request an inventory download - Console.WriteLine("Downloading Inventory."); - AgentInventory.DownloadInventory(); - } - } - - protected void Disconnect() - { - // Logout of Second Life - Console.WriteLine("Request logout"); - client.Network.Logout(); - } - - protected void doStuff() - { - Console.WriteLine("Dumping a copy of " + client.Avatar.FirstName + "'s inventory to the console."); - Console.WriteLine(); - - Console.WriteLine(AgentInventory.getRootFolder().toXML(false)); - } - } -} +/* + * Copyright (c) 2006, Second Life Reverse Engineering Team + * All rights reserved. + * + * - Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Neither the name of the Second Life Reverse Engineering Team nor the names + * of its contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; + +using libsecondlife; +using libsecondlife.InventorySystem; + +namespace IA_SimpleInventory +{ + /// + /// A simple base application for building console applications that access SL Inventory + /// + public class SimpleInventory + { + protected SecondLife client; + protected InventoryManager AgentInventory; + + protected bool DownloadInventoryOnConnect = true; + + public static void Main( string[] args ) + { + + if (args.Length < 3) + { + Console.WriteLine("Usage: SimpleInventory [loginfirstname] [loginlastname] [password]"); + return; + } + + SimpleInventory simple = new SimpleInventory(); + simple.Connect(args[0], args[1], args[2]); + simple.doStuff(); + simple.Disconnect(); + } + + protected SimpleInventory() + { + try + { + client = new SecondLife(); + } + catch (Exception e) + { + // Error initializing the client + Console.WriteLine(); + Console.WriteLine(e.ToString()); + } + } + + protected void Connect(string FirstName, string LastName, string Password) + { + Console.WriteLine("Attempting to connect and login to SecondLife."); + + // Setup Login to Second Life + Hashtable loginParams = NetworkManager.DefaultLoginValues(FirstName, LastName, Password, "00:00:00:00:00:00", + "last", "Win", "0", "createnotecard", "static.sprocket@gmail.com"); + Hashtable loginReply = new Hashtable(); + + // Login + if (!client.Network.Login(loginParams)) + { + // Login failed + Console.WriteLine("Error logging in: " + client.Network.LoginError); + return; + } + + // Login was successful + Console.WriteLine("Login was successful."); + Console.WriteLine("AgentID: " + client.Network.AgentID); + Console.WriteLine("SessionID: " + client.Network.SessionID); + + // Get Root Inventory Folder UUID + Console.WriteLine("Pulling root folder UUID from login data."); + ArrayList alInventoryRoot = (ArrayList)client.Network.LoginValues["inventory-root"]; + Hashtable htInventoryRoot = (Hashtable)alInventoryRoot[0]; + LLUUID agentRootFolderID = new LLUUID( (string)htInventoryRoot["folder_id"] ); + + // Initialize Inventory Manager object + Console.WriteLine("Initializing Inventory Manager."); + AgentInventory = new InventoryManager(client, agentRootFolderID); + + if( DownloadInventoryOnConnect ) + { + // and request an inventory download + Console.WriteLine("Downloading Inventory."); + AgentInventory.DownloadInventory(); + } + } + + protected void Disconnect() + { + // Logout of Second Life + Console.WriteLine("Request logout"); + client.Network.Logout(); + } + + protected void doStuff() + { + Console.WriteLine("Dumping a copy of " + client.Avatar.FirstName + "'s inventory to the console."); + Console.WriteLine(); + + Console.WriteLine(AgentInventory.getRootFolder().toXML(false)); + } + } +} diff --git a/libsecondlife-cs/examples/IA_SimpleInventory/IA_SimpleInventory.csproj b/libsecondlife-cs/examples/IA_SimpleInventory/IA_SimpleInventory.csproj index 4ca38351..5d7963d3 100644 --- a/libsecondlife-cs/examples/IA_SimpleInventory/IA_SimpleInventory.csproj +++ b/libsecondlife-cs/examples/IA_SimpleInventory/IA_SimpleInventory.csproj @@ -1,53 +1,53 @@ - - - Debug - AnyCPU - 8.0.50727 - 2.0 - {E464B963-46E3-4E1A-A36F-9C640C880E68} - Exe - Properties - IA_SimpleInventory - IA_SimpleInventory - - - true - full - false - ..\..\..\bin\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - {D9CDEDFB-8169-4B03-B57F-0DF638F044EC} - libsecondlife - - - - + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {E464B963-46E3-4E1A-A36F-9C640C880E68} + Exe + Properties + IA_SimpleInventory + IA_SimpleInventory + + + true + full + false + ..\..\..\bin\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + {D9CDEDFB-8169-4B03-B57F-0DF638F044EC} + libsecondlife + + + + \ No newline at end of file diff --git a/libsecondlife-cs/examples/IA_SimpleInventory/Properties/AssemblyInfo.cs b/libsecondlife-cs/examples/IA_SimpleInventory/Properties/AssemblyInfo.cs index 2a354333..1e2754cd 100644 --- a/libsecondlife-cs/examples/IA_SimpleInventory/Properties/AssemblyInfo.cs +++ b/libsecondlife-cs/examples/IA_SimpleInventory/Properties/AssemblyInfo.cs @@ -1,33 +1,33 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("IA_SimpleInventory")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("IA_SimpleInventory")] -[assembly: AssemblyCopyright("Copyright © 2006")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("a166c7c2-97fd-4bd2-8733-a156db565a4b")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("IA_SimpleInventory")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("IA_SimpleInventory")] +[assembly: AssemblyCopyright("Copyright © 2006")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("a166c7c2-97fd-4bd2-8733-a156db565a4b")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/libsecondlife-cs/examples/ParcelDownload/ParcelDownload.cs b/libsecondlife-cs/examples/ParcelDownload/ParcelDownload.cs index a9f93941..1d80894b 100644 --- a/libsecondlife-cs/examples/ParcelDownload/ParcelDownload.cs +++ b/libsecondlife-cs/examples/ParcelDownload/ParcelDownload.cs @@ -1,86 +1,86 @@ -/* - * Copyright (c) 2006, Second Life Reverse Engineering Team - * All rights reserved. - * - * - Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - Neither the name of the Second Life Reverse Engineering Team nor the names - * of its contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections; -using libsecondlife; - -namespace ParcelDownloader -{ - /// - /// Summary description for ParcelDownload. - /// - class ParcelDownload - { - static SecondLife client; - - /// - /// The main entry point for the application. - /// - [STAThread] - static void Main(string[] args) - { - - if (args.Length < 3) - { - Console.WriteLine("Usage: ParcelDownloader [loginfirstname] [loginlastname] [password]"); - return; - } - - client = new SecondLife(); - - Hashtable loginParams = NetworkManager.DefaultLoginValues(args[0], args[1], args[2], "00:00:00:00:00:00", - "last", "Win", "0", "ParcelDownload", "Adam \"Zaius\" Frisby "); - - if (!client.Network.Login(loginParams)) - { - // Login failed - Console.WriteLine("ERROR: " + client.Network.LoginError); - return; - } - - // The magic happens in these three lines - client.Network.CurrentSim.Region.FillParcels(); // Tell libsl to download parcels - System.Threading.Thread.Sleep(10000); // Give it some time to do it - client.Tick(); // Let things happen - - // Dump some info about our parcels - foreach (int pkey in client.Network.CurrentSim.Region.Parcels.Keys) - { - Parcel parcel = (Parcel)client.Network.CurrentSim.Region.Parcels[pkey]; - // Probably should comment this out :-) - //parcel.Buy(client,false,new LLUUID()); - Console.WriteLine(""); - Console.WriteLine("\tName: " + parcel.Name); - Console.WriteLine("\tSize: " + parcel.Area); - Console.WriteLine("\tDesc: " + parcel.Desc); - } - - client.Network.Logout(); - return; - } - } -} +/* + * Copyright (c) 2006, Second Life Reverse Engineering Team + * All rights reserved. + * + * - Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Neither the name of the Second Life Reverse Engineering Team nor the names + * of its contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using libsecondlife; + +namespace ParcelDownloader +{ + /// + /// Summary description for ParcelDownload. + /// + class ParcelDownload + { + static SecondLife client; + + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main(string[] args) + { + + if (args.Length < 3) + { + Console.WriteLine("Usage: ParcelDownloader [loginfirstname] [loginlastname] [password]"); + return; + } + + client = new SecondLife(); + + Hashtable loginParams = NetworkManager.DefaultLoginValues(args[0], args[1], args[2], "00:00:00:00:00:00", + "last", "Win", "0", "ParcelDownload", "Adam \"Zaius\" Frisby "); + + if (!client.Network.Login(loginParams)) + { + // Login failed + Console.WriteLine("ERROR: " + client.Network.LoginError); + return; + } + + // The magic happens in these three lines + client.Network.CurrentSim.Region.FillParcels(); // Tell libsl to download parcels + System.Threading.Thread.Sleep(10000); // Give it some time to do it + client.Tick(); // Let things happen + + // Dump some info about our parcels + foreach (int pkey in client.Network.CurrentSim.Region.Parcels.Keys) + { + Parcel parcel = (Parcel)client.Network.CurrentSim.Region.Parcels[pkey]; + // Probably should comment this out :-) + //parcel.Buy(client,false,new LLUUID()); + Console.WriteLine(""); + Console.WriteLine("\tName: " + parcel.Name); + Console.WriteLine("\tSize: " + parcel.Area); + Console.WriteLine("\tDesc: " + parcel.Desc); + } + + client.Network.Logout(); + return; + } + } +} diff --git a/libsecondlife-cs/examples/ParcelDownload/ParcelDownload.csproj b/libsecondlife-cs/examples/ParcelDownload/ParcelDownload.csproj index 1587756e..484e28a0 100644 --- a/libsecondlife-cs/examples/ParcelDownload/ParcelDownload.csproj +++ b/libsecondlife-cs/examples/ParcelDownload/ParcelDownload.csproj @@ -1,104 +1,104 @@ - - - Local - 8.0.50727 - 2.0 - {623B86F7-7753-44B7-A8C8-CBC89FB8AF8E} - Debug - AnyCPU - - - - - ParcelDownload - - - JScript - Grid - IE50 - false - Exe - ParcelDownload - OnBuildSuccess - - - - - - - - - bin\Debug\ - false - 285212672 - false - - - DEBUG;TRACE - - - true - 4096 - false - - - false - false - false - false - 4 - full - prompt - - - bin\Release\ - false - 285212672 - false - - - TRACE - - - false - 4096 - false - - - true - false - false - false - 4 - none - prompt - - - - System - - - System.Data - - - System.XML - - - libsecondlife - {D9CDEDFB-8169-4B03-B57F-0DF638F044EC} - {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - - - - - Code - - - - - - - - - + + + Local + 8.0.50727 + 2.0 + {623B86F7-7753-44B7-A8C8-CBC89FB8AF8E} + Debug + AnyCPU + + + + + ParcelDownload + + + JScript + Grid + IE50 + false + Exe + ParcelDownload + OnBuildSuccess + + + + + + + + + bin\Debug\ + false + 285212672 + false + + + DEBUG;TRACE + + + true + 4096 + false + + + false + false + false + false + 4 + full + prompt + + + bin\Release\ + false + 285212672 + false + + + TRACE + + + false + 4096 + false + + + true + false + false + false + 4 + none + prompt + + + + System + + + System.Data + + + System.XML + + + libsecondlife + {D9CDEDFB-8169-4B03-B57F-0DF638F044EC} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + + + + + Code + + + + + + + + + \ No newline at end of file diff --git a/libsecondlife-cs/examples/Teleport/Properties/AssemblyInfo.cs b/libsecondlife-cs/examples/Teleport/Properties/AssemblyInfo.cs index bbb8f50d..ddd31ceb 100644 --- a/libsecondlife-cs/examples/Teleport/Properties/AssemblyInfo.cs +++ b/libsecondlife-cs/examples/Teleport/Properties/AssemblyInfo.cs @@ -1,33 +1,33 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Teleport")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Teleport")] -[assembly: AssemblyCopyright("Copyright © 2006")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("a58948b5-e70a-4b43-bd37-76a126f63b08")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Teleport")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Teleport")] +[assembly: AssemblyCopyright("Copyright © 2006")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("a58948b5-e70a-4b43-bd37-76a126f63b08")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/libsecondlife-cs/examples/Teleport/Teleport.cs b/libsecondlife-cs/examples/Teleport/Teleport.cs index ce945b3e..6469c954 100644 --- a/libsecondlife-cs/examples/Teleport/Teleport.cs +++ b/libsecondlife-cs/examples/Teleport/Teleport.cs @@ -1,138 +1,138 @@ -using System; -using System.Collections; - -using libsecondlife; - - -namespace Teleport -{ - class Teleport - { - protected SecondLife client; - protected bool DoneTeleporting = false; - - static void Main(string[] args) - { - if (args.Length < 4) - { - Console.WriteLine("Usage: Teleport [loginfirstname] [loginlastname] [password] [sim/x/y/z]"); - return; - } - - char[] seps = { '/' }; - string[] destination = args[3].Split(seps); - if( destination.Length != 4 ) - { - Console.WriteLine("Destination should be specified as: sim/x/y/z"); - return; - } - - string sim = destination[0]; - float x = float.Parse(destination[1]); - float y = float.Parse(destination[2]); - float z = float.Parse(destination[3]); - - Console.WriteLine("Will attempt a teleport to " + sim + " {" + x + "," + y + "," + z + "}..."); - Console.WriteLine(); - - Teleport app = new Teleport(); - bool success = app.Connect(args[0], args[1], args[2]); - if (success) - { - while (app.client.Network.CurrentSim.Region.Name == null) - { - System.Threading.Thread.Sleep(100); - } - - if (sim.ToLower() == app.client.Network.CurrentSim.Region.Name.ToLower()) - { - Console.WriteLine("TODO: Add the ability to teleport somewhere in the local region. " + - "Exiting for now, please specify a region other than the current one"); - } - else - { - app.doStuff(sim, new LLVector3(x, y, z)); - } - - app.Disconnect(); - } - } - - protected Teleport() - { - try - { - client = new SecondLife(); - } - catch (Exception e) - { - // Error initializing the client - Console.WriteLine(); - Console.WriteLine(e.ToString()); - } - } - - protected bool Connect(string FirstName, string LastName, string Password) - { - Console.WriteLine("Attempting to connect and login to SecondLife."); - - // Setup Login to Second Life - Hashtable loginParams = NetworkManager.DefaultLoginValues(FirstName, LastName, Password, "00:00:00:00:00:00", - "last", "Win", "0", "createnotecard", "static.sprocket@gmail.com"); - Hashtable loginReply = new Hashtable(); - - // Login - if (!client.Network.Login(loginParams)) - { - // Login failed - Console.WriteLine("Error logging in: " + client.Network.LoginError); - return false; - } - - // Login was successful - Console.WriteLine("Login was successful."); - Console.WriteLine("AgentID: " + client.Network.AgentID); - Console.WriteLine("SessionID: " + client.Network.SessionID); - - return true; - } - - protected void Disconnect() - { - // Logout of Second Life - Console.WriteLine("Request logout"); - client.Network.Logout(); - } - - protected void doStuff(string sim, LLVector3 coords) - { - // Load up the list of estate simulators, incase we get a request to teleport to one. - // This doesn't block, and there's no easy way to know when it's done, so we'll wait a bit - // and hope for the best? - client.Grid.AddEstateSims(); - - System.Threading.Thread.Sleep(3000); - Console.WriteLine(); - Console.WriteLine("Okay, hopefully all the initial connect stuff is done, trying now..."); - - client.Avatar.OnTeleport += new TeleportCallback(Avatar_OnTeleportMessage); - - DoneTeleporting = false; - client.Avatar.Teleport(sim, coords); - - while (!DoneTeleporting) - { - client.Tick(); - } - } - - protected void Avatar_OnTeleportMessage(string message) - { - Console.WriteLine(message); - if (!message.Equals("Teleport started")) - { - DoneTeleporting = true; - } - } - } -} +using System; +using System.Collections; + +using libsecondlife; + + +namespace Teleport +{ + class Teleport + { + protected SecondLife client; + protected bool DoneTeleporting = false; + + static void Main(string[] args) + { + if (args.Length < 4) + { + Console.WriteLine("Usage: Teleport [loginfirstname] [loginlastname] [password] [sim/x/y/z]"); + return; + } + + char[] seps = { '/' }; + string[] destination = args[3].Split(seps); + if( destination.Length != 4 ) + { + Console.WriteLine("Destination should be specified as: sim/x/y/z"); + return; + } + + string sim = destination[0]; + float x = float.Parse(destination[1]); + float y = float.Parse(destination[2]); + float z = float.Parse(destination[3]); + + Console.WriteLine("Will attempt a teleport to " + sim + " {" + x + "," + y + "," + z + "}..."); + Console.WriteLine(); + + Teleport app = new Teleport(); + bool success = app.Connect(args[0], args[1], args[2]); + if (success) + { + while (app.client.Network.CurrentSim.Region.Name == null) + { + System.Threading.Thread.Sleep(100); + } + + if (sim.ToLower() == app.client.Network.CurrentSim.Region.Name.ToLower()) + { + Console.WriteLine("TODO: Add the ability to teleport somewhere in the local region. " + + "Exiting for now, please specify a region other than the current one"); + } + else + { + app.doStuff(sim, new LLVector3(x, y, z)); + } + + app.Disconnect(); + } + } + + protected Teleport() + { + try + { + client = new SecondLife(); + } + catch (Exception e) + { + // Error initializing the client + Console.WriteLine(); + Console.WriteLine(e.ToString()); + } + } + + protected bool Connect(string FirstName, string LastName, string Password) + { + Console.WriteLine("Attempting to connect and login to SecondLife."); + + // Setup Login to Second Life + Hashtable loginParams = NetworkManager.DefaultLoginValues(FirstName, LastName, Password, "00:00:00:00:00:00", + "last", "Win", "0", "createnotecard", "static.sprocket@gmail.com"); + Hashtable loginReply = new Hashtable(); + + // Login + if (!client.Network.Login(loginParams)) + { + // Login failed + Console.WriteLine("Error logging in: " + client.Network.LoginError); + return false; + } + + // Login was successful + Console.WriteLine("Login was successful."); + Console.WriteLine("AgentID: " + client.Network.AgentID); + Console.WriteLine("SessionID: " + client.Network.SessionID); + + return true; + } + + protected void Disconnect() + { + // Logout of Second Life + Console.WriteLine("Request logout"); + client.Network.Logout(); + } + + protected void doStuff(string sim, LLVector3 coords) + { + // Load up the list of estate simulators, incase we get a request to teleport to one. + // This doesn't block, and there's no easy way to know when it's done, so we'll wait a bit + // and hope for the best? + client.Grid.AddEstateSims(); + + System.Threading.Thread.Sleep(3000); + Console.WriteLine(); + Console.WriteLine("Okay, hopefully all the initial connect stuff is done, trying now..."); + + client.Avatar.OnTeleport += new TeleportCallback(Avatar_OnTeleportMessage); + + DoneTeleporting = false; + client.Avatar.Teleport(sim, coords); + + while (!DoneTeleporting) + { + client.Tick(); + } + } + + protected void Avatar_OnTeleportMessage(string message) + { + Console.WriteLine(message); + if (!message.Equals("Teleport started")) + { + DoneTeleporting = true; + } + } + } +} diff --git a/libsecondlife-cs/examples/Teleport/Teleport.csproj b/libsecondlife-cs/examples/Teleport/Teleport.csproj index f9d70edc..936b4c3a 100644 --- a/libsecondlife-cs/examples/Teleport/Teleport.csproj +++ b/libsecondlife-cs/examples/Teleport/Teleport.csproj @@ -1,54 +1,54 @@ - - - Debug - AnyCPU - 8.0.50727 - 2.0 - {B5AC6795-E426-4BC3-950F-D7B2970E2394} - Exe - Properties - Teleport - Teleport - Teleport.Teleport - - - true - full - false - ..\..\..\bin\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - {D9CDEDFB-8169-4B03-B57F-0DF638F044EC} - libsecondlife - - - - + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {B5AC6795-E426-4BC3-950F-D7B2970E2394} + Exe + Properties + Teleport + Teleport + Teleport.Teleport + + + true + full + false + ..\..\..\bin\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + {D9CDEDFB-8169-4B03-B57F-0DF638F044EC} + libsecondlife + + + + \ No newline at end of file diff --git a/libsecondlife-cs/examples/botmanager/botmanager.cs b/libsecondlife-cs/examples/botmanager/botmanager.cs index 4403f842..084dc56f 100644 --- a/libsecondlife-cs/examples/botmanager/botmanager.cs +++ b/libsecondlife-cs/examples/botmanager/botmanager.cs @@ -1,150 +1,150 @@ -/* - * Copyright (c) 2006, Second Life Reverse Engineering Team - * All rights reserved. - * - * - Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - Neither the name of the Second Life Reverse Engineering Team nor the names - * of its contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Threading; -using libsecondlife; -using libsecondlife.Packets; - -namespace botmanager -{ - public class Bot - { - public delegate void BotKilledHandler(Bot bot); - - public SecondLife Client; - public readonly string FirstName; - public readonly string LastName; - public readonly string Password; - - protected bool loggedIn = false; - public bool LoggedIn { get { return loggedIn; } } - - protected BotManager Manager; - protected BotKilledHandler KillHandler; - - public Bot(BotManager parent, BotKilledHandler killHandler, - string firstName, string lastName, string password) - { - Manager = parent; - KillHandler = killHandler; - FirstName = firstName; - LastName = lastName; - Password = password; - - Client = new SecondLife(); - Client.Network.OnDisconnected += new DisconnectCallback(DisconnectHandler); - } - - public bool Spawn() - { - if (!loggedIn) - { - Kill(); - } - - Hashtable loginParams = NetworkManager.DefaultLoginValues(FirstName, LastName, - Password, "00:00:00:00:00:00", "last", "Win", "0", - "botmanager", "contact@libsecondlife.org"); - - if (Client.Network.Login(loginParams)) - { - loggedIn = true; - return true; - } - else - { - loggedIn = false; - return false; - } - } - - public void Kill() - { - if (loggedIn) - { - Client.Network.Logout(); - } - } - - private void DisconnectHandler(DisconnectType type, string reason) - { - KillHandler(this); - } - } - - public class BotManager - { - protected List Bots; - - public BotManager() - { - Bots = new List(); - } - - public void AddBot(string firstName, string lastName, string password) - { - Bot bot = new Bot(this, new Bot.BotKilledHandler(KillHandler), firstName, lastName, password); - Bots.Add(bot); - AddBotToDB(bot); - } - - protected void AddBotToDB(Bot bot) - { - ; - } - - private void PollDBEvents() - { - ; - } - - private void KillHandler(Bot bot) - { - Console.WriteLine(bot.ToString() + " was killed"); - - if (Bots.Contains(bot)) - { - Bots.Remove(bot); - } - } - } - - class runbotmanager - { - /// - /// The main entry point for the application. - /// - [STAThread] - static void Main(string[] args) - { - BotManager manager = new BotManager(); - - } - } -} +/* + * Copyright (c) 2006, Second Life Reverse Engineering Team + * All rights reserved. + * + * - Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Neither the name of the Second Life Reverse Engineering Team nor the names + * of its contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Threading; +using libsecondlife; +using libsecondlife.Packets; + +namespace botmanager +{ + public class Bot + { + public delegate void BotKilledHandler(Bot bot); + + public SecondLife Client; + public readonly string FirstName; + public readonly string LastName; + public readonly string Password; + + protected bool loggedIn = false; + public bool LoggedIn { get { return loggedIn; } } + + protected BotManager Manager; + protected BotKilledHandler KillHandler; + + public Bot(BotManager parent, BotKilledHandler killHandler, + string firstName, string lastName, string password) + { + Manager = parent; + KillHandler = killHandler; + FirstName = firstName; + LastName = lastName; + Password = password; + + Client = new SecondLife(); + Client.Network.OnDisconnected += new DisconnectCallback(DisconnectHandler); + } + + public bool Spawn() + { + if (!loggedIn) + { + Kill(); + } + + Hashtable loginParams = NetworkManager.DefaultLoginValues(FirstName, LastName, + Password, "00:00:00:00:00:00", "last", "Win", "0", + "botmanager", "contact@libsecondlife.org"); + + if (Client.Network.Login(loginParams)) + { + loggedIn = true; + return true; + } + else + { + loggedIn = false; + return false; + } + } + + public void Kill() + { + if (loggedIn) + { + Client.Network.Logout(); + } + } + + private void DisconnectHandler(DisconnectType type, string reason) + { + KillHandler(this); + } + } + + public class BotManager + { + protected List Bots; + + public BotManager() + { + Bots = new List(); + } + + public void AddBot(string firstName, string lastName, string password) + { + Bot bot = new Bot(this, new Bot.BotKilledHandler(KillHandler), firstName, lastName, password); + Bots.Add(bot); + AddBotToDB(bot); + } + + protected void AddBotToDB(Bot bot) + { + ; + } + + private void PollDBEvents() + { + ; + } + + private void KillHandler(Bot bot) + { + Console.WriteLine(bot.ToString() + " was killed"); + + if (Bots.Contains(bot)) + { + Bots.Remove(bot); + } + } + } + + class runbotmanager + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main(string[] args) + { + BotManager manager = new BotManager(); + + } + } +} diff --git a/libsecondlife-cs/examples/botmanager/botmanager.csproj b/libsecondlife-cs/examples/botmanager/botmanager.csproj index b9463e61..6d3da277 100644 --- a/libsecondlife-cs/examples/botmanager/botmanager.csproj +++ b/libsecondlife-cs/examples/botmanager/botmanager.csproj @@ -1,105 +1,105 @@ - - - Local - 8.0.50727 - 2.0 - {3E891B97-7267-47D4-AAF1-7DCD2F6D60AB} - Debug - AnyCPU - - - - - botmanager - - - JScript - Grid - IE50 - false - Exe - botmanager - OnBuildSuccess - - - - - - - - - ..\..\..\bin\ - false - 285212672 - false - - - DEBUG;TRACE - - - true - 4096 - false - - - false - false - false - false - 4 - full - prompt - - - bin\Release\ - false - 285212672 - false - - - TRACE - - - false - 4096 - false - - - true - false - false - false - 4 - none - prompt - - - - System - - - System.Data - - - System.XML - - - libsecondlife - {D9CDEDFB-8169-4B03-B57F-0DF638F044EC} - {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - False - - - - - Code - - - - - - - - - + + + Local + 8.0.50727 + 2.0 + {3E891B97-7267-47D4-AAF1-7DCD2F6D60AB} + Debug + AnyCPU + + + + + botmanager + + + JScript + Grid + IE50 + false + Exe + botmanager + OnBuildSuccess + + + + + + + + + ..\..\..\bin\ + false + 285212672 + false + + + DEBUG;TRACE + + + true + 4096 + false + + + false + false + false + false + 4 + full + prompt + + + bin\Release\ + false + 285212672 + false + + + TRACE + + + false + 4096 + false + + + true + false + false + false + 4 + none + prompt + + + + System + + + System.Data + + + System.XML + + + libsecondlife + {D9CDEDFB-8169-4B03-B57F-0DF638F044EC} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + + + Code + + + + + + + + + \ No newline at end of file diff --git a/libsecondlife-cs/examples/groupmanager/frmGroupInfo.Designer.cs b/libsecondlife-cs/examples/groupmanager/frmGroupInfo.Designer.cs index 9adf6b79..3dc65200 100644 --- a/libsecondlife-cs/examples/groupmanager/frmGroupInfo.Designer.cs +++ b/libsecondlife-cs/examples/groupmanager/frmGroupInfo.Designer.cs @@ -1,38 +1,38 @@ -namespace groupmanager -{ - partial class frmGroupInfo - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Text = "frmGroupInfo"; - } - - #endregion - } +namespace groupmanager +{ + partial class frmGroupInfo + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Text = "frmGroupInfo"; + } + + #endregion + } } \ No newline at end of file diff --git a/libsecondlife-cs/examples/groupmanager/frmGroupInfo.cs b/libsecondlife-cs/examples/groupmanager/frmGroupInfo.cs index c302ecee..fee84042 100644 --- a/libsecondlife-cs/examples/groupmanager/frmGroupInfo.cs +++ b/libsecondlife-cs/examples/groupmanager/frmGroupInfo.cs @@ -1,22 +1,22 @@ -using System; -using System.Collections; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Text; -using System.Windows.Forms; -using libsecondlife; - -namespace groupmanager -{ - public partial class frmGroupInfo : Form - { - Group Group; - public frmGroupInfo(Group group) - { - Group = group; - - InitializeComponent(); - } - } +using System; +using System.Collections; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; +using libsecondlife; + +namespace groupmanager +{ + public partial class frmGroupInfo : Form + { + Group Group; + public frmGroupInfo(Group group) + { + Group = group; + + InitializeComponent(); + } + } } \ No newline at end of file diff --git a/libsecondlife-cs/examples/groupmanager/frmGroupManager.Designer.cs b/libsecondlife-cs/examples/groupmanager/frmGroupManager.Designer.cs index a9e24ccc..2a446910 100644 --- a/libsecondlife-cs/examples/groupmanager/frmGroupManager.Designer.cs +++ b/libsecondlife-cs/examples/groupmanager/frmGroupManager.Designer.cs @@ -1,220 +1,220 @@ -namespace groupmanager -{ - partial class frmGroupManager - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.groupBox = new System.Windows.Forms.GroupBox(); - this.lstGroups = new System.Windows.Forms.ListBox(); - this.grpLogin = new System.Windows.Forms.GroupBox(); - this.label3 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.label1 = new System.Windows.Forms.Label(); - this.txtPassword = new System.Windows.Forms.TextBox(); - this.txtLastName = new System.Windows.Forms.TextBox(); - this.cmdConnect = new System.Windows.Forms.Button(); - this.txtFirstName = new System.Windows.Forms.TextBox(); - this.cmdLeave = new System.Windows.Forms.Button(); - this.cmdCreate = new System.Windows.Forms.Button(); - this.cmdActivate = new System.Windows.Forms.Button(); - this.cmdInfo = new System.Windows.Forms.Button(); - this.groupBox.SuspendLayout(); - this.grpLogin.SuspendLayout(); - this.SuspendLayout(); - // - // groupBox - // - this.groupBox.Controls.Add(this.cmdInfo); - this.groupBox.Controls.Add(this.cmdActivate); - this.groupBox.Controls.Add(this.cmdCreate); - this.groupBox.Controls.Add(this.cmdLeave); - this.groupBox.Controls.Add(this.lstGroups); - this.groupBox.Enabled = false; - this.groupBox.Location = new System.Drawing.Point(12, 12); - this.groupBox.Name = "groupBox"; - this.groupBox.Size = new System.Drawing.Size(419, 214); - this.groupBox.TabIndex = 0; - this.groupBox.TabStop = false; - this.groupBox.Text = "Groups"; - // - // lstGroups - // - this.lstGroups.FormattingEnabled = true; - this.lstGroups.Location = new System.Drawing.Point(19, 31); - this.lstGroups.Name = "lstGroups"; - this.lstGroups.Size = new System.Drawing.Size(384, 134); - this.lstGroups.TabIndex = 0; - this.lstGroups.SelectedIndexChanged += new System.EventHandler(this.lstGroups_SelectedIndexChanged); - // - // grpLogin - // - this.grpLogin.Controls.Add(this.label3); - this.grpLogin.Controls.Add(this.label2); - this.grpLogin.Controls.Add(this.label1); - this.grpLogin.Controls.Add(this.txtPassword); - this.grpLogin.Controls.Add(this.txtLastName); - this.grpLogin.Controls.Add(this.cmdConnect); - this.grpLogin.Controls.Add(this.txtFirstName); - this.grpLogin.Location = new System.Drawing.Point(12, 232); - this.grpLogin.Name = "grpLogin"; - this.grpLogin.Size = new System.Drawing.Size(419, 108); - this.grpLogin.TabIndex = 51; - this.grpLogin.TabStop = false; - // - // label3 - // - this.label3.Location = new System.Drawing.Point(280, 24); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(120, 16); - this.label3.TabIndex = 50; - this.label3.Text = "Password"; - // - // label2 - // - this.label2.Location = new System.Drawing.Point(152, 24); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(120, 16); - this.label2.TabIndex = 50; - this.label2.Text = "Last Name"; - // - // label1 - // - this.label1.Location = new System.Drawing.Point(16, 24); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(120, 16); - this.label1.TabIndex = 50; - this.label1.Text = "First Name"; - // - // txtPassword - // - this.txtPassword.Location = new System.Drawing.Point(280, 40); - this.txtPassword.Name = "txtPassword"; - this.txtPassword.PasswordChar = '*'; - this.txtPassword.Size = new System.Drawing.Size(120, 20); - this.txtPassword.TabIndex = 2; - // - // txtLastName - // - this.txtLastName.Location = new System.Drawing.Point(152, 40); - this.txtLastName.Name = "txtLastName"; - this.txtLastName.Size = new System.Drawing.Size(112, 20); - this.txtLastName.TabIndex = 1; - // - // cmdConnect - // - this.cmdConnect.Location = new System.Drawing.Point(280, 66); - this.cmdConnect.Name = "cmdConnect"; - this.cmdConnect.Size = new System.Drawing.Size(120, 24); - this.cmdConnect.TabIndex = 3; - this.cmdConnect.Text = "Connect"; - this.cmdConnect.Click += new System.EventHandler(this.cmdConnect_Click); - // - // txtFirstName - // - this.txtFirstName.Location = new System.Drawing.Point(16, 40); - this.txtFirstName.Name = "txtFirstName"; - this.txtFirstName.Size = new System.Drawing.Size(120, 20); - this.txtFirstName.TabIndex = 0; - // - // cmdLeave - // - this.cmdLeave.Enabled = false; - this.cmdLeave.Location = new System.Drawing.Point(313, 174); - this.cmdLeave.Name = "cmdLeave"; - this.cmdLeave.Size = new System.Drawing.Size(90, 23); - this.cmdLeave.TabIndex = 7; - this.cmdLeave.Text = "Leave"; - this.cmdLeave.UseVisualStyleBackColor = true; - // - // cmdCreate - // - this.cmdCreate.Location = new System.Drawing.Point(19, 174); - this.cmdCreate.Name = "cmdCreate"; - this.cmdCreate.Size = new System.Drawing.Size(90, 23); - this.cmdCreate.TabIndex = 8; - this.cmdCreate.Text = "Create"; - this.cmdCreate.UseVisualStyleBackColor = true; - // - // cmdActivate - // - this.cmdActivate.Enabled = false; - this.cmdActivate.Location = new System.Drawing.Point(116, 174); - this.cmdActivate.Name = "cmdActivate"; - this.cmdActivate.Size = new System.Drawing.Size(90, 23); - this.cmdActivate.TabIndex = 9; - this.cmdActivate.Text = "Activate"; - this.cmdActivate.UseVisualStyleBackColor = true; - // - // cmdInfo - // - this.cmdInfo.Enabled = false; - this.cmdInfo.Location = new System.Drawing.Point(216, 174); - this.cmdInfo.Name = "cmdInfo"; - this.cmdInfo.Size = new System.Drawing.Size(90, 23); - this.cmdInfo.TabIndex = 10; - this.cmdInfo.Text = "Info"; - this.cmdInfo.UseVisualStyleBackColor = true; - this.cmdInfo.Click += new System.EventHandler(this.cmdInfo_Click); - // - // frmGroupManager - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(445, 351); - this.Controls.Add(this.grpLogin); - this.Controls.Add(this.groupBox); - this.MaximizeBox = false; - this.MaximumSize = new System.Drawing.Size(453, 378); - this.MinimumSize = new System.Drawing.Size(453, 378); - this.Name = "frmGroupManager"; - this.Text = "Group Manager"; - //this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.frmGroupManager_FormClosing); - this.groupBox.ResumeLayout(false); - this.grpLogin.ResumeLayout(false); - this.grpLogin.PerformLayout(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.GroupBox groupBox; - private System.Windows.Forms.ListBox lstGroups; - private System.Windows.Forms.GroupBox grpLogin; - private System.Windows.Forms.Label label3; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.TextBox txtPassword; - private System.Windows.Forms.TextBox txtLastName; - private System.Windows.Forms.Button cmdConnect; - private System.Windows.Forms.TextBox txtFirstName; - private System.Windows.Forms.Button cmdInfo; - private System.Windows.Forms.Button cmdActivate; - private System.Windows.Forms.Button cmdCreate; - private System.Windows.Forms.Button cmdLeave; - } +namespace groupmanager +{ + partial class frmGroupManager + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.groupBox = new System.Windows.Forms.GroupBox(); + this.lstGroups = new System.Windows.Forms.ListBox(); + this.grpLogin = new System.Windows.Forms.GroupBox(); + this.label3 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.txtPassword = new System.Windows.Forms.TextBox(); + this.txtLastName = new System.Windows.Forms.TextBox(); + this.cmdConnect = new System.Windows.Forms.Button(); + this.txtFirstName = new System.Windows.Forms.TextBox(); + this.cmdLeave = new System.Windows.Forms.Button(); + this.cmdCreate = new System.Windows.Forms.Button(); + this.cmdActivate = new System.Windows.Forms.Button(); + this.cmdInfo = new System.Windows.Forms.Button(); + this.groupBox.SuspendLayout(); + this.grpLogin.SuspendLayout(); + this.SuspendLayout(); + // + // groupBox + // + this.groupBox.Controls.Add(this.cmdInfo); + this.groupBox.Controls.Add(this.cmdActivate); + this.groupBox.Controls.Add(this.cmdCreate); + this.groupBox.Controls.Add(this.cmdLeave); + this.groupBox.Controls.Add(this.lstGroups); + this.groupBox.Enabled = false; + this.groupBox.Location = new System.Drawing.Point(12, 12); + this.groupBox.Name = "groupBox"; + this.groupBox.Size = new System.Drawing.Size(419, 214); + this.groupBox.TabIndex = 0; + this.groupBox.TabStop = false; + this.groupBox.Text = "Groups"; + // + // lstGroups + // + this.lstGroups.FormattingEnabled = true; + this.lstGroups.Location = new System.Drawing.Point(19, 31); + this.lstGroups.Name = "lstGroups"; + this.lstGroups.Size = new System.Drawing.Size(384, 134); + this.lstGroups.TabIndex = 0; + this.lstGroups.SelectedIndexChanged += new System.EventHandler(this.lstGroups_SelectedIndexChanged); + // + // grpLogin + // + this.grpLogin.Controls.Add(this.label3); + this.grpLogin.Controls.Add(this.label2); + this.grpLogin.Controls.Add(this.label1); + this.grpLogin.Controls.Add(this.txtPassword); + this.grpLogin.Controls.Add(this.txtLastName); + this.grpLogin.Controls.Add(this.cmdConnect); + this.grpLogin.Controls.Add(this.txtFirstName); + this.grpLogin.Location = new System.Drawing.Point(12, 232); + this.grpLogin.Name = "grpLogin"; + this.grpLogin.Size = new System.Drawing.Size(419, 108); + this.grpLogin.TabIndex = 51; + this.grpLogin.TabStop = false; + // + // label3 + // + this.label3.Location = new System.Drawing.Point(280, 24); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(120, 16); + this.label3.TabIndex = 50; + this.label3.Text = "Password"; + // + // label2 + // + this.label2.Location = new System.Drawing.Point(152, 24); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(120, 16); + this.label2.TabIndex = 50; + this.label2.Text = "Last Name"; + // + // label1 + // + this.label1.Location = new System.Drawing.Point(16, 24); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(120, 16); + this.label1.TabIndex = 50; + this.label1.Text = "First Name"; + // + // txtPassword + // + this.txtPassword.Location = new System.Drawing.Point(280, 40); + this.txtPassword.Name = "txtPassword"; + this.txtPassword.PasswordChar = '*'; + this.txtPassword.Size = new System.Drawing.Size(120, 20); + this.txtPassword.TabIndex = 2; + // + // txtLastName + // + this.txtLastName.Location = new System.Drawing.Point(152, 40); + this.txtLastName.Name = "txtLastName"; + this.txtLastName.Size = new System.Drawing.Size(112, 20); + this.txtLastName.TabIndex = 1; + // + // cmdConnect + // + this.cmdConnect.Location = new System.Drawing.Point(280, 66); + this.cmdConnect.Name = "cmdConnect"; + this.cmdConnect.Size = new System.Drawing.Size(120, 24); + this.cmdConnect.TabIndex = 3; + this.cmdConnect.Text = "Connect"; + this.cmdConnect.Click += new System.EventHandler(this.cmdConnect_Click); + // + // txtFirstName + // + this.txtFirstName.Location = new System.Drawing.Point(16, 40); + this.txtFirstName.Name = "txtFirstName"; + this.txtFirstName.Size = new System.Drawing.Size(120, 20); + this.txtFirstName.TabIndex = 0; + // + // cmdLeave + // + this.cmdLeave.Enabled = false; + this.cmdLeave.Location = new System.Drawing.Point(313, 174); + this.cmdLeave.Name = "cmdLeave"; + this.cmdLeave.Size = new System.Drawing.Size(90, 23); + this.cmdLeave.TabIndex = 7; + this.cmdLeave.Text = "Leave"; + this.cmdLeave.UseVisualStyleBackColor = true; + // + // cmdCreate + // + this.cmdCreate.Location = new System.Drawing.Point(19, 174); + this.cmdCreate.Name = "cmdCreate"; + this.cmdCreate.Size = new System.Drawing.Size(90, 23); + this.cmdCreate.TabIndex = 8; + this.cmdCreate.Text = "Create"; + this.cmdCreate.UseVisualStyleBackColor = true; + // + // cmdActivate + // + this.cmdActivate.Enabled = false; + this.cmdActivate.Location = new System.Drawing.Point(116, 174); + this.cmdActivate.Name = "cmdActivate"; + this.cmdActivate.Size = new System.Drawing.Size(90, 23); + this.cmdActivate.TabIndex = 9; + this.cmdActivate.Text = "Activate"; + this.cmdActivate.UseVisualStyleBackColor = true; + // + // cmdInfo + // + this.cmdInfo.Enabled = false; + this.cmdInfo.Location = new System.Drawing.Point(216, 174); + this.cmdInfo.Name = "cmdInfo"; + this.cmdInfo.Size = new System.Drawing.Size(90, 23); + this.cmdInfo.TabIndex = 10; + this.cmdInfo.Text = "Info"; + this.cmdInfo.UseVisualStyleBackColor = true; + this.cmdInfo.Click += new System.EventHandler(this.cmdInfo_Click); + // + // frmGroupManager + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(445, 351); + this.Controls.Add(this.grpLogin); + this.Controls.Add(this.groupBox); + this.MaximizeBox = false; + this.MaximumSize = new System.Drawing.Size(453, 378); + this.MinimumSize = new System.Drawing.Size(453, 378); + this.Name = "frmGroupManager"; + this.Text = "Group Manager"; + //this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.frmGroupManager_FormClosing); + this.groupBox.ResumeLayout(false); + this.grpLogin.ResumeLayout(false); + this.grpLogin.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.GroupBox groupBox; + private System.Windows.Forms.ListBox lstGroups; + private System.Windows.Forms.GroupBox grpLogin; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.TextBox txtPassword; + private System.Windows.Forms.TextBox txtLastName; + private System.Windows.Forms.Button cmdConnect; + private System.Windows.Forms.TextBox txtFirstName; + private System.Windows.Forms.Button cmdInfo; + private System.Windows.Forms.Button cmdActivate; + private System.Windows.Forms.Button cmdCreate; + private System.Windows.Forms.Button cmdLeave; + } } \ No newline at end of file diff --git a/libsecondlife-cs/examples/groupmanager/frmGroupManager.cs b/libsecondlife-cs/examples/groupmanager/frmGroupManager.cs index 709142d5..8c3fa006 100644 --- a/libsecondlife-cs/examples/groupmanager/frmGroupManager.cs +++ b/libsecondlife-cs/examples/groupmanager/frmGroupManager.cs @@ -1,115 +1,115 @@ -using System; -using System.Collections; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Text; -using System.Windows.Forms; -using libsecondlife; -using libsecondlife.Packets; - -namespace groupmanager -{ - public partial class frmGroupManager : Form - { - SecondLife client; - - public frmGroupManager() - { - client = new SecondLife(); - client.Groups.OnGroupsUpdated += new GroupManager.GroupsUpdatedCallback(GroupsUpdatedHandler); - - InitializeComponent(); - } - - void GroupsUpdatedHandler() - { - Invoke(new MethodInvoker(UpdateGroups)); - } - - void UpdateGroups() - { - lstGroups.Items.Clear(); - - foreach (Group group in client.Groups.Groups) - { - lstGroups.Items.Add(group); - } - } - - /// - /// The main entry point for the application. - /// - [STAThread] - static void Main() - { - frmGroupManager frm = new frmGroupManager(); - frm.ShowDialog(); - } - - private void cmdConnect_Click(object sender, EventArgs e) - { - if (cmdConnect.Text == "Connect") - { - cmdConnect.Text = "Disconnect"; - txtFirstName.Enabled = txtLastName.Enabled = txtPassword.Enabled = false; - - Hashtable loginParams = NetworkManager.DefaultLoginValues(txtFirstName.Text, - txtLastName.Text, txtPassword.Text, "00:00:00:00:00:00", "last", - "Win", "0", "groupmanager", "jhurliman@wsu.edu"); - - if (client.Network.Login(loginParams)) - { - groupBox.Enabled = true; - } - else - { - MessageBox.Show(this, "Error logging in: " + client.Network.LoginError); - cmdConnect.Text = "Connect"; - txtFirstName.Enabled = txtLastName.Enabled = txtPassword.Enabled = true; - groupBox.Enabled = false; - lstGroups.Items.Clear(); - } - } - else - { - client.Network.Logout(); - cmdConnect.Text = "Connect"; - txtFirstName.Enabled = txtLastName.Enabled = txtPassword.Enabled = true; - groupBox.Enabled = false; - lstGroups.Items.Clear(); - } - } - - private void lstGroups_SelectedIndexChanged(object sender, EventArgs e) - { - if (lstGroups.SelectedIndex >= 0) - { - cmdActivate.Enabled = cmdInfo.Enabled = cmdLeave.Enabled = true; - } - else - { - cmdActivate.Enabled = cmdInfo.Enabled = cmdLeave.Enabled = false; - } - } - - private void cmdInfo_Click(object sender, EventArgs e) - { - if (lstGroups.Items[lstGroups.SelectedIndex].ToString() != "none") - { - Group group = (Group)lstGroups.Items[lstGroups.SelectedIndex]; - - frmGroupInfo frm = new frmGroupInfo(group); - frm.ShowDialog(); - } - } - - private void frmGroupManager_FormClosing(object sender, FormClosingEventArgs e) - { - if (client.Network.Connected) - { - client.Network.Logout(); - } - } - } -} +using System; +using System.Collections; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; +using libsecondlife; +using libsecondlife.Packets; + +namespace groupmanager +{ + public partial class frmGroupManager : Form + { + SecondLife client; + + public frmGroupManager() + { + client = new SecondLife(); + client.Groups.OnGroupsUpdated += new GroupManager.GroupsUpdatedCallback(GroupsUpdatedHandler); + + InitializeComponent(); + } + + void GroupsUpdatedHandler() + { + Invoke(new MethodInvoker(UpdateGroups)); + } + + void UpdateGroups() + { + lstGroups.Items.Clear(); + + foreach (Group group in client.Groups.Groups) + { + lstGroups.Items.Add(group); + } + } + + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + frmGroupManager frm = new frmGroupManager(); + frm.ShowDialog(); + } + + private void cmdConnect_Click(object sender, EventArgs e) + { + if (cmdConnect.Text == "Connect") + { + cmdConnect.Text = "Disconnect"; + txtFirstName.Enabled = txtLastName.Enabled = txtPassword.Enabled = false; + + Hashtable loginParams = NetworkManager.DefaultLoginValues(txtFirstName.Text, + txtLastName.Text, txtPassword.Text, "00:00:00:00:00:00", "last", + "Win", "0", "groupmanager", "jhurliman@wsu.edu"); + + if (client.Network.Login(loginParams)) + { + groupBox.Enabled = true; + } + else + { + MessageBox.Show(this, "Error logging in: " + client.Network.LoginError); + cmdConnect.Text = "Connect"; + txtFirstName.Enabled = txtLastName.Enabled = txtPassword.Enabled = true; + groupBox.Enabled = false; + lstGroups.Items.Clear(); + } + } + else + { + client.Network.Logout(); + cmdConnect.Text = "Connect"; + txtFirstName.Enabled = txtLastName.Enabled = txtPassword.Enabled = true; + groupBox.Enabled = false; + lstGroups.Items.Clear(); + } + } + + private void lstGroups_SelectedIndexChanged(object sender, EventArgs e) + { + if (lstGroups.SelectedIndex >= 0) + { + cmdActivate.Enabled = cmdInfo.Enabled = cmdLeave.Enabled = true; + } + else + { + cmdActivate.Enabled = cmdInfo.Enabled = cmdLeave.Enabled = false; + } + } + + private void cmdInfo_Click(object sender, EventArgs e) + { + if (lstGroups.Items[lstGroups.SelectedIndex].ToString() != "none") + { + Group group = (Group)lstGroups.Items[lstGroups.SelectedIndex]; + + frmGroupInfo frm = new frmGroupInfo(group); + frm.ShowDialog(); + } + } + + private void frmGroupManager_FormClosing(object sender, FormClosingEventArgs e) + { + if (client.Network.Connected) + { + client.Network.Logout(); + } + } + } +} diff --git a/libsecondlife-cs/examples/groupmanager/frmGroupManager.resx b/libsecondlife-cs/examples/groupmanager/frmGroupManager.resx index ff31a6db..19dc0dd8 100644 --- a/libsecondlife-cs/examples/groupmanager/frmGroupManager.resx +++ b/libsecondlife-cs/examples/groupmanager/frmGroupManager.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/libsecondlife-cs/examples/groupmanager/groupmanager.csproj b/libsecondlife-cs/examples/groupmanager/groupmanager.csproj index ec77b773..02e93bca 100644 --- a/libsecondlife-cs/examples/groupmanager/groupmanager.csproj +++ b/libsecondlife-cs/examples/groupmanager/groupmanager.csproj @@ -1,128 +1,128 @@ - - - Local - 8.0.50727 - 2.0 - {F460FAB3-0D12-4873-89EB-2696818764B8} - Debug - AnyCPU - App.ico - - - groupmanager - - - JScript - Grid - IE50 - false - WinExe - groupmanager - OnBuildSuccess - - - - - - - - - ..\..\..\bin\ - false - 285212672 - false - - - DEBUG;TRACE - - - true - 4096 - false - - - false - false - false - false - 4 - full - prompt - - - bin\Release\ - false - 285212672 - false - - - TRACE - - - false - 4096 - false - - - true - false - false - false - 4 - none - prompt - - - - System - - - System.Data - - - System.Drawing - - - System.Windows.Forms - - - System.XML - - - libsecondlife - {D9CDEDFB-8169-4B03-B57F-0DF638F044EC} - {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - False - - - - - Form - - - frmGroupInfo.cs - - - Form - - - frmGroupManager.cs - - - - - - - - Designer - frmGroupManager.cs - - - - - - - - - + + + Local + 8.0.50727 + 2.0 + {F460FAB3-0D12-4873-89EB-2696818764B8} + Debug + AnyCPU + App.ico + + + groupmanager + + + JScript + Grid + IE50 + false + WinExe + groupmanager + OnBuildSuccess + + + + + + + + + ..\..\..\bin\ + false + 285212672 + false + + + DEBUG;TRACE + + + true + 4096 + false + + + false + false + false + false + 4 + full + prompt + + + bin\Release\ + false + 285212672 + false + + + TRACE + + + false + 4096 + false + + + true + false + false + false + 4 + none + prompt + + + + System + + + System.Data + + + System.Drawing + + + System.Windows.Forms + + + System.XML + + + libsecondlife + {D9CDEDFB-8169-4B03-B57F-0DF638F044EC} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + + + Form + + + frmGroupInfo.cs + + + Form + + + frmGroupManager.cs + + + + + + + + Designer + frmGroupManager.cs + + + + + + + + + \ No newline at end of file diff --git a/libsecondlife-cs/examples/name2key/name2key.cs b/libsecondlife-cs/examples/name2key/name2key.cs index 8666b690..a33279d8 100644 --- a/libsecondlife-cs/examples/name2key/name2key.cs +++ b/libsecondlife-cs/examples/name2key/name2key.cs @@ -1,108 +1,108 @@ -/* - * Copyright (c) 2006, Second Life Reverse Engineering Team - * All rights reserved. - * - * - Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - Neither the name of the Second Life Reverse Engineering Team nor the names - * of its contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections; -using libsecondlife; -using libsecondlife.Packets; - -namespace name2key -{ - class name2key - { - static bool waiting = true; - - public static void QueryHandler(Packet packet, Simulator simulator) - { - DirPeopleReplyPacket reply = (DirPeopleReplyPacket)packet; - - if (reply.QueryReplies.Length < 1) - { - Console.WriteLine("ERROR: Got an empty reply"); - } - else - { - if (reply.QueryReplies.Length > 1) - { - Console.WriteLine("ERROR: Ambiguous name. Returning first match"); - } - - Console.WriteLine("UUID: " + reply.QueryReplies[0].AgentID.ToString()); - } - - waiting = false; - } - - /// - /// The main entry point for the application. - /// - [STAThread] - static void Main(string[] args) - { - SecondLife client; - - if (args.Length < 5) - { - Console.WriteLine("Usage: name2key [loginfirstname] [loginlastname] [password] [firstname] [lastname]"); - return; - } - - client = new SecondLife(); - - // Setup the callback - client.Network.RegisterCallback(PacketType.DirPeopleReply, new PacketCallback(QueryHandler)); - - // Setup the login values - Hashtable loginParams = NetworkManager.DefaultLoginValues(args[0], args[1], args[2], "00:00:00:00:00:00", - "last", "Win", "0", "name2key", "jhurliman@wsu.edu"); - - if (!client.Network.Login(loginParams)) - { - // Login failed - Console.WriteLine("ERROR: " + client.Network.LoginError); - return; - } - - // Send the Query - DirFindQueryPacket find = new DirFindQueryPacket(); - find.AgentData.AgentID = client.Network.AgentID; - find.AgentData.SessionID = client.Network.SessionID; - find.QueryData.QueryFlags = 1; - find.QueryData.QueryText = Helpers.StringToField(args[3] + " " + args[4]); - find.QueryData.QueryID = new LLUUID("00000000000000000000000000000001"); - find.QueryData.QueryStart = 0; - - client.Network.SendPacket((Packet)find); - - while (waiting) - { - client.Tick(); - } - - client.Network.Logout(); - } - } -} +/* + * Copyright (c) 2006, Second Life Reverse Engineering Team + * All rights reserved. + * + * - Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Neither the name of the Second Life Reverse Engineering Team nor the names + * of its contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using libsecondlife; +using libsecondlife.Packets; + +namespace name2key +{ + class name2key + { + static bool waiting = true; + + public static void QueryHandler(Packet packet, Simulator simulator) + { + DirPeopleReplyPacket reply = (DirPeopleReplyPacket)packet; + + if (reply.QueryReplies.Length < 1) + { + Console.WriteLine("ERROR: Got an empty reply"); + } + else + { + if (reply.QueryReplies.Length > 1) + { + Console.WriteLine("ERROR: Ambiguous name. Returning first match"); + } + + Console.WriteLine("UUID: " + reply.QueryReplies[0].AgentID.ToString()); + } + + waiting = false; + } + + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main(string[] args) + { + SecondLife client; + + if (args.Length < 5) + { + Console.WriteLine("Usage: name2key [loginfirstname] [loginlastname] [password] [firstname] [lastname]"); + return; + } + + client = new SecondLife(); + + // Setup the callback + client.Network.RegisterCallback(PacketType.DirPeopleReply, new PacketCallback(QueryHandler)); + + // Setup the login values + Hashtable loginParams = NetworkManager.DefaultLoginValues(args[0], args[1], args[2], "00:00:00:00:00:00", + "last", "Win", "0", "name2key", "jhurliman@wsu.edu"); + + if (!client.Network.Login(loginParams)) + { + // Login failed + Console.WriteLine("ERROR: " + client.Network.LoginError); + return; + } + + // Send the Query + DirFindQueryPacket find = new DirFindQueryPacket(); + find.AgentData.AgentID = client.Network.AgentID; + find.AgentData.SessionID = client.Network.SessionID; + find.QueryData.QueryFlags = 1; + find.QueryData.QueryText = Helpers.StringToField(args[3] + " " + args[4]); + find.QueryData.QueryID = new LLUUID("00000000000000000000000000000001"); + find.QueryData.QueryStart = 0; + + client.Network.SendPacket((Packet)find); + + while (waiting) + { + client.Tick(); + } + + client.Network.Logout(); + } + } +} diff --git a/libsecondlife-cs/examples/name2key/name2key.csproj b/libsecondlife-cs/examples/name2key/name2key.csproj index a0df6520..7da86d9e 100644 --- a/libsecondlife-cs/examples/name2key/name2key.csproj +++ b/libsecondlife-cs/examples/name2key/name2key.csproj @@ -1,105 +1,105 @@ - - - Local - 8.0.50727 - 2.0 - {66FFD34E-652C-4EF5-81FE-06AD011169D2} - Debug - AnyCPU - - - - - name2key - - - JScript - Grid - IE50 - false - Exe - name2key - OnBuildSuccess - - - - - - - - - ..\..\..\bin\ - false - 285212672 - false - - - DEBUG;TRACE - - - true - 4096 - false - - - false - false - false - false - 4 - full - prompt - - - bin\Release\ - false - 285212672 - false - - - TRACE - - - false - 4096 - false - - - true - false - false - false - 4 - none - prompt - - - - System - - - System.Data - - - System.XML - - - - - Code - - - - - {D9CDEDFB-8169-4B03-B57F-0DF638F044EC} - libsecondlife - - - - - - - - - + + + Local + 8.0.50727 + 2.0 + {66FFD34E-652C-4EF5-81FE-06AD011169D2} + Debug + AnyCPU + + + + + name2key + + + JScript + Grid + IE50 + false + Exe + name2key + OnBuildSuccess + + + + + + + + + ..\..\..\bin\ + false + 285212672 + false + + + DEBUG;TRACE + + + true + 4096 + false + + + false + false + false + false + 4 + full + prompt + + + bin\Release\ + false + 285212672 + false + + + TRACE + + + false + 4096 + false + + + true + false + false + false + 4 + none + prompt + + + + System + + + System.Data + + + System.XML + + + + + Code + + + + + {D9CDEDFB-8169-4B03-B57F-0DF638F044EC} + libsecondlife + + + + + + + + + \ No newline at end of file diff --git a/libsecondlife-cs/examples/primexport/frmPrimExport.cs b/libsecondlife-cs/examples/primexport/frmPrimExport.cs index e1c4cec7..6fd802e3 100644 --- a/libsecondlife-cs/examples/primexport/frmPrimExport.cs +++ b/libsecondlife-cs/examples/primexport/frmPrimExport.cs @@ -1,364 +1,364 @@ -using System; -using System.ComponentModel; -using System.Data; -using System.Drawing; -using System.Text; -using System.Windows.Forms; -using System.Collections; -using libsecondlife; - -namespace primexport -{ - public class frmPrimExport : Form - { - private GroupBox grpLogin; - private Label label3; - private Label label2; - private Label label1; - private TextBox txtPassword; - private TextBox txtLastName; - private Button cmdConnect; - private TextBox txtFirstName; - private Button cmdCapture; - private TextBox txtLog; - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - private SecondLife client; - private NewPrimCallback primCallback; - private string currentText; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.grpLogin = new System.Windows.Forms.GroupBox(); - this.label3 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.label1 = new System.Windows.Forms.Label(); - this.txtPassword = new System.Windows.Forms.TextBox(); - this.txtLastName = new System.Windows.Forms.TextBox(); - this.cmdConnect = new System.Windows.Forms.Button(); - this.txtFirstName = new System.Windows.Forms.TextBox(); - this.cmdCapture = new System.Windows.Forms.Button(); - this.txtLog = new System.Windows.Forms.TextBox(); - this.grpLogin.SuspendLayout(); - this.SuspendLayout(); - // - // grpLogin - // - this.grpLogin.Controls.Add(this.label3); - this.grpLogin.Controls.Add(this.label2); - this.grpLogin.Controls.Add(this.label1); - this.grpLogin.Controls.Add(this.txtPassword); - this.grpLogin.Controls.Add(this.txtLastName); - this.grpLogin.Controls.Add(this.cmdConnect); - this.grpLogin.Controls.Add(this.txtFirstName); - this.grpLogin.Enabled = false; - this.grpLogin.Location = new System.Drawing.Point(12, 204); - this.grpLogin.Name = "grpLogin"; - this.grpLogin.Size = new System.Drawing.Size(560, 80); - this.grpLogin.TabIndex = 51; - this.grpLogin.TabStop = false; - // - // label3 - // - this.label3.Location = new System.Drawing.Point(280, 24); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(120, 16); - this.label3.TabIndex = 50; - this.label3.Text = "Password"; - // - // label2 - // - this.label2.Location = new System.Drawing.Point(152, 24); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(120, 16); - this.label2.TabIndex = 50; - this.label2.Text = "Last Name"; - // - // label1 - // - this.label1.Location = new System.Drawing.Point(16, 24); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(120, 16); - this.label1.TabIndex = 50; - this.label1.Text = "First Name"; - // - // txtPassword - // - this.txtPassword.Location = new System.Drawing.Point(280, 40); - this.txtPassword.Name = "txtPassword"; - this.txtPassword.PasswordChar = '*'; - this.txtPassword.Size = new System.Drawing.Size(120, 20); - this.txtPassword.TabIndex = 2; - // - // txtLastName - // - this.txtLastName.Location = new System.Drawing.Point(152, 40); - this.txtLastName.Name = "txtLastName"; - this.txtLastName.Size = new System.Drawing.Size(112, 20); - this.txtLastName.TabIndex = 1; - // - // cmdConnect - // - this.cmdConnect.Location = new System.Drawing.Point(424, 40); - this.cmdConnect.Name = "cmdConnect"; - this.cmdConnect.Size = new System.Drawing.Size(120, 24); - this.cmdConnect.TabIndex = 3; - this.cmdConnect.Text = "Connect"; - this.cmdConnect.Click += new System.EventHandler(this.cmdConnect_Click); - // - // txtFirstName - // - this.txtFirstName.Location = new System.Drawing.Point(16, 40); - this.txtFirstName.Name = "txtFirstName"; - this.txtFirstName.Size = new System.Drawing.Size(120, 20); - this.txtFirstName.TabIndex = 0; - // - // cmdCapture - // - this.cmdCapture.Enabled = false; - this.cmdCapture.Location = new System.Drawing.Point(12, 12); - this.cmdCapture.Name = "cmdCapture"; - this.cmdCapture.Size = new System.Drawing.Size(560, 49); - this.cmdCapture.TabIndex = 52; - this.cmdCapture.Text = "Start Capture"; - this.cmdCapture.Click += new System.EventHandler(this.cmdCapture_Click); - // - // txtLog - // - this.txtLog.Location = new System.Drawing.Point(12, 67); - this.txtLog.Multiline = true; - this.txtLog.Name = "txtLog"; - this.txtLog.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.txtLog.Size = new System.Drawing.Size(560, 131); - this.txtLog.TabIndex = 53; - // - // frmPrimExport - // - this.ClientSize = new System.Drawing.Size(587, 299); - this.Controls.Add(this.txtLog); - this.Controls.Add(this.cmdCapture); - this.Controls.Add(this.grpLogin); - this.MaximizeBox = false; - this.MaximumSize = new System.Drawing.Size(595, 326); - this.MinimumSize = new System.Drawing.Size(595, 326); - this.Name = "frmPrimExport"; - this.Text = "Prim Exporter"; - this.TopMost = true; - this.grpLogin.ResumeLayout(false); - this.grpLogin.PerformLayout(); - this.ResumeLayout(false); - this.PerformLayout(); - - } - - #endregion - - public frmPrimExport() - { - InitializeComponent(); - - primCallback = new NewPrimCallback(PrimSeen); - - client = new SecondLife(); - grpLogin.Enabled = true; - } - - private void Log(string text) - { - currentText = text; - - if (this.InvokeRequired) - { - this.Invoke(new MethodInvoker(UpdateLog)); - } - else - { - UpdateLog(); - } - } - - private void UpdateLog() - { - txtLog.Text += currentText + Environment.NewLine; - } - - private void PrimSeen(Simulator simulator, PrimObject prim, ulong regionHandle, ushort timeDilation) - { - uint type = 0; - string output = ""; - - output += "" + Environment.NewLine; - output += "" + Environment.NewLine + - "false" + Environment.NewLine + - "false" + Environment.NewLine + - "false" + Environment.NewLine + - "" + Environment.NewLine; - output += "" + Environment.NewLine + - "" + Environment.NewLine; - - if (prim.ProfileCurve == 1 && prim.PathCurve == 16) - { - // PRIM_TYPE_BOX - type = 0; - } - else if (prim.ProfileCurve == 0 && prim.PathCurve == 16) - { - // PRIM_TYPE_CYLINDER - type = 1; - } - else if (prim.ProfileCurve == 3 && prim.PathCurve == 16) - { - // PRIM_TYPE_PRISM - type = 2; - } - else if (prim.ProfileCurve == 5 && prim.PathCurve == 32) - { - // PRIM_TYPE_SPHERE - type = 3; - } - else if (prim.ProfileCurve == 0 && prim.PathCurve == 32) - { - // PRIM_TYPE_TORUS - type = 4; - } - else if (prim.ProfileCurve == 1 && prim.PathCurve == 32) - { - // PRIM_TYPE_TUBE - type = 5; - } - else if (prim.ProfileCurve == 3 && prim.PathCurve == 32) - { - // PRIM_TYPE_RING - type = 6; - } - else - { - Console.WriteLine("Unhandled prim type, ProfileCurve=" + - prim.ProfileCurve + ", PathCurve=" + prim.PathCurve); - type = 0; - } - - output += "" + Environment.NewLine; - output += "" + Environment.NewLine; - output += "" + Environment.NewLine; - output += "" + Environment.NewLine; - - if (type == 1) - { - output += "" + Environment.NewLine; - output += "" + Environment.NewLine; - } - else - { - output += "" + Environment.NewLine; - output += "" + Environment.NewLine; - } - - output += "" + Environment.NewLine; - output += "" + Environment.NewLine; - output += "" + Environment.NewLine; - output += "" + Environment.NewLine; - output += "" + Environment.NewLine; - output += "" + Environment.NewLine; - // prim.blender stores taper values a bit different than the SL network layer - output += "" + Environment.NewLine; - output += "" + Environment.NewLine; - output += "" + Environment.NewLine; - output += "" + Environment.NewLine; - output += "" + Environment.NewLine; - // TODO: Hollowshape. 16-21 = circle, 32-37 = square, 48-53 = triangle - output += "" + Environment.NewLine; - - output += "" + Environment.NewLine + - "" + Environment.NewLine + - "" + Environment.NewLine + - "" + Environment.NewLine + - "" + Environment.NewLine + - "" + Environment.NewLine; - - Log(output); - } - - private void cmdConnect_Click(object sender, EventArgs e) - { - cmdCapture.Text = "Start Capture"; - cmdCapture.Enabled = false; - - if (cmdConnect.Text == "Connect") - { - cmdConnect.Text = "Disconnect"; - txtFirstName.Enabled = txtLastName.Enabled = txtPassword.Enabled = false; - - Hashtable loginParams = NetworkManager.DefaultLoginValues(txtFirstName.Text, - txtLastName.Text, txtPassword.Text, "00:00:00:00:00:00", "last", - "Win", "0", "primexport", "jhurliman@wsu.edu"); - - // HAX - cmdCapture.Text = "Stop Capture"; - client.Objects.OnNewPrim += primCallback; - - if (client.Network.Login(loginParams)) - { - cmdCapture.Enabled = true; - } - else - { - MessageBox.Show(this, "Error logging in: " + client.Network.LoginError); - cmdConnect.Text = "Connect"; - txtFirstName.Enabled = txtLastName.Enabled = txtPassword.Enabled = true; - } - } - else - { - client.Network.Logout(); - cmdConnect.Text = "Connect"; - txtFirstName.Enabled = txtLastName.Enabled = txtPassword.Enabled = true; - } - } - - private void cmdCapture_Click(object sender, EventArgs e) - { - if (cmdCapture.Text == "Start Capture") - { - cmdCapture.Text = "Stop Capture"; - client.Objects.OnNewPrim += primCallback; - } - else - { - cmdCapture.Text = "Start Capture"; - client.Objects.OnNewPrim -= primCallback; - } - } - } -} +using System; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; +using System.Collections; +using libsecondlife; + +namespace primexport +{ + public class frmPrimExport : Form + { + private GroupBox grpLogin; + private Label label3; + private Label label2; + private Label label1; + private TextBox txtPassword; + private TextBox txtLastName; + private Button cmdConnect; + private TextBox txtFirstName; + private Button cmdCapture; + private TextBox txtLog; + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + private SecondLife client; + private NewPrimCallback primCallback; + private string currentText; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.grpLogin = new System.Windows.Forms.GroupBox(); + this.label3 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.txtPassword = new System.Windows.Forms.TextBox(); + this.txtLastName = new System.Windows.Forms.TextBox(); + this.cmdConnect = new System.Windows.Forms.Button(); + this.txtFirstName = new System.Windows.Forms.TextBox(); + this.cmdCapture = new System.Windows.Forms.Button(); + this.txtLog = new System.Windows.Forms.TextBox(); + this.grpLogin.SuspendLayout(); + this.SuspendLayout(); + // + // grpLogin + // + this.grpLogin.Controls.Add(this.label3); + this.grpLogin.Controls.Add(this.label2); + this.grpLogin.Controls.Add(this.label1); + this.grpLogin.Controls.Add(this.txtPassword); + this.grpLogin.Controls.Add(this.txtLastName); + this.grpLogin.Controls.Add(this.cmdConnect); + this.grpLogin.Controls.Add(this.txtFirstName); + this.grpLogin.Enabled = false; + this.grpLogin.Location = new System.Drawing.Point(12, 204); + this.grpLogin.Name = "grpLogin"; + this.grpLogin.Size = new System.Drawing.Size(560, 80); + this.grpLogin.TabIndex = 51; + this.grpLogin.TabStop = false; + // + // label3 + // + this.label3.Location = new System.Drawing.Point(280, 24); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(120, 16); + this.label3.TabIndex = 50; + this.label3.Text = "Password"; + // + // label2 + // + this.label2.Location = new System.Drawing.Point(152, 24); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(120, 16); + this.label2.TabIndex = 50; + this.label2.Text = "Last Name"; + // + // label1 + // + this.label1.Location = new System.Drawing.Point(16, 24); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(120, 16); + this.label1.TabIndex = 50; + this.label1.Text = "First Name"; + // + // txtPassword + // + this.txtPassword.Location = new System.Drawing.Point(280, 40); + this.txtPassword.Name = "txtPassword"; + this.txtPassword.PasswordChar = '*'; + this.txtPassword.Size = new System.Drawing.Size(120, 20); + this.txtPassword.TabIndex = 2; + // + // txtLastName + // + this.txtLastName.Location = new System.Drawing.Point(152, 40); + this.txtLastName.Name = "txtLastName"; + this.txtLastName.Size = new System.Drawing.Size(112, 20); + this.txtLastName.TabIndex = 1; + // + // cmdConnect + // + this.cmdConnect.Location = new System.Drawing.Point(424, 40); + this.cmdConnect.Name = "cmdConnect"; + this.cmdConnect.Size = new System.Drawing.Size(120, 24); + this.cmdConnect.TabIndex = 3; + this.cmdConnect.Text = "Connect"; + this.cmdConnect.Click += new System.EventHandler(this.cmdConnect_Click); + // + // txtFirstName + // + this.txtFirstName.Location = new System.Drawing.Point(16, 40); + this.txtFirstName.Name = "txtFirstName"; + this.txtFirstName.Size = new System.Drawing.Size(120, 20); + this.txtFirstName.TabIndex = 0; + // + // cmdCapture + // + this.cmdCapture.Enabled = false; + this.cmdCapture.Location = new System.Drawing.Point(12, 12); + this.cmdCapture.Name = "cmdCapture"; + this.cmdCapture.Size = new System.Drawing.Size(560, 49); + this.cmdCapture.TabIndex = 52; + this.cmdCapture.Text = "Start Capture"; + this.cmdCapture.Click += new System.EventHandler(this.cmdCapture_Click); + // + // txtLog + // + this.txtLog.Location = new System.Drawing.Point(12, 67); + this.txtLog.Multiline = true; + this.txtLog.Name = "txtLog"; + this.txtLog.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.txtLog.Size = new System.Drawing.Size(560, 131); + this.txtLog.TabIndex = 53; + // + // frmPrimExport + // + this.ClientSize = new System.Drawing.Size(587, 299); + this.Controls.Add(this.txtLog); + this.Controls.Add(this.cmdCapture); + this.Controls.Add(this.grpLogin); + this.MaximizeBox = false; + this.MaximumSize = new System.Drawing.Size(595, 326); + this.MinimumSize = new System.Drawing.Size(595, 326); + this.Name = "frmPrimExport"; + this.Text = "Prim Exporter"; + this.TopMost = true; + this.grpLogin.ResumeLayout(false); + this.grpLogin.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + public frmPrimExport() + { + InitializeComponent(); + + primCallback = new NewPrimCallback(PrimSeen); + + client = new SecondLife(); + grpLogin.Enabled = true; + } + + private void Log(string text) + { + currentText = text; + + if (this.InvokeRequired) + { + this.Invoke(new MethodInvoker(UpdateLog)); + } + else + { + UpdateLog(); + } + } + + private void UpdateLog() + { + txtLog.Text += currentText + Environment.NewLine; + } + + private void PrimSeen(Simulator simulator, PrimObject prim, ulong regionHandle, ushort timeDilation) + { + uint type = 0; + string output = ""; + + output += "" + Environment.NewLine; + output += "" + Environment.NewLine + + "false" + Environment.NewLine + + "false" + Environment.NewLine + + "false" + Environment.NewLine + + "" + Environment.NewLine; + output += "" + Environment.NewLine + + "" + Environment.NewLine; + + if (prim.ProfileCurve == 1 && prim.PathCurve == 16) + { + // PRIM_TYPE_BOX + type = 0; + } + else if (prim.ProfileCurve == 0 && prim.PathCurve == 16) + { + // PRIM_TYPE_CYLINDER + type = 1; + } + else if (prim.ProfileCurve == 3 && prim.PathCurve == 16) + { + // PRIM_TYPE_PRISM + type = 2; + } + else if (prim.ProfileCurve == 5 && prim.PathCurve == 32) + { + // PRIM_TYPE_SPHERE + type = 3; + } + else if (prim.ProfileCurve == 0 && prim.PathCurve == 32) + { + // PRIM_TYPE_TORUS + type = 4; + } + else if (prim.ProfileCurve == 1 && prim.PathCurve == 32) + { + // PRIM_TYPE_TUBE + type = 5; + } + else if (prim.ProfileCurve == 3 && prim.PathCurve == 32) + { + // PRIM_TYPE_RING + type = 6; + } + else + { + Console.WriteLine("Unhandled prim type, ProfileCurve=" + + prim.ProfileCurve + ", PathCurve=" + prim.PathCurve); + type = 0; + } + + output += "" + Environment.NewLine; + output += "" + Environment.NewLine; + output += "" + Environment.NewLine; + output += "" + Environment.NewLine; + + if (type == 1) + { + output += "" + Environment.NewLine; + output += "" + Environment.NewLine; + } + else + { + output += "" + Environment.NewLine; + output += "" + Environment.NewLine; + } + + output += "" + Environment.NewLine; + output += "" + Environment.NewLine; + output += "" + Environment.NewLine; + output += "" + Environment.NewLine; + output += "" + Environment.NewLine; + output += "" + Environment.NewLine; + // prim.blender stores taper values a bit different than the SL network layer + output += "" + Environment.NewLine; + output += "" + Environment.NewLine; + output += "" + Environment.NewLine; + output += "" + Environment.NewLine; + output += "" + Environment.NewLine; + // TODO: Hollowshape. 16-21 = circle, 32-37 = square, 48-53 = triangle + output += "" + Environment.NewLine; + + output += "" + Environment.NewLine + + "" + Environment.NewLine + + "" + Environment.NewLine + + "" + Environment.NewLine + + "" + Environment.NewLine + + "" + Environment.NewLine; + + Log(output); + } + + private void cmdConnect_Click(object sender, EventArgs e) + { + cmdCapture.Text = "Start Capture"; + cmdCapture.Enabled = false; + + if (cmdConnect.Text == "Connect") + { + cmdConnect.Text = "Disconnect"; + txtFirstName.Enabled = txtLastName.Enabled = txtPassword.Enabled = false; + + Hashtable loginParams = NetworkManager.DefaultLoginValues(txtFirstName.Text, + txtLastName.Text, txtPassword.Text, "00:00:00:00:00:00", "last", + "Win", "0", "primexport", "jhurliman@wsu.edu"); + + // HAX + cmdCapture.Text = "Stop Capture"; + client.Objects.OnNewPrim += primCallback; + + if (client.Network.Login(loginParams)) + { + cmdCapture.Enabled = true; + } + else + { + MessageBox.Show(this, "Error logging in: " + client.Network.LoginError); + cmdConnect.Text = "Connect"; + txtFirstName.Enabled = txtLastName.Enabled = txtPassword.Enabled = true; + } + } + else + { + client.Network.Logout(); + cmdConnect.Text = "Connect"; + txtFirstName.Enabled = txtLastName.Enabled = txtPassword.Enabled = true; + } + } + + private void cmdCapture_Click(object sender, EventArgs e) + { + if (cmdCapture.Text == "Start Capture") + { + cmdCapture.Text = "Stop Capture"; + client.Objects.OnNewPrim += primCallback; + } + else + { + cmdCapture.Text = "Start Capture"; + client.Objects.OnNewPrim -= primCallback; + } + } + } +} diff --git a/libsecondlife-cs/examples/primexport/frmPrimExport.resx b/libsecondlife-cs/examples/primexport/frmPrimExport.resx index ff31a6db..19dc0dd8 100644 --- a/libsecondlife-cs/examples/primexport/frmPrimExport.resx +++ b/libsecondlife-cs/examples/primexport/frmPrimExport.resx @@ -1,120 +1,120 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + \ No newline at end of file diff --git a/libsecondlife-cs/examples/primexport/primexport.cs b/libsecondlife-cs/examples/primexport/primexport.cs index 29aa462c..76874a86 100644 --- a/libsecondlife-cs/examples/primexport/primexport.cs +++ b/libsecondlife-cs/examples/primexport/primexport.cs @@ -1,45 +1,45 @@ -/* - * Copyright (c) 2006, Second Life Reverse Engineering Team - * All rights reserved. - * - * - Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - Neither the name of the Second Life Reverse Engineering Team nor the names - * of its contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections; -using libsecondlife; - -namespace primexport -{ - class primexport - { - /// - /// The main entry point for the application. - /// - [STAThread] - static void Main(string[] args) - { - frmPrimExport exportForm = new frmPrimExport(); - exportForm.ShowDialog(); - } - } -} +/* + * Copyright (c) 2006, Second Life Reverse Engineering Team + * All rights reserved. + * + * - Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Neither the name of the Second Life Reverse Engineering Team nor the names + * of its contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using libsecondlife; + +namespace primexport +{ + class primexport + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main(string[] args) + { + frmPrimExport exportForm = new frmPrimExport(); + exportForm.ShowDialog(); + } + } +} diff --git a/libsecondlife-cs/examples/primexport/primexport.csproj b/libsecondlife-cs/examples/primexport/primexport.csproj index c83973de..9392256d 100644 --- a/libsecondlife-cs/examples/primexport/primexport.csproj +++ b/libsecondlife-cs/examples/primexport/primexport.csproj @@ -1,116 +1,116 @@ - - - Local - 8.0.50727 - 2.0 - {77E5330D-8A8C-41B4-A2D1-6F06FE45ED6D} - Debug - AnyCPU - - - - - primexport - - - JScript - Grid - IE50 - false - WinExe - primexport - OnBuildSuccess - - - - - - - - - ..\..\..\bin\ - false - 285212672 - false - - - DEBUG;TRACE - - - true - 4096 - false - - - false - false - false - false - 4 - full - prompt - - - bin\Release\ - false - 285212672 - false - - - TRACE - - - false - 4096 - false - - - true - false - false - false - 4 - none - prompt - - - - System - - - System.Data - - - - - System.XML - - - libsecondlife - {D9CDEDFB-8169-4B03-B57F-0DF638F044EC} - {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - False - - - - - Form - - - Code - - - - - Designer - frmPrimExport.cs - - - - - - - - - + + + Local + 8.0.50727 + 2.0 + {77E5330D-8A8C-41B4-A2D1-6F06FE45ED6D} + Debug + AnyCPU + + + + + primexport + + + JScript + Grid + IE50 + false + WinExe + primexport + OnBuildSuccess + + + + + + + + + ..\..\..\bin\ + false + 285212672 + false + + + DEBUG;TRACE + + + true + 4096 + false + + + false + false + false + false + 4 + full + prompt + + + bin\Release\ + false + 285212672 + false + + + TRACE + + + false + 4096 + false + + + true + false + false + false + 4 + none + prompt + + + + System + + + System.Data + + + + + System.XML + + + libsecondlife + {D9CDEDFB-8169-4B03-B57F-0DF638F044EC} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + + + Form + + + Code + + + + + Designer + frmPrimExport.cs + + + + + + + + + \ No newline at end of file diff --git a/libsecondlife-cs/examples/slaccountant/AssemblyInfo.cs b/libsecondlife-cs/examples/slaccountant/AssemblyInfo.cs index 177a4f0e..9f89a328 100644 --- a/libsecondlife-cs/examples/slaccountant/AssemblyInfo.cs +++ b/libsecondlife-cs/examples/slaccountant/AssemblyInfo.cs @@ -1,58 +1,58 @@ -using System.Reflection; -using System.Runtime.CompilerServices; - -// -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -// -[assembly: AssemblyTitle("")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("")] -[assembly: AssemblyCopyright("")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Revision and Build Numbers -// by using the '*' as shown below: - -[assembly: AssemblyVersion("1.0.*")] - -// -// In order to sign your assembly you must specify a key to use. Refer to the -// Microsoft .NET Framework documentation for more information on assembly signing. -// -// Use the attributes below to control which key is used for signing. -// -// Notes: -// (*) If no key is specified, the assembly is not signed. -// (*) KeyName refers to a key that has been installed in the Crypto Service -// Provider (CSP) on your machine. KeyFile refers to a file which contains -// a key. -// (*) If the KeyFile and the KeyName values are both specified, the -// following processing occurs: -// (1) If the KeyName can be found in the CSP, that key is used. -// (2) If the KeyName does not exist and the KeyFile does exist, the key -// in the KeyFile is installed into the CSP and used. -// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. -// When specifying the KeyFile, the location of the KeyFile should be -// relative to the project output directory which is -// %Project Directory%\obj\. For example, if your KeyFile is -// located in the project directory, you would specify the AssemblyKeyFile -// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] -// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework -// documentation for more information on this. -// -[assembly: AssemblyDelaySign(false)] -[assembly: AssemblyKeyFile("")] -[assembly: AssemblyKeyName("")] +using System.Reflection; +using System.Runtime.CompilerServices; + +// +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +// +[assembly: AssemblyTitle("")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly: AssemblyVersion("1.0.*")] + +// +// In order to sign your assembly you must specify a key to use. Refer to the +// Microsoft .NET Framework documentation for more information on assembly signing. +// +// Use the attributes below to control which key is used for signing. +// +// Notes: +// (*) If no key is specified, the assembly is not signed. +// (*) KeyName refers to a key that has been installed in the Crypto Service +// Provider (CSP) on your machine. KeyFile refers to a file which contains +// a key. +// (*) If the KeyFile and the KeyName values are both specified, the +// following processing occurs: +// (1) If the KeyName can be found in the CSP, that key is used. +// (2) If the KeyName does not exist and the KeyFile does exist, the key +// in the KeyFile is installed into the CSP and used. +// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. +// When specifying the KeyFile, the location of the KeyFile should be +// relative to the project output directory which is +// %Project Directory%\obj\. For example, if your KeyFile is +// located in the project directory, you would specify the AssemblyKeyFile +// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] +// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework +// documentation for more information on this. +// +[assembly: AssemblyDelaySign(false)] +[assembly: AssemblyKeyFile("")] +[assembly: AssemblyKeyName("")] diff --git a/libsecondlife-cs/examples/slaccountant/frmSLAccountant.cs b/libsecondlife-cs/examples/slaccountant/frmSLAccountant.cs index 4d8f4117..817aa451 100644 --- a/libsecondlife-cs/examples/slaccountant/frmSLAccountant.cs +++ b/libsecondlife-cs/examples/slaccountant/frmSLAccountant.cs @@ -1,498 +1,498 @@ -/* - * Copyright (c) 2006, Second Life Reverse Engineering Team - * All rights reserved. - * - * - Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - Neither the name of the Second Life Reverse Engineering Team nor the names - * of its contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Drawing; -using System.Collections; -using System.ComponentModel; -using System.Windows.Forms; -using System.Data; -using System.Threading; -using libsecondlife; -using libsecondlife.Packets; - -namespace SLAccountant -{ - /// - /// Summary description for Form1. - /// - public class frmSLAccountant : System.Windows.Forms.Form - { - private System.Windows.Forms.GroupBox grpLogin; - private System.Windows.Forms.TextBox txtPassword; - private System.Windows.Forms.TextBox txtLastName; - private System.Windows.Forms.Button cmdConnect; - private System.Windows.Forms.TextBox txtFirstName; - private System.Windows.Forms.Label label1; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.Label label3; - /// - /// Required designer variable. - /// - private System.ComponentModel.Container components = null; - private System.Windows.Forms.Label label4; - private System.Windows.Forms.Label lblName; - private System.Windows.Forms.Label lblBalance; - private System.Windows.Forms.Label label6; - private System.Windows.Forms.Label label5; - private System.Windows.Forms.TextBox txtFind; - private System.Windows.Forms.Button cmdFind; - private System.Windows.Forms.TextBox txtTransfer; - private System.Windows.Forms.Button cmdTransfer; - private System.Windows.Forms.Label label7; - private System.Windows.Forms.ListView lstFind; - private System.Windows.Forms.ColumnHeader colName; - private System.Windows.Forms.ColumnHeader colOnline; - private System.Windows.Forms.ColumnHeader colUuid; - - // libsecondlife instance - private SecondLife client; - // Mutex for locking the listview - Mutex lstFindMutex; - - public frmSLAccountant() - { - // - // Required for Windows Form Designer support - // - InitializeComponent(); - } - - /// - /// Clean up any resources being used. - /// - protected override void Dispose( bool disposing ) - { - client.Network.Logout(); - - if( disposing ) - { - if (components != null) - { - components.Dispose(); - } - } - base.Dispose( disposing ); - } - - #region Windows Form Designer generated code - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.grpLogin = new System.Windows.Forms.GroupBox(); - this.label3 = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.label1 = new System.Windows.Forms.Label(); - this.txtPassword = new System.Windows.Forms.TextBox(); - this.txtLastName = new System.Windows.Forms.TextBox(); - this.cmdConnect = new System.Windows.Forms.Button(); - this.txtFirstName = new System.Windows.Forms.TextBox(); - this.label4 = new System.Windows.Forms.Label(); - this.lblName = new System.Windows.Forms.Label(); - this.lblBalance = new System.Windows.Forms.Label(); - this.label6 = new System.Windows.Forms.Label(); - this.label5 = new System.Windows.Forms.Label(); - this.txtFind = new System.Windows.Forms.TextBox(); - this.cmdFind = new System.Windows.Forms.Button(); - this.txtTransfer = new System.Windows.Forms.TextBox(); - this.cmdTransfer = new System.Windows.Forms.Button(); - this.label7 = new System.Windows.Forms.Label(); - this.lstFind = new System.Windows.Forms.ListView(); - this.colName = new System.Windows.Forms.ColumnHeader(); - this.colOnline = new System.Windows.Forms.ColumnHeader(); - this.colUuid = new System.Windows.Forms.ColumnHeader(); - this.grpLogin.SuspendLayout(); - this.SuspendLayout(); - // - // grpLogin - // - this.grpLogin.Controls.Add(this.label3); - this.grpLogin.Controls.Add(this.label2); - this.grpLogin.Controls.Add(this.label1); - this.grpLogin.Controls.Add(this.txtPassword); - this.grpLogin.Controls.Add(this.txtLastName); - this.grpLogin.Controls.Add(this.cmdConnect); - this.grpLogin.Controls.Add(this.txtFirstName); - this.grpLogin.Enabled = false; - this.grpLogin.Location = new System.Drawing.Point(16, 344); - this.grpLogin.Name = "grpLogin"; - this.grpLogin.Size = new System.Drawing.Size(560, 80); - this.grpLogin.TabIndex = 50; - this.grpLogin.TabStop = false; - // - // label3 - // - this.label3.Location = new System.Drawing.Point(280, 24); - this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(120, 16); - this.label3.TabIndex = 50; - this.label3.Text = "Password"; - // - // label2 - // - this.label2.Location = new System.Drawing.Point(152, 24); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(120, 16); - this.label2.TabIndex = 50; - this.label2.Text = "Last Name"; - // - // label1 - // - this.label1.Location = new System.Drawing.Point(16, 24); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(120, 16); - this.label1.TabIndex = 50; - this.label1.Text = "First Name"; - // - // txtPassword - // - this.txtPassword.Location = new System.Drawing.Point(280, 40); - this.txtPassword.Name = "txtPassword"; - this.txtPassword.PasswordChar = '*'; - this.txtPassword.Size = new System.Drawing.Size(120, 20); - this.txtPassword.TabIndex = 2; - this.txtPassword.Text = ""; - // - // txtLastName - // - this.txtLastName.Location = new System.Drawing.Point(152, 40); - this.txtLastName.Name = "txtLastName"; - this.txtLastName.Size = new System.Drawing.Size(112, 20); - this.txtLastName.TabIndex = 1; - this.txtLastName.Text = ""; - // - // cmdConnect - // - this.cmdConnect.Location = new System.Drawing.Point(424, 40); - this.cmdConnect.Name = "cmdConnect"; - this.cmdConnect.Size = new System.Drawing.Size(120, 24); - this.cmdConnect.TabIndex = 3; - this.cmdConnect.Text = "Connect"; - this.cmdConnect.Click += new System.EventHandler(this.cmdConnect_Click); - // - // txtFirstName - // - this.txtFirstName.Location = new System.Drawing.Point(16, 40); - this.txtFirstName.Name = "txtFirstName"; - this.txtFirstName.Size = new System.Drawing.Size(120, 20); - this.txtFirstName.TabIndex = 0; - this.txtFirstName.Text = ""; - // - // label4 - // - this.label4.Location = new System.Drawing.Point(16, 8); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(48, 16); - this.label4.TabIndex = 50; - this.label4.Text = "Name:"; - // - // lblName - // - this.lblName.Location = new System.Drawing.Point(64, 8); - this.lblName.Name = "lblName"; - this.lblName.Size = new System.Drawing.Size(184, 16); - this.lblName.TabIndex = 50; - // - // lblBalance - // - this.lblBalance.Location = new System.Drawing.Point(512, 8); - this.lblBalance.Name = "lblBalance"; - this.lblBalance.Size = new System.Drawing.Size(64, 16); - this.lblBalance.TabIndex = 50; - this.lblBalance.TextAlign = System.Drawing.ContentAlignment.TopRight; - // - // label6 - // - this.label6.Location = new System.Drawing.Point(456, 8); - this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(56, 16); - this.label6.TabIndex = 50; - this.label6.Text = "Balance:"; - // - // label5 - // - this.label5.Location = new System.Drawing.Point(16, 40); - this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(88, 16); - this.label5.TabIndex = 50; - this.label5.Text = "People Search"; - // - // txtFind - // - this.txtFind.Enabled = false; - this.txtFind.Location = new System.Drawing.Point(16, 56); - this.txtFind.Name = "txtFind"; - this.txtFind.Size = new System.Drawing.Size(184, 20); - this.txtFind.TabIndex = 4; - this.txtFind.Text = ""; - // - // cmdFind - // - this.cmdFind.Enabled = false; - this.cmdFind.Location = new System.Drawing.Point(208, 56); - this.cmdFind.Name = "cmdFind"; - this.cmdFind.Size = new System.Drawing.Size(48, 24); - this.cmdFind.TabIndex = 5; - this.cmdFind.Text = "Find"; - this.cmdFind.Click += new System.EventHandler(this.cmdFind_Click); - // - // txtTransfer - // - this.txtTransfer.Enabled = false; - this.txtTransfer.Location = new System.Drawing.Point(360, 192); - this.txtTransfer.MaxLength = 7; - this.txtTransfer.Name = "txtTransfer"; - this.txtTransfer.Size = new System.Drawing.Size(104, 20); - this.txtTransfer.TabIndex = 7; - this.txtTransfer.Text = ""; - // - // cmdTransfer - // - this.cmdTransfer.Enabled = false; - this.cmdTransfer.Location = new System.Drawing.Point(472, 192); - this.cmdTransfer.Name = "cmdTransfer"; - this.cmdTransfer.Size = new System.Drawing.Size(104, 24); - this.cmdTransfer.TabIndex = 8; - this.cmdTransfer.Text = "Transfer Lindens"; - this.cmdTransfer.Click += new System.EventHandler(this.cmdTransfer_Click); - // - // label7 - // - this.label7.Location = new System.Drawing.Point(360, 176); - this.label7.Name = "label7"; - this.label7.Size = new System.Drawing.Size(88, 16); - this.label7.TabIndex = 17; - this.label7.Text = "Amount:"; - // - // lstFind - // - this.lstFind.Activation = System.Windows.Forms.ItemActivation.OneClick; - this.lstFind.AllowColumnReorder = true; - this.lstFind.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.colName, - this.colOnline, - this.colUuid}); - this.lstFind.FullRowSelect = true; - this.lstFind.HideSelection = false; - this.lstFind.Location = new System.Drawing.Point(16, 88); - this.lstFind.Name = "lstFind"; - this.lstFind.Size = new System.Drawing.Size(336, 248); - this.lstFind.Sorting = System.Windows.Forms.SortOrder.Ascending; - this.lstFind.TabIndex = 6; - this.lstFind.View = System.Windows.Forms.View.Details; - // - // colName - // - this.colName.Text = "Name"; - this.colName.Width = 120; - // - // colOnline - // - this.colOnline.Text = "Online"; - this.colOnline.Width = 50; - // - // colUuid - // - this.colUuid.Text = "UUID"; - this.colUuid.Width = 150; - // - // frmSLAccountant - // - this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); - this.ClientSize = new System.Drawing.Size(592, 437); - this.Controls.Add(this.lstFind); - this.Controls.Add(this.label7); - this.Controls.Add(this.cmdTransfer); - this.Controls.Add(this.txtTransfer); - this.Controls.Add(this.txtFind); - this.Controls.Add(this.cmdFind); - this.Controls.Add(this.label5); - this.Controls.Add(this.lblBalance); - this.Controls.Add(this.label6); - this.Controls.Add(this.lblName); - this.Controls.Add(this.label4); - this.Controls.Add(this.grpLogin); - this.Name = "frmSLAccountant"; - this.Text = "SL Accountant"; - this.Load += new System.EventHandler(this.frmSLAccountant_Load); - this.grpLogin.ResumeLayout(false); - this.ResumeLayout(false); - - } - #endregion - - /// - /// The main entry point for the application. - /// - [STAThread] - static void Main() - { - frmSLAccountant frm = new frmSLAccountant(); - frm.ShowDialog(); - } - - private void BalanceHandler(Packet packet, Simulator simulator) - { - lblBalance.Text = ((MoneyBalanceReplyPacket)packet).MoneyData.MoneyBalance.ToString(); - } - - private void DirPeopleHandler(Packet packet, Simulator simulator) - { - DirPeopleReplyPacket reply = (DirPeopleReplyPacket)packet; - - lstFindMutex.WaitOne(); - - foreach (DirPeopleReplyPacket.QueryRepliesBlock block in reply.QueryReplies) - { - ListViewItem listItem = new ListViewItem(new string[] { - Helpers.FieldToString(block.FirstName) + " " + Helpers.FieldToString(block.LastName), - (block.Online ? "Yes" : "No"), block.AgentID.ToString() }); - lstFind.Items.Add(listItem); - } - - lstFindMutex.ReleaseMutex(); - } - - private void frmSLAccountant_Load(object sender, System.EventArgs e) - { - lstFindMutex = new Mutex(false, "lstFindMutex"); - - client = new SecondLife(); - - // Install our packet handlers - //client.Network.RegisterCallback(PacketType.AvatarAppearance, new PacketCallback(AvatarAppearanceHandler)); - client.Network.RegisterCallback(PacketType.MoneyBalanceReply, new PacketCallback(BalanceHandler)); - client.Network.RegisterCallback(PacketType.DirPeopleReply, new PacketCallback(DirPeopleHandler)); - - grpLogin.Enabled = true; - } - - private void cmdConnect_Click(object sender, System.EventArgs e) - { - if (cmdConnect.Text == "Connect") - { - cmdConnect.Text = "Disconnect"; - txtFirstName.Enabled = txtLastName.Enabled = txtPassword.Enabled = false; - - Hashtable loginParams = NetworkManager.DefaultLoginValues(txtFirstName.Text, - txtLastName.Text, txtPassword.Text, "00:00:00:00:00:00", "last", - "Win", "0", "accountant", "jhurliman@wsu.edu"); - - if (client.Network.Login(loginParams)) - { - Random rand = new Random(); - - lblName.Text = client.Network.LoginValues["first_name"] + " " + - client.Network.LoginValues["last_name"]; - - client.Avatar.SetHeightWidth((ushort)rand.Next(0, 65535), (ushort)rand.Next(0, 65535)); - - // AgentSetAppearance - AgentSetAppearancePacket appearance = new AgentSetAppearancePacket(); - appearance.VisualParam = new AgentSetAppearancePacket.VisualParamBlock[218]; - // Setup some random appearance values - for (int i = 0; i < 218; i++) - { - appearance.VisualParam[i] = new AgentSetAppearancePacket.VisualParamBlock(); - appearance.VisualParam[i].ParamValue = (byte)rand.Next(255); - } - appearance.AgentData.AgentID = client.Network.AgentID; - appearance.AgentData.SessionID = client.Network.SessionID; - appearance.AgentData.SerialNum = 1; - appearance.AgentData.Size = new LLVector3(0.45F, 0.6F, 1.831094F); - appearance.ObjectData.TextureEntry = new byte[0]; - - client.Network.SendPacket(appearance); - - txtFind.Enabled = cmdFind.Enabled = true; - txtTransfer.Enabled = cmdTransfer.Enabled = true; - } - else - { - MessageBox.Show(this, "Error logging in: " + client.Network.LoginError); - cmdConnect.Text = "Connect"; - txtFirstName.Enabled = txtLastName.Enabled = txtPassword.Enabled = true; - txtFind.Enabled = cmdFind.Enabled = false; - lblName.Text = lblBalance.Text = ""; - txtTransfer.Enabled = cmdTransfer.Enabled = false; - } - } - else - { - client.Network.Logout(); - cmdConnect.Text = "Connect"; - txtFirstName.Enabled = txtLastName.Enabled = txtPassword.Enabled = true; - txtFind.Enabled = cmdFind.Enabled = false; - lblName.Text = lblBalance.Text = ""; - txtTransfer.Enabled = cmdTransfer.Enabled = false; - } - } - - private void cmdFind_Click(object sender, System.EventArgs e) - { - lstFind.Items.Clear(); - - DirFindQueryPacket query = new DirFindQueryPacket(); - query.AgentData.AgentID = client.Network.AgentID; - query.AgentData.SessionID = client.Network.SessionID; - query.QueryData.QueryFlags = 1; - query.QueryData.QueryID = LLUUID.GenerateUUID(); - query.QueryData.QueryStart = 0; - query.QueryData.QueryText = Helpers.StringToField(txtFind.Text); - query.Header.Reliable = true; - - client.Network.SendPacket((Packet)query); - } - - private void cmdTransfer_Click(object sender, System.EventArgs e) - { - int amount = 0; - - try - { - amount = System.Convert.ToInt32(txtTransfer.Text); - } - catch (Exception) - { - MessageBox.Show(txtTransfer.Text + " is not a valid amount"); - return; - } - - if (lstFind.SelectedItems.Count != 1) - { - MessageBox.Show("Find an avatar using the directory search and select " + - "their name to transfer money"); - return; - } - - client.Avatar.GiveMoney(new LLUUID(lstFind.SelectedItems[0].SubItems[2].Text), - amount, "SLAccountant payment"); - } - } -} +/* + * Copyright (c) 2006, Second Life Reverse Engineering Team + * All rights reserved. + * + * - Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Neither the name of the Second Life Reverse Engineering Team nor the names + * of its contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Drawing; +using System.Collections; +using System.ComponentModel; +using System.Windows.Forms; +using System.Data; +using System.Threading; +using libsecondlife; +using libsecondlife.Packets; + +namespace SLAccountant +{ + /// + /// Summary description for Form1. + /// + public class frmSLAccountant : System.Windows.Forms.Form + { + private System.Windows.Forms.GroupBox grpLogin; + private System.Windows.Forms.TextBox txtPassword; + private System.Windows.Forms.TextBox txtLastName; + private System.Windows.Forms.Button cmdConnect; + private System.Windows.Forms.TextBox txtFirstName; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label3; + /// + /// Required designer variable. + /// + private System.ComponentModel.Container components = null; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.Label lblName; + private System.Windows.Forms.Label lblBalance; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.TextBox txtFind; + private System.Windows.Forms.Button cmdFind; + private System.Windows.Forms.TextBox txtTransfer; + private System.Windows.Forms.Button cmdTransfer; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.ListView lstFind; + private System.Windows.Forms.ColumnHeader colName; + private System.Windows.Forms.ColumnHeader colOnline; + private System.Windows.Forms.ColumnHeader colUuid; + + // libsecondlife instance + private SecondLife client; + // Mutex for locking the listview + Mutex lstFindMutex; + + public frmSLAccountant() + { + // + // Required for Windows Form Designer support + // + InitializeComponent(); + } + + /// + /// Clean up any resources being used. + /// + protected override void Dispose( bool disposing ) + { + client.Network.Logout(); + + if( disposing ) + { + if (components != null) + { + components.Dispose(); + } + } + base.Dispose( disposing ); + } + + #region Windows Form Designer generated code + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.grpLogin = new System.Windows.Forms.GroupBox(); + this.label3 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.txtPassword = new System.Windows.Forms.TextBox(); + this.txtLastName = new System.Windows.Forms.TextBox(); + this.cmdConnect = new System.Windows.Forms.Button(); + this.txtFirstName = new System.Windows.Forms.TextBox(); + this.label4 = new System.Windows.Forms.Label(); + this.lblName = new System.Windows.Forms.Label(); + this.lblBalance = new System.Windows.Forms.Label(); + this.label6 = new System.Windows.Forms.Label(); + this.label5 = new System.Windows.Forms.Label(); + this.txtFind = new System.Windows.Forms.TextBox(); + this.cmdFind = new System.Windows.Forms.Button(); + this.txtTransfer = new System.Windows.Forms.TextBox(); + this.cmdTransfer = new System.Windows.Forms.Button(); + this.label7 = new System.Windows.Forms.Label(); + this.lstFind = new System.Windows.Forms.ListView(); + this.colName = new System.Windows.Forms.ColumnHeader(); + this.colOnline = new System.Windows.Forms.ColumnHeader(); + this.colUuid = new System.Windows.Forms.ColumnHeader(); + this.grpLogin.SuspendLayout(); + this.SuspendLayout(); + // + // grpLogin + // + this.grpLogin.Controls.Add(this.label3); + this.grpLogin.Controls.Add(this.label2); + this.grpLogin.Controls.Add(this.label1); + this.grpLogin.Controls.Add(this.txtPassword); + this.grpLogin.Controls.Add(this.txtLastName); + this.grpLogin.Controls.Add(this.cmdConnect); + this.grpLogin.Controls.Add(this.txtFirstName); + this.grpLogin.Enabled = false; + this.grpLogin.Location = new System.Drawing.Point(16, 344); + this.grpLogin.Name = "grpLogin"; + this.grpLogin.Size = new System.Drawing.Size(560, 80); + this.grpLogin.TabIndex = 50; + this.grpLogin.TabStop = false; + // + // label3 + // + this.label3.Location = new System.Drawing.Point(280, 24); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(120, 16); + this.label3.TabIndex = 50; + this.label3.Text = "Password"; + // + // label2 + // + this.label2.Location = new System.Drawing.Point(152, 24); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(120, 16); + this.label2.TabIndex = 50; + this.label2.Text = "Last Name"; + // + // label1 + // + this.label1.Location = new System.Drawing.Point(16, 24); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(120, 16); + this.label1.TabIndex = 50; + this.label1.Text = "First Name"; + // + // txtPassword + // + this.txtPassword.Location = new System.Drawing.Point(280, 40); + this.txtPassword.Name = "txtPassword"; + this.txtPassword.PasswordChar = '*'; + this.txtPassword.Size = new System.Drawing.Size(120, 20); + this.txtPassword.TabIndex = 2; + this.txtPassword.Text = ""; + // + // txtLastName + // + this.txtLastName.Location = new System.Drawing.Point(152, 40); + this.txtLastName.Name = "txtLastName"; + this.txtLastName.Size = new System.Drawing.Size(112, 20); + this.txtLastName.TabIndex = 1; + this.txtLastName.Text = ""; + // + // cmdConnect + // + this.cmdConnect.Location = new System.Drawing.Point(424, 40); + this.cmdConnect.Name = "cmdConnect"; + this.cmdConnect.Size = new System.Drawing.Size(120, 24); + this.cmdConnect.TabIndex = 3; + this.cmdConnect.Text = "Connect"; + this.cmdConnect.Click += new System.EventHandler(this.cmdConnect_Click); + // + // txtFirstName + // + this.txtFirstName.Location = new System.Drawing.Point(16, 40); + this.txtFirstName.Name = "txtFirstName"; + this.txtFirstName.Size = new System.Drawing.Size(120, 20); + this.txtFirstName.TabIndex = 0; + this.txtFirstName.Text = ""; + // + // label4 + // + this.label4.Location = new System.Drawing.Point(16, 8); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(48, 16); + this.label4.TabIndex = 50; + this.label4.Text = "Name:"; + // + // lblName + // + this.lblName.Location = new System.Drawing.Point(64, 8); + this.lblName.Name = "lblName"; + this.lblName.Size = new System.Drawing.Size(184, 16); + this.lblName.TabIndex = 50; + // + // lblBalance + // + this.lblBalance.Location = new System.Drawing.Point(512, 8); + this.lblBalance.Name = "lblBalance"; + this.lblBalance.Size = new System.Drawing.Size(64, 16); + this.lblBalance.TabIndex = 50; + this.lblBalance.TextAlign = System.Drawing.ContentAlignment.TopRight; + // + // label6 + // + this.label6.Location = new System.Drawing.Point(456, 8); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(56, 16); + this.label6.TabIndex = 50; + this.label6.Text = "Balance:"; + // + // label5 + // + this.label5.Location = new System.Drawing.Point(16, 40); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(88, 16); + this.label5.TabIndex = 50; + this.label5.Text = "People Search"; + // + // txtFind + // + this.txtFind.Enabled = false; + this.txtFind.Location = new System.Drawing.Point(16, 56); + this.txtFind.Name = "txtFind"; + this.txtFind.Size = new System.Drawing.Size(184, 20); + this.txtFind.TabIndex = 4; + this.txtFind.Text = ""; + // + // cmdFind + // + this.cmdFind.Enabled = false; + this.cmdFind.Location = new System.Drawing.Point(208, 56); + this.cmdFind.Name = "cmdFind"; + this.cmdFind.Size = new System.Drawing.Size(48, 24); + this.cmdFind.TabIndex = 5; + this.cmdFind.Text = "Find"; + this.cmdFind.Click += new System.EventHandler(this.cmdFind_Click); + // + // txtTransfer + // + this.txtTransfer.Enabled = false; + this.txtTransfer.Location = new System.Drawing.Point(360, 192); + this.txtTransfer.MaxLength = 7; + this.txtTransfer.Name = "txtTransfer"; + this.txtTransfer.Size = new System.Drawing.Size(104, 20); + this.txtTransfer.TabIndex = 7; + this.txtTransfer.Text = ""; + // + // cmdTransfer + // + this.cmdTransfer.Enabled = false; + this.cmdTransfer.Location = new System.Drawing.Point(472, 192); + this.cmdTransfer.Name = "cmdTransfer"; + this.cmdTransfer.Size = new System.Drawing.Size(104, 24); + this.cmdTransfer.TabIndex = 8; + this.cmdTransfer.Text = "Transfer Lindens"; + this.cmdTransfer.Click += new System.EventHandler(this.cmdTransfer_Click); + // + // label7 + // + this.label7.Location = new System.Drawing.Point(360, 176); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(88, 16); + this.label7.TabIndex = 17; + this.label7.Text = "Amount:"; + // + // lstFind + // + this.lstFind.Activation = System.Windows.Forms.ItemActivation.OneClick; + this.lstFind.AllowColumnReorder = true; + this.lstFind.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.colName, + this.colOnline, + this.colUuid}); + this.lstFind.FullRowSelect = true; + this.lstFind.HideSelection = false; + this.lstFind.Location = new System.Drawing.Point(16, 88); + this.lstFind.Name = "lstFind"; + this.lstFind.Size = new System.Drawing.Size(336, 248); + this.lstFind.Sorting = System.Windows.Forms.SortOrder.Ascending; + this.lstFind.TabIndex = 6; + this.lstFind.View = System.Windows.Forms.View.Details; + // + // colName + // + this.colName.Text = "Name"; + this.colName.Width = 120; + // + // colOnline + // + this.colOnline.Text = "Online"; + this.colOnline.Width = 50; + // + // colUuid + // + this.colUuid.Text = "UUID"; + this.colUuid.Width = 150; + // + // frmSLAccountant + // + this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); + this.ClientSize = new System.Drawing.Size(592, 437); + this.Controls.Add(this.lstFind); + this.Controls.Add(this.label7); + this.Controls.Add(this.cmdTransfer); + this.Controls.Add(this.txtTransfer); + this.Controls.Add(this.txtFind); + this.Controls.Add(this.cmdFind); + this.Controls.Add(this.label5); + this.Controls.Add(this.lblBalance); + this.Controls.Add(this.label6); + this.Controls.Add(this.lblName); + this.Controls.Add(this.label4); + this.Controls.Add(this.grpLogin); + this.Name = "frmSLAccountant"; + this.Text = "SL Accountant"; + this.Load += new System.EventHandler(this.frmSLAccountant_Load); + this.grpLogin.ResumeLayout(false); + this.ResumeLayout(false); + + } + #endregion + + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + frmSLAccountant frm = new frmSLAccountant(); + frm.ShowDialog(); + } + + private void BalanceHandler(Packet packet, Simulator simulator) + { + lblBalance.Text = ((MoneyBalanceReplyPacket)packet).MoneyData.MoneyBalance.ToString(); + } + + private void DirPeopleHandler(Packet packet, Simulator simulator) + { + DirPeopleReplyPacket reply = (DirPeopleReplyPacket)packet; + + lstFindMutex.WaitOne(); + + foreach (DirPeopleReplyPacket.QueryRepliesBlock block in reply.QueryReplies) + { + ListViewItem listItem = new ListViewItem(new string[] { + Helpers.FieldToString(block.FirstName) + " " + Helpers.FieldToString(block.LastName), + (block.Online ? "Yes" : "No"), block.AgentID.ToString() }); + lstFind.Items.Add(listItem); + } + + lstFindMutex.ReleaseMutex(); + } + + private void frmSLAccountant_Load(object sender, System.EventArgs e) + { + lstFindMutex = new Mutex(false, "lstFindMutex"); + + client = new SecondLife(); + + // Install our packet handlers + //client.Network.RegisterCallback(PacketType.AvatarAppearance, new PacketCallback(AvatarAppearanceHandler)); + client.Network.RegisterCallback(PacketType.MoneyBalanceReply, new PacketCallback(BalanceHandler)); + client.Network.RegisterCallback(PacketType.DirPeopleReply, new PacketCallback(DirPeopleHandler)); + + grpLogin.Enabled = true; + } + + private void cmdConnect_Click(object sender, System.EventArgs e) + { + if (cmdConnect.Text == "Connect") + { + cmdConnect.Text = "Disconnect"; + txtFirstName.Enabled = txtLastName.Enabled = txtPassword.Enabled = false; + + Hashtable loginParams = NetworkManager.DefaultLoginValues(txtFirstName.Text, + txtLastName.Text, txtPassword.Text, "00:00:00:00:00:00", "last", + "Win", "0", "accountant", "jhurliman@wsu.edu"); + + if (client.Network.Login(loginParams)) + { + Random rand = new Random(); + + lblName.Text = client.Network.LoginValues["first_name"] + " " + + client.Network.LoginValues["last_name"]; + + client.Avatar.SetHeightWidth((ushort)rand.Next(0, 65535), (ushort)rand.Next(0, 65535)); + + // AgentSetAppearance + AgentSetAppearancePacket appearance = new AgentSetAppearancePacket(); + appearance.VisualParam = new AgentSetAppearancePacket.VisualParamBlock[218]; + // Setup some random appearance values + for (int i = 0; i < 218; i++) + { + appearance.VisualParam[i] = new AgentSetAppearancePacket.VisualParamBlock(); + appearance.VisualParam[i].ParamValue = (byte)rand.Next(255); + } + appearance.AgentData.AgentID = client.Network.AgentID; + appearance.AgentData.SessionID = client.Network.SessionID; + appearance.AgentData.SerialNum = 1; + appearance.AgentData.Size = new LLVector3(0.45F, 0.6F, 1.831094F); + appearance.ObjectData.TextureEntry = new byte[0]; + + client.Network.SendPacket(appearance); + + txtFind.Enabled = cmdFind.Enabled = true; + txtTransfer.Enabled = cmdTransfer.Enabled = true; + } + else + { + MessageBox.Show(this, "Error logging in: " + client.Network.LoginError); + cmdConnect.Text = "Connect"; + txtFirstName.Enabled = txtLastName.Enabled = txtPassword.Enabled = true; + txtFind.Enabled = cmdFind.Enabled = false; + lblName.Text = lblBalance.Text = ""; + txtTransfer.Enabled = cmdTransfer.Enabled = false; + } + } + else + { + client.Network.Logout(); + cmdConnect.Text = "Connect"; + txtFirstName.Enabled = txtLastName.Enabled = txtPassword.Enabled = true; + txtFind.Enabled = cmdFind.Enabled = false; + lblName.Text = lblBalance.Text = ""; + txtTransfer.Enabled = cmdTransfer.Enabled = false; + } + } + + private void cmdFind_Click(object sender, System.EventArgs e) + { + lstFind.Items.Clear(); + + DirFindQueryPacket query = new DirFindQueryPacket(); + query.AgentData.AgentID = client.Network.AgentID; + query.AgentData.SessionID = client.Network.SessionID; + query.QueryData.QueryFlags = 1; + query.QueryData.QueryID = LLUUID.GenerateUUID(); + query.QueryData.QueryStart = 0; + query.QueryData.QueryText = Helpers.StringToField(txtFind.Text); + query.Header.Reliable = true; + + client.Network.SendPacket((Packet)query); + } + + private void cmdTransfer_Click(object sender, System.EventArgs e) + { + int amount = 0; + + try + { + amount = System.Convert.ToInt32(txtTransfer.Text); + } + catch (Exception) + { + MessageBox.Show(txtTransfer.Text + " is not a valid amount"); + return; + } + + if (lstFind.SelectedItems.Count != 1) + { + MessageBox.Show("Find an avatar using the directory search and select " + + "their name to transfer money"); + return; + } + + client.Avatar.GiveMoney(new LLUUID(lstFind.SelectedItems[0].SubItems[2].Text), + amount, "SLAccountant payment"); + } + } +} diff --git a/libsecondlife-cs/examples/slaccountant/frmSLAccountant.resx b/libsecondlife-cs/examples/slaccountant/frmSLAccountant.resx index 0b39743a..85eaf362 100644 --- a/libsecondlife-cs/examples/slaccountant/frmSLAccountant.resx +++ b/libsecondlife-cs/examples/slaccountant/frmSLAccountant.resx @@ -1,328 +1,328 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 1.3 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Private - - - 8, 8 - - - True - - - False - - - True - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - False - - - Private - - - Private - - - Private - - - False - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - Private - - - False - - - Private - - - False - - - Private - - - Private - - - Private - - - False - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - False - - - Private - - - Private - - - Private - - - Private - - - Private - - - Private - - - Private - - - Private - - - False - - - (Default) - - - False - - - False - - - 8, 8 - - - True - - - 80 - - - True - - - frmSLAccountant - - - Private - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 1.3 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Private + + + 8, 8 + + + True + + + False + + + True + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + False + + + Private + + + Private + + + Private + + + False + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + Private + + + False + + + Private + + + False + + + Private + + + Private + + + Private + + + False + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + False + + + Private + + + Private + + + Private + + + Private + + + Private + + + Private + + + Private + + + Private + + + False + + + (Default) + + + False + + + False + + + 8, 8 + + + True + + + 80 + + + True + + + frmSLAccountant + + + Private + \ No newline at end of file diff --git a/libsecondlife-cs/examples/slaccountant/slaccountant.csproj b/libsecondlife-cs/examples/slaccountant/slaccountant.csproj index a426d85c..a5b84e39 100644 --- a/libsecondlife-cs/examples/slaccountant/slaccountant.csproj +++ b/libsecondlife-cs/examples/slaccountant/slaccountant.csproj @@ -1,118 +1,118 @@ - - - Local - 8.0.50727 - 2.0 - {FC19D5F6-076E-4923-8456-9B0E00E22896} - Debug - AnyCPU - App.ico - - - slaccountant - - - JScript - Grid - IE50 - false - WinExe - slaccountant - OnBuildSuccess - - - - - - - - - ..\..\..\bin\ - false - 285212672 - false - - - DEBUG;TRACE - - - true - 4096 - false - - - false - false - false - false - 4 - full - prompt - - - bin\Release\ - false - 285212672 - false - - - TRACE - - - false - 4096 - false - - - true - false - false - false - 4 - none - prompt - - - - System - - - System.Data - - - System.Drawing - - - System.Windows.Forms - - - System.XML - - - libsecondlife - {D9CDEDFB-8169-4B03-B57F-0DF638F044EC} - {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - False - - - - - - Code - - - Form - - - frmSLAccountant.cs - Designer - - - - - - - - - + + + Local + 8.0.50727 + 2.0 + {FC19D5F6-076E-4923-8456-9B0E00E22896} + Debug + AnyCPU + App.ico + + + slaccountant + + + JScript + Grid + IE50 + false + WinExe + slaccountant + OnBuildSuccess + + + + + + + + + ..\..\..\bin\ + false + 285212672 + false + + + DEBUG;TRACE + + + true + 4096 + false + + + false + false + false + false + 4 + full + prompt + + + bin\Release\ + false + 285212672 + false + + + TRACE + + + false + 4096 + false + + + true + false + false + false + 4 + none + prompt + + + + System + + + System.Data + + + System.Drawing + + + System.Windows.Forms + + + System.XML + + + libsecondlife + {D9CDEDFB-8169-4B03-B57F-0DF638F044EC} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + + + + Code + + + Form + + + frmSLAccountant.cs + Designer + + + + + + + + + \ No newline at end of file diff --git a/libsecondlife-cs/examples/sldump/sldump.cs b/libsecondlife-cs/examples/sldump/sldump.cs index 0dd14244..af2c0abb 100644 --- a/libsecondlife-cs/examples/sldump/sldump.cs +++ b/libsecondlife-cs/examples/sldump/sldump.cs @@ -1,132 +1,132 @@ -/* - * Copyright (c) 2006, Second Life Reverse Engineering Team - * All rights reserved. - * - * - Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - Neither the name of the Second Life Reverse Engineering Team nor the names - * of its contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using System.Collections; -using libsecondlife; -using libsecondlife.Packets; - -namespace sldump -{ - class sldump - { - // Default packet handler, registered for all packet types - public static void DefaultHandler(Packet packet, Simulator simulator) - { - Console.WriteLine(packet.ToString()); - } - - public static void DisconnectHandler(DisconnectType type, string message) - { - if (type == DisconnectType.NetworkTimeout) - { - Console.WriteLine("Network connection timed out, disconnected"); - } - else if (type == DisconnectType.ServerInitiated) - { - Console.WriteLine("Server disconnected us: " + message); - } - } - - /// - /// The main entry point for the application. - /// - [STAThread] - static void Main(string[] args) - { - SecondLife client; - - if (args.Length == 0 || (args.Length < 3 && args[0] != "--printmap")) - { - Console.WriteLine("Usage: sldump [--printmap] [--decrypt] [inputfile] [outputfile] [--protocol] [firstname] " + - "[lastname] [password]"); - return; - } - - if (args[0] == "--decrypt") - { - try - { - ProtocolManager.DecodeMapFile(args[1], args[2]); - } - catch (Exception e) - { - Console.WriteLine(e.ToString()); - } - - return; - } - - client = new SecondLife(); - - if (args[0] == "--printmap") - { - ProtocolManager protocol; - - try - { - protocol = new ProtocolManager("keywords.txt", "message_template.msg", client); - } - catch (Exception e) - { - // Error initializing the client, probably missing file(s) - Console.WriteLine(e.ToString()); - return; - } - - protocol.PrintMap(); - return; - } - - // Setup the packet callback and disconnect event handler - client.Network.RegisterCallback(PacketType.Default, new PacketCallback(DefaultHandler)); - client.Network.OnDisconnected += new DisconnectCallback(DisconnectHandler); - - Hashtable loginParams = NetworkManager.DefaultLoginValues(args[0], args[1], args[2], - "b15396fa7ec5f19ff1131800673aa132", "last", "Win", "0", "sldump", - "contact@libsecondlife.org"); - - // An example of how to pass additional options to the login server - loginParams["id0"] = "65e142a8d3c1ee6632259f111cb168c6"; - loginParams["viewer_digest"] = "0e63550f-0991-a092-3158-b4206e728ffa"; - - if (!client.Network.Login(loginParams/*, "http://127.0.0.1:8080/"*/)) - { - // Login failed - Console.WriteLine("Error logging in: " + client.Network.LoginError); - return; - } - - // Login was successful - Console.WriteLine("Message of the day: " + client.Network.LoginValues["message"]); - - while (true) - { - client.Tick(); - } - } - } -} +/* + * Copyright (c) 2006, Second Life Reverse Engineering Team + * All rights reserved. + * + * - Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Neither the name of the Second Life Reverse Engineering Team nor the names + * of its contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using libsecondlife; +using libsecondlife.Packets; + +namespace sldump +{ + class sldump + { + // Default packet handler, registered for all packet types + public static void DefaultHandler(Packet packet, Simulator simulator) + { + Console.WriteLine(packet.ToString()); + } + + public static void DisconnectHandler(DisconnectType type, string message) + { + if (type == DisconnectType.NetworkTimeout) + { + Console.WriteLine("Network connection timed out, disconnected"); + } + else if (type == DisconnectType.ServerInitiated) + { + Console.WriteLine("Server disconnected us: " + message); + } + } + + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main(string[] args) + { + SecondLife client; + + if (args.Length == 0 || (args.Length < 3 && args[0] != "--printmap")) + { + Console.WriteLine("Usage: sldump [--printmap] [--decrypt] [inputfile] [outputfile] [--protocol] [firstname] " + + "[lastname] [password]"); + return; + } + + if (args[0] == "--decrypt") + { + try + { + ProtocolManager.DecodeMapFile(args[1], args[2]); + } + catch (Exception e) + { + Console.WriteLine(e.ToString()); + } + + return; + } + + client = new SecondLife(); + + if (args[0] == "--printmap") + { + ProtocolManager protocol; + + try + { + protocol = new ProtocolManager("keywords.txt", "message_template.msg", client); + } + catch (Exception e) + { + // Error initializing the client, probably missing file(s) + Console.WriteLine(e.ToString()); + return; + } + + protocol.PrintMap(); + return; + } + + // Setup the packet callback and disconnect event handler + client.Network.RegisterCallback(PacketType.Default, new PacketCallback(DefaultHandler)); + client.Network.OnDisconnected += new DisconnectCallback(DisconnectHandler); + + Hashtable loginParams = NetworkManager.DefaultLoginValues(args[0], args[1], args[2], + "b15396fa7ec5f19ff1131800673aa132", "last", "Win", "0", "sldump", + "contact@libsecondlife.org"); + + // An example of how to pass additional options to the login server + loginParams["id0"] = "65e142a8d3c1ee6632259f111cb168c6"; + loginParams["viewer_digest"] = "0e63550f-0991-a092-3158-b4206e728ffa"; + + if (!client.Network.Login(loginParams/*, "http://127.0.0.1:8080/"*/)) + { + // Login failed + Console.WriteLine("Error logging in: " + client.Network.LoginError); + return; + } + + // Login was successful + Console.WriteLine("Message of the day: " + client.Network.LoginValues["message"]); + + while (true) + { + client.Tick(); + } + } + } +} diff --git a/libsecondlife-cs/examples/sldump/sldump.csproj b/libsecondlife-cs/examples/sldump/sldump.csproj index acfda7da..6b70e572 100644 --- a/libsecondlife-cs/examples/sldump/sldump.csproj +++ b/libsecondlife-cs/examples/sldump/sldump.csproj @@ -1,105 +1,105 @@ - - - Local - 8.0.50727 - 2.0 - {F6258A68-C624-46A0-BA73-B55D21BB0A3B} - Debug - AnyCPU - - - - - sldump - - - JScript - Grid - IE50 - false - Exe - sldump - OnBuildSuccess - - - - - - - - - ..\..\..\bin\ - false - 285212672 - false - - - DEBUG;TRACE - - - true - 4096 - false - - - false - false - false - false - 4 - full - prompt - - - bin\Release\ - false - 285212672 - false - - - TRACE - - - false - 4096 - false - - - true - false - false - false - 4 - none - prompt - - - - System - - - System.Data - - - System.XML - - - libsecondlife - {D9CDEDFB-8169-4B03-B57F-0DF638F044EC} - {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - False - - - - - Code - - - - - - - - - + + + Local + 8.0.50727 + 2.0 + {F6258A68-C624-46A0-BA73-B55D21BB0A3B} + Debug + AnyCPU + + + + + sldump + + + JScript + Grid + IE50 + false + Exe + sldump + OnBuildSuccess + + + + + + + + + ..\..\..\bin\ + false + 285212672 + false + + + DEBUG;TRACE + + + true + 4096 + false + + + false + false + false + false + 4 + full + prompt + + + bin\Release\ + false + 285212672 + false + + + TRACE + + + false + 4096 + false + + + true + false + false + false + 4 + none + prompt + + + + System + + + System.Data + + + System.XML + + + libsecondlife + {D9CDEDFB-8169-4B03-B57F-0DF638F044EC} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + + + Code + + + + + + + + + \ No newline at end of file diff --git a/libsecondlife-cs/libsecondlife.build b/libsecondlife-cs/libsecondlife.build index 07da2efc..5e690c13 100644 --- a/libsecondlife-cs/libsecondlife.build +++ b/libsecondlife-cs/libsecondlife.build @@ -1,96 +1,96 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libsecondlife-cs/libsecondlife.csproj b/libsecondlife-cs/libsecondlife.csproj index 1cb62108..b18b8af8 100644 --- a/libsecondlife-cs/libsecondlife.csproj +++ b/libsecondlife-cs/libsecondlife.csproj @@ -1,200 +1,200 @@ - - - Local - 8.0.50727 - 2.0 - {D9CDEDFB-8169-4B03-B57F-0DF638F044EC} - Debug - AnyCPU - - - - - libsecondlife - - - JScript - Grid - IE50 - false - Library - libsecondlife - OnBuildSuccess - - - - - - - - - ..\bin\ - false - 285212672 - false - - - DEBUG;TRACE - - - true - 4096 - false - - - false - false - false - false - 4 - full - prompt - - - bin\Release\ - false - 285212672 - false - - - TRACE - - - false - 4096 - false - - - true - false - false - false - 4 - none - prompt - - - ..\bin\ - - - - System - - - System.Data - - - System.XML - - - - - Code - - - - - - - - - - Code - - - Code - - - Code - - - - - - - - - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - - - - - - - - - + + + Local + 8.0.50727 + 2.0 + {D9CDEDFB-8169-4B03-B57F-0DF638F044EC} + Debug + AnyCPU + + + + + libsecondlife + + + JScript + Grid + IE50 + false + Library + libsecondlife + OnBuildSuccess + + + + + + + + + ..\bin\ + false + 285212672 + false + + + DEBUG;TRACE + + + true + 4096 + false + + + false + false + false + false + 4 + full + prompt + + + bin\Release\ + false + 285212672 + false + + + TRACE + + + false + 4096 + false + + + true + false + false + false + 4 + none + prompt + + + ..\bin\ + + + + System + + + System.Data + + + System.XML + + + + + Code + + + + + + + + + + Code + + + Code + + + Code + + + + + + + + + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + + + + + + + + + \ No newline at end of file diff --git a/libsecondlife-cs/libsecondlife.sln b/libsecondlife-cs/libsecondlife.sln index e549ddec..66500afb 100644 --- a/libsecondlife-cs/libsecondlife.sln +++ b/libsecondlife-cs/libsecondlife.sln @@ -1,109 +1,109 @@ -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "libsecondlife", "libsecondlife.csproj", "{D9CDEDFB-8169-4B03-B57F-0DF638F044EC}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "sldump", "examples\sldump\sldump.csproj", "{F6258A68-C624-46A0-BA73-B55D21BB0A3B}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "slaccountant", "examples\slaccountant\slaccountant.csproj", "{FC19D5F6-076E-4923-8456-9B0E00E22896}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "name2key", "examples\name2key\name2key.csproj", "{66FFD34E-652C-4EF5-81FE-06AD011169D2}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ParcelDownload", "examples\ParcelDownload\ParcelDownload.csproj", "{623B86F7-7753-44B7-A8C8-CBC89FB8AF8E}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "primexport", "examples\primexport\primexport.csproj", "{77E5330D-8A8C-41B4-A2D1-6F06FE45ED6D}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "libsecondlife.Tests", "tests\libsecondlife.Tests.csproj", "{E0BCBBAE-A620-431A-9EB7-30173EAF195B}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mapgenerator", "mapgenerator\mapgenerator.csproj", "{C59B1312-57EF-4146-B6B2-1C7B6DC4638B}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IA_SimpleInventory", "examples\IA_SimpleInventory\IA_SimpleInventory.csproj", "{E464B963-46E3-4E1A-A36F-9C640C880E68}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "botmanager", "examples\botmanager\botmanager.csproj", "{3E891B97-7267-47D4-AAF1-7DCD2F6D60AB}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IA_NotecardTool", "examples\IA_NotecardTool\IA_NotecardTool.csproj", "{E185E4E1-62D2-430C-A94C-E8E38190805B}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Teleport", "examples\Teleport\Teleport.csproj", "{B5AC6795-E426-4BC3-950F-D7B2970E2394}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Decoder", "..\applications\Decoder\Decoder.csproj", "{7AE16AC1-E64C-4FDC-9B85-4BB6145D511C}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IA_ImageTool", "examples\IA_ImageTool\IA_ImageTool.csproj", "{8D2E5240-2247-42F5-AAAC-CF0CCCEE349A}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IA_InventoryManager", "examples\IA_InventoryManager\IA_InventoryManager.csproj", "{D6D1D020-D8D8-4D7E-B7AC-5913A903D6E7}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "groupmanager", "examples\groupmanager\groupmanager.csproj", "{F460FAB3-0D12-4873-89EB-2696818764B8}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {D9CDEDFB-8169-4B03-B57F-0DF638F044EC}.Debug|Any CPU.ActiveCfg = Debug|.NET 1.1 - {D9CDEDFB-8169-4B03-B57F-0DF638F044EC}.Debug|Any CPU.Build.0 = Debug|.NET 1.1 - {D9CDEDFB-8169-4B03-B57F-0DF638F044EC}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D9CDEDFB-8169-4B03-B57F-0DF638F044EC}.Release|Any CPU.Build.0 = Release|Any CPU - {F6258A68-C624-46A0-BA73-B55D21BB0A3B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F6258A68-C624-46A0-BA73-B55D21BB0A3B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F6258A68-C624-46A0-BA73-B55D21BB0A3B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F6258A68-C624-46A0-BA73-B55D21BB0A3B}.Release|Any CPU.Build.0 = Release|Any CPU - {FC19D5F6-076E-4923-8456-9B0E00E22896}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {FC19D5F6-076E-4923-8456-9B0E00E22896}.Debug|Any CPU.Build.0 = Debug|Any CPU - {FC19D5F6-076E-4923-8456-9B0E00E22896}.Release|Any CPU.ActiveCfg = Release|Any CPU - {FC19D5F6-076E-4923-8456-9B0E00E22896}.Release|Any CPU.Build.0 = Release|Any CPU - {66FFD34E-652C-4EF5-81FE-06AD011169D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {66FFD34E-652C-4EF5-81FE-06AD011169D2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {66FFD34E-652C-4EF5-81FE-06AD011169D2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {66FFD34E-652C-4EF5-81FE-06AD011169D2}.Release|Any CPU.Build.0 = Release|Any CPU - {623B86F7-7753-44B7-A8C8-CBC89FB8AF8E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {623B86F7-7753-44B7-A8C8-CBC89FB8AF8E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {623B86F7-7753-44B7-A8C8-CBC89FB8AF8E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {623B86F7-7753-44B7-A8C8-CBC89FB8AF8E}.Release|Any CPU.Build.0 = Release|Any CPU - {77E5330D-8A8C-41B4-A2D1-6F06FE45ED6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {77E5330D-8A8C-41B4-A2D1-6F06FE45ED6D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {77E5330D-8A8C-41B4-A2D1-6F06FE45ED6D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {77E5330D-8A8C-41B4-A2D1-6F06FE45ED6D}.Release|Any CPU.Build.0 = Release|Any CPU - {E0BCBBAE-A620-431A-9EB7-30173EAF195B}.Debug|Any CPU.ActiveCfg = Debug|.NET 1.1 - {E0BCBBAE-A620-431A-9EB7-30173EAF195B}.Debug|Any CPU.Build.0 = Debug|.NET 1.1 - {E0BCBBAE-A620-431A-9EB7-30173EAF195B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E0BCBBAE-A620-431A-9EB7-30173EAF195B}.Release|Any CPU.Build.0 = Release|Any CPU - {C59B1312-57EF-4146-B6B2-1C7B6DC4638B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C59B1312-57EF-4146-B6B2-1C7B6DC4638B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C59B1312-57EF-4146-B6B2-1C7B6DC4638B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C59B1312-57EF-4146-B6B2-1C7B6DC4638B}.Release|Any CPU.Build.0 = Release|Any CPU - {E464B963-46E3-4E1A-A36F-9C640C880E68}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E464B963-46E3-4E1A-A36F-9C640C880E68}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E464B963-46E3-4E1A-A36F-9C640C880E68}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E464B963-46E3-4E1A-A36F-9C640C880E68}.Release|Any CPU.Build.0 = Release|Any CPU - {3E891B97-7267-47D4-AAF1-7DCD2F6D60AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3E891B97-7267-47D4-AAF1-7DCD2F6D60AB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3E891B97-7267-47D4-AAF1-7DCD2F6D60AB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3E891B97-7267-47D4-AAF1-7DCD2F6D60AB}.Release|Any CPU.Build.0 = Release|Any CPU - {E185E4E1-62D2-430C-A94C-E8E38190805B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E185E4E1-62D2-430C-A94C-E8E38190805B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E185E4E1-62D2-430C-A94C-E8E38190805B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E185E4E1-62D2-430C-A94C-E8E38190805B}.Release|Any CPU.Build.0 = Release|Any CPU - {B5AC6795-E426-4BC3-950F-D7B2970E2394}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B5AC6795-E426-4BC3-950F-D7B2970E2394}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B5AC6795-E426-4BC3-950F-D7B2970E2394}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B5AC6795-E426-4BC3-950F-D7B2970E2394}.Release|Any CPU.Build.0 = Release|Any CPU - {7AE16AC1-E64C-4FDC-9B85-4BB6145D511C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7AE16AC1-E64C-4FDC-9B85-4BB6145D511C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7AE16AC1-E64C-4FDC-9B85-4BB6145D511C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7AE16AC1-E64C-4FDC-9B85-4BB6145D511C}.Release|Any CPU.Build.0 = Release|Any CPU - {8D2E5240-2247-42F5-AAAC-CF0CCCEE349A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8D2E5240-2247-42F5-AAAC-CF0CCCEE349A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8D2E5240-2247-42F5-AAAC-CF0CCCEE349A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8D2E5240-2247-42F5-AAAC-CF0CCCEE349A}.Release|Any CPU.Build.0 = Release|Any CPU - {D6D1D020-D8D8-4D7E-B7AC-5913A903D6E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D6D1D020-D8D8-4D7E-B7AC-5913A903D6E7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D6D1D020-D8D8-4D7E-B7AC-5913A903D6E7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D6D1D020-D8D8-4D7E-B7AC-5913A903D6E7}.Release|Any CPU.Build.0 = Release|Any CPU - {F460FAB3-0D12-4873-89EB-2696818764B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F460FAB3-0D12-4873-89EB-2696818764B8}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F460FAB3-0D12-4873-89EB-2696818764B8}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F460FAB3-0D12-4873-89EB-2696818764B8}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "libsecondlife", "libsecondlife.csproj", "{D9CDEDFB-8169-4B03-B57F-0DF638F044EC}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "sldump", "examples\sldump\sldump.csproj", "{F6258A68-C624-46A0-BA73-B55D21BB0A3B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "slaccountant", "examples\slaccountant\slaccountant.csproj", "{FC19D5F6-076E-4923-8456-9B0E00E22896}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "name2key", "examples\name2key\name2key.csproj", "{66FFD34E-652C-4EF5-81FE-06AD011169D2}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ParcelDownload", "examples\ParcelDownload\ParcelDownload.csproj", "{623B86F7-7753-44B7-A8C8-CBC89FB8AF8E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "primexport", "examples\primexport\primexport.csproj", "{77E5330D-8A8C-41B4-A2D1-6F06FE45ED6D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "libsecondlife.Tests", "tests\libsecondlife.Tests.csproj", "{E0BCBBAE-A620-431A-9EB7-30173EAF195B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mapgenerator", "mapgenerator\mapgenerator.csproj", "{C59B1312-57EF-4146-B6B2-1C7B6DC4638B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IA_SimpleInventory", "examples\IA_SimpleInventory\IA_SimpleInventory.csproj", "{E464B963-46E3-4E1A-A36F-9C640C880E68}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "botmanager", "examples\botmanager\botmanager.csproj", "{3E891B97-7267-47D4-AAF1-7DCD2F6D60AB}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IA_NotecardTool", "examples\IA_NotecardTool\IA_NotecardTool.csproj", "{E185E4E1-62D2-430C-A94C-E8E38190805B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Teleport", "examples\Teleport\Teleport.csproj", "{B5AC6795-E426-4BC3-950F-D7B2970E2394}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Decoder", "..\applications\Decoder\Decoder.csproj", "{7AE16AC1-E64C-4FDC-9B85-4BB6145D511C}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IA_ImageTool", "examples\IA_ImageTool\IA_ImageTool.csproj", "{8D2E5240-2247-42F5-AAAC-CF0CCCEE349A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IA_InventoryManager", "examples\IA_InventoryManager\IA_InventoryManager.csproj", "{D6D1D020-D8D8-4D7E-B7AC-5913A903D6E7}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "groupmanager", "examples\groupmanager\groupmanager.csproj", "{F460FAB3-0D12-4873-89EB-2696818764B8}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D9CDEDFB-8169-4B03-B57F-0DF638F044EC}.Debug|Any CPU.ActiveCfg = Debug|.NET 1.1 + {D9CDEDFB-8169-4B03-B57F-0DF638F044EC}.Debug|Any CPU.Build.0 = Debug|.NET 1.1 + {D9CDEDFB-8169-4B03-B57F-0DF638F044EC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D9CDEDFB-8169-4B03-B57F-0DF638F044EC}.Release|Any CPU.Build.0 = Release|Any CPU + {F6258A68-C624-46A0-BA73-B55D21BB0A3B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F6258A68-C624-46A0-BA73-B55D21BB0A3B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F6258A68-C624-46A0-BA73-B55D21BB0A3B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F6258A68-C624-46A0-BA73-B55D21BB0A3B}.Release|Any CPU.Build.0 = Release|Any CPU + {FC19D5F6-076E-4923-8456-9B0E00E22896}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FC19D5F6-076E-4923-8456-9B0E00E22896}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FC19D5F6-076E-4923-8456-9B0E00E22896}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FC19D5F6-076E-4923-8456-9B0E00E22896}.Release|Any CPU.Build.0 = Release|Any CPU + {66FFD34E-652C-4EF5-81FE-06AD011169D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {66FFD34E-652C-4EF5-81FE-06AD011169D2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {66FFD34E-652C-4EF5-81FE-06AD011169D2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {66FFD34E-652C-4EF5-81FE-06AD011169D2}.Release|Any CPU.Build.0 = Release|Any CPU + {623B86F7-7753-44B7-A8C8-CBC89FB8AF8E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {623B86F7-7753-44B7-A8C8-CBC89FB8AF8E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {623B86F7-7753-44B7-A8C8-CBC89FB8AF8E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {623B86F7-7753-44B7-A8C8-CBC89FB8AF8E}.Release|Any CPU.Build.0 = Release|Any CPU + {77E5330D-8A8C-41B4-A2D1-6F06FE45ED6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {77E5330D-8A8C-41B4-A2D1-6F06FE45ED6D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {77E5330D-8A8C-41B4-A2D1-6F06FE45ED6D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {77E5330D-8A8C-41B4-A2D1-6F06FE45ED6D}.Release|Any CPU.Build.0 = Release|Any CPU + {E0BCBBAE-A620-431A-9EB7-30173EAF195B}.Debug|Any CPU.ActiveCfg = Debug|.NET 1.1 + {E0BCBBAE-A620-431A-9EB7-30173EAF195B}.Debug|Any CPU.Build.0 = Debug|.NET 1.1 + {E0BCBBAE-A620-431A-9EB7-30173EAF195B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E0BCBBAE-A620-431A-9EB7-30173EAF195B}.Release|Any CPU.Build.0 = Release|Any CPU + {C59B1312-57EF-4146-B6B2-1C7B6DC4638B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C59B1312-57EF-4146-B6B2-1C7B6DC4638B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C59B1312-57EF-4146-B6B2-1C7B6DC4638B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C59B1312-57EF-4146-B6B2-1C7B6DC4638B}.Release|Any CPU.Build.0 = Release|Any CPU + {E464B963-46E3-4E1A-A36F-9C640C880E68}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E464B963-46E3-4E1A-A36F-9C640C880E68}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E464B963-46E3-4E1A-A36F-9C640C880E68}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E464B963-46E3-4E1A-A36F-9C640C880E68}.Release|Any CPU.Build.0 = Release|Any CPU + {3E891B97-7267-47D4-AAF1-7DCD2F6D60AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3E891B97-7267-47D4-AAF1-7DCD2F6D60AB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3E891B97-7267-47D4-AAF1-7DCD2F6D60AB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3E891B97-7267-47D4-AAF1-7DCD2F6D60AB}.Release|Any CPU.Build.0 = Release|Any CPU + {E185E4E1-62D2-430C-A94C-E8E38190805B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E185E4E1-62D2-430C-A94C-E8E38190805B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E185E4E1-62D2-430C-A94C-E8E38190805B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E185E4E1-62D2-430C-A94C-E8E38190805B}.Release|Any CPU.Build.0 = Release|Any CPU + {B5AC6795-E426-4BC3-950F-D7B2970E2394}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B5AC6795-E426-4BC3-950F-D7B2970E2394}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B5AC6795-E426-4BC3-950F-D7B2970E2394}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B5AC6795-E426-4BC3-950F-D7B2970E2394}.Release|Any CPU.Build.0 = Release|Any CPU + {7AE16AC1-E64C-4FDC-9B85-4BB6145D511C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7AE16AC1-E64C-4FDC-9B85-4BB6145D511C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7AE16AC1-E64C-4FDC-9B85-4BB6145D511C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7AE16AC1-E64C-4FDC-9B85-4BB6145D511C}.Release|Any CPU.Build.0 = Release|Any CPU + {8D2E5240-2247-42F5-AAAC-CF0CCCEE349A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8D2E5240-2247-42F5-AAAC-CF0CCCEE349A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8D2E5240-2247-42F5-AAAC-CF0CCCEE349A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8D2E5240-2247-42F5-AAAC-CF0CCCEE349A}.Release|Any CPU.Build.0 = Release|Any CPU + {D6D1D020-D8D8-4D7E-B7AC-5913A903D6E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D6D1D020-D8D8-4D7E-B7AC-5913A903D6E7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D6D1D020-D8D8-4D7E-B7AC-5913A903D6E7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D6D1D020-D8D8-4D7E-B7AC-5913A903D6E7}.Release|Any CPU.Build.0 = Release|Any CPU + {F460FAB3-0D12-4873-89EB-2696818764B8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F460FAB3-0D12-4873-89EB-2696818764B8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F460FAB3-0D12-4873-89EB-2696818764B8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F460FAB3-0D12-4873-89EB-2696818764B8}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/libsecondlife-cs/mapgenerator/Properties/AssemblyInfo.cs b/libsecondlife-cs/mapgenerator/Properties/AssemblyInfo.cs index 88fa1df9..83d5b6a7 100644 --- a/libsecondlife-cs/mapgenerator/Properties/AssemblyInfo.cs +++ b/libsecondlife-cs/mapgenerator/Properties/AssemblyInfo.cs @@ -1,33 +1,33 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("mapgenerator")] -[assembly: AssemblyDescription("C# class generator from the Second Life message template")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("libsecondlife")] -[assembly: AssemblyProduct("mapgenerator")] -[assembly: AssemblyCopyright("Copyright © libsecondlife 2006")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("87314973-b32d-4dab-b0da-ab3c5280d268")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -[assembly: AssemblyVersion("0.0.0.1")] -[assembly: AssemblyFileVersion("0.0.0.1")] +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("mapgenerator")] +[assembly: AssemblyDescription("C# class generator from the Second Life message template")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("libsecondlife")] +[assembly: AssemblyProduct("mapgenerator")] +[assembly: AssemblyCopyright("Copyright © libsecondlife 2006")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("87314973-b32d-4dab-b0da-ab3c5280d268")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("0.0.0.1")] +[assembly: AssemblyFileVersion("0.0.0.1")] diff --git a/libsecondlife-cs/mapgenerator/ProtocolManager.cs b/libsecondlife-cs/mapgenerator/ProtocolManager.cs index 998f6f85..9456be49 100644 --- a/libsecondlife-cs/mapgenerator/ProtocolManager.cs +++ b/libsecondlife-cs/mapgenerator/ProtocolManager.cs @@ -1,701 +1,701 @@ -using System; -using System.Collections; -using System.IO; - -namespace libsecondlife -{ - /// - /// - /// - public enum PacketFrequency - { - /// - Low, - /// - Medium, - /// - High - } - - /// - /// - /// - public enum FieldType - { - /// - U8, - /// - U16, - /// - U32, - /// - U64, - /// - S8, - /// - S16, - /// - S32, - /// - F32, - /// - F64, - /// - LLUUID, - /// - BOOL, - /// - LLVector3, - /// - LLVector3d, - /// - LLVector4, - /// - LLQuaternion, - /// - IPADDR, - /// - IPPORT, - /// - Variable, - /// - Fixed, - /// - Single, - /// - Multiple - } - - /// - /// - /// - public class MapField : IComparable - { - /// - public int KeywordPosition; - /// - public string Name; - /// - public FieldType Type; - /// - public int Count; - - /// - /// - /// - /// - /// - public int CompareTo(object obj) - { - MapField temp = (MapField)obj; - - if (this.KeywordPosition > temp.KeywordPosition) - { - return 1; - } - else - { - if(temp.KeywordPosition == this.KeywordPosition) - { - return 0; - } - else - { - return -1; - } - } - } - } - - /// - /// - /// - public class MapBlock : IComparable - { - /// - public int KeywordPosition; - /// - public string Name; - /// - public int Count; - /// - public ArrayList Fields; - - /// - /// - /// - /// - /// - public int CompareTo(object obj) - { - MapBlock temp = (MapBlock)obj; - - if (this.KeywordPosition > temp.KeywordPosition) - { - return 1; - } - else - { - if(temp.KeywordPosition == this.KeywordPosition) - { - return 0; - } - else - { - return -1; - } - } - } - } - - /// - /// - /// - public class MapPacket - { - /// - public ushort ID; - /// - public string Name; - /// - public PacketFrequency Frequency; - /// - public bool Trusted; - /// - public bool Encoded; - /// - public ArrayList Blocks; - } - - /// - /// - /// - public class ProtocolManager - { - /// - public Hashtable TypeSizes; - /// - public Hashtable KeywordPositions; - /// - public MapPacket[] LowMaps; - /// - public MapPacket[] MediumMaps; - /// - public MapPacket[] HighMaps; - - private int i = 0; - - /// - /// - /// - /// - /// - /// - public ProtocolManager(string keywordFile, string mapFile) - { - // Initialize the map arrays - LowMaps = new MapPacket[65536]; - MediumMaps = new MapPacket[256]; - HighMaps = new MapPacket[256]; - - // Build the type size hash table - TypeSizes = new Hashtable(); - TypeSizes.Add(FieldType.U8, 1); - TypeSizes.Add(FieldType.U16, 2); - TypeSizes.Add(FieldType.U32, 4); - TypeSizes.Add(FieldType.U64, 8); - TypeSizes.Add(FieldType.S8, 1); - TypeSizes.Add(FieldType.S16, 2); - TypeSizes.Add(FieldType.S32, 4); - TypeSizes.Add(FieldType.F32, 4); - TypeSizes.Add(FieldType.F64, 8); - TypeSizes.Add(FieldType.LLUUID, 16); - TypeSizes.Add(FieldType.BOOL, 1); - TypeSizes.Add(FieldType.LLVector3, 12); - TypeSizes.Add(FieldType.LLVector3d, 24); - TypeSizes.Add(FieldType.LLVector4, 16); - TypeSizes.Add(FieldType.LLQuaternion, 16); - TypeSizes.Add(FieldType.IPADDR, 4); - TypeSizes.Add(FieldType.IPPORT, 2); - TypeSizes.Add(FieldType.Variable, -1); - TypeSizes.Add(FieldType.Fixed, -2); - - LoadKeywordFile(keywordFile); - LoadMapFile(mapFile); - } - - /// - /// - /// - /// - /// - public MapPacket Command(string command) - { - foreach (MapPacket map in HighMaps) - { - if (map != null) - { - if (command == map.Name) - { - return map; - } - } - } - - foreach (MapPacket map in MediumMaps) - { - if (map != null) - { - if (command == map.Name) - { - return map; - } - } - } - - foreach (MapPacket map in LowMaps) - { - if (map != null) - { - if (command == map.Name) - { - return map; - } - } - } - - throw new Exception("Cannot find map for command \"" + command + "\""); - } - - /// - /// - /// - /// - /// - public MapPacket Command(byte[] data) - { - ushort command; - - if (data.Length < 5) - { - return null; - } - - if (data[4] == 0xFF) - { - if ((byte)data[5] == 0xFF) - { - // Low frequency - command = (ushort)(data[6] * 256 + data[7]); - return Command(command, PacketFrequency.Low); - } - else - { - // Medium frequency - command = (ushort)data[5]; - return Command(command, PacketFrequency.Medium); - } - } - else - { - // High frequency - command = (ushort)data[4]; - return Command(command, PacketFrequency.High); - } - } - - /// - /// - /// - /// - /// - /// - public MapPacket Command(ushort command, PacketFrequency frequency) - { - switch (frequency) - { - case PacketFrequency.High: - return HighMaps[command]; - case PacketFrequency.Medium: - return MediumMaps[command]; - case PacketFrequency.Low: - return LowMaps[command]; - } - - throw new Exception("Cannot find map for command \"" + command + "\" with frequency \"" + frequency + "\""); - } - - /// - /// - /// - public void PrintMap(TextWriter writer) - { - PrintOneMap(writer, LowMaps, "Low "); - PrintOneMap(writer, MediumMaps, "Medium"); - PrintOneMap(writer, HighMaps, "High "); - } - - /// - /// - /// - /// - /// - private void PrintOneMap(TextWriter writer, MapPacket[] map, string frequency) { - int i; - - for (i = 0; i < map.Length; ++i) - { - if (map[i] != null) - { - writer.WriteLine("{0} {1,5} - {2} - {3} - {4}", frequency, i, map[i].Name, - map[i].Trusted ? "Trusted" : "Untrusted", - map[i].Encoded ? "Unencoded" : "Zerocoded"); - - foreach (MapBlock block in map[i].Blocks) - { - if (block.Count == -1) - { - writer.WriteLine("\t{0,4} {1} (Variable)", block.KeywordPosition, block.Name); - } - else - { - writer.WriteLine("\t{0,4} {1} ({2})", block.KeywordPosition, block.Name, block.Count); - } - - foreach (MapField field in block.Fields) - { - writer.WriteLine("\t\t{0,4} {1} ({2} / {3})", field.KeywordPosition, field.Name, - field.Type, field.Count); - } - } - } - } - } - - /// - /// - /// - /// - private void LoadKeywordFile(string keywordFile) - { - string line; - StreamReader file; - - KeywordPositions = new Hashtable(); - - // Load the keyword file - try - { - file = File.OpenText(keywordFile); - } - catch(Exception e) - { - //Client.Log("Error opening \"" + keywordFile + "\": " + e.Message, Helpers.LogLevel.Error); - throw new Exception("Keyword file error", e); - } - - while((line = file.ReadLine()) != null) - { - KeywordPositions.Add(line.Trim(), i++); - } - - file.Close(); - } - - /// - /// - /// - /// - /// - public static void DecodeMapFile(string mapFile, string outputFile) - { - byte magicKey = 0; - byte[] buffer = new byte[2048]; - int nread; - BinaryReader map; - BinaryWriter output; - - try - { - map = new BinaryReader(new FileStream(mapFile, FileMode.Open)); - } - catch(Exception e) - { - throw new Exception("Map file error", e); - } - - try - { - output = new BinaryWriter(new FileStream(outputFile, FileMode.CreateNew)); - } - catch(Exception e) - { - throw new Exception("Map file error", e); - } - - while ((nread = map.Read(buffer, 0, 2048)) != 0) - { - for (int i = 0; i < nread; ++i) - { - buffer[i] ^= magicKey; - magicKey += 43; - } - - output.Write(buffer, 0, nread); - } - - map.Close(); - output.Close(); - } - - /// - /// - /// - /// - private void LoadMapFile(string mapFile) - { - FileStream map; - ushort low = 1; - ushort medium = 1; - ushort high = 1; - - // Load the protocol map file - try - { - map = new FileStream(mapFile, FileMode.Open, FileAccess.Read); - } - catch(Exception e) - { - throw new Exception("Map file error", e); - } - - try - { - StreamReader r = new StreamReader(map); - r.BaseStream.Seek(0, SeekOrigin.Begin); - string newline; - string trimmedline; - bool inPacket = false; - bool inBlock = false; - MapPacket currentPacket = null; - MapBlock currentBlock = null; - char[] trimArray = new char[] {' ', '\t'}; - - // While not at the end of the file - while (r.Peek() > -1) - { - #region ParseMap - - newline = r.ReadLine(); - trimmedline = System.Text.RegularExpressions.Regex.Replace(newline, @"\s+", " "); - trimmedline = trimmedline.Trim(trimArray); - - if (!inPacket) - { - // Outside of all packet blocks - - if (trimmedline == "{") - { - inPacket = true; - } - } - else - { - // Inside of a packet block - - if (!inBlock) - { - // Inside a packet block, outside of the blocks - - if (trimmedline == "{") - { - inBlock = true; - } - else if (trimmedline == "}") - { - // Reached the end of the packet - currentPacket.Blocks.Sort(); - inPacket = false; - } - else - { - // The packet header - #region ParsePacketHeader - - // Splice the string in to tokens - string[] tokens = trimmedline.Split(new char[] {' ', '\t'}); - - if (tokens.Length > 3) - { - if (tokens[1] == "Fixed") - { - // Remove the leading "0x" - if (tokens[2].Substring(0, 2) == "0x") - { - tokens[2] = tokens[2].Substring(2, tokens[2].Length - 2); - } - - uint fixedID = UInt32.Parse(tokens[2], System.Globalization.NumberStyles.HexNumber); - // Truncate the id to a short - fixedID ^= 0xFFFF0000; - LowMaps[fixedID] = new MapPacket(); - LowMaps[fixedID].ID = (ushort)fixedID; - LowMaps[fixedID].Frequency = PacketFrequency.Low; - LowMaps[fixedID].Name = tokens[0]; - LowMaps[fixedID].Trusted = (tokens[3] == "Trusted"); - LowMaps[fixedID].Encoded = (tokens[4] == "Zerocoded"); - LowMaps[fixedID].Blocks = new ArrayList(); - - currentPacket = LowMaps[fixedID]; - } - else if (tokens[1] == "Low") - { - LowMaps[low] = new MapPacket(); - LowMaps[low].ID = low; - LowMaps[low].Frequency = PacketFrequency.Low; - LowMaps[low].Name = tokens[0]; - LowMaps[low].Trusted = (tokens[2] == "Trusted"); - LowMaps[low].Encoded = (tokens[3] == "Zerocoded"); - LowMaps[low].Blocks = new ArrayList(); - - currentPacket = LowMaps[low]; - - low++; - } - else if (tokens[1] == "Medium") - { - MediumMaps[medium] = new MapPacket(); - MediumMaps[medium].ID = medium; - MediumMaps[medium].Frequency = PacketFrequency.Medium; - MediumMaps[medium].Name = tokens[0]; - MediumMaps[medium].Trusted = (tokens[2] == "Trusted"); - MediumMaps[medium].Encoded = (tokens[3] == "Zerocoded"); - MediumMaps[medium].Blocks = new ArrayList(); - - currentPacket = MediumMaps[medium]; - - medium++; - } - else if (tokens[1] == "High") - { - HighMaps[high] = new MapPacket(); - HighMaps[high].ID = high; - HighMaps[high].Frequency = PacketFrequency.High; - HighMaps[high].Name = tokens[0]; - HighMaps[high].Trusted = (tokens[2] == "Trusted"); - HighMaps[high].Encoded = (tokens[3] == "Zerocoded"); - HighMaps[high].Blocks = new ArrayList(); - - currentPacket = HighMaps[high]; - - high++; - } - else - { - //Client.Log("Unknown packet frequency", Helpers.LogLevel.Error); - throw new Exception("Unknown packet frequency"); - } - } - - #endregion - } - } - else - { - if (trimmedline.Length > 0 && trimmedline.Substring(0, 1) == "{") - { - // A field - #region ParseField - - MapField field = new MapField(); - - // Splice the string in to tokens - string[] tokens = trimmedline.Split(new char[] {' ', '\t'}); - - field.Name = tokens[1]; - field.KeywordPosition = KeywordPosition(field.Name); - field.Type = (FieldType)Enum.Parse(typeof(FieldType), tokens[2], true); - - if (tokens[3] != "}") - { - field.Count = Int32.Parse(tokens[3]); - } - else - { - field.Count = 1; - } - - // Save this field to the current block - currentBlock.Fields.Add(field); - - #endregion - } - else if (trimmedline == "}") - { - currentBlock.Fields.Sort(); - inBlock = false; - } - else if (trimmedline.Length != 0 && trimmedline.Substring(0, 2) != "//") - { - // The block header - #region ParseBlockHeader - - currentBlock = new MapBlock(); - - // Splice the string in to tokens - string[] tokens = trimmedline.Split(new char[] {' ', '\t'}); - - currentBlock.Name = tokens[0]; - currentBlock.KeywordPosition = KeywordPosition(currentBlock.Name); - currentBlock.Fields = new ArrayList(); - currentPacket.Blocks.Add(currentBlock); - - if (tokens[1] == "Single") - { - currentBlock.Count = 1; - } - else if (tokens[1] == "Multiple") - { - currentBlock.Count = Int32.Parse(tokens[2]); - } - else if (tokens[1] == "Variable") - { - currentBlock.Count = -1; - } - else - { - //Client.Log("Unknown block frequency", Helpers.LogLevel.Error); - throw new Exception("Unknown block frequency"); - } - - #endregion - } - } - } - - #endregion - } - - r.Close(); - map.Close(); - } - catch (Exception e) - { - throw e; - } - } - - private int KeywordPosition(string keyword) - { - if (KeywordPositions.ContainsKey(keyword)) - { - return (int)KeywordPositions[keyword]; - } - else - { - //Client.Log("Couldn't find keyword: " + keyword, Helpers.LogLevel.Warning); - throw new Exception("Couldn't find keyword " + keyword); - } - } - } -} +using System; +using System.Collections; +using System.IO; + +namespace libsecondlife +{ + /// + /// + /// + public enum PacketFrequency + { + /// + Low, + /// + Medium, + /// + High + } + + /// + /// + /// + public enum FieldType + { + /// + U8, + /// + U16, + /// + U32, + /// + U64, + /// + S8, + /// + S16, + /// + S32, + /// + F32, + /// + F64, + /// + LLUUID, + /// + BOOL, + /// + LLVector3, + /// + LLVector3d, + /// + LLVector4, + /// + LLQuaternion, + /// + IPADDR, + /// + IPPORT, + /// + Variable, + /// + Fixed, + /// + Single, + /// + Multiple + } + + /// + /// + /// + public class MapField : IComparable + { + /// + public int KeywordPosition; + /// + public string Name; + /// + public FieldType Type; + /// + public int Count; + + /// + /// + /// + /// + /// + public int CompareTo(object obj) + { + MapField temp = (MapField)obj; + + if (this.KeywordPosition > temp.KeywordPosition) + { + return 1; + } + else + { + if(temp.KeywordPosition == this.KeywordPosition) + { + return 0; + } + else + { + return -1; + } + } + } + } + + /// + /// + /// + public class MapBlock : IComparable + { + /// + public int KeywordPosition; + /// + public string Name; + /// + public int Count; + /// + public ArrayList Fields; + + /// + /// + /// + /// + /// + public int CompareTo(object obj) + { + MapBlock temp = (MapBlock)obj; + + if (this.KeywordPosition > temp.KeywordPosition) + { + return 1; + } + else + { + if(temp.KeywordPosition == this.KeywordPosition) + { + return 0; + } + else + { + return -1; + } + } + } + } + + /// + /// + /// + public class MapPacket + { + /// + public ushort ID; + /// + public string Name; + /// + public PacketFrequency Frequency; + /// + public bool Trusted; + /// + public bool Encoded; + /// + public ArrayList Blocks; + } + + /// + /// + /// + public class ProtocolManager + { + /// + public Hashtable TypeSizes; + /// + public Hashtable KeywordPositions; + /// + public MapPacket[] LowMaps; + /// + public MapPacket[] MediumMaps; + /// + public MapPacket[] HighMaps; + + private int i = 0; + + /// + /// + /// + /// + /// + /// + public ProtocolManager(string keywordFile, string mapFile) + { + // Initialize the map arrays + LowMaps = new MapPacket[65536]; + MediumMaps = new MapPacket[256]; + HighMaps = new MapPacket[256]; + + // Build the type size hash table + TypeSizes = new Hashtable(); + TypeSizes.Add(FieldType.U8, 1); + TypeSizes.Add(FieldType.U16, 2); + TypeSizes.Add(FieldType.U32, 4); + TypeSizes.Add(FieldType.U64, 8); + TypeSizes.Add(FieldType.S8, 1); + TypeSizes.Add(FieldType.S16, 2); + TypeSizes.Add(FieldType.S32, 4); + TypeSizes.Add(FieldType.F32, 4); + TypeSizes.Add(FieldType.F64, 8); + TypeSizes.Add(FieldType.LLUUID, 16); + TypeSizes.Add(FieldType.BOOL, 1); + TypeSizes.Add(FieldType.LLVector3, 12); + TypeSizes.Add(FieldType.LLVector3d, 24); + TypeSizes.Add(FieldType.LLVector4, 16); + TypeSizes.Add(FieldType.LLQuaternion, 16); + TypeSizes.Add(FieldType.IPADDR, 4); + TypeSizes.Add(FieldType.IPPORT, 2); + TypeSizes.Add(FieldType.Variable, -1); + TypeSizes.Add(FieldType.Fixed, -2); + + LoadKeywordFile(keywordFile); + LoadMapFile(mapFile); + } + + /// + /// + /// + /// + /// + public MapPacket Command(string command) + { + foreach (MapPacket map in HighMaps) + { + if (map != null) + { + if (command == map.Name) + { + return map; + } + } + } + + foreach (MapPacket map in MediumMaps) + { + if (map != null) + { + if (command == map.Name) + { + return map; + } + } + } + + foreach (MapPacket map in LowMaps) + { + if (map != null) + { + if (command == map.Name) + { + return map; + } + } + } + + throw new Exception("Cannot find map for command \"" + command + "\""); + } + + /// + /// + /// + /// + /// + public MapPacket Command(byte[] data) + { + ushort command; + + if (data.Length < 5) + { + return null; + } + + if (data[4] == 0xFF) + { + if ((byte)data[5] == 0xFF) + { + // Low frequency + command = (ushort)(data[6] * 256 + data[7]); + return Command(command, PacketFrequency.Low); + } + else + { + // Medium frequency + command = (ushort)data[5]; + return Command(command, PacketFrequency.Medium); + } + } + else + { + // High frequency + command = (ushort)data[4]; + return Command(command, PacketFrequency.High); + } + } + + /// + /// + /// + /// + /// + /// + public MapPacket Command(ushort command, PacketFrequency frequency) + { + switch (frequency) + { + case PacketFrequency.High: + return HighMaps[command]; + case PacketFrequency.Medium: + return MediumMaps[command]; + case PacketFrequency.Low: + return LowMaps[command]; + } + + throw new Exception("Cannot find map for command \"" + command + "\" with frequency \"" + frequency + "\""); + } + + /// + /// + /// + public void PrintMap(TextWriter writer) + { + PrintOneMap(writer, LowMaps, "Low "); + PrintOneMap(writer, MediumMaps, "Medium"); + PrintOneMap(writer, HighMaps, "High "); + } + + /// + /// + /// + /// + /// + private void PrintOneMap(TextWriter writer, MapPacket[] map, string frequency) { + int i; + + for (i = 0; i < map.Length; ++i) + { + if (map[i] != null) + { + writer.WriteLine("{0} {1,5} - {2} - {3} - {4}", frequency, i, map[i].Name, + map[i].Trusted ? "Trusted" : "Untrusted", + map[i].Encoded ? "Unencoded" : "Zerocoded"); + + foreach (MapBlock block in map[i].Blocks) + { + if (block.Count == -1) + { + writer.WriteLine("\t{0,4} {1} (Variable)", block.KeywordPosition, block.Name); + } + else + { + writer.WriteLine("\t{0,4} {1} ({2})", block.KeywordPosition, block.Name, block.Count); + } + + foreach (MapField field in block.Fields) + { + writer.WriteLine("\t\t{0,4} {1} ({2} / {3})", field.KeywordPosition, field.Name, + field.Type, field.Count); + } + } + } + } + } + + /// + /// + /// + /// + private void LoadKeywordFile(string keywordFile) + { + string line; + StreamReader file; + + KeywordPositions = new Hashtable(); + + // Load the keyword file + try + { + file = File.OpenText(keywordFile); + } + catch(Exception e) + { + //Client.Log("Error opening \"" + keywordFile + "\": " + e.Message, Helpers.LogLevel.Error); + throw new Exception("Keyword file error", e); + } + + while((line = file.ReadLine()) != null) + { + KeywordPositions.Add(line.Trim(), i++); + } + + file.Close(); + } + + /// + /// + /// + /// + /// + public static void DecodeMapFile(string mapFile, string outputFile) + { + byte magicKey = 0; + byte[] buffer = new byte[2048]; + int nread; + BinaryReader map; + BinaryWriter output; + + try + { + map = new BinaryReader(new FileStream(mapFile, FileMode.Open)); + } + catch(Exception e) + { + throw new Exception("Map file error", e); + } + + try + { + output = new BinaryWriter(new FileStream(outputFile, FileMode.CreateNew)); + } + catch(Exception e) + { + throw new Exception("Map file error", e); + } + + while ((nread = map.Read(buffer, 0, 2048)) != 0) + { + for (int i = 0; i < nread; ++i) + { + buffer[i] ^= magicKey; + magicKey += 43; + } + + output.Write(buffer, 0, nread); + } + + map.Close(); + output.Close(); + } + + /// + /// + /// + /// + private void LoadMapFile(string mapFile) + { + FileStream map; + ushort low = 1; + ushort medium = 1; + ushort high = 1; + + // Load the protocol map file + try + { + map = new FileStream(mapFile, FileMode.Open, FileAccess.Read); + } + catch(Exception e) + { + throw new Exception("Map file error", e); + } + + try + { + StreamReader r = new StreamReader(map); + r.BaseStream.Seek(0, SeekOrigin.Begin); + string newline; + string trimmedline; + bool inPacket = false; + bool inBlock = false; + MapPacket currentPacket = null; + MapBlock currentBlock = null; + char[] trimArray = new char[] {' ', '\t'}; + + // While not at the end of the file + while (r.Peek() > -1) + { + #region ParseMap + + newline = r.ReadLine(); + trimmedline = System.Text.RegularExpressions.Regex.Replace(newline, @"\s+", " "); + trimmedline = trimmedline.Trim(trimArray); + + if (!inPacket) + { + // Outside of all packet blocks + + if (trimmedline == "{") + { + inPacket = true; + } + } + else + { + // Inside of a packet block + + if (!inBlock) + { + // Inside a packet block, outside of the blocks + + if (trimmedline == "{") + { + inBlock = true; + } + else if (trimmedline == "}") + { + // Reached the end of the packet + currentPacket.Blocks.Sort(); + inPacket = false; + } + else + { + // The packet header + #region ParsePacketHeader + + // Splice the string in to tokens + string[] tokens = trimmedline.Split(new char[] {' ', '\t'}); + + if (tokens.Length > 3) + { + if (tokens[1] == "Fixed") + { + // Remove the leading "0x" + if (tokens[2].Substring(0, 2) == "0x") + { + tokens[2] = tokens[2].Substring(2, tokens[2].Length - 2); + } + + uint fixedID = UInt32.Parse(tokens[2], System.Globalization.NumberStyles.HexNumber); + // Truncate the id to a short + fixedID ^= 0xFFFF0000; + LowMaps[fixedID] = new MapPacket(); + LowMaps[fixedID].ID = (ushort)fixedID; + LowMaps[fixedID].Frequency = PacketFrequency.Low; + LowMaps[fixedID].Name = tokens[0]; + LowMaps[fixedID].Trusted = (tokens[3] == "Trusted"); + LowMaps[fixedID].Encoded = (tokens[4] == "Zerocoded"); + LowMaps[fixedID].Blocks = new ArrayList(); + + currentPacket = LowMaps[fixedID]; + } + else if (tokens[1] == "Low") + { + LowMaps[low] = new MapPacket(); + LowMaps[low].ID = low; + LowMaps[low].Frequency = PacketFrequency.Low; + LowMaps[low].Name = tokens[0]; + LowMaps[low].Trusted = (tokens[2] == "Trusted"); + LowMaps[low].Encoded = (tokens[3] == "Zerocoded"); + LowMaps[low].Blocks = new ArrayList(); + + currentPacket = LowMaps[low]; + + low++; + } + else if (tokens[1] == "Medium") + { + MediumMaps[medium] = new MapPacket(); + MediumMaps[medium].ID = medium; + MediumMaps[medium].Frequency = PacketFrequency.Medium; + MediumMaps[medium].Name = tokens[0]; + MediumMaps[medium].Trusted = (tokens[2] == "Trusted"); + MediumMaps[medium].Encoded = (tokens[3] == "Zerocoded"); + MediumMaps[medium].Blocks = new ArrayList(); + + currentPacket = MediumMaps[medium]; + + medium++; + } + else if (tokens[1] == "High") + { + HighMaps[high] = new MapPacket(); + HighMaps[high].ID = high; + HighMaps[high].Frequency = PacketFrequency.High; + HighMaps[high].Name = tokens[0]; + HighMaps[high].Trusted = (tokens[2] == "Trusted"); + HighMaps[high].Encoded = (tokens[3] == "Zerocoded"); + HighMaps[high].Blocks = new ArrayList(); + + currentPacket = HighMaps[high]; + + high++; + } + else + { + //Client.Log("Unknown packet frequency", Helpers.LogLevel.Error); + throw new Exception("Unknown packet frequency"); + } + } + + #endregion + } + } + else + { + if (trimmedline.Length > 0 && trimmedline.Substring(0, 1) == "{") + { + // A field + #region ParseField + + MapField field = new MapField(); + + // Splice the string in to tokens + string[] tokens = trimmedline.Split(new char[] {' ', '\t'}); + + field.Name = tokens[1]; + field.KeywordPosition = KeywordPosition(field.Name); + field.Type = (FieldType)Enum.Parse(typeof(FieldType), tokens[2], true); + + if (tokens[3] != "}") + { + field.Count = Int32.Parse(tokens[3]); + } + else + { + field.Count = 1; + } + + // Save this field to the current block + currentBlock.Fields.Add(field); + + #endregion + } + else if (trimmedline == "}") + { + currentBlock.Fields.Sort(); + inBlock = false; + } + else if (trimmedline.Length != 0 && trimmedline.Substring(0, 2) != "//") + { + // The block header + #region ParseBlockHeader + + currentBlock = new MapBlock(); + + // Splice the string in to tokens + string[] tokens = trimmedline.Split(new char[] {' ', '\t'}); + + currentBlock.Name = tokens[0]; + currentBlock.KeywordPosition = KeywordPosition(currentBlock.Name); + currentBlock.Fields = new ArrayList(); + currentPacket.Blocks.Add(currentBlock); + + if (tokens[1] == "Single") + { + currentBlock.Count = 1; + } + else if (tokens[1] == "Multiple") + { + currentBlock.Count = Int32.Parse(tokens[2]); + } + else if (tokens[1] == "Variable") + { + currentBlock.Count = -1; + } + else + { + //Client.Log("Unknown block frequency", Helpers.LogLevel.Error); + throw new Exception("Unknown block frequency"); + } + + #endregion + } + } + } + + #endregion + } + + r.Close(); + map.Close(); + } + catch (Exception e) + { + throw e; + } + } + + private int KeywordPosition(string keyword) + { + if (KeywordPositions.ContainsKey(keyword)) + { + return (int)KeywordPositions[keyword]; + } + else + { + //Client.Log("Couldn't find keyword: " + keyword, Helpers.LogLevel.Warning); + throw new Exception("Couldn't find keyword " + keyword); + } + } + } +} diff --git a/libsecondlife-cs/mapgenerator/mapgenerator.cs b/libsecondlife-cs/mapgenerator/mapgenerator.cs index a5aacf2d..c26e13cf 100644 --- a/libsecondlife-cs/mapgenerator/mapgenerator.cs +++ b/libsecondlife-cs/mapgenerator/mapgenerator.cs @@ -1,889 +1,889 @@ -using System; -using System.Text; -using System.IO; -using libsecondlife; - -namespace mapgenerator -{ - class mapgenerator - { - static void WriteFieldMember(TextWriter writer, MapField field) - { - string type = ""; - - switch (field.Type) - { - case FieldType.BOOL: - type = "bool"; - break; - case FieldType.F32: - type = "float"; - break; - case FieldType.F64: - type = "double"; - break; - case FieldType.IPPORT: - case FieldType.U16: - type = "ushort"; - break; - case FieldType.IPADDR: - case FieldType.U32: - type = "uint"; - break; - case FieldType.LLQuaternion: - type = "LLQuaternion"; - break; - case FieldType.LLUUID: - type = "LLUUID"; - break; - case FieldType.LLVector3: - type = "LLVector3"; - break; - case FieldType.LLVector3d: - type = "LLVector3d"; - break; - case FieldType.LLVector4: - type = "LLVector4"; - break; - case FieldType.S16: - type = "short"; - break; - case FieldType.S32: - type = "int"; - break; - case FieldType.S8: - type = "sbyte"; - break; - case FieldType.U64: - type = "ulong"; - break; - case FieldType.U8: - type = "byte"; - break; - case FieldType.Fixed: - type = "byte[]"; - break; - } - if (field.Type != FieldType.Variable) - { - writer.WriteLine(" /// " + field.Name + " field"); - writer.WriteLine(" public " + type + " " + field.Name + ";"); - } - else - { - writer.WriteLine(" private byte[] _" + field.Name.ToLower() + ";"); - writer.WriteLine(" /// " + field.Name + " field"); - writer.WriteLine(" public byte[] " + field.Name + "\n {"); - writer.WriteLine(" get { return _" + field.Name.ToLower() + "; }"); - writer.WriteLine(" set\n {"); - writer.WriteLine(" if (value == null) { _" + - field.Name.ToLower() + " = null; return; }"); - writer.WriteLine(" if (value.Length > " + - ((field.Count == 1) ? "255" : "1024") + ") { throw new OverflowException(" + - "\"Value exceeds " + ((field.Count == 1) ? "255" : "1024") + " characters\"); }"); - writer.WriteLine(" else { _" + field.Name.ToLower() + - " = new byte[value.Length]; Array.Copy(value, _" + - field.Name.ToLower() + ", value.Length); }"); - writer.WriteLine(" }\n }"); - } - } - - static void WriteFieldFromBytes(TextWriter writer, MapField field) - { - switch (field.Type) - { - case FieldType.BOOL: - writer.WriteLine(" " + - field.Name + " = (bytes[i++] != 0) ? (bool)true : (bool)false;"); - break; - case FieldType.F32: - writer.WriteLine(" " + - "if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4);"); - writer.WriteLine(" " + - field.Name + " = BitConverter.ToSingle(bytes, i); i += 4;"); - break; - case FieldType.F64: - writer.WriteLine(" " + - "if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 8);"); - writer.WriteLine(" " + - field.Name + " = BitConverter.ToDouble(bytes, i); i += 8;"); - break; - case FieldType.Fixed: - writer.WriteLine(" " + field.Name + " = new byte[" + field.Count + "];"); - writer.WriteLine(" Array.Copy(bytes, i, " + field.Name + - ", 0, " + field.Count + "); i += " + field.Count + ";"); - break; - case FieldType.IPADDR: - case FieldType.U32: - writer.WriteLine(" " + field.Name + - " = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24));"); - break; - case FieldType.IPPORT: - // IPPORT is big endian while U16/S16 are little endian. Go figure - writer.WriteLine(" " + field.Name + - " = (ushort)((bytes[i++] << 8) + bytes[i++]);"); - break; - case FieldType.U16: - writer.WriteLine(" " + field.Name + - " = (ushort)(bytes[i++] + (bytes[i++] << 8));"); - break; - case FieldType.LLQuaternion: - //writer.WriteLine(" " + field.Name + - // " = new LLQuaternion(bytes, i); i += 16;"); - writer.WriteLine(" " + field.Name + - " = new LLQuaternion(bytes, i, true); i += 12;"); - break; - case FieldType.LLUUID: - writer.WriteLine(" " + field.Name + - " = new LLUUID(bytes, i); i += 16;"); - break; - case FieldType.LLVector3: - writer.WriteLine(" " + field.Name + - " = new LLVector3(bytes, i); i += 12;"); - break; - case FieldType.LLVector3d: - writer.WriteLine(" " + field.Name + - " = new LLVector3d(bytes, i); i += 24;"); - break; - case FieldType.LLVector4: - writer.WriteLine(" " + field.Name + - " = new LLVector4(bytes, i); i += 16;"); - break; - case FieldType.S16: - writer.WriteLine(" " + field.Name + - " = (short)(bytes[i++] + (bytes[i++] << 8));"); - break; - case FieldType.S32: - writer.WriteLine(" " + field.Name + - " = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24));"); - break; - case FieldType.S8: - writer.WriteLine(" " + field.Name + - " = (sbyte)bytes[i++];"); - break; - case FieldType.U64: - writer.WriteLine(" " + field.Name + - " = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + " + - "((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + " + - "((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + " + - "((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56));"); - break; - case FieldType.U8: - writer.WriteLine(" " + field.Name + - " = (byte)bytes[i++];"); - break; - case FieldType.Variable: - if (field.Count == 1) - { - writer.WriteLine(" length = (ushort)bytes[i++];"); - } - else - { - writer.WriteLine(" length = (ushort)(bytes[i++] + (bytes[i++] << 8));"); - } - writer.WriteLine(" _" + field.Name.ToLower() + " = new byte[length];"); - writer.WriteLine(" Array.Copy(bytes, i, _" + field.Name.ToLower() + - ", 0, length); i += length;"); - break; - default: - writer.WriteLine("!!! ERROR: Unhandled FieldType: " + field.Type.ToString() + " !!!"); - break; - } - } - - static void WriteFieldToBytes(TextWriter writer, MapField field) - { - writer.Write(" "); - - switch (field.Type) - { - case FieldType.BOOL: - writer.WriteLine("bytes[i++] = (byte)((" + field.Name + ") ? 1 : 0);"); - break; - case FieldType.F32: - writer.WriteLine("ba = BitConverter.GetBytes(" + field.Name + ");\n" + - " if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); }\n" + - " Array.Copy(ba, 0, bytes, i, 4); i += 4;"); - break; - case FieldType.F64: - writer.WriteLine("ba = BitConverter.GetBytes(" + field.Name + ");\n" + - " if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 8); }\n" + - " Array.Copy(ba, 0, bytes, i, 8); i += 8;"); - break; - case FieldType.Fixed: - writer.WriteLine(" Array.Copy(" + field.Name + ", 0, bytes, i, " + field.Count + ");" + - "i += " + field.Count + ";"); - break; - case FieldType.IPPORT: - // IPPORT is big endian while U16/S16 is little endian. Go figure - writer.WriteLine("bytes[i++] = (byte)((" + field.Name + " >> 8) % 256);"); - writer.WriteLine(" bytes[i++] = (byte)(" + field.Name + " % 256);"); - break; - case FieldType.U16: - case FieldType.S16: - writer.WriteLine("bytes[i++] = (byte)(" + field.Name + " % 256);"); - writer.WriteLine(" bytes[i++] = (byte)((" + field.Name + " >> 8) % 256);"); - break; - //case FieldType.LLQuaternion: - case FieldType.LLUUID: - case FieldType.LLVector4: - writer.WriteLine("if(" + field.Name + " == null) { Console.WriteLine(\"Warning: " + field.Name + " is null, in \" + this.GetType()); }"); - writer.Write(" "); - writer.WriteLine("Array.Copy(" + field.Name + ".GetBytes(), 0, bytes, i, 16); i += 16;"); - break; - case FieldType.LLQuaternion: - case FieldType.LLVector3: - writer.WriteLine("if(" + field.Name + " == null) { Console.WriteLine(\"Warning: " + field.Name + " is null, in \" + this.GetType()); }"); - writer.Write(" "); - writer.WriteLine("Array.Copy(" + field.Name + ".GetBytes(), 0, bytes, i, 12); i += 12;"); - break; - case FieldType.LLVector3d: - writer.WriteLine("if(" + field.Name + " == null) { Console.WriteLine(\"Warning: " + field.Name + " is null, in \" + this.GetType()); }"); - writer.Write(" "); - writer.WriteLine("Array.Copy(" + field.Name + ".GetBytes(), 0, bytes, i, 24); i += 24;"); - break; - case FieldType.U8: - writer.WriteLine("bytes[i++] = " + field.Name + ";"); - break; - case FieldType.S8: - writer.WriteLine("bytes[i++] = (byte)" + field.Name + ";"); - break; - case FieldType.IPADDR: - case FieldType.U32: - case FieldType.S32: - writer.WriteLine("bytes[i++] = (byte)(" + field.Name + " % 256);"); - writer.WriteLine(" bytes[i++] = (byte)((" + field.Name + " >> 8) % 256);"); - writer.WriteLine(" bytes[i++] = (byte)((" + field.Name + " >> 16) % 256);"); - writer.WriteLine(" bytes[i++] = (byte)((" + field.Name + " >> 24) % 256);"); - break; - case FieldType.U64: - writer.WriteLine("bytes[i++] = (byte)(" + field.Name + " % 256);"); - writer.WriteLine(" bytes[i++] = (byte)((" + field.Name + " >> 8) % 256);"); - writer.WriteLine(" bytes[i++] = (byte)((" + field.Name + " >> 16) % 256);"); - writer.WriteLine(" bytes[i++] = (byte)((" + field.Name + " >> 24) % 256);"); - writer.WriteLine(" bytes[i++] = (byte)((" + field.Name + " >> 32) % 256);"); - writer.WriteLine(" bytes[i++] = (byte)((" + field.Name + " >> 40) % 256);"); - writer.WriteLine(" bytes[i++] = (byte)((" + field.Name + " >> 48) % 256);"); - writer.WriteLine(" bytes[i++] = (byte)((" + field.Name + " >> 56) % 256);"); - break; - case FieldType.Variable: - writer.WriteLine("if(" + field.Name + " == null) { Console.WriteLine(\"Warning: " + field.Name + " is null, in \" + this.GetType()); }"); - writer.Write(" "); - if (field.Count == 1) - { - writer.WriteLine("bytes[i++] = (byte)" + field.Name + ".Length;"); - } - else - { - writer.WriteLine("bytes[i++] = (byte)(" + field.Name + ".Length % 256);"); - writer.WriteLine(" bytes[i++] = (byte)((" + - field.Name + ".Length >> 8) % 256);"); - } - writer.WriteLine(" Array.Copy(" + field.Name + ", 0, bytes, i, " + - field.Name + ".Length); " + "i += " + field.Name + ".Length;"); - break; - default: - writer.WriteLine("!!! ERROR: Unhandled FieldType: " + field.Type.ToString() + " !!!"); - break; - } - } - - static int GetFieldLength(TextWriter writer, MapField field) - { - switch(field.Type) - { - case FieldType.BOOL: - case FieldType.U8: - case FieldType.S8: - return 1; - case FieldType.U16: - case FieldType.S16: - case FieldType.IPPORT: - return 2; - case FieldType.U32: - case FieldType.S32: - case FieldType.F32: - case FieldType.IPADDR: - return 4; - case FieldType.U64: - case FieldType.F64: - return 8; - case FieldType.LLVector3: - case FieldType.LLQuaternion: - return 12; - case FieldType.LLUUID: - case FieldType.LLVector4: - //case FieldType.LLQuaternion: - return 16; - case FieldType.LLVector3d: - return 24; - case FieldType.Fixed: - return field.Count; - case FieldType.Variable: - return 0; - default: - writer.WriteLine("!!! ERROR: Unhandled FieldType " + field.Type.ToString() + " !!!"); - return 0; - } - } - - static void WriteBlockClass(TextWriter writer, MapBlock block) - { - bool variableFields = false; - bool floatFields = false; - - writer.WriteLine(" /// " + block.Name + " block"); - writer.WriteLine(" public class " + block.Name + "Block\n {"); - - foreach (MapField field in block.Fields) - { - WriteFieldMember(writer, field); - - if (field.Type == FieldType.Variable) { variableFields = true; } - if (field.Type == FieldType.F32 || field.Type == FieldType.F64) { floatFields = true; } - } - - // Length property - writer.WriteLine(""); - writer.WriteLine(" /// Length of this block serialized in bytes"); - writer.WriteLine(" public int Length\n {\n get\n" + - " {"); - int length = 0; - foreach (MapField field in block.Fields) - { - length += GetFieldLength(writer, field); - } - - if (!variableFields) - { - writer.WriteLine(" return " + length + ";"); - } - else - { - writer.WriteLine(" int length = " + length + ";"); - - foreach (MapField field in block.Fields) - { - if (field.Type == FieldType.Variable) - { - writer.WriteLine(" if (" + field.Name + - " != null) { length += " + field.Count + " + " + field.Name + ".Length; }"); - } - } - - writer.WriteLine(" return length;"); - } - - writer.WriteLine(" }\n }\n"); - - // Default constructor - writer.WriteLine(" /// Default constructor"); - writer.WriteLine(" public " + block.Name + "Block() { }"); - - // Constructor for building the class from bytes - writer.WriteLine(" /// Constructor for building the block from a byte array"); - writer.WriteLine(" public " + block.Name + "Block(byte[] bytes, ref int i)" + - "\n {"); - - // Declare a length variable if we need it for variable fields in this constructor - if (variableFields) { writer.WriteLine(" int length;"); } - - // Start of the try catch block - writer.WriteLine(" try\n {"); - - foreach (MapField field in block.Fields) - { - WriteFieldFromBytes(writer, field); - } - - writer.WriteLine(" }\n catch (Exception)\n" + - " {\n throw new MalformedDataException();\n" + - " }\n }\n"); - - // ToBytes() function - writer.WriteLine(" /// Serialize this block to a byte array"); - writer.WriteLine(" public void ToBytes(byte[] bytes, ref int i)\n {"); - - // Declare a byte[] variable if we need it for floating point field conversions - if (floatFields) { writer.WriteLine(" byte[] ba;"); } - - foreach (MapField field in block.Fields) - { - WriteFieldToBytes(writer, field); - } - - writer.WriteLine(" }\n"); - - // ToString() function - writer.WriteLine(" /// Serialize this block to a stringA string containing the serialized block"); - writer.WriteLine(" public override string ToString()\n {"); - writer.WriteLine(" string output = \"-- " + block.Name + " --\\n\";"); - - foreach (MapField field in block.Fields) - { - if (field.Type == FieldType.Variable || field.Type == FieldType.Fixed) - { - writer.WriteLine(" output += Helpers.FieldToString(" + field.Name + ", \"" + field.Name + "\") + \"\\n\";"); - } - else - { - writer.WriteLine(" output += \"" + field.Name + ": \" + " + field.Name + ".ToString() + \"\\n\";"); - } - } - - writer.WriteLine(" output = output.Trim();\n return output;\n }"); - - writer.WriteLine(" }\n"); - } - - static void WritePacketClass(TextWriter writer, MapPacket packet) - { - string sanitizedName; - - writer.WriteLine(" /// " + packet.Name + " packet"); - writer.WriteLine(" public class " + packet.Name + "Packet : Packet\n {"); - - // Write out each block class - foreach (MapBlock block in packet.Blocks) - { - WriteBlockClass(writer, block); - } - - // Header member - writer.WriteLine(" private Header header;"); - writer.WriteLine(" /// The header for this packet"); - writer.WriteLine(" public override Header Header { get { return header; } set { header = value; } }"); - - // PacketType member - writer.WriteLine(" /// Will return PacketType." + packet.Name+ ""); - writer.WriteLine(" public override PacketType Type { get { return PacketType." + - packet.Name + "; } }"); - - // Block members - foreach (MapBlock block in packet.Blocks) - { - // TODO: More thorough name blacklisting - if (block.Name == "Header") { sanitizedName = "_" + block.Name; } - else { sanitizedName = block.Name; } - - writer.WriteLine(" /// " + block.Name + " block"); - writer.WriteLine(" public " + block.Name + "Block" + - ((block.Count != 1) ? "[]" : "") + " " + sanitizedName + ";"); - } - - writer.WriteLine(""); - - // Default constructor - writer.WriteLine(" /// Default constructor"); - writer.WriteLine(" public " + packet.Name + "Packet()\n {"); - writer.WriteLine(" Header = new " + packet.Frequency.ToString() + "Header();"); - writer.WriteLine(" Header.ID = " + packet.ID + ";"); - writer.WriteLine(" Header.Reliable = true;"); // Turn the reliable flag on by default - if (packet.Encoded) { writer.WriteLine(" Header.Zerocoded = true;"); } - foreach (MapBlock block in packet.Blocks) - { - if (block.Name == "Header") { sanitizedName = "_" + block.Name; } - else { sanitizedName = block.Name; } - - if (block.Count == 1) - { - // Single count block - writer.WriteLine(" " + sanitizedName + " = new " + block.Name + "Block();"); - } - else if (block.Count == -1) - { - // Variable count block - writer.WriteLine(" " + sanitizedName + " = new " + block.Name + "Block[0];"); - } - else - { - // Multiple count block - writer.WriteLine(" " + sanitizedName + " = new " + block.Name + - "Block[" + block.Count + "];"); - } - } - writer.WriteLine(" }\n"); - - // Constructor that takes a byte array and beginning position only (no prebuilt header) - bool seenVariable = false; - writer.WriteLine(" /// Constructor that takes a byte array and beginning position (no prebuilt header)"); - writer.WriteLine(" public " + packet.Name + "Packet(byte[] bytes, ref int i)\n {"); - writer.WriteLine(" int packetEnd = bytes.Length - 1;"); - writer.WriteLine(" Header = new " + packet.Frequency.ToString() + - "Header(bytes, ref i, ref packetEnd);"); - foreach (MapBlock block in packet.Blocks) - { - if (block.Name == "Header") { sanitizedName = "_" + block.Name; } - else { sanitizedName = block.Name; } - - if (block.Count == 1) - { - // Single count block - writer.WriteLine(" " + sanitizedName + " = new " + block.Name + "Block(bytes, ref i);"); - } - else if (block.Count == -1) - { - // Variable count block - if (!seenVariable) - { - writer.WriteLine(" int count = (int)bytes[i++];"); - seenVariable = true; - } - else - { - writer.WriteLine(" count = (int)bytes[i++];"); - } - writer.WriteLine(" " + sanitizedName + " = new " + block.Name + "Block[count];"); - writer.WriteLine(" for (int j = 0; j < count; j++)"); - writer.WriteLine(" { " + sanitizedName + "[j] = new " + - block.Name + "Block(bytes, ref i); }"); - } - else - { - // Multiple count block - writer.WriteLine(" " + sanitizedName + " = new " + block.Name + - "Block[" + block.Count + "];"); - writer.WriteLine(" for (int j = 0; j < " + block.Count + "; j++)"); - writer.WriteLine(" { " + sanitizedName + "[j] = new " + - block.Name + "Block(bytes, ref i); }"); - } - } - writer.WriteLine(" }\n"); - - seenVariable = false; - - // Constructor that takes a byte array and a prebuilt header - writer.WriteLine(" /// Constructor that takes a byte array and a prebuilt header"); - writer.WriteLine(" public " + packet.Name + "Packet(Header head, byte[] bytes, ref int i)\n {"); - writer.WriteLine(" Header = head;"); - foreach (MapBlock block in packet.Blocks) - { - if (block.Name == "Header") { sanitizedName = "_" + block.Name; } - else { sanitizedName = block.Name; } - - if (block.Count == 1) - { - // Single count block - writer.WriteLine(" " + sanitizedName + " = new " + block.Name + "Block(bytes, ref i);"); - } - else if (block.Count == -1) - { - // Variable count block - if (!seenVariable) - { - writer.WriteLine(" int count = (int)bytes[i++];"); - seenVariable = true; - } - else - { - writer.WriteLine(" count = (int)bytes[i++];"); - } - writer.WriteLine(" " + sanitizedName + " = new " + block.Name + "Block[count];"); - writer.WriteLine(" for (int j = 0; j < count; j++)"); - writer.WriteLine(" { " + sanitizedName + "[j] = new " + - block.Name + "Block(bytes, ref i); }"); - } - else - { - // Multiple count block - writer.WriteLine(" " + sanitizedName + " = new " + block.Name + - "Block[" + block.Count + "];"); - writer.WriteLine(" for (int j = 0; j < " + block.Count + "; j++)"); - writer.WriteLine(" { " + sanitizedName + "[j] = new " + - block.Name + "Block(bytes, ref i); }"); - } - } - writer.WriteLine(" }\n"); - - // ToBytes() function - writer.WriteLine(" /// Serialize this packet to a byte arrayA byte array containing the serialized packet"); - writer.WriteLine(" public override byte[] ToBytes()\n {"); - - writer.Write(" int length = "); - if (packet.Frequency == PacketFrequency.Low) { writer.WriteLine("8;"); } - else if (packet.Frequency == PacketFrequency.Medium) { writer.WriteLine("6;"); } - else { writer.WriteLine("5;"); } - - foreach (MapBlock block in packet.Blocks) - { - if (block.Name == "Header") { sanitizedName = "_" + block.Name; } - else { sanitizedName = block.Name; } - - if (block.Count == 1) - { - // Single count block - writer.Write(" length += " + sanitizedName + ".Length;"); - } - } - writer.WriteLine(";"); - - foreach (MapBlock block in packet.Blocks) - { - if (block.Name == "Header") { sanitizedName = "_" + block.Name; } - else { sanitizedName = block.Name; } - - if (block.Count == -1) - { - writer.WriteLine(" length++;"); - writer.WriteLine(" for (int j = 0; j < " + sanitizedName + - ".Length; j++) { length += " + sanitizedName + "[j].Length; }"); - } - else if (block.Count > 1) - { - writer.WriteLine(" for (int j = 0; j < " + block.Count + - "; j++) { length += " + sanitizedName + "[j].Length; }"); - } - } - - writer.WriteLine(" if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; }"); - writer.WriteLine(" byte[] bytes = new byte[length];"); - writer.WriteLine(" int i = 0;"); - writer.WriteLine(" header.ToBytes(bytes, ref i);"); - foreach (MapBlock block in packet.Blocks) - { - if (block.Name == "Header") { sanitizedName = "_" + block.Name; } - else { sanitizedName = block.Name; } - - if (block.Count == -1) - { - // Variable count block - writer.WriteLine(" bytes[i++] = (byte)" + sanitizedName + ".Length;"); - writer.WriteLine(" for (int j = 0; j < " + sanitizedName + - ".Length; j++) { " + sanitizedName + "[j].ToBytes(bytes, ref i); }"); - } - else if (block.Count == 1) - { - writer.WriteLine(" " + sanitizedName + ".ToBytes(bytes, ref i);"); - } - else - { - // Multiple count block - writer.WriteLine(" for (int j = 0; j < " + block.Count + - "; j++) { " + sanitizedName + "[j].ToBytes(bytes, ref i); }"); - } - } - - writer.WriteLine(" if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); }"); - writer.WriteLine(" return bytes;\n }\n"); - - // ToString() function - writer.WriteLine(" /// Serialize this packet to a stringA string containing the serialized packet"); - writer.WriteLine(" public override string ToString()\n {"); - writer.WriteLine(" string output = \"--- " + packet.Name + " ---\\n\";"); - - foreach (MapBlock block in packet.Blocks) - { - if (block.Name == "Header") { sanitizedName = "_" + block.Name; } - else { sanitizedName = block.Name; } - - if (block.Count == -1) - { - // Variable count block - writer.WriteLine(" for (int j = 0; j < " + sanitizedName + ".Length; j++)\n {"); - writer.WriteLine(" output += " + sanitizedName + "[j].ToString() + \"\\n\";\n }"); - } - else if (block.Count == 1) - { - writer.WriteLine(" output += " + sanitizedName + ".ToString() + \"\\n\";"); - } - else - { - // Multiple count block - writer.WriteLine(" for (int j = 0; j < " + block.Count + "; j++)\n {"); - writer.WriteLine(" output += " + sanitizedName + "[j].ToString() + \"\\n\";\n }"); - } - } - - writer.WriteLine(" return output;\n }\n"); - - // Closing function bracket - writer.WriteLine(" }\n"); - } - - static int Main(string[] args) - { - ProtocolManager protocol; - TextWriter writer; - - try - { - if (args.Length < 4) - { - Console.WriteLine("Invalid arguments, need [keywords.txt] [message_template.msg] [template.cs] [_Packets_.cs]"); - return -1; - } - - writer = new StreamWriter(args[3]); - protocol = new ProtocolManager(args[0], args[1]); - - TextReader reader = new StreamReader(args[2]); - writer.WriteLine(reader.ReadToEnd()); - reader.Close(); - } - catch (Exception e) - { - Console.WriteLine(e.ToString()); - return -2; - } - - // Write the PacketType enum - writer.WriteLine(" /// Used to identify the type of a packet"); - writer.WriteLine(" public enum PacketType\n {\n" + - " /// A generic value, not an actual packet type\n" + - " Default,"); - foreach (MapPacket packet in protocol.LowMaps) - { - if (packet != null) - { - writer.WriteLine(" /// " + packet.Name + ""); - writer.WriteLine(" " + packet.Name + ","); - } - } - foreach (MapPacket packet in protocol.MediumMaps) - { - if (packet != null) - { - writer.WriteLine(" /// " + packet.Name + ""); - writer.WriteLine(" " + packet.Name + ","); - } - } - foreach (MapPacket packet in protocol.HighMaps) - { - if (packet != null) - { - writer.WriteLine(" /// " + packet.Name + ""); - writer.WriteLine(" " + packet.Name + ","); - } - } - writer.WriteLine(" }\n"); - - // Write the base Packet class - writer.WriteLine(" /// Base class for all packet classes\n" + - " public abstract class Packet\n {\n" + - " /// Either a LowHeader, MediumHeader, or HighHeader representing the first bytes of the packet\n" + - " public abstract Header Header { get; set; }\n" + - " /// The type of this packet, identified by it's frequency and ID\n" + - " public abstract PacketType Type { get; }\n" + - " /// Used internally to track timeouts, do not use\n" + - " public int TickCount;\n\n" + - " /// Serializes the packet in to a byte array\n" + - " /// A byte array containing the serialized packet payload, ready to be sent across the wire\n" + - " public abstract byte[] ToBytes();\n\n" + - " /// Get the PacketType for a given packet id and packet frequency\n" + - " /// The packet ID from the header\n" + - " /// Frequency of this packet\n" + - " /// The packet type, or PacketType.Default\n" + - " public static PacketType GetType(ushort id, PacketFrequency frequency)\n {\n" + - " switch (frequency)\n {\n case PacketFrequency.Low:\n" + - " switch (id)\n {"); - - foreach (MapPacket packet in protocol.LowMaps) - { - if (packet != null) - { - writer.WriteLine(" case " + packet.ID + - ": return PacketType." + packet.Name + ";"); - } - } - - writer.WriteLine(" }\n break;\n" + - " case PacketFrequency.Medium:\n switch (id)\n {"); - - foreach (MapPacket packet in protocol.MediumMaps) - { - if (packet != null) - { - writer.WriteLine(" case " + packet.ID + - ": return PacketType." + packet.Name + ";"); - } - } - - writer.WriteLine(" }\n break;\n" + - " case PacketFrequency.High:\n switch (id)\n {"); - - foreach (MapPacket packet in protocol.HighMaps) - { - if (packet != null) - { - writer.WriteLine(" case " + packet.ID + - ": return PacketType." + packet.Name + ";"); - } - } - - writer.WriteLine(" }\n break;\n }\n\n" + - " return PacketType.Default;\n }\n"); - - writer.WriteLine(" /// Construct a packet in it's native class from a byte array\n" + - " /// Byte array containing the packet, starting at position 0\n" + - " /// The last byte of the packet. If the packet was 76 bytes long, packetEnd would be 75\n" + - " /// The native packet class for this type of packet, typecasted to the generic Packet\n" + - " public static Packet BuildPacket(byte[] bytes, ref int packetEnd)\n" + - " {\n ushort id;\n int i = 0;\n" + - " Header header = Header.BuildHeader(bytes, ref i, ref packetEnd);\n" + - " if (header.Zerocoded)\n {\n" + - " byte[] zeroBuffer = new byte[8192];\n" + - " packetEnd = Helpers.ZeroDecode(bytes, packetEnd + 1, zeroBuffer) - 1;\n" + - " bytes = zeroBuffer;\n }\n\n" + - " if (bytes[4] == 0xFF)\n {\n" + - " if (bytes[5] == 0xFF)\n {\n" + - " id = (ushort)((bytes[6] << 8) + bytes[7]);\n" + - " switch (id)\n {"); - foreach (MapPacket packet in protocol.LowMaps) - { - if (packet != null) - { - writer.WriteLine(" case " + packet.ID + - ": return new " + packet.Name + "Packet(header, bytes, ref i);"); - } - } - writer.WriteLine(" }\n }\n else\n" + - " {\n id = (ushort)bytes[5];\n" + - " switch (id)\n {"); - foreach (MapPacket packet in protocol.MediumMaps) - { - if (packet != null) - { - writer.WriteLine(" case " + packet.ID + - ": return new " + packet.Name + "Packet(header, bytes, ref i);"); - } - } - writer.WriteLine(" }\n }\n }\n" + - " else\n {\n" + - " id = (ushort)bytes[4];\n" + - " switch (id)\n {"); - foreach (MapPacket packet in protocol.HighMaps) - { - if (packet != null) - { - writer.WriteLine(" case " + packet.ID + - ": return new " + packet.Name + "Packet(header, bytes, ref i);"); - } - } - writer.WriteLine(" }\n }\n\n" + - " throw new MalformedDataException(\"Unknown packet ID\");\n" + - " }\n }\n"); - - // Write the packet classes - foreach (MapPacket packet in protocol.LowMaps) - { - if (packet != null) { WritePacketClass(writer, packet); } - } - - foreach (MapPacket packet in protocol.MediumMaps) - { - if (packet != null) { WritePacketClass(writer, packet); } - } - - foreach (MapPacket packet in protocol.HighMaps) - { - if (packet != null) { WritePacketClass(writer, packet); } - } - - writer.WriteLine("}"); - - writer.Close(); - - return 0; - } - } -} +using System; +using System.Text; +using System.IO; +using libsecondlife; + +namespace mapgenerator +{ + class mapgenerator + { + static void WriteFieldMember(TextWriter writer, MapField field) + { + string type = ""; + + switch (field.Type) + { + case FieldType.BOOL: + type = "bool"; + break; + case FieldType.F32: + type = "float"; + break; + case FieldType.F64: + type = "double"; + break; + case FieldType.IPPORT: + case FieldType.U16: + type = "ushort"; + break; + case FieldType.IPADDR: + case FieldType.U32: + type = "uint"; + break; + case FieldType.LLQuaternion: + type = "LLQuaternion"; + break; + case FieldType.LLUUID: + type = "LLUUID"; + break; + case FieldType.LLVector3: + type = "LLVector3"; + break; + case FieldType.LLVector3d: + type = "LLVector3d"; + break; + case FieldType.LLVector4: + type = "LLVector4"; + break; + case FieldType.S16: + type = "short"; + break; + case FieldType.S32: + type = "int"; + break; + case FieldType.S8: + type = "sbyte"; + break; + case FieldType.U64: + type = "ulong"; + break; + case FieldType.U8: + type = "byte"; + break; + case FieldType.Fixed: + type = "byte[]"; + break; + } + if (field.Type != FieldType.Variable) + { + writer.WriteLine(" /// " + field.Name + " field"); + writer.WriteLine(" public " + type + " " + field.Name + ";"); + } + else + { + writer.WriteLine(" private byte[] _" + field.Name.ToLower() + ";"); + writer.WriteLine(" /// " + field.Name + " field"); + writer.WriteLine(" public byte[] " + field.Name + "\n {"); + writer.WriteLine(" get { return _" + field.Name.ToLower() + "; }"); + writer.WriteLine(" set\n {"); + writer.WriteLine(" if (value == null) { _" + + field.Name.ToLower() + " = null; return; }"); + writer.WriteLine(" if (value.Length > " + + ((field.Count == 1) ? "255" : "1024") + ") { throw new OverflowException(" + + "\"Value exceeds " + ((field.Count == 1) ? "255" : "1024") + " characters\"); }"); + writer.WriteLine(" else { _" + field.Name.ToLower() + + " = new byte[value.Length]; Array.Copy(value, _" + + field.Name.ToLower() + ", value.Length); }"); + writer.WriteLine(" }\n }"); + } + } + + static void WriteFieldFromBytes(TextWriter writer, MapField field) + { + switch (field.Type) + { + case FieldType.BOOL: + writer.WriteLine(" " + + field.Name + " = (bytes[i++] != 0) ? (bool)true : (bool)false;"); + break; + case FieldType.F32: + writer.WriteLine(" " + + "if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 4);"); + writer.WriteLine(" " + + field.Name + " = BitConverter.ToSingle(bytes, i); i += 4;"); + break; + case FieldType.F64: + writer.WriteLine(" " + + "if (!BitConverter.IsLittleEndian) Array.Reverse(bytes, i, 8);"); + writer.WriteLine(" " + + field.Name + " = BitConverter.ToDouble(bytes, i); i += 8;"); + break; + case FieldType.Fixed: + writer.WriteLine(" " + field.Name + " = new byte[" + field.Count + "];"); + writer.WriteLine(" Array.Copy(bytes, i, " + field.Name + + ", 0, " + field.Count + "); i += " + field.Count + ";"); + break; + case FieldType.IPADDR: + case FieldType.U32: + writer.WriteLine(" " + field.Name + + " = (uint)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24));"); + break; + case FieldType.IPPORT: + // IPPORT is big endian while U16/S16 are little endian. Go figure + writer.WriteLine(" " + field.Name + + " = (ushort)((bytes[i++] << 8) + bytes[i++]);"); + break; + case FieldType.U16: + writer.WriteLine(" " + field.Name + + " = (ushort)(bytes[i++] + (bytes[i++] << 8));"); + break; + case FieldType.LLQuaternion: + //writer.WriteLine(" " + field.Name + + // " = new LLQuaternion(bytes, i); i += 16;"); + writer.WriteLine(" " + field.Name + + " = new LLQuaternion(bytes, i, true); i += 12;"); + break; + case FieldType.LLUUID: + writer.WriteLine(" " + field.Name + + " = new LLUUID(bytes, i); i += 16;"); + break; + case FieldType.LLVector3: + writer.WriteLine(" " + field.Name + + " = new LLVector3(bytes, i); i += 12;"); + break; + case FieldType.LLVector3d: + writer.WriteLine(" " + field.Name + + " = new LLVector3d(bytes, i); i += 24;"); + break; + case FieldType.LLVector4: + writer.WriteLine(" " + field.Name + + " = new LLVector4(bytes, i); i += 16;"); + break; + case FieldType.S16: + writer.WriteLine(" " + field.Name + + " = (short)(bytes[i++] + (bytes[i++] << 8));"); + break; + case FieldType.S32: + writer.WriteLine(" " + field.Name + + " = (int)(bytes[i++] + (bytes[i++] << 8) + (bytes[i++] << 16) + (bytes[i++] << 24));"); + break; + case FieldType.S8: + writer.WriteLine(" " + field.Name + + " = (sbyte)bytes[i++];"); + break; + case FieldType.U64: + writer.WriteLine(" " + field.Name + + " = (ulong)((ulong)bytes[i++] + ((ulong)bytes[i++] << 8) + " + + "((ulong)bytes[i++] << 16) + ((ulong)bytes[i++] << 24) + " + + "((ulong)bytes[i++] << 32) + ((ulong)bytes[i++] << 40) + " + + "((ulong)bytes[i++] << 48) + ((ulong)bytes[i++] << 56));"); + break; + case FieldType.U8: + writer.WriteLine(" " + field.Name + + " = (byte)bytes[i++];"); + break; + case FieldType.Variable: + if (field.Count == 1) + { + writer.WriteLine(" length = (ushort)bytes[i++];"); + } + else + { + writer.WriteLine(" length = (ushort)(bytes[i++] + (bytes[i++] << 8));"); + } + writer.WriteLine(" _" + field.Name.ToLower() + " = new byte[length];"); + writer.WriteLine(" Array.Copy(bytes, i, _" + field.Name.ToLower() + + ", 0, length); i += length;"); + break; + default: + writer.WriteLine("!!! ERROR: Unhandled FieldType: " + field.Type.ToString() + " !!!"); + break; + } + } + + static void WriteFieldToBytes(TextWriter writer, MapField field) + { + writer.Write(" "); + + switch (field.Type) + { + case FieldType.BOOL: + writer.WriteLine("bytes[i++] = (byte)((" + field.Name + ") ? 1 : 0);"); + break; + case FieldType.F32: + writer.WriteLine("ba = BitConverter.GetBytes(" + field.Name + ");\n" + + " if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 4); }\n" + + " Array.Copy(ba, 0, bytes, i, 4); i += 4;"); + break; + case FieldType.F64: + writer.WriteLine("ba = BitConverter.GetBytes(" + field.Name + ");\n" + + " if(!BitConverter.IsLittleEndian) { Array.Reverse(ba, 0, 8); }\n" + + " Array.Copy(ba, 0, bytes, i, 8); i += 8;"); + break; + case FieldType.Fixed: + writer.WriteLine(" Array.Copy(" + field.Name + ", 0, bytes, i, " + field.Count + ");" + + "i += " + field.Count + ";"); + break; + case FieldType.IPPORT: + // IPPORT is big endian while U16/S16 is little endian. Go figure + writer.WriteLine("bytes[i++] = (byte)((" + field.Name + " >> 8) % 256);"); + writer.WriteLine(" bytes[i++] = (byte)(" + field.Name + " % 256);"); + break; + case FieldType.U16: + case FieldType.S16: + writer.WriteLine("bytes[i++] = (byte)(" + field.Name + " % 256);"); + writer.WriteLine(" bytes[i++] = (byte)((" + field.Name + " >> 8) % 256);"); + break; + //case FieldType.LLQuaternion: + case FieldType.LLUUID: + case FieldType.LLVector4: + writer.WriteLine("if(" + field.Name + " == null) { Console.WriteLine(\"Warning: " + field.Name + " is null, in \" + this.GetType()); }"); + writer.Write(" "); + writer.WriteLine("Array.Copy(" + field.Name + ".GetBytes(), 0, bytes, i, 16); i += 16;"); + break; + case FieldType.LLQuaternion: + case FieldType.LLVector3: + writer.WriteLine("if(" + field.Name + " == null) { Console.WriteLine(\"Warning: " + field.Name + " is null, in \" + this.GetType()); }"); + writer.Write(" "); + writer.WriteLine("Array.Copy(" + field.Name + ".GetBytes(), 0, bytes, i, 12); i += 12;"); + break; + case FieldType.LLVector3d: + writer.WriteLine("if(" + field.Name + " == null) { Console.WriteLine(\"Warning: " + field.Name + " is null, in \" + this.GetType()); }"); + writer.Write(" "); + writer.WriteLine("Array.Copy(" + field.Name + ".GetBytes(), 0, bytes, i, 24); i += 24;"); + break; + case FieldType.U8: + writer.WriteLine("bytes[i++] = " + field.Name + ";"); + break; + case FieldType.S8: + writer.WriteLine("bytes[i++] = (byte)" + field.Name + ";"); + break; + case FieldType.IPADDR: + case FieldType.U32: + case FieldType.S32: + writer.WriteLine("bytes[i++] = (byte)(" + field.Name + " % 256);"); + writer.WriteLine(" bytes[i++] = (byte)((" + field.Name + " >> 8) % 256);"); + writer.WriteLine(" bytes[i++] = (byte)((" + field.Name + " >> 16) % 256);"); + writer.WriteLine(" bytes[i++] = (byte)((" + field.Name + " >> 24) % 256);"); + break; + case FieldType.U64: + writer.WriteLine("bytes[i++] = (byte)(" + field.Name + " % 256);"); + writer.WriteLine(" bytes[i++] = (byte)((" + field.Name + " >> 8) % 256);"); + writer.WriteLine(" bytes[i++] = (byte)((" + field.Name + " >> 16) % 256);"); + writer.WriteLine(" bytes[i++] = (byte)((" + field.Name + " >> 24) % 256);"); + writer.WriteLine(" bytes[i++] = (byte)((" + field.Name + " >> 32) % 256);"); + writer.WriteLine(" bytes[i++] = (byte)((" + field.Name + " >> 40) % 256);"); + writer.WriteLine(" bytes[i++] = (byte)((" + field.Name + " >> 48) % 256);"); + writer.WriteLine(" bytes[i++] = (byte)((" + field.Name + " >> 56) % 256);"); + break; + case FieldType.Variable: + writer.WriteLine("if(" + field.Name + " == null) { Console.WriteLine(\"Warning: " + field.Name + " is null, in \" + this.GetType()); }"); + writer.Write(" "); + if (field.Count == 1) + { + writer.WriteLine("bytes[i++] = (byte)" + field.Name + ".Length;"); + } + else + { + writer.WriteLine("bytes[i++] = (byte)(" + field.Name + ".Length % 256);"); + writer.WriteLine(" bytes[i++] = (byte)((" + + field.Name + ".Length >> 8) % 256);"); + } + writer.WriteLine(" Array.Copy(" + field.Name + ", 0, bytes, i, " + + field.Name + ".Length); " + "i += " + field.Name + ".Length;"); + break; + default: + writer.WriteLine("!!! ERROR: Unhandled FieldType: " + field.Type.ToString() + " !!!"); + break; + } + } + + static int GetFieldLength(TextWriter writer, MapField field) + { + switch(field.Type) + { + case FieldType.BOOL: + case FieldType.U8: + case FieldType.S8: + return 1; + case FieldType.U16: + case FieldType.S16: + case FieldType.IPPORT: + return 2; + case FieldType.U32: + case FieldType.S32: + case FieldType.F32: + case FieldType.IPADDR: + return 4; + case FieldType.U64: + case FieldType.F64: + return 8; + case FieldType.LLVector3: + case FieldType.LLQuaternion: + return 12; + case FieldType.LLUUID: + case FieldType.LLVector4: + //case FieldType.LLQuaternion: + return 16; + case FieldType.LLVector3d: + return 24; + case FieldType.Fixed: + return field.Count; + case FieldType.Variable: + return 0; + default: + writer.WriteLine("!!! ERROR: Unhandled FieldType " + field.Type.ToString() + " !!!"); + return 0; + } + } + + static void WriteBlockClass(TextWriter writer, MapBlock block) + { + bool variableFields = false; + bool floatFields = false; + + writer.WriteLine(" /// " + block.Name + " block"); + writer.WriteLine(" public class " + block.Name + "Block\n {"); + + foreach (MapField field in block.Fields) + { + WriteFieldMember(writer, field); + + if (field.Type == FieldType.Variable) { variableFields = true; } + if (field.Type == FieldType.F32 || field.Type == FieldType.F64) { floatFields = true; } + } + + // Length property + writer.WriteLine(""); + writer.WriteLine(" /// Length of this block serialized in bytes"); + writer.WriteLine(" public int Length\n {\n get\n" + + " {"); + int length = 0; + foreach (MapField field in block.Fields) + { + length += GetFieldLength(writer, field); + } + + if (!variableFields) + { + writer.WriteLine(" return " + length + ";"); + } + else + { + writer.WriteLine(" int length = " + length + ";"); + + foreach (MapField field in block.Fields) + { + if (field.Type == FieldType.Variable) + { + writer.WriteLine(" if (" + field.Name + + " != null) { length += " + field.Count + " + " + field.Name + ".Length; }"); + } + } + + writer.WriteLine(" return length;"); + } + + writer.WriteLine(" }\n }\n"); + + // Default constructor + writer.WriteLine(" /// Default constructor"); + writer.WriteLine(" public " + block.Name + "Block() { }"); + + // Constructor for building the class from bytes + writer.WriteLine(" /// Constructor for building the block from a byte array"); + writer.WriteLine(" public " + block.Name + "Block(byte[] bytes, ref int i)" + + "\n {"); + + // Declare a length variable if we need it for variable fields in this constructor + if (variableFields) { writer.WriteLine(" int length;"); } + + // Start of the try catch block + writer.WriteLine(" try\n {"); + + foreach (MapField field in block.Fields) + { + WriteFieldFromBytes(writer, field); + } + + writer.WriteLine(" }\n catch (Exception)\n" + + " {\n throw new MalformedDataException();\n" + + " }\n }\n"); + + // ToBytes() function + writer.WriteLine(" /// Serialize this block to a byte array"); + writer.WriteLine(" public void ToBytes(byte[] bytes, ref int i)\n {"); + + // Declare a byte[] variable if we need it for floating point field conversions + if (floatFields) { writer.WriteLine(" byte[] ba;"); } + + foreach (MapField field in block.Fields) + { + WriteFieldToBytes(writer, field); + } + + writer.WriteLine(" }\n"); + + // ToString() function + writer.WriteLine(" /// Serialize this block to a stringA string containing the serialized block"); + writer.WriteLine(" public override string ToString()\n {"); + writer.WriteLine(" string output = \"-- " + block.Name + " --\\n\";"); + + foreach (MapField field in block.Fields) + { + if (field.Type == FieldType.Variable || field.Type == FieldType.Fixed) + { + writer.WriteLine(" output += Helpers.FieldToString(" + field.Name + ", \"" + field.Name + "\") + \"\\n\";"); + } + else + { + writer.WriteLine(" output += \"" + field.Name + ": \" + " + field.Name + ".ToString() + \"\\n\";"); + } + } + + writer.WriteLine(" output = output.Trim();\n return output;\n }"); + + writer.WriteLine(" }\n"); + } + + static void WritePacketClass(TextWriter writer, MapPacket packet) + { + string sanitizedName; + + writer.WriteLine(" /// " + packet.Name + " packet"); + writer.WriteLine(" public class " + packet.Name + "Packet : Packet\n {"); + + // Write out each block class + foreach (MapBlock block in packet.Blocks) + { + WriteBlockClass(writer, block); + } + + // Header member + writer.WriteLine(" private Header header;"); + writer.WriteLine(" /// The header for this packet"); + writer.WriteLine(" public override Header Header { get { return header; } set { header = value; } }"); + + // PacketType member + writer.WriteLine(" /// Will return PacketType." + packet.Name+ ""); + writer.WriteLine(" public override PacketType Type { get { return PacketType." + + packet.Name + "; } }"); + + // Block members + foreach (MapBlock block in packet.Blocks) + { + // TODO: More thorough name blacklisting + if (block.Name == "Header") { sanitizedName = "_" + block.Name; } + else { sanitizedName = block.Name; } + + writer.WriteLine(" /// " + block.Name + " block"); + writer.WriteLine(" public " + block.Name + "Block" + + ((block.Count != 1) ? "[]" : "") + " " + sanitizedName + ";"); + } + + writer.WriteLine(""); + + // Default constructor + writer.WriteLine(" /// Default constructor"); + writer.WriteLine(" public " + packet.Name + "Packet()\n {"); + writer.WriteLine(" Header = new " + packet.Frequency.ToString() + "Header();"); + writer.WriteLine(" Header.ID = " + packet.ID + ";"); + writer.WriteLine(" Header.Reliable = true;"); // Turn the reliable flag on by default + if (packet.Encoded) { writer.WriteLine(" Header.Zerocoded = true;"); } + foreach (MapBlock block in packet.Blocks) + { + if (block.Name == "Header") { sanitizedName = "_" + block.Name; } + else { sanitizedName = block.Name; } + + if (block.Count == 1) + { + // Single count block + writer.WriteLine(" " + sanitizedName + " = new " + block.Name + "Block();"); + } + else if (block.Count == -1) + { + // Variable count block + writer.WriteLine(" " + sanitizedName + " = new " + block.Name + "Block[0];"); + } + else + { + // Multiple count block + writer.WriteLine(" " + sanitizedName + " = new " + block.Name + + "Block[" + block.Count + "];"); + } + } + writer.WriteLine(" }\n"); + + // Constructor that takes a byte array and beginning position only (no prebuilt header) + bool seenVariable = false; + writer.WriteLine(" /// Constructor that takes a byte array and beginning position (no prebuilt header)"); + writer.WriteLine(" public " + packet.Name + "Packet(byte[] bytes, ref int i)\n {"); + writer.WriteLine(" int packetEnd = bytes.Length - 1;"); + writer.WriteLine(" Header = new " + packet.Frequency.ToString() + + "Header(bytes, ref i, ref packetEnd);"); + foreach (MapBlock block in packet.Blocks) + { + if (block.Name == "Header") { sanitizedName = "_" + block.Name; } + else { sanitizedName = block.Name; } + + if (block.Count == 1) + { + // Single count block + writer.WriteLine(" " + sanitizedName + " = new " + block.Name + "Block(bytes, ref i);"); + } + else if (block.Count == -1) + { + // Variable count block + if (!seenVariable) + { + writer.WriteLine(" int count = (int)bytes[i++];"); + seenVariable = true; + } + else + { + writer.WriteLine(" count = (int)bytes[i++];"); + } + writer.WriteLine(" " + sanitizedName + " = new " + block.Name + "Block[count];"); + writer.WriteLine(" for (int j = 0; j < count; j++)"); + writer.WriteLine(" { " + sanitizedName + "[j] = new " + + block.Name + "Block(bytes, ref i); }"); + } + else + { + // Multiple count block + writer.WriteLine(" " + sanitizedName + " = new " + block.Name + + "Block[" + block.Count + "];"); + writer.WriteLine(" for (int j = 0; j < " + block.Count + "; j++)"); + writer.WriteLine(" { " + sanitizedName + "[j] = new " + + block.Name + "Block(bytes, ref i); }"); + } + } + writer.WriteLine(" }\n"); + + seenVariable = false; + + // Constructor that takes a byte array and a prebuilt header + writer.WriteLine(" /// Constructor that takes a byte array and a prebuilt header"); + writer.WriteLine(" public " + packet.Name + "Packet(Header head, byte[] bytes, ref int i)\n {"); + writer.WriteLine(" Header = head;"); + foreach (MapBlock block in packet.Blocks) + { + if (block.Name == "Header") { sanitizedName = "_" + block.Name; } + else { sanitizedName = block.Name; } + + if (block.Count == 1) + { + // Single count block + writer.WriteLine(" " + sanitizedName + " = new " + block.Name + "Block(bytes, ref i);"); + } + else if (block.Count == -1) + { + // Variable count block + if (!seenVariable) + { + writer.WriteLine(" int count = (int)bytes[i++];"); + seenVariable = true; + } + else + { + writer.WriteLine(" count = (int)bytes[i++];"); + } + writer.WriteLine(" " + sanitizedName + " = new " + block.Name + "Block[count];"); + writer.WriteLine(" for (int j = 0; j < count; j++)"); + writer.WriteLine(" { " + sanitizedName + "[j] = new " + + block.Name + "Block(bytes, ref i); }"); + } + else + { + // Multiple count block + writer.WriteLine(" " + sanitizedName + " = new " + block.Name + + "Block[" + block.Count + "];"); + writer.WriteLine(" for (int j = 0; j < " + block.Count + "; j++)"); + writer.WriteLine(" { " + sanitizedName + "[j] = new " + + block.Name + "Block(bytes, ref i); }"); + } + } + writer.WriteLine(" }\n"); + + // ToBytes() function + writer.WriteLine(" /// Serialize this packet to a byte arrayA byte array containing the serialized packet"); + writer.WriteLine(" public override byte[] ToBytes()\n {"); + + writer.Write(" int length = "); + if (packet.Frequency == PacketFrequency.Low) { writer.WriteLine("8;"); } + else if (packet.Frequency == PacketFrequency.Medium) { writer.WriteLine("6;"); } + else { writer.WriteLine("5;"); } + + foreach (MapBlock block in packet.Blocks) + { + if (block.Name == "Header") { sanitizedName = "_" + block.Name; } + else { sanitizedName = block.Name; } + + if (block.Count == 1) + { + // Single count block + writer.Write(" length += " + sanitizedName + ".Length;"); + } + } + writer.WriteLine(";"); + + foreach (MapBlock block in packet.Blocks) + { + if (block.Name == "Header") { sanitizedName = "_" + block.Name; } + else { sanitizedName = block.Name; } + + if (block.Count == -1) + { + writer.WriteLine(" length++;"); + writer.WriteLine(" for (int j = 0; j < " + sanitizedName + + ".Length; j++) { length += " + sanitizedName + "[j].Length; }"); + } + else if (block.Count > 1) + { + writer.WriteLine(" for (int j = 0; j < " + block.Count + + "; j++) { length += " + sanitizedName + "[j].Length; }"); + } + } + + writer.WriteLine(" if (header.AckList.Length > 0) { length += header.AckList.Length * 4 + 1; }"); + writer.WriteLine(" byte[] bytes = new byte[length];"); + writer.WriteLine(" int i = 0;"); + writer.WriteLine(" header.ToBytes(bytes, ref i);"); + foreach (MapBlock block in packet.Blocks) + { + if (block.Name == "Header") { sanitizedName = "_" + block.Name; } + else { sanitizedName = block.Name; } + + if (block.Count == -1) + { + // Variable count block + writer.WriteLine(" bytes[i++] = (byte)" + sanitizedName + ".Length;"); + writer.WriteLine(" for (int j = 0; j < " + sanitizedName + + ".Length; j++) { " + sanitizedName + "[j].ToBytes(bytes, ref i); }"); + } + else if (block.Count == 1) + { + writer.WriteLine(" " + sanitizedName + ".ToBytes(bytes, ref i);"); + } + else + { + // Multiple count block + writer.WriteLine(" for (int j = 0; j < " + block.Count + + "; j++) { " + sanitizedName + "[j].ToBytes(bytes, ref i); }"); + } + } + + writer.WriteLine(" if (header.AckList.Length > 0) { header.AcksToBytes(bytes, ref i); }"); + writer.WriteLine(" return bytes;\n }\n"); + + // ToString() function + writer.WriteLine(" /// Serialize this packet to a stringA string containing the serialized packet"); + writer.WriteLine(" public override string ToString()\n {"); + writer.WriteLine(" string output = \"--- " + packet.Name + " ---\\n\";"); + + foreach (MapBlock block in packet.Blocks) + { + if (block.Name == "Header") { sanitizedName = "_" + block.Name; } + else { sanitizedName = block.Name; } + + if (block.Count == -1) + { + // Variable count block + writer.WriteLine(" for (int j = 0; j < " + sanitizedName + ".Length; j++)\n {"); + writer.WriteLine(" output += " + sanitizedName + "[j].ToString() + \"\\n\";\n }"); + } + else if (block.Count == 1) + { + writer.WriteLine(" output += " + sanitizedName + ".ToString() + \"\\n\";"); + } + else + { + // Multiple count block + writer.WriteLine(" for (int j = 0; j < " + block.Count + "; j++)\n {"); + writer.WriteLine(" output += " + sanitizedName + "[j].ToString() + \"\\n\";\n }"); + } + } + + writer.WriteLine(" return output;\n }\n"); + + // Closing function bracket + writer.WriteLine(" }\n"); + } + + static int Main(string[] args) + { + ProtocolManager protocol; + TextWriter writer; + + try + { + if (args.Length < 4) + { + Console.WriteLine("Invalid arguments, need [keywords.txt] [message_template.msg] [template.cs] [_Packets_.cs]"); + return -1; + } + + writer = new StreamWriter(args[3]); + protocol = new ProtocolManager(args[0], args[1]); + + TextReader reader = new StreamReader(args[2]); + writer.WriteLine(reader.ReadToEnd()); + reader.Close(); + } + catch (Exception e) + { + Console.WriteLine(e.ToString()); + return -2; + } + + // Write the PacketType enum + writer.WriteLine(" /// Used to identify the type of a packet"); + writer.WriteLine(" public enum PacketType\n {\n" + + " /// A generic value, not an actual packet type\n" + + " Default,"); + foreach (MapPacket packet in protocol.LowMaps) + { + if (packet != null) + { + writer.WriteLine(" /// " + packet.Name + ""); + writer.WriteLine(" " + packet.Name + ","); + } + } + foreach (MapPacket packet in protocol.MediumMaps) + { + if (packet != null) + { + writer.WriteLine(" /// " + packet.Name + ""); + writer.WriteLine(" " + packet.Name + ","); + } + } + foreach (MapPacket packet in protocol.HighMaps) + { + if (packet != null) + { + writer.WriteLine(" /// " + packet.Name + ""); + writer.WriteLine(" " + packet.Name + ","); + } + } + writer.WriteLine(" }\n"); + + // Write the base Packet class + writer.WriteLine(" /// Base class for all packet classes\n" + + " public abstract class Packet\n {\n" + + " /// Either a LowHeader, MediumHeader, or HighHeader representing the first bytes of the packet\n" + + " public abstract Header Header { get; set; }\n" + + " /// The type of this packet, identified by it's frequency and ID\n" + + " public abstract PacketType Type { get; }\n" + + " /// Used internally to track timeouts, do not use\n" + + " public int TickCount;\n\n" + + " /// Serializes the packet in to a byte array\n" + + " /// A byte array containing the serialized packet payload, ready to be sent across the wire\n" + + " public abstract byte[] ToBytes();\n\n" + + " /// Get the PacketType for a given packet id and packet frequency\n" + + " /// The packet ID from the header\n" + + " /// Frequency of this packet\n" + + " /// The packet type, or PacketType.Default\n" + + " public static PacketType GetType(ushort id, PacketFrequency frequency)\n {\n" + + " switch (frequency)\n {\n case PacketFrequency.Low:\n" + + " switch (id)\n {"); + + foreach (MapPacket packet in protocol.LowMaps) + { + if (packet != null) + { + writer.WriteLine(" case " + packet.ID + + ": return PacketType." + packet.Name + ";"); + } + } + + writer.WriteLine(" }\n break;\n" + + " case PacketFrequency.Medium:\n switch (id)\n {"); + + foreach (MapPacket packet in protocol.MediumMaps) + { + if (packet != null) + { + writer.WriteLine(" case " + packet.ID + + ": return PacketType." + packet.Name + ";"); + } + } + + writer.WriteLine(" }\n break;\n" + + " case PacketFrequency.High:\n switch (id)\n {"); + + foreach (MapPacket packet in protocol.HighMaps) + { + if (packet != null) + { + writer.WriteLine(" case " + packet.ID + + ": return PacketType." + packet.Name + ";"); + } + } + + writer.WriteLine(" }\n break;\n }\n\n" + + " return PacketType.Default;\n }\n"); + + writer.WriteLine(" /// Construct a packet in it's native class from a byte array\n" + + " /// Byte array containing the packet, starting at position 0\n" + + " /// The last byte of the packet. If the packet was 76 bytes long, packetEnd would be 75\n" + + " /// The native packet class for this type of packet, typecasted to the generic Packet\n" + + " public static Packet BuildPacket(byte[] bytes, ref int packetEnd)\n" + + " {\n ushort id;\n int i = 0;\n" + + " Header header = Header.BuildHeader(bytes, ref i, ref packetEnd);\n" + + " if (header.Zerocoded)\n {\n" + + " byte[] zeroBuffer = new byte[8192];\n" + + " packetEnd = Helpers.ZeroDecode(bytes, packetEnd + 1, zeroBuffer) - 1;\n" + + " bytes = zeroBuffer;\n }\n\n" + + " if (bytes[4] == 0xFF)\n {\n" + + " if (bytes[5] == 0xFF)\n {\n" + + " id = (ushort)((bytes[6] << 8) + bytes[7]);\n" + + " switch (id)\n {"); + foreach (MapPacket packet in protocol.LowMaps) + { + if (packet != null) + { + writer.WriteLine(" case " + packet.ID + + ": return new " + packet.Name + "Packet(header, bytes, ref i);"); + } + } + writer.WriteLine(" }\n }\n else\n" + + " {\n id = (ushort)bytes[5];\n" + + " switch (id)\n {"); + foreach (MapPacket packet in protocol.MediumMaps) + { + if (packet != null) + { + writer.WriteLine(" case " + packet.ID + + ": return new " + packet.Name + "Packet(header, bytes, ref i);"); + } + } + writer.WriteLine(" }\n }\n }\n" + + " else\n {\n" + + " id = (ushort)bytes[4];\n" + + " switch (id)\n {"); + foreach (MapPacket packet in protocol.HighMaps) + { + if (packet != null) + { + writer.WriteLine(" case " + packet.ID + + ": return new " + packet.Name + "Packet(header, bytes, ref i);"); + } + } + writer.WriteLine(" }\n }\n\n" + + " throw new MalformedDataException(\"Unknown packet ID\");\n" + + " }\n }\n"); + + // Write the packet classes + foreach (MapPacket packet in protocol.LowMaps) + { + if (packet != null) { WritePacketClass(writer, packet); } + } + + foreach (MapPacket packet in protocol.MediumMaps) + { + if (packet != null) { WritePacketClass(writer, packet); } + } + + foreach (MapPacket packet in protocol.HighMaps) + { + if (packet != null) { WritePacketClass(writer, packet); } + } + + writer.WriteLine("}"); + + writer.Close(); + + return 0; + } + } +} diff --git a/libsecondlife-cs/mapgenerator/mapgenerator.csproj b/libsecondlife-cs/mapgenerator/mapgenerator.csproj index c4f07708..d0f71672 100644 --- a/libsecondlife-cs/mapgenerator/mapgenerator.csproj +++ b/libsecondlife-cs/mapgenerator/mapgenerator.csproj @@ -1,48 +1,48 @@ - - - Debug - AnyCPU - 8.0.50727 - 2.0 - {C59B1312-57EF-4146-B6B2-1C7B6DC4638B} - Exe - Properties - mapgenerator - mapgenerator - - - true - full - false - ..\..\bin\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {C59B1312-57EF-4146-B6B2-1C7B6DC4638B} + Exe + Properties + mapgenerator + mapgenerator + + + true + full + false + ..\..\bin\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + \ No newline at end of file diff --git a/libsecondlife-cs/mapgenerator/mapgenerator.sln b/libsecondlife-cs/mapgenerator/mapgenerator.sln index 0390683d..afa656c6 100644 --- a/libsecondlife-cs/mapgenerator/mapgenerator.sln +++ b/libsecondlife-cs/mapgenerator/mapgenerator.sln @@ -1,20 +1,20 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mapgenerator", "mapgenerator.csproj", "{C59B1312-57EF-4146-B6B2-1C7B6DC4638B}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {C59B1312-57EF-4146-B6B2-1C7B6DC4638B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C59B1312-57EF-4146-B6B2-1C7B6DC4638B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C59B1312-57EF-4146-B6B2-1C7B6DC4638B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C59B1312-57EF-4146-B6B2-1C7B6DC4638B}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mapgenerator", "mapgenerator.csproj", "{C59B1312-57EF-4146-B6B2-1C7B6DC4638B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C59B1312-57EF-4146-B6B2-1C7B6DC4638B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C59B1312-57EF-4146-B6B2-1C7B6DC4638B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C59B1312-57EF-4146-B6B2-1C7B6DC4638B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C59B1312-57EF-4146-B6B2-1C7B6DC4638B}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/libsecondlife-cs/mapgenerator/template.cs b/libsecondlife-cs/mapgenerator/template.cs index 11567a1d..e4fd2022 100644 --- a/libsecondlife-cs/mapgenerator/template.cs +++ b/libsecondlife-cs/mapgenerator/template.cs @@ -1,345 +1,345 @@ -/* - * Copyright (c) 2006, the libsecondlife development team - * All rights reserved. - * - * - Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * - Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * - Neither the name of the Second Life Reverse Engineering Team nor the names - * of its contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -using System; -using libsecondlife; - -namespace libsecondlife.Packets -{ - /// - /// - /// - public class MalformedDataException : ApplicationException - { - /// - /// - /// - public MalformedDataException() { } - - /// - /// - /// - /// - public MalformedDataException(string Message) - : base(Message) - { - this.Source = "Packet decoding"; - } - } - - /// - /// - /// - public abstract class Header - { - /// - public byte[] Data; - /// - public byte Flags - { - get { return Data[0]; } - set { Data[0] = value; } - } - /// - public bool Reliable - { - get { return (Data[0] & Helpers.MSG_RELIABLE) != 0; } - set { if (value) { Data[0] |= (byte)Helpers.MSG_RELIABLE; } else { Data[0] -= (byte)Helpers.MSG_RELIABLE; } } - } - /// - public bool Resent - { - get { return (Data[0] & Helpers.MSG_RESENT) != 0; } - set { if (value) { Data[0] |= (byte)Helpers.MSG_RESENT; } else { Data[0] -= (byte)Helpers.MSG_RESENT; } } - } - /// - public bool Zerocoded - { - get { return (Data[0] & Helpers.MSG_ZEROCODED) != 0; } - set { if (value) { Data[0] |= (byte)Helpers.MSG_ZEROCODED; } else { Data[0] -= (byte)Helpers.MSG_ZEROCODED; } } - } - /// - public bool AppendedAcks - { - get { return (Data[0] & Helpers.MSG_APPENDED_ACKS) != 0; } - set { if (value) { Data[0] |= (byte)Helpers.MSG_APPENDED_ACKS; } else { Data[0] -= (byte)Helpers.MSG_APPENDED_ACKS; } } - } - /// - public ushort Sequence - { - get { return (ushort)((Data[2] << 8) + Data[3]); } - set { Data[2] = (byte)(value >> 8); Data[3] = (byte)(value % 256); } - } - /// - public abstract ushort ID { get; set; } - /// - public abstract PacketFrequency Frequency { get; } - /// - public abstract void ToBytes(byte[] bytes, ref int i); - /// - public uint[] AckList; - - /// - /// - /// - /// - /// - public void AcksToBytes(byte[] bytes, ref int i) - { - foreach (uint ack in AckList) - { - bytes[i++] = (byte)((ack >> 24) % 256); - bytes[i++] = (byte)((ack >> 16) % 256); - bytes[i++] = (byte)((ack >> 8) % 256); - bytes[i++] = (byte)(ack % 256); - } - if (AckList.Length > 0) { bytes[i++] = (byte)AckList.Length; } - } - - /// - /// - /// - /// - /// - /// - /// - public static Header BuildHeader(byte[] bytes, ref int pos, ref int packetEnd) - { - if (bytes[4] == 0xFF) - { - if (bytes[5] == 0xFF) - { - return new LowHeader(bytes, ref pos, ref packetEnd); - } - else - { - return new MediumHeader(bytes, ref pos, ref packetEnd); - } - } - else - { - return new HighHeader(bytes, ref pos, ref packetEnd); - } - } - - /// - /// - /// - /// - /// - protected void CreateAckList(byte[] bytes, ref int packetEnd) - { - if (AppendedAcks) - { - try - { - int count = bytes[packetEnd--]; - AckList = new uint[count]; - - for (int i = 0; i < count; i++) - { - AckList[i] = (ushort)((bytes[(packetEnd - i * 4) - 1] << 8) | (bytes[packetEnd - i * 4])); - } - - packetEnd -= (count * 4); - } - catch (Exception) - { - AckList = new uint[0]; - throw new MalformedDataException(); - } - } - else - { - AckList = new uint[0]; - } - } - } - - /// - /// - /// - public class LowHeader : Header - { - /// - public override ushort ID - { - get { return (ushort)((Data[6] << 8) + Data[7]); } - set { Data[6] = (byte)(value >> 8); Data[7] = (byte)(value % 256); } - } - /// - public override PacketFrequency Frequency { get { return PacketFrequency.Low; } } - - /// - /// - /// - public LowHeader() - { - Data = new byte[8]; - Data[4] = Data[5] = 0xFF; - AckList = new uint[0]; - } - - /// - /// - /// - /// - /// - /// - public LowHeader(byte[] bytes, ref int pos, ref int packetEnd) - { - if (bytes.Length < 8) { throw new MalformedDataException(); } - Data = new byte[8]; - Array.Copy(bytes, Data, 8); - - if ((bytes[0] & Helpers.MSG_ZEROCODED) != 0 && bytes[6] == 0) - { - if (bytes[7] == 1) - { - Data[7] = bytes[8]; - } - else - { - throw new MalformedDataException(); - } - } - - pos = 8; - CreateAckList(bytes, ref packetEnd); - } - - /// - /// - /// - /// - /// - public override void ToBytes(byte[] bytes, ref int i) - { - Array.Copy(Data, 0, bytes, i, 8); - i += 8; - } - } - - /// - /// - /// - public class MediumHeader : Header - { - /// - public override ushort ID - { - get { return (ushort)Data[5]; } - set { Data[5] = (byte)value; } - } - /// - public override PacketFrequency Frequency { get { return PacketFrequency.Medium; } } - - /// - /// - /// - public MediumHeader() - { - Data = new byte[6]; - Data[4] = 0xFF; - AckList = new uint[0]; - } - - /// - /// - /// - /// - /// - /// - public MediumHeader(byte[] bytes, ref int pos, ref int packetEnd) - { - if (bytes.Length < 6) { throw new MalformedDataException(); } - Data = new byte[6]; - Array.Copy(bytes, Data, 6); - pos = 6; - CreateAckList(bytes, ref packetEnd); - } - - /// - /// - /// - /// - /// - public override void ToBytes(byte[] bytes, ref int i) - { - Array.Copy(Data, 0, bytes, i, 6); - i += 6; - } - } - - /// - /// - /// - public class HighHeader : Header - { - /// - public override ushort ID - { - get { return (ushort)Data[4]; } - set { Data[4] = (byte)value; } - } - /// - public override PacketFrequency Frequency { get { return PacketFrequency.High; } } - - /// - /// - /// - public HighHeader() - { - Data = new byte[5]; - AckList = new uint[0]; - } - - /// - /// - /// - /// - /// - /// - public HighHeader(byte[] bytes, ref int pos, ref int packetEnd) - { - if (bytes.Length < 5) { throw new MalformedDataException(); } - Data = new byte[5]; - Array.Copy(bytes, Data, 5); - pos = 5; - CreateAckList(bytes, ref packetEnd); - } - - /// - /// - /// - /// - /// - public override void ToBytes(byte[] bytes, ref int i) - { - Array.Copy(Data, 0, bytes, i, 5); - i += 5; - } - } +/* + * Copyright (c) 2006, the libsecondlife development team + * All rights reserved. + * + * - Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * - Neither the name of the Second Life Reverse Engineering Team nor the names + * of its contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using libsecondlife; + +namespace libsecondlife.Packets +{ + /// + /// + /// + public class MalformedDataException : ApplicationException + { + /// + /// + /// + public MalformedDataException() { } + + /// + /// + /// + /// + public MalformedDataException(string Message) + : base(Message) + { + this.Source = "Packet decoding"; + } + } + + /// + /// + /// + public abstract class Header + { + /// + public byte[] Data; + /// + public byte Flags + { + get { return Data[0]; } + set { Data[0] = value; } + } + /// + public bool Reliable + { + get { return (Data[0] & Helpers.MSG_RELIABLE) != 0; } + set { if (value) { Data[0] |= (byte)Helpers.MSG_RELIABLE; } else { Data[0] -= (byte)Helpers.MSG_RELIABLE; } } + } + /// + public bool Resent + { + get { return (Data[0] & Helpers.MSG_RESENT) != 0; } + set { if (value) { Data[0] |= (byte)Helpers.MSG_RESENT; } else { Data[0] -= (byte)Helpers.MSG_RESENT; } } + } + /// + public bool Zerocoded + { + get { return (Data[0] & Helpers.MSG_ZEROCODED) != 0; } + set { if (value) { Data[0] |= (byte)Helpers.MSG_ZEROCODED; } else { Data[0] -= (byte)Helpers.MSG_ZEROCODED; } } + } + /// + public bool AppendedAcks + { + get { return (Data[0] & Helpers.MSG_APPENDED_ACKS) != 0; } + set { if (value) { Data[0] |= (byte)Helpers.MSG_APPENDED_ACKS; } else { Data[0] -= (byte)Helpers.MSG_APPENDED_ACKS; } } + } + /// + public ushort Sequence + { + get { return (ushort)((Data[2] << 8) + Data[3]); } + set { Data[2] = (byte)(value >> 8); Data[3] = (byte)(value % 256); } + } + /// + public abstract ushort ID { get; set; } + /// + public abstract PacketFrequency Frequency { get; } + /// + public abstract void ToBytes(byte[] bytes, ref int i); + /// + public uint[] AckList; + + /// + /// + /// + /// + /// + public void AcksToBytes(byte[] bytes, ref int i) + { + foreach (uint ack in AckList) + { + bytes[i++] = (byte)((ack >> 24) % 256); + bytes[i++] = (byte)((ack >> 16) % 256); + bytes[i++] = (byte)((ack >> 8) % 256); + bytes[i++] = (byte)(ack % 256); + } + if (AckList.Length > 0) { bytes[i++] = (byte)AckList.Length; } + } + + /// + /// + /// + /// + /// + /// + /// + public static Header BuildHeader(byte[] bytes, ref int pos, ref int packetEnd) + { + if (bytes[4] == 0xFF) + { + if (bytes[5] == 0xFF) + { + return new LowHeader(bytes, ref pos, ref packetEnd); + } + else + { + return new MediumHeader(bytes, ref pos, ref packetEnd); + } + } + else + { + return new HighHeader(bytes, ref pos, ref packetEnd); + } + } + + /// + /// + /// + /// + /// + protected void CreateAckList(byte[] bytes, ref int packetEnd) + { + if (AppendedAcks) + { + try + { + int count = bytes[packetEnd--]; + AckList = new uint[count]; + + for (int i = 0; i < count; i++) + { + AckList[i] = (ushort)((bytes[(packetEnd - i * 4) - 1] << 8) | (bytes[packetEnd - i * 4])); + } + + packetEnd -= (count * 4); + } + catch (Exception) + { + AckList = new uint[0]; + throw new MalformedDataException(); + } + } + else + { + AckList = new uint[0]; + } + } + } + + /// + /// + /// + public class LowHeader : Header + { + /// + public override ushort ID + { + get { return (ushort)((Data[6] << 8) + Data[7]); } + set { Data[6] = (byte)(value >> 8); Data[7] = (byte)(value % 256); } + } + /// + public override PacketFrequency Frequency { get { return PacketFrequency.Low; } } + + /// + /// + /// + public LowHeader() + { + Data = new byte[8]; + Data[4] = Data[5] = 0xFF; + AckList = new uint[0]; + } + + /// + /// + /// + /// + /// + /// + public LowHeader(byte[] bytes, ref int pos, ref int packetEnd) + { + if (bytes.Length < 8) { throw new MalformedDataException(); } + Data = new byte[8]; + Array.Copy(bytes, Data, 8); + + if ((bytes[0] & Helpers.MSG_ZEROCODED) != 0 && bytes[6] == 0) + { + if (bytes[7] == 1) + { + Data[7] = bytes[8]; + } + else + { + throw new MalformedDataException(); + } + } + + pos = 8; + CreateAckList(bytes, ref packetEnd); + } + + /// + /// + /// + /// + /// + public override void ToBytes(byte[] bytes, ref int i) + { + Array.Copy(Data, 0, bytes, i, 8); + i += 8; + } + } + + /// + /// + /// + public class MediumHeader : Header + { + /// + public override ushort ID + { + get { return (ushort)Data[5]; } + set { Data[5] = (byte)value; } + } + /// + public override PacketFrequency Frequency { get { return PacketFrequency.Medium; } } + + /// + /// + /// + public MediumHeader() + { + Data = new byte[6]; + Data[4] = 0xFF; + AckList = new uint[0]; + } + + /// + /// + /// + /// + /// + /// + public MediumHeader(byte[] bytes, ref int pos, ref int packetEnd) + { + if (bytes.Length < 6) { throw new MalformedDataException(); } + Data = new byte[6]; + Array.Copy(bytes, Data, 6); + pos = 6; + CreateAckList(bytes, ref packetEnd); + } + + /// + /// + /// + /// + /// + public override void ToBytes(byte[] bytes, ref int i) + { + Array.Copy(Data, 0, bytes, i, 6); + i += 6; + } + } + + /// + /// + /// + public class HighHeader : Header + { + /// + public override ushort ID + { + get { return (ushort)Data[4]; } + set { Data[4] = (byte)value; } + } + /// + public override PacketFrequency Frequency { get { return PacketFrequency.High; } } + + /// + /// + /// + public HighHeader() + { + Data = new byte[5]; + AckList = new uint[0]; + } + + /// + /// + /// + /// + /// + /// + public HighHeader(byte[] bytes, ref int pos, ref int packetEnd) + { + if (bytes.Length < 5) { throw new MalformedDataException(); } + Data = new byte[5]; + Array.Copy(bytes, Data, 5); + pos = 5; + CreateAckList(bytes, ref packetEnd); + } + + /// + /// + /// + /// + /// + public override void ToBytes(byte[] bytes, ref int i) + { + Array.Copy(Data, 0, bytes, i, 5); + i += 5; + } + } diff --git a/libsecondlife-cs/tests/DebugServer.cs b/libsecondlife-cs/tests/DebugServer.cs index 45116706..e7ddb9c3 100644 --- a/libsecondlife-cs/tests/DebugServer.cs +++ b/libsecondlife-cs/tests/DebugServer.cs @@ -1,122 +1,122 @@ -using System; -using System.Collections; -using System.IO; -using System.Net; -using System.Net.Sockets; -using System.Text.RegularExpressions; -using System.Threading; -using System.Xml; -using Nwc.XmlRpc; -using libsecondlife; -using libsecondlife.Packets; - -namespace libsecondlife.Tests -{ - public class DebugServer - { - public bool Initialized = false; - - private SecondLife libsl; - private bool done = false; - private Socket Listener; - private IPEndPoint Endpoint; - EndPoint RemoteEndpoint = new IPEndPoint(IPAddress.Loopback, 0); - private ushort Sequence = 0; - - public DebugServer(string keywordFile, string mapFile, int port) - { - libsl = new SecondLife(); - - BindSocket(port); - } - - private void BindSocket(int port) - { - Endpoint = new IPEndPoint(IPAddress.Loopback, port); - Listener = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); - - Console.WriteLine("[SERVER] Binding a UDP socket to " + Endpoint.ToString()); - - try - { - Listener.Bind(Endpoint); - } - catch (SocketException) - { - Console.WriteLine("[SERVER] Failed to bind to " + Endpoint.ToString()); - return; - } - - // Start listening for incoming data - Thread thread = new Thread(new ThreadStart(Listen)); - thread.Start(); - - Initialized = true; - } - - private void Listen() - { - Packet packet; - int length; - byte[] bytes = new byte[4096]; - - Console.WriteLine("[SERVER] Listening for incoming data on " + Endpoint.ToString()); - - while (!done) - { - packet = null; - - // Grab the next packet - length = Listener.ReceiveFrom(bytes, ref RemoteEndpoint); - - Console.WriteLine("[SERVER] Received a packet from {0}", RemoteEndpoint.ToString()); - - if (Helpers.FieldToString(bytes).StartsWith("stopserver")) - { - Console.WriteLine("[SERVER] Received a shutdown request, stopping the server"); - done = true; - break; - } - - int packetEnd = length - 1; - packet = Packet.BuildPacket(bytes, ref packetEnd); - - if (packet.Header.AppendedAcks) - { - Console.WriteLine("[SERVER] Found " + packet.Header.AckList.Length + " appended acks"); - } - - if (packet.Header.Reliable) - { - SendACK((uint)packet.Header.Sequence); - } - - Console.WriteLine(packet.ToString()); - } - - Console.WriteLine("[SERVER] Shutting down the socket on " + Endpoint.ToString()); - Listener.Close(); - } - - private void SendACK(uint id) - { - try - { - PacketAckPacket ack = new PacketAckPacket(); - ack.Packets = new PacketAckPacket.PacketsBlock[1]; - ack.Packets[0].ID = id; - - ack.Header.Reliable = false; - - // Set the sequence number - ack.Header.Sequence = ++Sequence; - - Listener.SendTo(ack.ToBytes(), RemoteEndpoint); - } - catch (Exception e) - { - Console.WriteLine(e.ToString()); - } - } - } -} +using System; +using System.Collections; +using System.IO; +using System.Net; +using System.Net.Sockets; +using System.Text.RegularExpressions; +using System.Threading; +using System.Xml; +using Nwc.XmlRpc; +using libsecondlife; +using libsecondlife.Packets; + +namespace libsecondlife.Tests +{ + public class DebugServer + { + public bool Initialized = false; + + private SecondLife libsl; + private bool done = false; + private Socket Listener; + private IPEndPoint Endpoint; + EndPoint RemoteEndpoint = new IPEndPoint(IPAddress.Loopback, 0); + private ushort Sequence = 0; + + public DebugServer(string keywordFile, string mapFile, int port) + { + libsl = new SecondLife(); + + BindSocket(port); + } + + private void BindSocket(int port) + { + Endpoint = new IPEndPoint(IPAddress.Loopback, port); + Listener = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); + + Console.WriteLine("[SERVER] Binding a UDP socket to " + Endpoint.ToString()); + + try + { + Listener.Bind(Endpoint); + } + catch (SocketException) + { + Console.WriteLine("[SERVER] Failed to bind to " + Endpoint.ToString()); + return; + } + + // Start listening for incoming data + Thread thread = new Thread(new ThreadStart(Listen)); + thread.Start(); + + Initialized = true; + } + + private void Listen() + { + Packet packet; + int length; + byte[] bytes = new byte[4096]; + + Console.WriteLine("[SERVER] Listening for incoming data on " + Endpoint.ToString()); + + while (!done) + { + packet = null; + + // Grab the next packet + length = Listener.ReceiveFrom(bytes, ref RemoteEndpoint); + + Console.WriteLine("[SERVER] Received a packet from {0}", RemoteEndpoint.ToString()); + + if (Helpers.FieldToString(bytes).StartsWith("stopserver")) + { + Console.WriteLine("[SERVER] Received a shutdown request, stopping the server"); + done = true; + break; + } + + int packetEnd = length - 1; + packet = Packet.BuildPacket(bytes, ref packetEnd); + + if (packet.Header.AppendedAcks) + { + Console.WriteLine("[SERVER] Found " + packet.Header.AckList.Length + " appended acks"); + } + + if (packet.Header.Reliable) + { + SendACK((uint)packet.Header.Sequence); + } + + Console.WriteLine(packet.ToString()); + } + + Console.WriteLine("[SERVER] Shutting down the socket on " + Endpoint.ToString()); + Listener.Close(); + } + + private void SendACK(uint id) + { + try + { + PacketAckPacket ack = new PacketAckPacket(); + ack.Packets = new PacketAckPacket.PacketsBlock[1]; + ack.Packets[0].ID = id; + + ack.Header.Reliable = false; + + // Set the sequence number + ack.Header.Sequence = ++Sequence; + + Listener.SendTo(ack.ToBytes(), RemoteEndpoint); + } + catch (Exception e) + { + Console.WriteLine(e.ToString()); + } + } + } +} diff --git a/libsecondlife-cs/tests/Tests.cs b/libsecondlife-cs/tests/Tests.cs index 5053aad1..e17d5284 100644 --- a/libsecondlife-cs/tests/Tests.cs +++ b/libsecondlife-cs/tests/Tests.cs @@ -1,95 +1,95 @@ -using System; -using System.Collections; -using System.Net; -using libsecondlife; -using libsecondlife.Packets; -using NUnit.Framework; - -namespace libsecondlife.Tests -{ - [TestFixture] - public class EndianTests : Assert - { - SecondLife Client = null; - DebugServer Server = null; - Packet CurrentPacket = null; - bool NetworkFinished = false; - - [SetUp] - public void Init() - { - Client = new SecondLife(); - Client.Network.AgentID = LLUUID.GenerateUUID(); - Client.Network.SessionID = LLUUID.GenerateUUID(); - - Server = new DebugServer("keywords.txt", "message_template.msg", 8338); - Assert.IsTrue(Server.Initialized, "Failed to initialize the server, couldn't bind to port 8338?"); - - Simulator debugSim = Client.Network.Connect(IPAddress.Loopback, 8338, 1, true); - Assert.IsNotNull(debugSim, "Failed to connect to the debugging simulator"); - - Client.Network.RegisterCallback(PacketType.SimulatorAssign, new PacketCallback(SimulatorAssignHandler)); - } - - [Test] - public void U8Receive() - { - CurrentPacket = null; - NetworkFinished = false; - - // 2. Instruct the server to send a SimulatorAssign to the client with some fixed values - - int start = Environment.TickCount; - - while (!NetworkFinished && Environment.TickCount - start < 5000) - { - System.Threading.Thread.Sleep(0); - } - - // 5. Parse the Packet and run our assertion(s) - Assert.IsNotNull(CurrentPacket, "Never received the packet"); - Assert.IsTrue(true); - } - - [Test] - public void S8Receive() - { - ; - } - - [Test] - public void U16Receive() - { - ; - } - - [Test] - public void S16Receive() - { - ; - } - - private void SimulatorAssignHandler(Packet packet, Simulator sim) - { - CurrentPacket = packet; - NetworkFinished = true; - } - - [TearDown] - public void Shutdown() - { - try - { - Client.Network.SendPacket(System.Text.Encoding.UTF8.GetBytes("stopserver")); - Client.Network.Logout(); - } - catch (NotConnectedException) - { - Assert.IsTrue(false, "Logout failed, not connected"); - } - - Client = null; - Server = null; - } - } -} +using System; +using System.Collections; +using System.Net; +using libsecondlife; +using libsecondlife.Packets; +using NUnit.Framework; + +namespace libsecondlife.Tests +{ + [TestFixture] + public class EndianTests : Assert + { + SecondLife Client = null; + DebugServer Server = null; + Packet CurrentPacket = null; + bool NetworkFinished = false; + + [SetUp] + public void Init() + { + Client = new SecondLife(); + Client.Network.AgentID = LLUUID.GenerateUUID(); + Client.Network.SessionID = LLUUID.GenerateUUID(); + + Server = new DebugServer("keywords.txt", "message_template.msg", 8338); + Assert.IsTrue(Server.Initialized, "Failed to initialize the server, couldn't bind to port 8338?"); + + Simulator debugSim = Client.Network.Connect(IPAddress.Loopback, 8338, 1, true); + Assert.IsNotNull(debugSim, "Failed to connect to the debugging simulator"); + + Client.Network.RegisterCallback(PacketType.SimulatorAssign, new PacketCallback(SimulatorAssignHandler)); + } + + [Test] + public void U8Receive() + { + CurrentPacket = null; + NetworkFinished = false; + + // 2. Instruct the server to send a SimulatorAssign to the client with some fixed values + + int start = Environment.TickCount; + + while (!NetworkFinished && Environment.TickCount - start < 5000) + { + System.Threading.Thread.Sleep(0); + } + + // 5. Parse the Packet and run our assertion(s) + Assert.IsNotNull(CurrentPacket, "Never received the packet"); + Assert.IsTrue(true); + } + + [Test] + public void S8Receive() + { + ; + } + + [Test] + public void U16Receive() + { + ; + } + + [Test] + public void S16Receive() + { + ; + } + + private void SimulatorAssignHandler(Packet packet, Simulator sim) + { + CurrentPacket = packet; + NetworkFinished = true; + } + + [TearDown] + public void Shutdown() + { + try + { + Client.Network.SendPacket(System.Text.Encoding.UTF8.GetBytes("stopserver")); + Client.Network.Logout(); + } + catch (NotConnectedException) + { + Assert.IsTrue(false, "Logout failed, not connected"); + } + + Client = null; + Server = null; + } + } +} diff --git a/libsecondlife-cs/tests/libsecondlife.Tests.csproj b/libsecondlife-cs/tests/libsecondlife.Tests.csproj index 93217279..a835735d 100644 --- a/libsecondlife-cs/tests/libsecondlife.Tests.csproj +++ b/libsecondlife-cs/tests/libsecondlife.Tests.csproj @@ -1,61 +1,61 @@ - - - Debug - AnyCPU - 8.0.50727 - 2.0 - {E0BCBBAE-A620-431A-9EB7-30173EAF195B} - Library - Properties - libsecondlife.Tests - libsecondlife.Tests - - - true - full - false - ..\..\bin\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - ..\..\bin\ - - - - - - - - - - - - - - {D9CDEDFB-8169-4B03-B57F-0DF638F044EC} - libsecondlife - - - - - - - - + + + Debug + AnyCPU + 8.0.50727 + 2.0 + {E0BCBBAE-A620-431A-9EB7-30173EAF195B} + Library + Properties + libsecondlife.Tests + libsecondlife.Tests + + + true + full + false + ..\..\bin\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + ..\..\bin\ + + + + + + + + + + + + + + {D9CDEDFB-8169-4B03-B57F-0DF638F044EC} + libsecondlife + + + + + + + + \ No newline at end of file diff --git a/libsecondlife-cs/tests/libsecondlife.Tests.sln b/libsecondlife-cs/tests/libsecondlife.Tests.sln index 69454e03..46132fb1 100644 --- a/libsecondlife-cs/tests/libsecondlife.Tests.sln +++ b/libsecondlife-cs/tests/libsecondlife.Tests.sln @@ -1,20 +1,20 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "libsecondlife.Tests", "libsecondlife.Tests.csproj", "{E0BCBBAE-A620-431A-9EB7-30173EAF195B}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {E0BCBBAE-A620-431A-9EB7-30173EAF195B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E0BCBBAE-A620-431A-9EB7-30173EAF195B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E0BCBBAE-A620-431A-9EB7-30173EAF195B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E0BCBBAE-A620-431A-9EB7-30173EAF195B}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "libsecondlife.Tests", "libsecondlife.Tests.csproj", "{E0BCBBAE-A620-431A-9EB7-30173EAF195B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E0BCBBAE-A620-431A-9EB7-30173EAF195B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E0BCBBAE-A620-431A-9EB7-30173EAF195B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E0BCBBAE-A620-431A-9EB7-30173EAF195B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E0BCBBAE-A620-431A-9EB7-30173EAF195B}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal